summaryrefslogtreecommitdiffstats
path: root/media/libeffects/lvm/lib/Bundle
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2010-07-09 12:28:50 -0700
committerEric Laurent <elaurent@google.com>2010-07-17 06:33:00 -0700
commit2c8e5cab3faa6d360e222b7a6c40a80083d021ac (patch)
treefd19b8baa829edb78116b089d1122ea4ef0921e1 /media/libeffects/lvm/lib/Bundle
parentada2ac8e09b6d3f2b3c3155a852ba0fffae1b592 (diff)
downloadframeworks_av-2c8e5cab3faa6d360e222b7a6c40a80083d021ac.zip
frameworks_av-2c8e5cab3faa6d360e222b7a6c40a80083d021ac.tar.gz
frameworks_av-2c8e5cab3faa6d360e222b7a6c40a80083d021ac.tar.bz2
First submission of audio effect library from NXP software.
This CL contains the first open sourceable version of the audio effect library from NXP software. The effects implemented are: - Bass boost - Virtualizer (stereo widening) - Equalizer - Spectrum analyzer Source file for the effect engines are located under libeffects/lvm/lib The wrapper implementing the interface with the audio effect framework in under libeffects/lvm/wrapper The code of other effect libraries has also been reorganized fo clarity: - the effect factory is now under libeffects/factory - the test equalizer and reverb effects are under libeffect/testlibs - the visualizer is under libeffects/virtualizer Change-Id: I8d91e2181f81b89f8fc0c1e1e6bf552c5809b2eb
Diffstat (limited to 'media/libeffects/lvm/lib/Bundle')
-rwxr-xr-xmedia/libeffects/lvm/lib/Bundle/lib/LVM.h637
-rwxr-xr-xmedia/libeffects/lvm/lib/Bundle/src/LVM_API_Specials.c158
-rwxr-xr-xmedia/libeffects/lvm/lib/Bundle/src/LVM_Buffers.c878
-rwxr-xr-xmedia/libeffects/lvm/lib/Bundle/src/LVM_Coeffs.h573
-rwxr-xr-xmedia/libeffects/lvm/lib/Bundle/src/LVM_Control.c1032
-rwxr-xr-xmedia/libeffects/lvm/lib/Bundle/src/LVM_Init.c1003
-rwxr-xr-xmedia/libeffects/lvm/lib/Bundle/src/LVM_Private.h292
-rwxr-xr-xmedia/libeffects/lvm/lib/Bundle/src/LVM_Process.c283
-rwxr-xr-xmedia/libeffects/lvm/lib/Bundle/src/LVM_Tables.c397
-rwxr-xr-xmedia/libeffects/lvm/lib/Bundle/src/LVM_Tables.h67
10 files changed, 5320 insertions, 0 deletions
diff --git a/media/libeffects/lvm/lib/Bundle/lib/LVM.h b/media/libeffects/lvm/lib/Bundle/lib/LVM.h
new file mode 100755
index 0000000..d472182
--- /dev/null
+++ b/media/libeffects/lvm/lib/Bundle/lib/LVM.h
@@ -0,0 +1,637 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*****************************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1002 $
+ $Date: 2010-06-28 13:40:09 +0200 (Mon, 28 Jun 2010) $
+
+*****************************************************************************************/
+
+/****************************************************************************************/
+/* */
+/* Header file for the application layer interface of Concert Sound, Bass Enhancement, */
+/* Equalizer, Power Spectrum Analyzer, Trebble Enhancement and volume management */
+/* bundle. */
+/* */
+/* This files includes all definitions, types, structures and function */
+/* prototypes required by the calling layer. All other types, structures and */
+/* functions are private. */
+/* */
+/****************************************************************************************/
+/* */
+/* Note: 1 */
+/* ======= */
+/* The algorithm can execute either with separate input and output buffers or with */
+/* a common buffer, i.e. the data is processed in-place. */
+/* */
+/****************************************************************************************/
+/* */
+/* Note: 2 */
+/* ======= */
+/* Three data formats are support Stereo,Mono-In-Stereo and Mono. The data is */
+/* interleaved as follows: */
+/* */
+/* Byte Offset Stereo Input Mono-In-Stereo Input Mono Input */
+/* =========== ============ ==================== ============== */
+/* 0 Left Sample #1 Mono Sample #1 Mono Sample #1 */
+/* 2 Right Sample #1 Mono Sample #1 Mono Sample #2 */
+/* 4 Left Sample #2 Mono Sample #2 Mono Sample #3 */
+/* 6 Right Sample #2 Mono Sample #2 Mono Sample #4 */
+/* . . . . */
+/* . . . . */
+/* */
+/****************************************************************************************/
+
+#ifndef __LVM_H__
+#define __LVM_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/****************************************************************************************/
+/* */
+/* Includes */
+/* */
+/****************************************************************************************/
+
+#include "LVM_Types.h"
+
+
+/****************************************************************************************/
+/* */
+/* Definitions */
+/* */
+/****************************************************************************************/
+
+/* Memory table*/
+#define LVM_NR_MEMORY_REGIONS 4 /* Number of memory regions */
+
+/* Concert Sound effect level presets */
+#define LVM_CS_EFFECT_NONE 0 /* 0% effect, minimum value */
+#define LVM_CS_EFFECT_LOW 16384 /* 50% effect */
+#define LVM_CS_EFFECT_MED 24576 /* 75% effect */
+#define LVM_CS_EFFECT_HIGH 32767 /* 100% effect, maximum value */
+
+/* Treble enhancement */
+#define LVM_TE_LOW_MIPS 32767
+
+/* Bass enhancement effect level presets */
+#define LVM_BE_0DB 0 /* 0dB boost, no effect */
+#define LVM_BE_3DB 3 /* +3dB boost */
+#define LVM_BE_6DB 6 /* +6dB boost */
+#define LVM_BE_9DB 9 /* +9dB boost */
+#define LVM_BE_12DB 12 /* +12dB boost */
+#define LVM_BE_15DB 15 /* +15dB boost */
+
+/* N-Band Equalizer */
+#define LVM_EQ_NBANDS 5 /* Number of bands for equalizer */
+
+/* Headroom management */
+#define LVM_HEADROOM_MAX_NBANDS 5
+
+/****************************************************************************************/
+/* */
+/* Types */
+/* */
+/****************************************************************************************/
+
+/* Instance handle */
+typedef void *LVM_Handle_t;
+
+
+/* Status return values */
+typedef enum
+{
+ LVM_SUCCESS = 0, /* Successful return from a routine */
+ LVM_ALIGNMENTERROR = 1, /* Memory alignment error */
+ LVM_NULLADDRESS = 2, /* NULL allocation address */
+ LVM_OUTOFRANGE = 3, /* Out of range control parameter */
+ LVM_INVALIDNUMSAMPLES = 4, /* Invalid number of samples */
+ LVM_WRONGAUDIOTIME = 5, /* Wrong time value for audio time*/
+ LVM_ALGORITHMDISABLED = 6, /* Algorithm is disabled*/
+ LVM_ALGORITHMPSA = 7, /* Algorithm PSA returns an error */
+ LVM_RETURNSTATUS_DUMMY = LVM_MAXENUM
+} LVM_ReturnStatus_en;
+
+
+/* Buffer Management mode */
+typedef enum
+{
+ LVM_MANAGED_BUFFERS = 0,
+ LVM_UNMANAGED_BUFFERS = 1,
+ LVM_BUFFERS_DUMMY = LVM_MAXENUM
+} LVM_BufferMode_en;
+
+/* Output device type */
+typedef enum
+{
+ LVM_HEADPHONES = 0,
+ LVM_EX_HEADPHONES = 1,
+ LVM_SPEAKERTYPE_MAX = LVM_MAXENUM
+} LVM_OutputDeviceType_en;
+
+/* Virtualizer mode selection*/
+typedef enum
+{
+ LVM_CONCERTSOUND = 0,
+ LVM_VIRTUALIZERTYPE_DUMMY = LVM_MAXENUM
+} LVM_VirtualizerType_en;
+
+/* N-Band Equaliser operating mode */
+typedef enum
+{
+ LVM_EQNB_OFF = 0,
+ LVM_EQNB_ON = 1,
+ LVM_EQNB_DUMMY = LVM_MAXENUM
+} LVM_EQNB_Mode_en;
+
+/* Bass Enhancement operating mode */
+typedef enum
+{
+ LVM_BE_OFF = 0,
+ LVM_BE_ON = 1,
+ LVM_BE_DUMMY = LVM_MAXENUM
+} LVM_BE_Mode_en;
+
+/* Bass Enhancement centre frequency selection control */
+typedef enum
+{
+ LVM_BE_CENTRE_55Hz = 0,
+ LVM_BE_CENTRE_66Hz = 1,
+ LVM_BE_CENTRE_78Hz = 2,
+ LVM_BE_CENTRE_90Hz = 3,
+ LVM_BE_CENTRE_DUMMY = LVM_MAXENUM
+} LVM_BE_CentreFreq_en;
+
+/* Bass Enhancement HPF selection control */
+typedef enum
+{
+ LVM_BE_HPF_OFF = 0,
+ LVM_BE_HPF_ON = 1,
+ LVM_BE_HPF_DUMMY = LVM_MAXENUM
+} LVM_BE_FilterSelect_en;
+
+/* Volume Control operating mode */
+typedef enum
+{
+ LVM_VC_OFF = 0,
+ LVM_VC_ON = 1,
+ LVM_VC_DUMMY = LVM_MAXENUM
+} LVM_VC_Mode_en;
+
+/* Treble Enhancement operating mode */
+typedef enum
+{
+ LVM_TE_OFF = 0,
+ LVM_TE_ON = 1,
+ LVM_TE_DUMMY = LVM_MAXENUM
+} LVM_TE_Mode_en;
+
+/* Headroom management operating mode */
+typedef enum
+{
+ LVM_HEADROOM_OFF = 0,
+ LVM_HEADROOM_ON = 1,
+ LVM_Headroom_DUMMY = LVM_MAXENUM
+} LVM_Headroom_Mode_en;
+
+typedef enum
+{
+ LVM_PSA_SPEED_SLOW, /* Peak decaying at slow speed */
+ LVM_PSA_SPEED_MEDIUM, /* Peak decaying at medium speed */
+ LVM_PSA_SPEED_FAST, /* Peak decaying at fast speed */
+ LVM_PSA_SPEED_DUMMY = LVM_MAXENUM
+} LVM_PSA_DecaySpeed_en;
+
+typedef enum
+{
+ LVM_PSA_OFF = 0,
+ LVM_PSA_ON = 1,
+ LVM_PSA_DUMMY = LVM_MAXENUM
+} LVM_PSA_Mode_en;
+
+/* Version information */
+typedef struct
+{
+ LVM_CHAR *pVersionNumber; /* Pointer to the version number in the format X.YY.ZZ */
+ LVM_CHAR *pPlatform; /* Pointer to the library platform type */
+} LVM_VersionInfo_st;
+
+
+/****************************************************************************************/
+/* */
+/* Structures */
+/* */
+/****************************************************************************************/
+
+/* Memory table containing the region definitions */
+typedef struct
+{
+ LVM_MemoryRegion_st Region[LVM_NR_MEMORY_REGIONS]; /* One definition for each region */
+} LVM_MemTab_t;
+
+/* N-Band equaliser band definition */
+typedef struct
+{
+ LVM_INT16 Gain; /* Band gain in dB */
+ LVM_UINT16 Frequency; /* Band centre frequency in Hz */
+ LVM_UINT16 QFactor; /* Band quality factor (x100) */
+} LVM_EQNB_BandDef_t;
+
+
+/* Headroom band definition */
+typedef struct
+{
+ LVM_UINT16 Limit_Low; /* Low frequency limit of the band in Hertz */
+ LVM_UINT16 Limit_High; /* High frequency limit of the band in Hertz */
+ LVM_INT16 Headroom_Offset; /* Headroom = biggest band gain - Headroom_Offset */
+} LVM_HeadroomBandDef_t;
+
+
+/* Control Parameter structure */
+typedef struct
+{
+ /* General parameters */
+ LVM_Mode_en OperatingMode; /* Bundle operating mode On/Bypass */
+ LVM_Fs_en SampleRate; /* Sample rate */
+ LVM_Format_en SourceFormat; /* Input data format */
+ LVM_OutputDeviceType_en SpeakerType; /* Output device type */
+
+ /* Concert Sound Virtualizer parameters*/
+ LVM_Mode_en VirtualizerOperatingMode; /* Virtualizer operating mode On/Off */
+ LVM_VirtualizerType_en VirtualizerType; /* Virtualizer type: ConcertSound */
+ LVM_UINT16 VirtualizerReverbLevel; /* Virtualizer reverb level in % */
+ LVM_INT16 CS_EffectLevel; /* Concert Sound effect level */
+
+ /* N-Band Equaliser parameters */
+ LVM_EQNB_Mode_en EQNB_OperatingMode; /* N-Band Equaliser operating mode */
+ LVM_UINT16 EQNB_NBands; /* Number of bands */
+ LVM_EQNB_BandDef_t *pEQNB_BandDefinition; /* Pointer to equaliser definitions */
+
+ /* Bass Enhancement parameters */
+ LVM_BE_Mode_en BE_OperatingMode; /* Bass Enhancement operating mode */
+ LVM_INT16 BE_EffectLevel; /* Bass Enhancement effect level */
+ LVM_BE_CentreFreq_en BE_CentreFreq; /* Bass Enhancement centre frequency */
+ LVM_BE_FilterSelect_en BE_HPF; /* Bass Enhancement high pass filter selector */
+
+ /* Volume Control parameters */
+ LVM_INT16 VC_EffectLevel; /* Volume Control setting in dBs */
+ LVM_INT16 VC_Balance; /* Left Right Balance control in dB (-96 to 96 dB), -ve values reduce
+ Right channel while +ve value reduces Left channel*/
+
+ /* Treble Enhancement parameters */
+ LVM_TE_Mode_en TE_OperatingMode; /* Treble Enhancement On/Off */
+ LVM_INT16 TE_EffectLevel; /* Treble Enhancement gain dBs */
+
+ /* Spectrum Analyzer parameters Control */
+ LVM_PSA_Mode_en PSA_Enable;
+ LVM_PSA_DecaySpeed_en PSA_PeakDecayRate; /* Peak value decay rate*/
+
+} LVM_ControlParams_t;
+
+
+/* Instance Parameter structure */
+typedef struct
+{
+ /* General */
+ LVM_BufferMode_en BufferMode; /* Buffer management mode */
+ LVM_UINT16 MaxBlockSize; /* Maximum processing block size */
+
+ /* N-Band Equaliser */
+ LVM_UINT16 EQNB_NumBands; /* Maximum number of equaliser bands */
+
+ /* PSA */
+ LVM_PSA_Mode_en PSA_Included; /* Controls the instance memory allocation for PSA: ON/OFF */
+} LVM_InstParams_t;
+
+/* Headroom management parameter structure */
+typedef struct
+{
+ LVM_Headroom_Mode_en Headroom_OperatingMode; /* Headroom Control On/Off */
+ LVM_HeadroomBandDef_t *pHeadroomDefinition; /* Pointer to headroom bands definition */
+ LVM_UINT16 NHeadroomBands; /* Number of headroom bands */
+
+} LVM_HeadroomParams_t;
+
+/****************************************************************************************/
+/* */
+/* Function Prototypes */
+/* */
+/****************************************************************************************/
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_GetVersionInfo */
+/* */
+/* DESCRIPTION: */
+/* This function is used to retrieve information about the library's version. */
+/* */
+/* PARAMETERS: */
+/* pVersion Pointer to an empty version info structure */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Succeeded */
+/* LVM_NULLADDRESS when pVersion is NULL */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+LVM_ReturnStatus_en LVM_GetVersionInfo(LVM_VersionInfo_st *pVersion);
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_GetMemoryTable */
+/* */
+/* DESCRIPTION: */
+/* This function is used for memory allocation and free. It can be called in */
+/* two ways: */
+/* */
+/* hInstance = NULL Returns the memory requirements */
+/* hInstance = Instance handle Returns the memory requirements and */
+/* allocated base addresses for the instance */
+/* */
+/* When this function is called for memory allocation (hInstance=NULL) the memory */
+/* base address pointers are NULL on return. */
+/* */
+/* When the function is called for free (hInstance = Instance Handle) the memory */
+/* table returns the allocated memory and base addresses used during initialisation. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pMemoryTable Pointer to an empty memory definition table */
+/* pInstParams Pointer to the instance parameters */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Succeeded */
+/* LVM_NULLADDRESS When one of pMemoryTable or pInstParams is NULL */
+/* LVM_OUTOFRANGE When any of the Instance parameters are out of range */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+LVM_ReturnStatus_en LVM_GetMemoryTable(LVM_Handle_t hInstance,
+ LVM_MemTab_t *pMemoryTable,
+ LVM_InstParams_t *pInstParams);
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_GetInstanceHandle */
+/* */
+/* DESCRIPTION: */
+/* This function is used to create a bundle instance. It returns the created instance */
+/* handle through phInstance. All parameters are set to their default, inactive state. */
+/* */
+/* PARAMETERS: */
+/* phInstance pointer to the instance handle */
+/* pMemoryTable Pointer to the memory definition table */
+/* pInstParams Pointer to the instance parameters */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Initialisation succeeded */
+/* LVM_NULLADDRESS One or more memory has a NULL pointer */
+/* LVM_OUTOFRANGE When any of the Instance parameters are out of range */
+/* */
+/* NOTES: */
+/* 1. This function must not be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+LVM_ReturnStatus_en LVM_GetInstanceHandle(LVM_Handle_t *phInstance,
+ LVM_MemTab_t *pMemoryTable,
+ LVM_InstParams_t *pInstParams);
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_ClearAudioBuffers */
+/* */
+/* DESCRIPTION: */
+/* This function is used to clear the internal audio buffers of the bundle. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Initialisation succeeded */
+/* LVM_NULLADDRESS Instance memory has a NULL pointer */
+/* */
+/* NOTES: */
+/* 1. This function must not be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+LVM_ReturnStatus_en LVM_ClearAudioBuffers(LVM_Handle_t hInstance);
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_GetControlParameters */
+/* */
+/* DESCRIPTION: */
+/* Request the LifeVibes module parameters. The current parameter set is returned */
+/* via the parameter pointer. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pParams Pointer to an empty parameter structure */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Succeeded */
+/* LVM_NULLADDRESS when any of hInstance or pParams is NULL */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+LVM_ReturnStatus_en LVM_GetControlParameters(LVM_Handle_t hInstance,
+ LVM_ControlParams_t *pParams);
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_SetControlParameters */
+/* */
+/* DESCRIPTION: */
+/* Sets or changes the LifeVibes module parameters. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pParams Pointer to a parameter structure */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Succeeded */
+/* LVM_NULLADDRESS When hInstance, pParams or any control pointers are NULL */
+/* LVM_OUTOFRANGE When any of the control parameters are out of range */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+LVM_ReturnStatus_en LVM_SetControlParameters(LVM_Handle_t hInstance,
+ LVM_ControlParams_t *pParams);
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_Process */
+/* */
+/* DESCRIPTION: */
+/* Process function for the LifeVibes module. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pInData Pointer to the input data */
+/* pOutData Pointer to the output data */
+/* NumSamples Number of samples in the input buffer */
+/* AudioTime Audio Time of the current input data in milli-seconds */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Succeeded */
+/* LVM_INVALIDNUMSAMPLES When the NumSamples is not a valied multiple in unmanaged */
+/* buffer mode */
+/* LVM_ALIGNMENTERROR When either the input our output buffers are not 32-bit */
+/* aligned in unmanaged mode */
+/* LVM_NULLADDRESS When one of hInstance, pInData or pOutData is NULL */
+/* */
+/* NOTES: */
+/* 1. The input and output buffers must be 32-bit aligned */
+/* 2. Number of samples is defined as follows: */
+/* MONO the number of samples in the block */
+/* MONOINSTEREO the number of sample pairs in the block */
+/* STEREO the number of sample pairs in the block */
+/* */
+/****************************************************************************************/
+LVM_ReturnStatus_en LVM_Process(LVM_Handle_t hInstance,
+ const LVM_INT16 *pInData,
+ LVM_INT16 *pOutData,
+ LVM_UINT16 NumSamples,
+ LVM_UINT32 AudioTime);
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_SetHeadroomParams */
+/* */
+/* DESCRIPTION: */
+/* This function is used to set the automatic headroom management parameters. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pHeadroomParams Pointer to headroom parameter structure */
+/* */
+/* RETURNS: */
+/* LVM_NULLADDRESS When hInstance or pHeadroomParams is NULL */
+/* LVM_SUCCESS Succeeded */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+LVM_ReturnStatus_en LVM_SetHeadroomParams( LVM_Handle_t hInstance,
+ LVM_HeadroomParams_t *pHeadroomParams);
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_GetHeadroomParams */
+/* */
+/* DESCRIPTION: */
+/* This function is used to get the automatic headroom management parameters. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pHeadroomParams Pointer to headroom parameter structure (output) */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Succeeded */
+/* LVM_NULLADDRESS When hInstance or pHeadroomParams are NULL */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+LVM_ReturnStatus_en LVM_GetHeadroomParams( LVM_Handle_t hInstance,
+ LVM_HeadroomParams_t *pHeadroomParams);
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_GetSpectrum */
+/* */
+/* DESCRIPTION: */
+/* This function is used to retrieve Spectral information at a given Audio time */
+/* for display usage */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pCurrentPeaks Pointer to location where currents peaks are to be saved */
+/* pPastPeaks Pointer to location where past peaks are to be saved */
+/* pCentreFreqs Pointer to location where centre frequency of each band is */
+/* to be saved */
+/* AudioTime Audio time at which the spectral information is needed */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Succeeded */
+/* LVM_NULLADDRESS If any of input addresses are NULL */
+/* LVM_WRONGAUDIOTIME Failure due to audio time error */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+LVM_ReturnStatus_en LVM_GetSpectrum( LVM_Handle_t hInstance,
+ LVM_UINT8 *pCurrentPeaks,
+ LVM_UINT8 *pPastPeaks,
+ LVM_INT32 AudioTime);
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_SetVolumeNoSmoothing */
+/* */
+/* DESCRIPTION: */
+/* This function is used to set output volume without any smoothing */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pParams Control Parameters, only volume value is used here */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Succeeded */
+/* LVM_NULLADDRESS If any of input addresses are NULL */
+/* LVM_OUTOFRANGE When any of the control parameters are out of range */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+LVM_ReturnStatus_en LVM_SetVolumeNoSmoothing( LVM_Handle_t hInstance,
+ LVM_ControlParams_t *pParams);
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __LVM_H__ */
+
diff --git a/media/libeffects/lvm/lib/Bundle/src/LVM_API_Specials.c b/media/libeffects/lvm/lib/Bundle/src/LVM_API_Specials.c
new file mode 100755
index 0000000..2f6fa4c
--- /dev/null
+++ b/media/libeffects/lvm/lib/Bundle/src/LVM_API_Specials.c
@@ -0,0 +1,158 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/****************************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1002 $
+ $Date: 2010-06-28 13:40:09 +0200 (Mon, 28 Jun 2010) $
+
+*****************************************************************************************/
+
+
+/****************************************************************************************/
+/* */
+/* Includes */
+/* */
+/****************************************************************************************/
+
+#include "LVM_Private.h"
+#include "LVM_Tables.h"
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_GetSpectrum */
+/* */
+/* DESCRIPTION: */
+/* This function is used to retrieve Spectral information at a given Audio time */
+/* for display usage */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pCurrentPeaks Pointer to location where currents peaks are to be saved */
+/* pPastPeaks Pointer to location where past peaks are to be saved */
+/* AudioTime Audio time at which the spectral information is needed */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Succeeded */
+/* LVM_NULLADDRESS If any of input addresses are NULL */
+/* LVM_WRONGAUDIOTIME Failure due to audio time error */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+LVM_ReturnStatus_en LVM_GetSpectrum(
+ LVM_Handle_t hInstance,
+ LVM_UINT8 *pCurrentPeaks,
+ LVM_UINT8 *pPastPeaks,
+ LVM_INT32 AudioTime
+ )
+{
+ LVM_Instance_t *pInstance = (LVM_Instance_t *)hInstance;
+
+ pLVPSA_Handle_t *hPSAInstance;
+ LVPSA_RETURN LVPSA_Status;
+
+
+ if(pInstance == LVM_NULL)
+ {
+ return LVM_NULLADDRESS;
+ }
+
+ /*If PSA is not included at the time of instance creation, return without any processing*/
+ if(pInstance->InstParams.PSA_Included!=LVM_PSA_ON)
+ {
+ return LVM_SUCCESS;
+ }
+
+ hPSAInstance = pInstance->hPSAInstance;
+
+ if((pCurrentPeaks == LVM_NULL) ||
+ (pPastPeaks == LVM_NULL))
+ {
+ return LVM_NULLADDRESS;
+ }
+
+
+ /*
+ * Update new parameters if necessary
+ */
+ if (pInstance->ControlPending == LVM_TRUE)
+ {
+ LVM_ApplyNewSettings(hInstance);
+ }
+
+ /* If PSA module is disabled, do nothing */
+ if(pInstance->Params.PSA_Enable==LVM_PSA_OFF)
+ {
+ return LVM_ALGORITHMDISABLED;
+ }
+
+ LVPSA_Status = LVPSA_GetSpectrum(hPSAInstance,
+ (LVPSA_Time) (AudioTime),
+ (LVM_UINT8*) pCurrentPeaks,
+ (LVM_UINT8*) pPastPeaks );
+
+ if(LVPSA_Status != LVPSA_OK)
+ {
+ if(LVPSA_Status == LVPSA_ERROR_WRONGTIME)
+ {
+ return (LVM_ReturnStatus_en) LVM_WRONGAUDIOTIME;
+ }
+ else
+ {
+ return (LVM_ReturnStatus_en) LVM_NULLADDRESS;
+ }
+ }
+
+ return(LVM_SUCCESS);
+}
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_SetVolumeNoSmoothing */
+/* */
+/* DESCRIPTION: */
+/* This function is used to set output volume without any smoothing */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pParams Control Parameters, only volume value is used here */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Succeeded */
+/* LVM_NULLADDRESS If any of input addresses are NULL */
+/* LVM_OUTOFRANGE When any of the control parameters are out of range */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+LVM_ReturnStatus_en LVM_SetVolumeNoSmoothing( LVM_Handle_t hInstance,
+ LVM_ControlParams_t *pParams)
+{
+ LVM_Instance_t *pInstance =(LVM_Instance_t *)hInstance;
+ LVM_ReturnStatus_en Error;
+
+ /*Apply new controls*/
+ Error = LVM_SetControlParameters(hInstance,pParams);
+ pInstance->NoSmoothVolume = LVM_TRUE;
+ return Error;
+}
+
diff --git a/media/libeffects/lvm/lib/Bundle/src/LVM_Buffers.c b/media/libeffects/lvm/lib/Bundle/src/LVM_Buffers.c
new file mode 100755
index 0000000..41785a3
--- /dev/null
+++ b/media/libeffects/lvm/lib/Bundle/src/LVM_Buffers.c
@@ -0,0 +1,878 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/****************************************************************************************
+
+ $Author: nxp007753 $
+ $Revision: 1082 $
+ $Date: 2010-07-05 12:44:39 +0200 (Mon, 05 Jul 2010) $
+
+*****************************************************************************************/
+
+/****************************************************************************************/
+/* */
+/* Includes */
+/* */
+/****************************************************************************************/
+
+#include "LVM_Private.h"
+#include "VectorArithmetic.h"
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_BufferManagedIn */
+/* */
+/* DESCRIPTION: */
+/* Full buffer management allowing the user to provide input and output buffers on */
+/* any alignment and with any number of samples. The alignment is corrected within */
+/* the buffer management and the samples are grouped in to blocks of the correct size */
+/* before processing. */
+/* */
+/* PARAMETERS: */
+/* hInstance - Instance handle */
+/* pInData - Pointer to the input data stream */
+/* *pToProcess - Pointer to pointer to the start of data processing */
+/* *pProcessed - Pointer to pointer to the destination of the processed data */
+/* pNumSamples - Pointer to the number of samples to process */
+/* */
+/* RETURNS: */
+/* None */
+/* */
+/* NOTES: */
+/* */
+/****************************************************************************************/
+
+void LVM_BufferManagedIn(LVM_Handle_t hInstance,
+ const LVM_INT16 *pInData,
+ LVM_INT16 **pToProcess,
+ LVM_INT16 **pProcessed,
+ LVM_UINT16 *pNumSamples)
+{
+
+ LVM_INT16 SampleCount; /* Number of samples to be processed this call */
+ LVM_INT16 NumSamples; /* Number of samples in scratch buffer */
+ LVM_INT16 *pStart;
+ LVM_Instance_t *pInstance = (LVM_Instance_t *)hInstance;
+ LVM_Buffer_t *pBuffer;
+ LVM_INT16 *pDest;
+ LVM_INT16 NumChannels =2;
+
+
+ /*
+ * Set the processing address pointers
+ */
+ pBuffer = pInstance->pBufferManagement;
+ pDest = pBuffer->pScratch;
+ *pToProcess = pBuffer->pScratch;
+ *pProcessed = pBuffer->pScratch;
+
+ /*
+ * Check if it is the first call of a block
+ */
+ if (pInstance->SamplesToProcess == 0)
+ {
+ /*
+ * First call for a new block of samples
+ */
+ pInstance->SamplesToProcess = (LVM_INT16)(*pNumSamples + pBuffer->InDelaySamples);
+ pInstance->pInputSamples = (LVM_INT16 *)pInData;
+ pBuffer->BufferState = LVM_FIRSTCALL;
+ }
+ pStart = pInstance->pInputSamples; /* Pointer to the input samples */
+ pBuffer->SamplesToOutput = 0; /* Samples to output is same as number read for inplace processing */
+
+
+ /*
+ * Calculate the number of samples to process this call and update the buffer state
+ */
+ if (pInstance->SamplesToProcess > pInstance->InternalBlockSize)
+ {
+ /*
+ * Process the maximum bock size of samples.
+ */
+ SampleCount = pInstance->InternalBlockSize;
+ NumSamples = pInstance->InternalBlockSize;
+ }
+ else
+ {
+ /*
+ * Last call for the block, so calculate how many frames and samples to process
+ */
+ LVM_INT16 NumFrames;
+
+ NumSamples = pInstance->SamplesToProcess;
+ NumFrames = (LVM_INT16)(NumSamples >> MIN_INTERNAL_BLOCKSHIFT);
+ SampleCount = (LVM_INT16)(NumFrames << MIN_INTERNAL_BLOCKSHIFT);
+
+ /*
+ * Update the buffer state
+ */
+ if (pBuffer->BufferState == LVM_FIRSTCALL)
+ {
+ pBuffer->BufferState = LVM_FIRSTLASTCALL;
+ }
+ else
+ {
+ pBuffer->BufferState = LVM_LASTCALL;
+ }
+ }
+ *pNumSamples = (LVM_UINT16)SampleCount; /* Set the number of samples to process this call */
+
+
+ /*
+ * Copy samples from the delay buffer as required
+ */
+ if (((pBuffer->BufferState == LVM_FIRSTCALL) ||
+ (pBuffer->BufferState == LVM_FIRSTLASTCALL)) &&
+ (pBuffer->InDelaySamples != 0))
+ {
+ Copy_16(&pBuffer->InDelayBuffer[0], /* Source */
+ pDest, /* Destination */
+ (LVM_INT16)(NumChannels*pBuffer->InDelaySamples)); /* Number of delay samples, left and right */
+ NumSamples = (LVM_INT16)(NumSamples - pBuffer->InDelaySamples); /* Update sample count */
+ pDest += NumChannels * pBuffer->InDelaySamples; /* Update the destination pointer */
+ }
+
+
+ /*
+ * Copy the rest of the samples for this call from the input buffer
+ */
+ if (NumSamples > 0)
+ {
+ Copy_16(pStart, /* Source */
+ pDest, /* Destination */
+ (LVM_INT16)(NumChannels*NumSamples)); /* Number of input samples */
+ pStart += NumChannels * NumSamples; /* Update the input pointer */
+
+ /*
+ * Update the input data pointer and samples to output
+ */
+ pBuffer->SamplesToOutput = (LVM_INT16)(pBuffer->SamplesToOutput + NumSamples); /* Update samples to output */
+ }
+
+
+ /*
+ * Update the sample count and input pointer
+ */
+ pInstance->SamplesToProcess = (LVM_INT16)(pInstance->SamplesToProcess - SampleCount); /* Update the count of samples */
+ pInstance->pInputSamples = pStart; /* Update input sample pointer */
+
+
+ /*
+ * Save samples to the delay buffer if any left unprocessed
+ */
+ if ((pBuffer->BufferState == LVM_FIRSTLASTCALL) ||
+ (pBuffer->BufferState == LVM_LASTCALL))
+ {
+ NumSamples = pInstance->SamplesToProcess;
+ pStart = pBuffer->pScratch; /* Start of the buffer */
+ pStart += NumChannels*SampleCount; /* Offset by the number of processed samples */
+ if (NumSamples != 0)
+ {
+ Copy_16(pStart, /* Source */
+ &pBuffer->InDelayBuffer[0], /* Destination */
+ (LVM_INT16)(NumChannels*NumSamples)); /* Number of input samples */
+ }
+
+
+ /*
+ * Update the delay sample count
+ */
+ pBuffer->InDelaySamples = NumSamples; /* Number of delay sample pairs */
+ pInstance->SamplesToProcess = 0; /* All Samples used */
+ }
+}
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_BufferUnmanagedIn */
+/* */
+/* DESCRIPTION: */
+/* This mode is selected by the user code and disables the buffer management with the */
+/* exception of the maximum block size processing. The user must ensure that the */
+/* input and output buffers are 32-bit aligned and also that the number of samples to */
+/* process is a correct multiple of samples. */
+/* */
+/* PARAMETERS: */
+/* hInstance - Instance handle */
+/* *pToProcess - Pointer to the start of data processing */
+/* *pProcessed - Pointer to the destination of the processed data */
+/* pNumSamples - Pointer to the number of samples to process */
+/* */
+/* RETURNS: */
+/* None */
+/* */
+/* NOTES: */
+/* */
+/****************************************************************************************/
+
+void LVM_BufferUnmanagedIn(LVM_Handle_t hInstance,
+ LVM_INT16 **pToProcess,
+ LVM_INT16 **pProcessed,
+ LVM_UINT16 *pNumSamples)
+{
+
+ LVM_Instance_t *pInstance = (LVM_Instance_t *)hInstance;
+
+
+ /*
+ * Check if this is the first call of a block
+ */
+ if (pInstance->SamplesToProcess == 0)
+ {
+ pInstance->SamplesToProcess = (LVM_INT16)*pNumSamples; /* Get the number of samples on first call */
+ pInstance->pInputSamples = *pToProcess; /* Get the I/O pointers */
+ pInstance->pOutputSamples = *pProcessed;
+
+
+ /*
+ * Set te block size to process
+ */
+ if (pInstance->SamplesToProcess > pInstance->InternalBlockSize)
+ {
+ *pNumSamples = (LVM_UINT16)pInstance->InternalBlockSize;
+ }
+ else
+ {
+ *pNumSamples = (LVM_UINT16)pInstance->SamplesToProcess;
+ }
+ }
+
+ /*
+ * Set the process pointers
+ */
+ *pToProcess = pInstance->pInputSamples;
+ *pProcessed = pInstance->pOutputSamples;
+}
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_BufferOptimisedIn */
+/* */
+/* DESCRIPTION: */
+/* Optimised buffer management for the case where the data is outplace processing, */
+/* the output data is 32-bit aligned and there are sufficient samples to allow some */
+/* processing directly in the output buffer. This saves one data copy per sample */
+/* compared with the unoptimsed version. */
+/* */
+/* PARAMETERS: */
+/* hInstance - Instance handle */
+/* pInData - Pointer to the input data stream */
+/* *pToProcess - Pointer to the start of data processing */
+/* *pProcessed - Pointer to the destination of the processed data */
+/* pNumSamples - Pointer to the number of samples to process */
+/* */
+/* RETURNS: */
+/* None */
+/* */
+/* NOTES: */
+/* */
+/****************************************************************************************/
+
+void LVM_BufferOptimisedIn(LVM_Handle_t hInstance,
+ const LVM_INT16 *pInData,
+ LVM_INT16 **pToProcess,
+ LVM_INT16 **pProcessed,
+ LVM_UINT16 *pNumSamples)
+{
+
+ LVM_Instance_t *pInstance = (LVM_Instance_t *)hInstance;
+ LVM_Buffer_t *pBuffer = pInstance->pBufferManagement;
+ LVM_INT16 *pDest;
+ LVM_INT16 SampleCount;
+ LVM_INT16 NumSamples;
+ LVM_INT16 NumFrames;
+
+ /*
+ * Check if it is the first call for this block
+ */
+ if (pInstance->SamplesToProcess == 0)
+ {
+ /*
+ * First call for a new block of samples
+ */
+ pBuffer->BufferState = LVM_FIRSTCALL;
+ pInstance->pInputSamples = (LVM_INT16 *)pInData;
+ pInstance->SamplesToProcess = (LVM_INT16)*pNumSamples;
+ pBuffer->SamplesToOutput = (LVM_INT16)*pNumSamples;
+ pDest = *pProcessed; /* The start of the output buffer */
+
+
+ /*
+ * Copy the already processed samples to the output buffer
+ */
+ if (pBuffer->OutDelaySamples != 0)
+ {
+ Copy_16(&pBuffer->OutDelayBuffer[0], /* Source */
+ pDest, /* Detsination */
+ (LVM_INT16)(2*pBuffer->OutDelaySamples)); /* Number of delay samples */
+ pDest += 2 * pBuffer->OutDelaySamples; /* Update the output pointer */
+ pBuffer->SamplesToOutput = (LVM_INT16)(pBuffer->SamplesToOutput - pBuffer->OutDelaySamples); /* Update the numbr of samples to output */
+ }
+ *pToProcess = pDest; /* Set the address to start processing */
+ *pProcessed = pDest; /* Process in the output buffer, now inplace */
+
+ /*
+ * Copy the input delay buffer (unprocessed) samples to the output buffer
+ */
+ if (pBuffer->InDelaySamples != 0)
+ {
+ Copy_16(&pBuffer->InDelayBuffer[0], /* Source */
+ pDest, /* Destination */
+ (LVM_INT16)(2*pBuffer->InDelaySamples)); /* Number of delay samples */
+ pDest += 2 * pBuffer->InDelaySamples; /* Update the output pointer */
+ }
+
+
+ /*
+ * Calculate how many input samples to process and copy
+ */
+ NumSamples = (LVM_INT16)(*pNumSamples - pBuffer->OutDelaySamples); /* Number that will fit in the output buffer */
+ if (NumSamples >= pInstance->InternalBlockSize)
+ {
+ NumSamples = pInstance->InternalBlockSize;
+ }
+ NumFrames = (LVM_INT16)(NumSamples >> MIN_INTERNAL_BLOCKSHIFT);
+ SampleCount = (LVM_INT16)(NumFrames << MIN_INTERNAL_BLOCKSHIFT);
+ *pNumSamples = (LVM_UINT16)SampleCount; /* The number of samples to process */
+ pBuffer->SamplesToOutput = (LVM_INT16)(pBuffer->SamplesToOutput - SampleCount); /* Update the number of samples to output */
+ SampleCount = (LVM_INT16)(SampleCount - pBuffer->InDelaySamples); /* The number of samples to copy from the input */
+
+
+ /*
+ * Copy samples from the input buffer and update counts and pointers
+ */
+ Copy_16(pInstance->pInputSamples, /* Source */
+ pDest, /* Destination */
+ (LVM_INT16)(2*SampleCount)); /* Number of input samples */
+ pInstance->pInputSamples += 2 * SampleCount; /* Update the input pointer */
+ pInstance->pOutputSamples = pDest + (2 * SampleCount); /* Update the output pointer */
+ pInstance->SamplesToProcess = (LVM_INT16)(pInstance->SamplesToProcess - SampleCount); /* Samples left in the input buffer */
+ }
+ else
+ {
+ /*
+ * Second or subsequent call in optimised mode
+ */
+ if (pBuffer->SamplesToOutput >= MIN_INTERNAL_BLOCKSIZE)
+ {
+ /*
+ * More samples can be processed directly in the output buffer
+ */
+ *pToProcess = pInstance->pOutputSamples; /* Set the address to start processing */
+ *pProcessed = pInstance->pOutputSamples; /* Process in the output buffer, now inplace */
+ NumSamples = pBuffer->SamplesToOutput; /* Number that will fit in the output buffer */
+ if (NumSamples >= pInstance->InternalBlockSize)
+ {
+ NumSamples = pInstance->InternalBlockSize;
+ }
+ NumFrames = (LVM_INT16)(NumSamples >> MIN_INTERNAL_BLOCKSHIFT);
+ SampleCount = (LVM_INT16)(NumFrames << MIN_INTERNAL_BLOCKSHIFT);
+ *pNumSamples = (LVM_UINT16)SampleCount; /* The number of samples to process */
+
+
+ /*
+ * Copy samples from the input buffer and update counts and pointers
+ */
+ Copy_16(pInstance->pInputSamples, /* Source */
+ pInstance->pOutputSamples, /* Destination */
+ (LVM_INT16)(2*SampleCount)); /* Number of input samples */
+ pInstance->pInputSamples += 2 * SampleCount; /* Update the input pointer */
+ pInstance->pOutputSamples += 2 * SampleCount; /* Update the output pointer */
+ pInstance->SamplesToProcess = (LVM_INT16)(pInstance->SamplesToProcess - SampleCount); /* Samples left in the input buffer */
+ pBuffer->SamplesToOutput = (LVM_INT16)(pBuffer->SamplesToOutput - SampleCount); /* Number that will fit in the output buffer */
+ }
+ else
+ {
+ /*
+ * The remaining samples can not be processed in the output buffer
+ */
+ pBuffer->BufferState = LVM_LASTCALL; /* Indicate this is the last bock to process */
+ *pToProcess = pBuffer->pScratch; /* Set the address to start processing */
+ *pProcessed = pBuffer->pScratch; /* Process in the output buffer, now inplace */
+ NumSamples = pInstance->SamplesToProcess; /* Number left to be processed */
+ NumFrames = (LVM_INT16)(NumSamples >> MIN_INTERNAL_BLOCKSHIFT);
+ SampleCount = (LVM_INT16)(NumFrames << MIN_INTERNAL_BLOCKSHIFT);
+ *pNumSamples = (LVM_UINT16)SampleCount; /* The number of samples to process */
+
+
+ /*
+ * Copy samples from the input buffer and update counts and pointers
+ */
+ Copy_16(pInstance->pInputSamples, /* Source */
+ pBuffer->pScratch, /* Destination */
+ (LVM_INT16)(2*SampleCount)); /* Number of input samples */
+ pInstance->pInputSamples += 2 * SampleCount; /* Update the input pointer */
+ pInstance->SamplesToProcess = (LVM_INT16)(pInstance->SamplesToProcess - SampleCount); /* Samples left in the input buffer */
+ }
+ }
+}
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_BufferIn */
+/* */
+/* DESCRIPTION: */
+/* This function manages the data input, it has the following features: */
+/* - Accepts data in 16-bit aligned memory */
+/* - Copies the data to 32-bit aligned memory */
+/* - Converts Mono inputs to Mono-in-Stereo */
+/* - Accepts any number of samples as input, except 0 */
+/* - Breaks the input sample stream in to blocks of the configured frame size or */
+/* multiples of the frame size */
+/* - Limits the processing block size to the maximum block size. */
+/* - Works with inplace or outplace processing automatically */
+/* */
+/* To manage the data the function has a number of operating states: */
+/* LVM_FIRSTCALL - The first call for this block of input samples */
+/* LVM_MAXBLOCKCALL - The current block is the maximum size. Only used for the */
+/* second and subsequent blocks. */
+/* LVM_LASTCALL - The last call for this block of input samples */
+/* LVM_FIRSTLASTCALL - This is the first and last call for this block of input*/
+/* samples, this occurs when the number of samples to */
+/* process is less than the maximum block size. */
+/* */
+/* The function uses an internal delay buffer the size of the minimum frame, this is */
+/* used to temporarily hold samples when the number of samples to process is not a */
+/* multiple of the frame size. */
+/* */
+/* To ensure correct operation with inplace buffering the number of samples to output*/
+/* per call is calculated in this function and is set to the number of samples read */
+/* from the input buffer. */
+/* */
+/* The total number of samples to process is stored when the function is called for */
+/* the first time. The value is overwritten by the size of the block to be processed */
+/* in each call so the size of the processing blocks can be controlled. The number of */
+/* samples actually processed for each block of input samples is always a multiple of*/
+/* the frame size so for any particular block of input samples the actual number of */
+/* processed samples may not match the number of input samples, sometime it will be */
+/* sometimes less. The average is the same and the difference is never more than the */
+/* frame size. */
+/* */
+/* PARAMETERS: */
+/* hInstance - Instance handle */
+/* pInData - Pointer to the input data stream */
+/* *pToProcess - Pointer to the start of data processing */
+/* *pProcessed - Pointer to the destination of the processed data */
+/* pNumSamples - Pointer to the number of samples to process */
+/* */
+/* RETURNS: */
+/* None */
+/* */
+/* NOTES: */
+/* */
+/****************************************************************************************/
+
+void LVM_BufferIn(LVM_Handle_t hInstance,
+ const LVM_INT16 *pInData,
+ LVM_INT16 **pToProcess,
+ LVM_INT16 **pProcessed,
+ LVM_UINT16 *pNumSamples)
+{
+
+ LVM_Instance_t *pInstance = (LVM_Instance_t *)hInstance;
+
+
+ /*
+ * Check which mode, managed or unmanaged
+ */
+ if (pInstance->InstParams.BufferMode == LVM_MANAGED_BUFFERS)
+ {
+ LVM_BufferManagedIn(hInstance,
+ pInData,
+ pToProcess,
+ pProcessed,
+ pNumSamples);
+ }
+ else
+ {
+ LVM_BufferUnmanagedIn(hInstance,
+ pToProcess,
+ pProcessed,
+ pNumSamples);
+ }
+}
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_BufferManagedOut */
+/* */
+/* DESCRIPTION: */
+/* Full buffer management output. This works in conjunction with the managed input */
+/* routine and ensures the correct number of samples are always output to the output */
+/* buffer. */
+/* */
+/* PARAMETERS: */
+/* hInstance - Instance handle */
+/* pOutData - Pointer to the output data stream */
+/* pNumSamples - Pointer to the number of samples to process */
+/* */
+/* RETURNS: */
+/* None */
+/* */
+/* NOTES: */
+/* */
+/****************************************************************************************/
+
+void LVM_BufferManagedOut(LVM_Handle_t hInstance,
+ LVM_INT16 *pOutData,
+ LVM_UINT16 *pNumSamples)
+{
+
+ LVM_Instance_t *pInstance = (LVM_Instance_t *)hInstance;
+ LVM_Buffer_t *pBuffer = pInstance->pBufferManagement;
+ LVM_INT16 SampleCount = (LVM_INT16)*pNumSamples;
+ LVM_INT16 NumSamples;
+ LVM_INT16 *pStart;
+ LVM_INT16 *pDest;
+
+
+ /*
+ * Set the pointers
+ */
+ NumSamples = pBuffer->SamplesToOutput;
+ pStart = pBuffer->pScratch;
+
+
+ /*
+ * check if it is the first call of a block
+ */
+ if ((pBuffer->BufferState == LVM_FIRSTCALL) ||
+ (pBuffer->BufferState == LVM_FIRSTLASTCALL))
+ {
+ /* First call for a new block */
+ pInstance->pOutputSamples = pOutData; /* Initialise the destination */
+ }
+ pDest = pInstance->pOutputSamples; /* Set the output address */
+
+
+ /*
+ * If the number of samples is non-zero then there are still samples to send to
+ * the output buffer
+ */
+ if ((NumSamples != 0) &&
+ (pBuffer->OutDelaySamples != 0))
+ {
+ /*
+ * Copy the delayed output buffer samples to the output
+ */
+ if (pBuffer->OutDelaySamples <= NumSamples)
+ {
+ /*
+ * Copy all output delay samples to the output
+ */
+ Copy_16(&pBuffer->OutDelayBuffer[0], /* Source */
+ pDest, /* Detsination */
+ (LVM_INT16)(2*pBuffer->OutDelaySamples)); /* Number of delay samples */
+
+ /*
+ * Update the pointer and sample counts
+ */
+ pDest += 2*pBuffer->OutDelaySamples; /* Output sample pointer */
+ NumSamples = (LVM_INT16)(NumSamples - pBuffer->OutDelaySamples); /* Samples left to send */
+ pBuffer->OutDelaySamples = 0; /* No samples left in the buffer */
+
+ }
+ else
+ {
+ /*
+ * Copy only some of the ouput delay samples to the output
+ */
+ Copy_16(&pBuffer->OutDelayBuffer[0], /* Source */
+ pDest, /* Detsination */
+ (LVM_INT16)(2*NumSamples)); /* Number of delay samples */
+
+ /*
+ * Update the pointer and sample counts
+ */
+ pDest += 2*NumSamples; /* Output sample pointer */
+ pBuffer->OutDelaySamples = (LVM_INT16)(pBuffer->OutDelaySamples - NumSamples); /* No samples left in the buffer */
+
+
+ /*
+ * Realign the delay buffer data to avoid using circular buffer management
+ */
+ Copy_16(&pBuffer->OutDelayBuffer[2*NumSamples], /* Source */
+ &pBuffer->OutDelayBuffer[0], /* Destination */
+ (LVM_INT16)(2*pBuffer->OutDelaySamples)); /* Number of samples to move */
+ NumSamples = 0; /* Samples left to send */
+ }
+ }
+
+
+ /*
+ * Copy the processed results to the output
+ */
+ if ((NumSamples != 0) &&
+ (SampleCount != 0))
+ {
+ if (SampleCount <= NumSamples)
+ {
+ /*
+ * Copy all processed samples to the output
+ */
+ Copy_16(pStart, /* Source */
+ pDest, /* Detsination */
+ (LVM_INT16)(2*SampleCount)); /* Number of processed samples */
+
+ /*
+ * Update the pointer and sample counts
+ */
+ pDest += 2 * SampleCount; /* Output sample pointer */
+ NumSamples = (LVM_INT16)(NumSamples - SampleCount); /* Samples left to send */
+ SampleCount = 0; /* No samples left in the buffer */
+ }
+ else
+ {
+ /*
+ * Copy only some processed samples to the output
+ */
+ Copy_16(pStart, /* Source */
+ pDest, /* Destination */
+ (LVM_INT16)(2*NumSamples)); /* Number of processed samples */
+
+
+ /*
+ * Update the pointers and sample counts
+ */
+ pStart += 2 * NumSamples; /* Processed sample pointer */
+ pDest += 2 * NumSamples; /* Output sample pointer */
+ SampleCount = (LVM_INT16)(SampleCount - NumSamples); /* Processed samples left */
+ NumSamples = 0; /* Clear the sample count */
+ }
+ }
+
+
+ /*
+ * Copy the remaining processed data to the output delay buffer
+ */
+ if (SampleCount != 0)
+ {
+ Copy_16(pStart, /* Source */
+ &pBuffer->OutDelayBuffer[2*pBuffer->OutDelaySamples], /* Destination */
+ (LVM_INT16)(2*SampleCount)); /* Number of processed samples */
+ pBuffer->OutDelaySamples = (LVM_INT16)(pBuffer->OutDelaySamples + SampleCount); /* Update the buffer count */
+ }
+
+
+ /*
+ * pointers, counts and set default buffer processing
+ */
+ pBuffer->SamplesToOutput = NumSamples; /* Samples left to send */
+ pInstance->pOutputSamples = pDest; /* Output sample pointer */
+ pBuffer->BufferState = LVM_MAXBLOCKCALL; /* Set for the default call block size */
+ *pNumSamples = (LVM_UINT16)pInstance->SamplesToProcess; /* This will terminate the loop when all samples processed */
+}
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_BufferUnmanagedOut */
+/* */
+/* DESCRIPTION: */
+/* This works in conjunction with the unmanaged input routine and updates the number */
+/* of samples left to be processed and adjusts the buffer pointers. */
+/* */
+/* PARAMETERS: */
+/* hInstance - Instance handle */
+/* pNumSamples - Pointer to the number of samples to process */
+/* */
+/* RETURNS: */
+/* None */
+/* */
+/* NOTES: */
+/* */
+/****************************************************************************************/
+
+void LVM_BufferUnmanagedOut(LVM_Handle_t hInstance,
+ LVM_UINT16 *pNumSamples)
+{
+
+ LVM_Instance_t *pInstance = (LVM_Instance_t *)hInstance;
+ LVM_INT16 NumChannels =2;
+
+
+ /*
+ * Update sample counts
+ */
+ pInstance->pInputSamples += (LVM_INT16)(*pNumSamples * NumChannels); /* Update the I/O pointers */
+ pInstance->pOutputSamples += (LVM_INT16)(*pNumSamples * 2);
+ pInstance->SamplesToProcess = (LVM_INT16)(pInstance->SamplesToProcess - *pNumSamples); /* Update the sample count */
+
+ /*
+ * Set te block size to process
+ */
+ if (pInstance->SamplesToProcess > pInstance->InternalBlockSize)
+ {
+ *pNumSamples = (LVM_UINT16)pInstance->InternalBlockSize;
+ }
+ else
+ {
+ *pNumSamples = (LVM_UINT16)pInstance->SamplesToProcess;
+ }
+}
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_BufferOptimisedOut */
+/* */
+/* DESCRIPTION: */
+/* This works in conjunction with the optimised input routine and copies the last few */
+/* processed and unprocessed samples to their respective buffers. */
+/* */
+/* PARAMETERS: */
+/* hInstance - Instance handle */
+/* pNumSamples - Pointer to the number of samples to process */
+/* */
+/* RETURNS: */
+/* None */
+/* */
+/* NOTES: */
+/* */
+/****************************************************************************************/
+
+void LVM_BufferOptimisedOut(LVM_Handle_t hInstance,
+ LVM_UINT16 *pNumSamples)
+{
+
+ LVM_Instance_t *pInstance = (LVM_Instance_t *)hInstance;
+ LVM_Buffer_t *pBuffer = pInstance->pBufferManagement;
+
+ /*
+ * Check if it is the last block to process
+ */
+ if (pBuffer->BufferState == LVM_LASTCALL)
+ {
+ LVM_INT16 *pSrc = pBuffer->pScratch;
+
+ /*
+ * Copy the unprocessed samples to the input delay buffer
+ */
+ if (pInstance->SamplesToProcess != 0)
+ {
+ Copy_16(pInstance->pInputSamples, /* Source */
+ &pBuffer->InDelayBuffer[0], /* Destination */
+ (LVM_INT16)(2*pInstance->SamplesToProcess)); /* Number of input samples */
+ pBuffer->InDelaySamples = pInstance->SamplesToProcess;
+ pInstance->SamplesToProcess = 0;
+ }
+ else
+ {
+ pBuffer->InDelaySamples = 0;
+ }
+
+
+ /*
+ * Fill the last empty spaces in the output buffer
+ */
+ if (pBuffer->SamplesToOutput != 0)
+ {
+ Copy_16(pSrc, /* Source */
+ pInstance->pOutputSamples, /* Destination */
+ (LVM_INT16)(2*pBuffer->SamplesToOutput)); /* Number of input samples */
+ *pNumSamples = (LVM_UINT16)(*pNumSamples - pBuffer->SamplesToOutput);
+ pSrc += 2 * pBuffer->SamplesToOutput; /* Update scratch pointer */
+ pBuffer->SamplesToOutput = 0; /* No more samples in this block */
+ }
+
+
+ /*
+ * Save any remaining processed samples in the output delay buffer
+ */
+ if (*pNumSamples != 0)
+ {
+ Copy_16(pSrc, /* Source */
+ &pBuffer->OutDelayBuffer[0], /* Destination */
+ (LVM_INT16)(2**pNumSamples)); /* Number of input samples */
+
+ pBuffer->OutDelaySamples = (LVM_INT16)*pNumSamples;
+
+ *pNumSamples = 0; /* No more samples in this block */
+ }
+ else
+ {
+ pBuffer->OutDelaySamples = 0;
+ }
+ }
+}
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_BufferOut */
+/* */
+/* DESCRIPTION: */
+/* This function manages the data output, it has the following features: */
+/* - Output data to 16-bit aligned memory */
+/* - Reads data from 32-bit aligned memory */
+/* - Reads data only in blocks of frame size or multiples of frame size */
+/* - Writes the same number of samples as the LVM_BufferIn function reads */
+/* - Works with inplace or outplace processing automatically */
+/* */
+/* To manage the data the function has a number of operating states: */
+/* LVM_FIRSTCALL - The first call for this block of input samples */
+/* LVM_FIRSTLASTCALL - This is the first and last call for this block of input*/
+/* samples, this occurs when the number of samples to */
+/* process is less than the maximum block size. */
+/* */
+/* The function uses an internal delay buffer the size of the minimum frame, this is */
+/* used to temporarily hold samples when the number of samples to write is not a */
+/* multiple of the frame size. */
+/* */
+/* To ensure correct operation with inplace buffering the number of samples to output*/
+/* per call is always the same as the number of samples read from the input buffer. */
+/* */
+/* PARAMETERS: */
+/* hInstance - Instance handle */
+/* pOutData - Pointer to the output data stream */
+/* pNumSamples - Pointer to the number of samples to process */
+/* */
+/* RETURNS: */
+/* None */
+/* */
+/* NOTES: */
+/* */
+/****************************************************************************************/
+
+void LVM_BufferOut(LVM_Handle_t hInstance,
+ LVM_INT16 *pOutData,
+ LVM_UINT16 *pNumSamples)
+{
+
+ LVM_Instance_t *pInstance = (LVM_Instance_t *)hInstance;
+
+
+ /*
+ * Check which mode, managed or unmanaged
+ */
+ if (pInstance->InstParams.BufferMode == LVM_MANAGED_BUFFERS)
+ {
+ LVM_BufferManagedOut(hInstance,
+ pOutData,
+ pNumSamples);
+ }
+ else
+ {
+ LVM_BufferUnmanagedOut(hInstance,
+ pNumSamples);
+ }
+}
+
diff --git a/media/libeffects/lvm/lib/Bundle/src/LVM_Coeffs.h b/media/libeffects/lvm/lib/Bundle/src/LVM_Coeffs.h
new file mode 100755
index 0000000..f578db9
--- /dev/null
+++ b/media/libeffects/lvm/lib/Bundle/src/LVM_Coeffs.h
@@ -0,0 +1,573 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __LVM_COEFFS_H__
+#define __LVM_COEFFS_H__
+
+
+/************************************************************************************/
+/* */
+/* High Pass Shelving Filter coefficients */
+/* */
+/************************************************************************************/
+
+#define TrebleBoostCorner 8000
+#define TrebleBoostMinRate 4
+#define TrebleBoostSteps 15
+
+
+/* Coefficients for sample rate 22050Hz */
+ /* Gain = 1.000000 dB */
+#define HPF_Fs22050_Gain1_A0 5383 /* Floating point value 0.164291 */
+#define HPF_Fs22050_Gain1_A1 16859 /* Floating point value 0.514492 */
+#define HPF_Fs22050_Gain1_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain1_B1 12125 /* Floating point value 0.370033 */
+#define HPF_Fs22050_Gain1_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain1_Shift 1 /* Shift value */
+ /* Gain = 2.000000 dB */
+#define HPF_Fs22050_Gain2_A0 4683 /* Floating point value 0.142925 */
+#define HPF_Fs22050_Gain2_A1 17559 /* Floating point value 0.535858 */
+#define HPF_Fs22050_Gain2_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain2_B1 12125 /* Floating point value 0.370033 */
+#define HPF_Fs22050_Gain2_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain2_Shift 1 /* Shift value */
+ /* Gain = 3.000000 dB */
+#define HPF_Fs22050_Gain3_A0 3898 /* Floating point value 0.118953 */
+#define HPF_Fs22050_Gain3_A1 18345 /* Floating point value 0.559830 */
+#define HPF_Fs22050_Gain3_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain3_B1 12125 /* Floating point value 0.370033 */
+#define HPF_Fs22050_Gain3_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain3_Shift 1 /* Shift value */
+ /* Gain = 4.000000 dB */
+#define HPF_Fs22050_Gain4_A0 3016 /* Floating point value 0.092055 */
+#define HPF_Fs22050_Gain4_A1 19226 /* Floating point value 0.586728 */
+#define HPF_Fs22050_Gain4_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain4_B1 12125 /* Floating point value 0.370033 */
+#define HPF_Fs22050_Gain4_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain4_Shift 1 /* Shift value */
+ /* Gain = 5.000000 dB */
+#define HPF_Fs22050_Gain5_A0 2028 /* Floating point value 0.061876 */
+#define HPF_Fs22050_Gain5_A1 20215 /* Floating point value 0.616907 */
+#define HPF_Fs22050_Gain5_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain5_B1 12125 /* Floating point value 0.370033 */
+#define HPF_Fs22050_Gain5_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain5_Shift 1 /* Shift value */
+ /* Gain = 6.000000 dB */
+#define HPF_Fs22050_Gain6_A0 918 /* Floating point value 0.028013 */
+#define HPF_Fs22050_Gain6_A1 21324 /* Floating point value 0.650770 */
+#define HPF_Fs22050_Gain6_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain6_B1 12125 /* Floating point value 0.370033 */
+#define HPF_Fs22050_Gain6_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain6_Shift 1 /* Shift value */
+ /* Gain = 7.000000 dB */
+#define HPF_Fs22050_Gain7_A0 -164 /* Floating point value -0.005002 */
+#define HPF_Fs22050_Gain7_A1 11311 /* Floating point value 0.345199 */
+#define HPF_Fs22050_Gain7_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain7_B1 12125 /* Floating point value 0.370033 */
+#define HPF_Fs22050_Gain7_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain7_Shift 2 /* Shift value */
+ /* Gain = 8.000000 dB */
+#define HPF_Fs22050_Gain8_A0 -864 /* Floating point value -0.026368 */
+#define HPF_Fs22050_Gain8_A1 12012 /* Floating point value 0.366565 */
+#define HPF_Fs22050_Gain8_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain8_B1 12125 /* Floating point value 0.370033 */
+#define HPF_Fs22050_Gain8_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain8_Shift 2 /* Shift value */
+ /* Gain = 9.000000 dB */
+#define HPF_Fs22050_Gain9_A0 -1650 /* Floating point value -0.050340 */
+#define HPF_Fs22050_Gain9_A1 12797 /* Floating point value 0.390537 */
+#define HPF_Fs22050_Gain9_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain9_B1 12125 /* Floating point value 0.370033 */
+#define HPF_Fs22050_Gain9_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain9_Shift 2 /* Shift value */
+ /* Gain = 10.000000 dB */
+#define HPF_Fs22050_Gain10_A0 -2531 /* Floating point value -0.077238 */
+#define HPF_Fs22050_Gain10_A1 13679 /* Floating point value 0.417435 */
+#define HPF_Fs22050_Gain10_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain10_B1 12125 /* Floating point value 0.370033 */
+#define HPF_Fs22050_Gain10_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain10_Shift 2 /* Shift value */
+ /* Gain = 11.000000 dB */
+#define HPF_Fs22050_Gain11_A0 -3520 /* Floating point value -0.107417 */
+#define HPF_Fs22050_Gain11_A1 14667 /* Floating point value 0.447615 */
+#define HPF_Fs22050_Gain11_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain11_B1 12125 /* Floating point value 0.370033 */
+#define HPF_Fs22050_Gain11_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain11_Shift 2 /* Shift value */
+ /* Gain = 12.000000 dB */
+#define HPF_Fs22050_Gain12_A0 -4629 /* Floating point value -0.141279 */
+#define HPF_Fs22050_Gain12_A1 15777 /* Floating point value 0.481477 */
+#define HPF_Fs22050_Gain12_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain12_B1 12125 /* Floating point value 0.370033 */
+#define HPF_Fs22050_Gain12_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain12_Shift 2 /* Shift value */
+ /* Gain = 13.000000 dB */
+#define HPF_Fs22050_Gain13_A0 -2944 /* Floating point value -0.089849 */
+#define HPF_Fs22050_Gain13_A1 8531 /* Floating point value 0.260352 */
+#define HPF_Fs22050_Gain13_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain13_B1 12125 /* Floating point value 0.370033 */
+#define HPF_Fs22050_Gain13_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain13_Shift 3 /* Shift value */
+ /* Gain = 14.000000 dB */
+#define HPF_Fs22050_Gain14_A0 -3644 /* Floating point value -0.111215 */
+#define HPF_Fs22050_Gain14_A1 9231 /* Floating point value 0.281718 */
+#define HPF_Fs22050_Gain14_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain14_B1 12125 /* Floating point value 0.370033 */
+#define HPF_Fs22050_Gain14_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain14_Shift 3 /* Shift value */
+ /* Gain = 15.000000 dB */
+#define HPF_Fs22050_Gain15_A0 -4430 /* Floating point value -0.135187 */
+#define HPF_Fs22050_Gain15_A1 10017 /* Floating point value 0.305690 */
+#define HPF_Fs22050_Gain15_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain15_B1 12125 /* Floating point value 0.370033 */
+#define HPF_Fs22050_Gain15_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs22050_Gain15_Shift 3 /* Shift value */
+
+
+/* Coefficients for sample rate 24000Hz */
+ /* Gain = 1.000000 dB */
+#define HPF_Fs24000_Gain1_A0 3625 /* Floating point value 0.110628 */
+#define HPF_Fs24000_Gain1_A1 16960 /* Floating point value 0.517578 */
+#define HPF_Fs24000_Gain1_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain1_B1 8780 /* Floating point value 0.267949 */
+#define HPF_Fs24000_Gain1_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain1_Shift 1 /* Shift value */
+ /* Gain = 2.000000 dB */
+#define HPF_Fs24000_Gain2_A0 2811 /* Floating point value 0.085800 */
+#define HPF_Fs24000_Gain2_A1 17774 /* Floating point value 0.542406 */
+#define HPF_Fs24000_Gain2_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain2_B1 8780 /* Floating point value 0.267949 */
+#define HPF_Fs24000_Gain2_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain2_Shift 1 /* Shift value */
+ /* Gain = 3.000000 dB */
+#define HPF_Fs24000_Gain3_A0 1899 /* Floating point value 0.057943 */
+#define HPF_Fs24000_Gain3_A1 18686 /* Floating point value 0.570263 */
+#define HPF_Fs24000_Gain3_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain3_B1 8780 /* Floating point value 0.267949 */
+#define HPF_Fs24000_Gain3_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain3_Shift 1 /* Shift value */
+ /* Gain = 4.000000 dB */
+#define HPF_Fs24000_Gain4_A0 874 /* Floating point value 0.026687 */
+#define HPF_Fs24000_Gain4_A1 19711 /* Floating point value 0.601519 */
+#define HPF_Fs24000_Gain4_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain4_B1 8780 /* Floating point value 0.267949 */
+#define HPF_Fs24000_Gain4_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain4_Shift 1 /* Shift value */
+ /* Gain = 5.000000 dB */
+#define HPF_Fs24000_Gain5_A0 -275 /* Floating point value -0.008383 */
+#define HPF_Fs24000_Gain5_A1 20860 /* Floating point value 0.636589 */
+#define HPF_Fs24000_Gain5_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain5_B1 8780 /* Floating point value 0.267949 */
+#define HPF_Fs24000_Gain5_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain5_Shift 1 /* Shift value */
+ /* Gain = 6.000000 dB */
+#define HPF_Fs24000_Gain6_A0 -1564 /* Floating point value -0.047733 */
+#define HPF_Fs24000_Gain6_A1 22149 /* Floating point value 0.675938 */
+#define HPF_Fs24000_Gain6_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain6_B1 8780 /* Floating point value 0.267949 */
+#define HPF_Fs24000_Gain6_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain6_Shift 1 /* Shift value */
+ /* Gain = 7.000000 dB */
+#define HPF_Fs24000_Gain7_A0 -1509 /* Floating point value -0.046051 */
+#define HPF_Fs24000_Gain7_A1 11826 /* Floating point value 0.360899 */
+#define HPF_Fs24000_Gain7_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain7_B1 8780 /* Floating point value 0.267949 */
+#define HPF_Fs24000_Gain7_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain7_Shift 2 /* Shift value */
+ /* Gain = 8.000000 dB */
+#define HPF_Fs24000_Gain8_A0 -2323 /* Floating point value -0.070878 */
+#define HPF_Fs24000_Gain8_A1 12640 /* Floating point value 0.385727 */
+#define HPF_Fs24000_Gain8_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain8_B1 8780 /* Floating point value 0.267949 */
+#define HPF_Fs24000_Gain8_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain8_Shift 2 /* Shift value */
+ /* Gain = 9.000000 dB */
+#define HPF_Fs24000_Gain9_A0 -3235 /* Floating point value -0.098736 */
+#define HPF_Fs24000_Gain9_A1 13552 /* Floating point value 0.413584 */
+#define HPF_Fs24000_Gain9_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain9_B1 8780 /* Floating point value 0.267949 */
+#define HPF_Fs24000_Gain9_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain9_Shift 2 /* Shift value */
+ /* Gain = 10.000000 dB */
+#define HPF_Fs24000_Gain10_A0 -4260 /* Floating point value -0.129992 */
+#define HPF_Fs24000_Gain10_A1 14577 /* Floating point value 0.444841 */
+#define HPF_Fs24000_Gain10_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain10_B1 8780 /* Floating point value 0.267949 */
+#define HPF_Fs24000_Gain10_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain10_Shift 2 /* Shift value */
+ /* Gain = 11.000000 dB */
+#define HPF_Fs24000_Gain11_A0 -5409 /* Floating point value -0.165062 */
+#define HPF_Fs24000_Gain11_A1 15726 /* Floating point value 0.479911 */
+#define HPF_Fs24000_Gain11_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain11_B1 8780 /* Floating point value 0.267949 */
+#define HPF_Fs24000_Gain11_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain11_Shift 2 /* Shift value */
+ /* Gain = 12.000000 dB */
+#define HPF_Fs24000_Gain12_A0 -6698 /* Floating point value -0.204411 */
+#define HPF_Fs24000_Gain12_A1 17015 /* Floating point value 0.519260 */
+#define HPF_Fs24000_Gain12_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain12_B1 8780 /* Floating point value 0.267949 */
+#define HPF_Fs24000_Gain12_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain12_Shift 2 /* Shift value */
+ /* Gain = 13.000000 dB */
+#define HPF_Fs24000_Gain13_A0 -4082 /* Floating point value -0.124576 */
+#define HPF_Fs24000_Gain13_A1 9253 /* Floating point value 0.282374 */
+#define HPF_Fs24000_Gain13_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain13_B1 8780 /* Floating point value 0.267949 */
+#define HPF_Fs24000_Gain13_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain13_Shift 3 /* Shift value */
+ /* Gain = 14.000000 dB */
+#define HPF_Fs24000_Gain14_A0 -4896 /* Floating point value -0.149404 */
+#define HPF_Fs24000_Gain14_A1 10066 /* Floating point value 0.307202 */
+#define HPF_Fs24000_Gain14_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain14_B1 8780 /* Floating point value 0.267949 */
+#define HPF_Fs24000_Gain14_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain14_Shift 3 /* Shift value */
+ /* Gain = 15.000000 dB */
+#define HPF_Fs24000_Gain15_A0 -5808 /* Floating point value -0.177261 */
+#define HPF_Fs24000_Gain15_A1 10979 /* Floating point value 0.335059 */
+#define HPF_Fs24000_Gain15_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain15_B1 8780 /* Floating point value 0.267949 */
+#define HPF_Fs24000_Gain15_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs24000_Gain15_Shift 3 /* Shift value */
+
+
+/* Coefficients for sample rate 32000Hz */
+ /* Gain = 1.000000 dB */
+#define HPF_Fs32000_Gain1_A0 17225 /* Floating point value 0.525677 */
+#define HPF_Fs32000_Gain1_A1 -990 /* Floating point value -0.030227 */
+#define HPF_Fs32000_Gain1_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain1_B1 0 /* Floating point value -0.000000 */
+#define HPF_Fs32000_Gain1_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain1_Shift 1 /* Shift value */
+ /* Gain = 2.000000 dB */
+#define HPF_Fs32000_Gain2_A0 18337 /* Floating point value 0.559593 */
+#define HPF_Fs32000_Gain2_A1 -2102 /* Floating point value -0.064142 */
+#define HPF_Fs32000_Gain2_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain2_B1 0 /* Floating point value -0.000000 */
+#define HPF_Fs32000_Gain2_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain2_Shift 1 /* Shift value */
+ /* Gain = 3.000000 dB */
+#define HPF_Fs32000_Gain3_A0 19584 /* Floating point value 0.597646 */
+#define HPF_Fs32000_Gain3_A1 -3349 /* Floating point value -0.102196 */
+#define HPF_Fs32000_Gain3_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain3_B1 0 /* Floating point value -0.000000 */
+#define HPF_Fs32000_Gain3_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain3_Shift 1 /* Shift value */
+ /* Gain = 4.000000 dB */
+#define HPF_Fs32000_Gain4_A0 20983 /* Floating point value 0.640343 */
+#define HPF_Fs32000_Gain4_A1 -4748 /* Floating point value -0.144893 */
+#define HPF_Fs32000_Gain4_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain4_B1 0 /* Floating point value -0.000000 */
+#define HPF_Fs32000_Gain4_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain4_Shift 1 /* Shift value */
+ /* Gain = 5.000000 dB */
+#define HPF_Fs32000_Gain5_A0 22553 /* Floating point value 0.688250 */
+#define HPF_Fs32000_Gain5_A1 -6318 /* Floating point value -0.192799 */
+#define HPF_Fs32000_Gain5_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain5_B1 0 /* Floating point value -0.000000 */
+#define HPF_Fs32000_Gain5_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain5_Shift 1 /* Shift value */
+ /* Gain = 6.000000 dB */
+#define HPF_Fs32000_Gain6_A0 24314 /* Floating point value 0.742002 */
+#define HPF_Fs32000_Gain6_A1 -8079 /* Floating point value -0.246551 */
+#define HPF_Fs32000_Gain6_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain6_B1 0 /* Floating point value -0.000000 */
+#define HPF_Fs32000_Gain6_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain6_Shift 1 /* Shift value */
+ /* Gain = 7.000000 dB */
+#define HPF_Fs32000_Gain7_A0 13176 /* Floating point value 0.402109 */
+#define HPF_Fs32000_Gain7_A1 -5040 /* Floating point value -0.153795 */
+#define HPF_Fs32000_Gain7_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain7_B1 0 /* Floating point value -0.000000 */
+#define HPF_Fs32000_Gain7_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain7_Shift 2 /* Shift value */
+ /* Gain = 8.000000 dB */
+#define HPF_Fs32000_Gain8_A0 14288 /* Floating point value 0.436024 */
+#define HPF_Fs32000_Gain8_A1 -6151 /* Floating point value -0.187711 */
+#define HPF_Fs32000_Gain8_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain8_B1 0 /* Floating point value -0.000000 */
+#define HPF_Fs32000_Gain8_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain8_Shift 2 /* Shift value */
+ /* Gain = 9.000000 dB */
+#define HPF_Fs32000_Gain9_A0 15535 /* Floating point value 0.474078 */
+#define HPF_Fs32000_Gain9_A1 -7398 /* Floating point value -0.225764 */
+#define HPF_Fs32000_Gain9_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain9_B1 0 /* Floating point value -0.000000 */
+#define HPF_Fs32000_Gain9_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain9_Shift 2 /* Shift value */
+ /* Gain = 10.000000 dB */
+#define HPF_Fs32000_Gain10_A0 16934 /* Floating point value 0.516774 */
+#define HPF_Fs32000_Gain10_A1 -8797 /* Floating point value -0.268461 */
+#define HPF_Fs32000_Gain10_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain10_B1 0 /* Floating point value -0.000000 */
+#define HPF_Fs32000_Gain10_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain10_Shift 2 /* Shift value */
+ /* Gain = 11.000000 dB */
+#define HPF_Fs32000_Gain11_A0 18503 /* Floating point value 0.564681 */
+#define HPF_Fs32000_Gain11_A1 -10367 /* Floating point value -0.316368 */
+#define HPF_Fs32000_Gain11_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain11_B1 0 /* Floating point value -0.000000 */
+#define HPF_Fs32000_Gain11_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain11_Shift 2 /* Shift value */
+ /* Gain = 12.000000 dB */
+#define HPF_Fs32000_Gain12_A0 20265 /* Floating point value 0.618433 */
+#define HPF_Fs32000_Gain12_A1 -12128 /* Floating point value -0.370120 */
+#define HPF_Fs32000_Gain12_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain12_B1 0 /* Floating point value -0.000000 */
+#define HPF_Fs32000_Gain12_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain12_Shift 2 /* Shift value */
+ /* Gain = 13.000000 dB */
+#define HPF_Fs32000_Gain13_A0 11147 /* Floating point value 0.340178 */
+#define HPF_Fs32000_Gain13_A1 -7069 /* Floating point value -0.215726 */
+#define HPF_Fs32000_Gain13_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain13_B1 0 /* Floating point value -0.000000 */
+#define HPF_Fs32000_Gain13_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain13_Shift 3 /* Shift value */
+ /* Gain = 14.000000 dB */
+#define HPF_Fs32000_Gain14_A0 12258 /* Floating point value 0.374093 */
+#define HPF_Fs32000_Gain14_A1 -8180 /* Floating point value -0.249642 */
+#define HPF_Fs32000_Gain14_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain14_B1 0 /* Floating point value -0.000000 */
+#define HPF_Fs32000_Gain14_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain14_Shift 3 /* Shift value */
+ /* Gain = 15.000000 dB */
+#define HPF_Fs32000_Gain15_A0 13505 /* Floating point value 0.412147 */
+#define HPF_Fs32000_Gain15_A1 -9427 /* Floating point value -0.287695 */
+#define HPF_Fs32000_Gain15_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain15_B1 0 /* Floating point value -0.000000 */
+#define HPF_Fs32000_Gain15_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs32000_Gain15_Shift 3 /* Shift value */
+
+
+/* Coefficients for sample rate 44100Hz */
+ /* Gain = 1.000000 dB */
+#define HPF_Fs44100_Gain1_A0 17442 /* Floating point value 0.532294 */
+#define HPF_Fs44100_Gain1_A1 -4761 /* Floating point value -0.145294 */
+#define HPF_Fs44100_Gain1_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain1_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain1_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain1_Shift 1 /* Shift value */
+ /* Gain = 2.000000 dB */
+#define HPF_Fs44100_Gain2_A0 18797 /* Floating point value 0.573633 */
+#define HPF_Fs44100_Gain2_A1 -6116 /* Floating point value -0.186634 */
+#define HPF_Fs44100_Gain2_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain2_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain2_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain2_Shift 1 /* Shift value */
+ /* Gain = 3.000000 dB */
+#define HPF_Fs44100_Gain3_A0 20317 /* Floating point value 0.620016 */
+#define HPF_Fs44100_Gain3_A1 -7635 /* Floating point value -0.233017 */
+#define HPF_Fs44100_Gain3_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain3_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain3_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain3_Shift 1 /* Shift value */
+ /* Gain = 4.000000 dB */
+#define HPF_Fs44100_Gain4_A0 22022 /* Floating point value 0.672059 */
+#define HPF_Fs44100_Gain4_A1 -9341 /* Floating point value -0.285060 */
+#define HPF_Fs44100_Gain4_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain4_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain4_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain4_Shift 1 /* Shift value */
+ /* Gain = 5.000000 dB */
+#define HPF_Fs44100_Gain5_A0 23935 /* Floating point value 0.730452 */
+#define HPF_Fs44100_Gain5_A1 -11254 /* Floating point value -0.343453 */
+#define HPF_Fs44100_Gain5_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain5_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain5_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain5_Shift 1 /* Shift value */
+ /* Gain = 6.000000 dB */
+#define HPF_Fs44100_Gain6_A0 26082 /* Floating point value 0.795970 */
+#define HPF_Fs44100_Gain6_A1 -13401 /* Floating point value -0.408971 */
+#define HPF_Fs44100_Gain6_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain6_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain6_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain6_Shift 1 /* Shift value */
+ /* Gain = 7.000000 dB */
+#define HPF_Fs44100_Gain7_A0 14279 /* Floating point value 0.435774 */
+#define HPF_Fs44100_Gain7_A1 -7924 /* Floating point value -0.241815 */
+#define HPF_Fs44100_Gain7_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain7_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain7_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain7_Shift 2 /* Shift value */
+ /* Gain = 8.000000 dB */
+#define HPF_Fs44100_Gain8_A0 15634 /* Floating point value 0.477113 */
+#define HPF_Fs44100_Gain8_A1 -9278 /* Floating point value -0.283154 */
+#define HPF_Fs44100_Gain8_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain8_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain8_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain8_Shift 2 /* Shift value */
+ /* Gain = 9.000000 dB */
+#define HPF_Fs44100_Gain9_A0 17154 /* Floating point value 0.523496 */
+#define HPF_Fs44100_Gain9_A1 -10798 /* Floating point value -0.329537 */
+#define HPF_Fs44100_Gain9_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain9_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain9_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain9_Shift 2 /* Shift value */
+ /* Gain = 10.000000 dB */
+#define HPF_Fs44100_Gain10_A0 18859 /* Floating point value 0.575539 */
+#define HPF_Fs44100_Gain10_A1 -12504 /* Floating point value -0.381580 */
+#define HPF_Fs44100_Gain10_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain10_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain10_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain10_Shift 2 /* Shift value */
+ /* Gain = 11.000000 dB */
+#define HPF_Fs44100_Gain11_A0 20773 /* Floating point value 0.633932 */
+#define HPF_Fs44100_Gain11_A1 -14417 /* Floating point value -0.439973 */
+#define HPF_Fs44100_Gain11_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain11_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain11_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain11_Shift 2 /* Shift value */
+ /* Gain = 12.000000 dB */
+#define HPF_Fs44100_Gain12_A0 22920 /* Floating point value 0.699450 */
+#define HPF_Fs44100_Gain12_A1 -16564 /* Floating point value -0.505491 */
+#define HPF_Fs44100_Gain12_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain12_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain12_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain12_Shift 2 /* Shift value */
+ /* Gain = 13.000000 dB */
+#define HPF_Fs44100_Gain13_A0 12694 /* Floating point value 0.387399 */
+#define HPF_Fs44100_Gain13_A1 -9509 /* Floating point value -0.290189 */
+#define HPF_Fs44100_Gain13_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain13_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain13_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain13_Shift 3 /* Shift value */
+ /* Gain = 14.000000 dB */
+#define HPF_Fs44100_Gain14_A0 14049 /* Floating point value 0.428738 */
+#define HPF_Fs44100_Gain14_A1 -10864 /* Floating point value -0.331528 */
+#define HPF_Fs44100_Gain14_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain14_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain14_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain14_Shift 3 /* Shift value */
+ /* Gain = 15.000000 dB */
+#define HPF_Fs44100_Gain15_A0 15569 /* Floating point value 0.475121 */
+#define HPF_Fs44100_Gain15_A1 -12383 /* Floating point value -0.377912 */
+#define HPF_Fs44100_Gain15_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain15_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain15_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs44100_Gain15_Shift 3 /* Shift value */
+
+
+/* Coefficients for sample rate 48000Hz */
+ /* Gain = 1.000000 dB */
+#define HPF_Fs48000_Gain1_A0 17491 /* Floating point value 0.533777 */
+#define HPF_Fs48000_Gain1_A1 -5606 /* Floating point value -0.171082 */
+#define HPF_Fs48000_Gain1_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain1_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain1_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain1_Shift 1 /* Shift value */
+ /* Gain = 2.000000 dB */
+#define HPF_Fs48000_Gain2_A0 18900 /* Floating point value 0.576779 */
+#define HPF_Fs48000_Gain2_A1 -7015 /* Floating point value -0.214085 */
+#define HPF_Fs48000_Gain2_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain2_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain2_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain2_Shift 1 /* Shift value */
+ /* Gain = 3.000000 dB */
+#define HPF_Fs48000_Gain3_A0 20481 /* Floating point value 0.625029 */
+#define HPF_Fs48000_Gain3_A1 -8596 /* Floating point value -0.262335 */
+#define HPF_Fs48000_Gain3_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain3_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain3_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain3_Shift 1 /* Shift value */
+ /* Gain = 4.000000 dB */
+#define HPF_Fs48000_Gain4_A0 22255 /* Floating point value 0.679167 */
+#define HPF_Fs48000_Gain4_A1 -10370 /* Floating point value -0.316472 */
+#define HPF_Fs48000_Gain4_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain4_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain4_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain4_Shift 1 /* Shift value */
+ /* Gain = 5.000000 dB */
+#define HPF_Fs48000_Gain5_A0 24245 /* Floating point value 0.739910 */
+#define HPF_Fs48000_Gain5_A1 -12361 /* Floating point value -0.377215 */
+#define HPF_Fs48000_Gain5_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain5_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain5_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain5_Shift 1 /* Shift value */
+ /* Gain = 6.000000 dB */
+#define HPF_Fs48000_Gain6_A0 26479 /* Floating point value 0.808065 */
+#define HPF_Fs48000_Gain6_A1 -14594 /* Floating point value -0.445370 */
+#define HPF_Fs48000_Gain6_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain6_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain6_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain6_Shift 1 /* Shift value */
+ /* Gain = 7.000000 dB */
+#define HPF_Fs48000_Gain7_A0 14527 /* Floating point value 0.443318 */
+#define HPF_Fs48000_Gain7_A1 -8570 /* Floating point value -0.261540 */
+#define HPF_Fs48000_Gain7_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain7_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain7_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain7_Shift 2 /* Shift value */
+ /* Gain = 8.000000 dB */
+#define HPF_Fs48000_Gain8_A0 15936 /* Floating point value 0.486321 */
+#define HPF_Fs48000_Gain8_A1 -9979 /* Floating point value -0.304543 */
+#define HPF_Fs48000_Gain8_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain8_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain8_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain8_Shift 2 /* Shift value */
+ /* Gain = 9.000000 dB */
+#define HPF_Fs48000_Gain9_A0 17517 /* Floating point value 0.534571 */
+#define HPF_Fs48000_Gain9_A1 -11560 /* Floating point value -0.352793 */
+#define HPF_Fs48000_Gain9_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain9_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain9_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain9_Shift 2 /* Shift value */
+ /* Gain = 10.000000 dB */
+#define HPF_Fs48000_Gain10_A0 19291 /* Floating point value 0.588708 */
+#define HPF_Fs48000_Gain10_A1 -13334 /* Floating point value -0.406930 */
+#define HPF_Fs48000_Gain10_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain10_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain10_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain10_Shift 2 /* Shift value */
+ /* Gain = 11.000000 dB */
+#define HPF_Fs48000_Gain11_A0 21281 /* Floating point value 0.649452 */
+#define HPF_Fs48000_Gain11_A1 -15325 /* Floating point value -0.467674 */
+#define HPF_Fs48000_Gain11_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain11_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain11_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain11_Shift 2 /* Shift value */
+ /* Gain = 12.000000 dB */
+#define HPF_Fs48000_Gain12_A0 23515 /* Floating point value 0.717607 */
+#define HPF_Fs48000_Gain12_A1 -17558 /* Floating point value -0.535829 */
+#define HPF_Fs48000_Gain12_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain12_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain12_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain12_Shift 2 /* Shift value */
+ /* Gain = 13.000000 dB */
+#define HPF_Fs48000_Gain13_A0 13041 /* Floating point value 0.397982 */
+#define HPF_Fs48000_Gain13_A1 -10056 /* Floating point value -0.306877 */
+#define HPF_Fs48000_Gain13_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain13_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain13_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain13_Shift 3 /* Shift value */
+ /* Gain = 14.000000 dB */
+#define HPF_Fs48000_Gain14_A0 14450 /* Floating point value 0.440984 */
+#define HPF_Fs48000_Gain14_A1 -11465 /* Floating point value -0.349880 */
+#define HPF_Fs48000_Gain14_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain14_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain14_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain14_Shift 3 /* Shift value */
+ /* Gain = 15.000000 dB */
+#define HPF_Fs48000_Gain15_A0 16031 /* Floating point value 0.489234 */
+#define HPF_Fs48000_Gain15_A1 -13046 /* Floating point value -0.398130 */
+#define HPF_Fs48000_Gain15_A2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain15_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain15_B2 0 /* Floating point value 0.000000 */
+#define HPF_Fs48000_Gain15_Shift 3 /* Shift value */
+
+
+#endif
diff --git a/media/libeffects/lvm/lib/Bundle/src/LVM_Control.c b/media/libeffects/lvm/lib/Bundle/src/LVM_Control.c
new file mode 100755
index 0000000..4667feb
--- /dev/null
+++ b/media/libeffects/lvm/lib/Bundle/src/LVM_Control.c
@@ -0,0 +1,1032 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/****************************************************************************************
+
+ $Author: nxp007753 $
+ $Revision: 1255 $
+ $Date: 2010-07-16 17:07:29 +0200 (Fri, 16 Jul 2010) $
+
+*****************************************************************************************/
+
+
+/****************************************************************************************/
+/* */
+/* Includes */
+/* */
+/****************************************************************************************/
+
+#include "VectorArithmetic.h"
+#include "ScalarArithmetic.h"
+#include "LVM_Coeffs.h"
+#include "LVM_Tables.h"
+#include "LVM_Private.h"
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_SetControlParameters */
+/* */
+/* DESCRIPTION: */
+/* Sets or changes the LifeVibes module parameters. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pParams Pointer to a parameter structure */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Succeeded */
+/* LVM_NULLADDRESS When hInstance, pParams or any control pointers are NULL */
+/* LVM_OUTOFRANGE When any of the control parameters are out of range */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+
+LVM_ReturnStatus_en LVM_SetControlParameters(LVM_Handle_t hInstance,
+ LVM_ControlParams_t *pParams)
+{
+ LVM_Instance_t *pInstance =(LVM_Instance_t *)hInstance;
+
+
+ if ((pParams == LVM_NULL) || (hInstance == LVM_NULL))
+ {
+ return (LVM_NULLADDRESS);
+ }
+
+ pInstance->NewParams = *pParams;
+
+ if(
+ /* General parameters */
+ ((pParams->OperatingMode != LVM_MODE_OFF) && (pParams->OperatingMode != LVM_MODE_ON)) ||
+ ((pParams->SampleRate != LVM_FS_8000) && (pParams->SampleRate != LVM_FS_11025) && (pParams->SampleRate != LVM_FS_12000) &&
+ (pParams->SampleRate != LVM_FS_16000) && (pParams->SampleRate != LVM_FS_22050) && (pParams->SampleRate != LVM_FS_24000) &&
+ (pParams->SampleRate != LVM_FS_32000) && (pParams->SampleRate != LVM_FS_44100) && (pParams->SampleRate != LVM_FS_48000)) ||
+ ((pParams->SourceFormat != LVM_STEREO) && (pParams->SourceFormat != LVM_MONOINSTEREO) && (pParams->SourceFormat != LVM_MONO)) ||
+ (pParams->SpeakerType > LVM_EX_HEADPHONES))
+ {
+ return (LVM_OUTOFRANGE);
+ }
+
+ /*
+ * Cinema Sound parameters
+ */
+ if((pParams->VirtualizerOperatingMode != LVM_MODE_OFF) && (pParams->VirtualizerOperatingMode != LVM_MODE_ON))
+ {
+ return (LVM_OUTOFRANGE);
+ }
+
+ if(pParams->VirtualizerType != LVM_CONCERTSOUND)
+ {
+ return (LVM_OUTOFRANGE);
+ }
+
+ if(pParams->VirtualizerReverbLevel > LVM_VIRTUALIZER_MAX_REVERB_LEVEL)
+ {
+ return (LVM_OUTOFRANGE);
+ }
+
+ if(pParams->CS_EffectLevel < LVM_CS_MIN_EFFECT_LEVEL)
+ {
+ return (LVM_OUTOFRANGE);
+ }
+
+ /*
+ * N-Band Equalizer
+ */
+ if(pParams->EQNB_NBands > pInstance->InstParams.EQNB_NumBands)
+ {
+ return (LVM_OUTOFRANGE);
+ }
+
+ /* Definition pointer */
+ if ((pParams->pEQNB_BandDefinition == LVM_NULL) &&
+ (pParams->EQNB_NBands != 0))
+ {
+ return (LVM_NULLADDRESS);
+ }
+
+ /*
+ * Copy the filter definitions for the Equaliser
+ */
+ {
+ LVM_INT16 i;
+
+ if (pParams->EQNB_NBands != 0)
+ {
+ for (i=0; i<pParams->EQNB_NBands; i++)
+ {
+ pInstance->pEQNB_BandDefs[i] = pParams->pEQNB_BandDefinition[i];
+ }
+ pInstance->NewParams.pEQNB_BandDefinition = pInstance->pEQNB_BandDefs;
+ }
+ }
+ if( /* N-Band Equaliser parameters */
+ ((pParams->EQNB_OperatingMode != LVM_EQNB_OFF) && (pParams->EQNB_OperatingMode != LVM_EQNB_ON)) ||
+ (pParams->EQNB_NBands > pInstance->InstParams.EQNB_NumBands))
+ {
+ return (LVM_OUTOFRANGE);
+ }
+ /* Band parameters*/
+ {
+ LVM_INT16 i;
+ for(i = 0; i < pParams->EQNB_NBands; i++)
+ {
+ if(((pParams->pEQNB_BandDefinition[i].Frequency < LVM_EQNB_MIN_BAND_FREQ) ||
+ (pParams->pEQNB_BandDefinition[i].Frequency > LVM_EQNB_MAX_BAND_FREQ)) ||
+ ((pParams->pEQNB_BandDefinition[i].Gain < LVM_EQNB_MIN_BAND_GAIN) ||
+ (pParams->pEQNB_BandDefinition[i].Gain > LVM_EQNB_MAX_BAND_GAIN)) ||
+ ((pParams->pEQNB_BandDefinition[i].QFactor < LVM_EQNB_MIN_QFACTOR) ||
+ (pParams->pEQNB_BandDefinition[i].QFactor > LVM_EQNB_MAX_QFACTOR)))
+ {
+ return (LVM_OUTOFRANGE);
+ }
+ }
+ }
+
+ /*
+ * Bass Enhancement parameters
+ */
+ if(((pParams->BE_OperatingMode != LVM_BE_OFF) && (pParams->BE_OperatingMode != LVM_BE_ON)) ||
+ ((pParams->BE_EffectLevel < LVM_BE_MIN_EFFECTLEVEL ) || (pParams->BE_EffectLevel > LVM_BE_MAX_EFFECTLEVEL ))||
+ ((pParams->BE_CentreFreq != LVM_BE_CENTRE_55Hz) && (pParams->BE_CentreFreq != LVM_BE_CENTRE_66Hz) &&
+ (pParams->BE_CentreFreq != LVM_BE_CENTRE_78Hz) && (pParams->BE_CentreFreq != LVM_BE_CENTRE_90Hz)) ||
+ ((pParams->BE_HPF != LVM_BE_HPF_OFF) && (pParams->BE_HPF != LVM_BE_HPF_ON)))
+ {
+ return (LVM_OUTOFRANGE);
+ }
+
+ /*
+ * Volume Control parameters
+ */
+ if((pParams->VC_EffectLevel < LVM_VC_MIN_EFFECTLEVEL ) || (pParams->VC_EffectLevel > LVM_VC_MAX_EFFECTLEVEL ))
+ {
+ return (LVM_OUTOFRANGE);
+ }
+ if((pParams->VC_Balance < LVM_VC_BALANCE_MIN ) || (pParams->VC_Balance > LVM_VC_BALANCE_MAX ))
+ {
+ return (LVM_OUTOFRANGE);
+ }
+
+ /*
+ * PSA parameters
+ */
+ if( (pParams->PSA_PeakDecayRate > LVPSA_SPEED_HIGH) ||
+ (pParams->PSA_Enable > LVM_PSA_ON))
+ {
+ return (LVM_OUTOFRANGE);
+ }
+
+
+ /*
+ * Set the flag to indicate there are new parameters to use
+ *
+ * Protect the copy of the new parameters from interrupts to avoid possible problems
+ * with loss control parameters. This problem can occur if this control function is called more
+ * than once before a call to the process function. If the process function interrupts
+ * the copy to NewParams then one frame may have mixed parameters, some old and some new.
+ */
+ pInstance->ControlPending = LVM_TRUE;
+ pInstance->NoSmoothVolume = LVM_FALSE;
+
+ return(LVM_SUCCESS);
+}
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_GetControlParameters */
+/* */
+/* DESCRIPTION: */
+/* Request the LifeVibes module parameters. The current parameter set is returned */
+/* via the parameter pointer. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pParams Pointer to an empty parameter structure */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Succeeded */
+/* LVM_NULLADDRESS when any of hInstance or pParams is NULL */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+
+LVM_ReturnStatus_en LVM_GetControlParameters(LVM_Handle_t hInstance,
+ LVM_ControlParams_t *pParams)
+{
+ LVM_Instance_t *pInstance =(LVM_Instance_t *)hInstance;
+
+
+ /*
+ * Check pointer
+ */
+ if ((pParams == LVM_NULL) || (hInstance == LVM_NULL))
+ {
+ return (LVM_NULLADDRESS);
+ }
+ *pParams = pInstance->NewParams;
+
+ /*
+ * Copy the filter definitions for the Equaliser
+ */
+ {
+ LVM_INT16 i;
+
+ if (pInstance->NewParams.EQNB_NBands != 0)
+ for (i=0; i<pInstance->NewParams.EQNB_NBands; i++)
+ {
+ pInstance->pEQNB_UserDefs[i] = pInstance->pEQNB_BandDefs[i];
+ }
+ pParams->pEQNB_BandDefinition = pInstance->pEQNB_UserDefs;
+ }
+
+ return(LVM_SUCCESS);
+}
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_SetTrebleBoost */
+/* */
+/* DESCRIPTION: */
+/* Enable the treble boost when the settings are appropriate, i.e. non-zero gain */
+/* and the sample rate is high enough for the effect to be heard. */
+/* */
+/* PARAMETERS: */
+/* pInstance Pointer to the instance structure */
+/* pParams Pointer to the parameters to use */
+/* */
+/****************************************************************************************/
+void LVM_SetTrebleBoost(LVM_Instance_t *pInstance,
+ LVM_ControlParams_t *pParams)
+{
+ extern FO_C16_LShx_Coefs_t LVM_TrebleBoostCoefs[];
+ LVM_INT16 Offset;
+ LVM_INT16 EffectLevel = 0;
+
+ /*
+ * Load the coefficients
+ */
+ if ((pParams->TE_OperatingMode == LVM_TE_ON) &&
+ (pParams->SampleRate >= TrebleBoostMinRate) &&
+ (pParams->OperatingMode == LVM_MODE_ON) &&
+ (pParams->TE_EffectLevel > 0))
+ {
+ if((pParams->TE_EffectLevel == LVM_TE_LOW_MIPS) &&
+ ((pParams->SpeakerType == LVM_HEADPHONES)||
+ (pParams->SpeakerType == LVM_EX_HEADPHONES)))
+ {
+ pInstance->TE_Active = LVM_FALSE;
+ }
+ else
+ {
+ EffectLevel = pParams->TE_EffectLevel;
+ pInstance->TE_Active = LVM_TRUE;
+ }
+
+ if(pInstance->TE_Active == LVM_TRUE)
+ {
+ /*
+ * Load the coefficients and enabled the treble boost
+ */
+ Offset = (LVM_INT16)(EffectLevel - 1 + TrebleBoostSteps * (pParams->SampleRate - TrebleBoostMinRate));
+ FO_2I_D16F32Css_LShx_TRC_WRA_01_Init(&pInstance->pTE_State->TrebleBoost_State,
+ &pInstance->pTE_Taps->TrebleBoost_Taps,
+ &LVM_TrebleBoostCoefs[Offset]);
+
+ /*
+ * Clear the taps
+ */
+ LoadConst_16((LVM_INT16)0, /* Value */
+ (LVM_INT16 *)&pInstance->pTE_Taps->TrebleBoost_Taps, /* Destination */
+ (LVM_UINT16)(sizeof(pInstance->pTE_Taps->TrebleBoost_Taps)/sizeof(LVM_INT16))); /* Number of words */
+ }
+ }
+ else
+ {
+ /*
+ * Disable the treble boost
+ */
+ pInstance->TE_Active = LVM_FALSE;
+ }
+
+ return;
+}
+
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVM_SetVolume */
+/* */
+/* DESCRIPTION: */
+/* Converts the input volume demand from dBs to linear. */
+/* */
+/* PARAMETERS: */
+/* pInstance Pointer to the instance */
+/* pParams Initialisation parameters */
+/* */
+/************************************************************************************/
+void LVM_SetVolume(LVM_Instance_t *pInstance,
+ LVM_ControlParams_t *pParams)
+{
+
+ LVM_UINT16 dBShifts; /* 6dB shifts */
+ LVM_UINT16 dBOffset; /* Table offset */
+ LVM_INT16 Volume = 0; /* Required volume in dBs */
+
+ /*
+ * Limit the gain to the maximum allowed
+ */
+ if (pParams->VC_EffectLevel > 0)
+ {
+ Volume = 0;
+ }
+ else
+ {
+ Volume = pParams->VC_EffectLevel;
+ }
+
+ /* Compensate this volume in PSA plot */
+ if(Volume > -60) /* Limit volume loss to PSA Limits*/
+ pInstance->PSA_GainOffset=(LVM_INT16)(-Volume);/* Loss is compensated by Gain*/
+ else
+ pInstance->PSA_GainOffset=(LVM_INT16)60;/* Loss is compensated by Gain*/
+
+ pInstance->VC_AVLFixedVolume = 0;
+
+ /*
+ * Set volume control and AVL volumes according to headroom and volume user setting
+ */
+ if(pParams->OperatingMode == LVM_MODE_ON)
+ {
+ /* Default Situation with no AVL and no RS */
+ if(pParams->EQNB_OperatingMode == LVM_EQNB_ON)
+ {
+ if(Volume > -pInstance->Headroom)
+ Volume = (LVM_INT16)-pInstance->Headroom;
+ }
+ }
+
+ /*
+ * Activate volume control if necessary
+ */
+ pInstance->VC_Active = LVM_TRUE;
+ if (Volume != 0)
+ {
+ pInstance->VC_VolumedB = Volume;
+ }
+ else
+ {
+ pInstance->VC_VolumedB = 0;
+ }
+
+ /*
+ * Calculate the required gain and shifts
+ */
+ dBOffset = (LVM_UINT16)((-Volume) % 6); /* Get the dBs 0-5 */
+ dBShifts = (LVM_UINT16)(Volume / -6); /* Get the 6dB shifts */
+
+
+ /*
+ * Set the parameters
+ */
+ if(dBShifts == 0)
+ {
+ LVC_Mixer_SetTarget(&pInstance->VC_Volume.MixerStream[0],
+ (LVM_INT32)LVM_VolumeTable[dBOffset]);
+ }
+ else
+ {
+ LVC_Mixer_SetTarget(&pInstance->VC_Volume.MixerStream[0],
+ (((LVM_INT32)LVM_VolumeTable[dBOffset])>>dBShifts));
+ }
+ pInstance->VC_Volume.MixerStream[0].CallbackSet = 1;
+ if(pInstance->NoSmoothVolume == LVM_TRUE)
+ {
+ LVC_Mixer_SetTimeConstant(&pInstance->VC_Volume.MixerStream[0],0,pInstance->Params.SampleRate,2);
+ }
+ else
+ {
+ LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->VC_Volume.MixerStream[0],LVM_VC_MIXER_TIME,pInstance->Params.SampleRate,2);
+ }
+}
+
+
+/************************************************************************************/
+/* */
+/* FUNCTION: LVM_SetHeadroom */
+/* */
+/* DESCRIPTION: */
+/* Find suitable headroom based on EQ settings. */
+/* */
+/* PARAMETERS: */
+/* pInstance Pointer to the instance */
+/* pParams Initialisation parameters */
+/* */
+/* RETURNS: */
+/* void Nothing */
+/* */
+/* NOTES: */
+/* */
+/************************************************************************************/
+void LVM_SetHeadroom(LVM_Instance_t *pInstance,
+ LVM_ControlParams_t *pParams)
+{
+ LVM_INT16 ii, jj;
+ LVM_INT16 Headroom = 0;
+ LVM_INT16 MaxGain = 0;
+
+
+ if ((pParams->EQNB_OperatingMode == LVEQNB_ON) && (pInstance->HeadroomParams.Headroom_OperatingMode == LVM_HEADROOM_ON))
+ {
+ /* Find typical headroom value */
+ for(jj = 0; jj < pInstance->HeadroomParams.NHeadroomBands; jj++)
+ {
+ MaxGain = 0;
+ for( ii = 0; ii < pParams->EQNB_NBands; ii++)
+ {
+ if((pParams->pEQNB_BandDefinition[ii].Frequency >= pInstance->HeadroomParams.pHeadroomDefinition[jj].Limit_Low) &&
+ (pParams->pEQNB_BandDefinition[ii].Frequency <= pInstance->HeadroomParams.pHeadroomDefinition[jj].Limit_High))
+ {
+ if(pParams->pEQNB_BandDefinition[ii].Gain > MaxGain)
+ {
+ MaxGain = pParams->pEQNB_BandDefinition[ii].Gain;
+ }
+ }
+ }
+
+ if((MaxGain - pInstance->HeadroomParams.pHeadroomDefinition[jj].Headroom_Offset) > Headroom){
+ Headroom = (LVM_INT16)(MaxGain - pInstance->HeadroomParams.pHeadroomDefinition[jj].Headroom_Offset);
+ }
+ }
+
+ /* Saturate */
+ if(Headroom < 0)
+ Headroom = 0;
+ }
+ pInstance->Headroom = (LVM_UINT16)Headroom ;
+
+}
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_ApplyNewSettings */
+/* */
+/* DESCRIPTION: */
+/* Applies changes to parametres. This function makes no assumptions about what */
+/* each module needs for initialisation and hence passes all parameters to all the */
+/* the modules in turn. */
+/* */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* */
+/* RETURNS: */
+/* LVM_Success Succeeded */
+/* */
+/****************************************************************************************/
+
+LVM_ReturnStatus_en LVM_ApplyNewSettings(LVM_Handle_t hInstance)
+{
+ LVM_Instance_t *pInstance =(LVM_Instance_t *)hInstance;
+ LVM_ControlParams_t LocalParams;
+ LVM_INT16 Count = 5;
+
+
+ /*
+ * Copy the new parameters but make sure they didn't change while copying
+ */
+ do
+ {
+ pInstance->ControlPending = LVM_FALSE;
+ LocalParams = pInstance->NewParams;
+ pInstance->HeadroomParams = pInstance->NewHeadroomParams;
+ Count--;
+ } while ((pInstance->ControlPending != LVM_FALSE) &&
+ (Count > 0));
+
+ /* Clear all internal data if format change*/
+ if(LocalParams.SourceFormat != pInstance->Params.SourceFormat)
+ {
+ LVM_ClearAudioBuffers(pInstance);
+ pInstance->ControlPending = LVM_FALSE;
+ }
+
+ /*
+ * Update the treble boost if required
+ */
+ if ((pInstance->Params.SampleRate != LocalParams.SampleRate) ||
+ (pInstance->Params.TE_EffectLevel != LocalParams.TE_EffectLevel) ||
+ (pInstance->Params.TE_OperatingMode != LocalParams.TE_OperatingMode) ||
+ (pInstance->Params.OperatingMode != LocalParams.OperatingMode) ||
+ (pInstance->Params.SpeakerType != LocalParams.SpeakerType))
+ {
+ LVM_SetTrebleBoost(pInstance,
+ &LocalParams);
+ }
+
+ /*
+ * Update the headroom if required
+ */
+ LVM_SetHeadroom(pInstance, /* Instance pointer */
+ &LocalParams); /* New parameters */
+
+ /*
+ * Update the volume if required
+ */
+ {
+ LVM_SetVolume(pInstance, /* Instance pointer */
+ &LocalParams); /* New parameters */
+ }
+ /* Apply balance changes*/
+ if(pInstance->Params.VC_Balance != LocalParams.VC_Balance)
+ {
+ /* Configure Mixer module for gradual changes to volume*/
+ if(LocalParams.VC_Balance < 0)
+ {
+ LVM_INT32 Target;
+ /* Drop in right channel volume*/
+ Target = LVM_MAXINT_16;
+ LVC_Mixer_SetTarget(&pInstance->VC_BalanceMix.MixerStream[0],Target);
+ LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->VC_BalanceMix.MixerStream[0],LVM_VC_MIXER_TIME,LocalParams.SampleRate,1);
+
+ Target = dB_to_Lin32((LVM_INT16)(LocalParams.VC_Balance<<4));
+ LVC_Mixer_SetTarget(&pInstance->VC_BalanceMix.MixerStream[1],Target);
+ LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->VC_BalanceMix.MixerStream[1],LVM_VC_MIXER_TIME,LocalParams.SampleRate,1);
+ }
+ else if(LocalParams.VC_Balance >0)
+ {
+ LVM_INT32 Target;
+ /* Drop in left channel volume*/
+ Target = dB_to_Lin32((LVM_INT16)((-LocalParams.VC_Balance)<<4));
+ LVC_Mixer_SetTarget(&pInstance->VC_BalanceMix.MixerStream[0],Target);
+ LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->VC_BalanceMix.MixerStream[0],LVM_VC_MIXER_TIME,LocalParams.SampleRate,1);
+
+ Target = LVM_MAXINT_16;
+ LVC_Mixer_SetTarget(&pInstance->VC_BalanceMix.MixerStream[1],Target);
+ LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->VC_BalanceMix.MixerStream[1],LVM_VC_MIXER_TIME,LocalParams.SampleRate,1);
+ }
+ else
+ {
+ LVM_INT32 Target;
+ /* No drop*/
+ Target = LVM_MAXINT_16;
+ LVC_Mixer_SetTarget(&pInstance->VC_BalanceMix.MixerStream[0],Target);
+ LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->VC_BalanceMix.MixerStream[0],LVM_VC_MIXER_TIME,LocalParams.SampleRate,1);
+
+ LVC_Mixer_SetTarget(&pInstance->VC_BalanceMix.MixerStream[1],Target);
+ LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->VC_BalanceMix.MixerStream[1],LVM_VC_MIXER_TIME,LocalParams.SampleRate,1);
+ }
+ }
+ /*
+ * Update the bass enhancement
+ */
+ {
+ LVDBE_ReturnStatus_en DBE_Status;
+ LVDBE_Params_t DBE_Params;
+ LVDBE_Handle_t *hDBEInstance = pInstance->hDBEInstance;
+
+
+ /*
+ * Set the new parameters
+ */
+ if(LocalParams.OperatingMode == LVM_MODE_OFF)
+ {
+ DBE_Params.OperatingMode = LVDBE_OFF;
+ }
+ else
+ {
+ DBE_Params.OperatingMode = (LVDBE_Mode_en)LocalParams.BE_OperatingMode;
+ }
+ DBE_Params.SampleRate = (LVDBE_Fs_en)LocalParams.SampleRate;
+ DBE_Params.EffectLevel = LocalParams.BE_EffectLevel;
+ DBE_Params.CentreFrequency = (LVDBE_CentreFreq_en)LocalParams.BE_CentreFreq;
+ DBE_Params.HPFSelect = (LVDBE_FilterSelect_en)LocalParams.BE_HPF;
+ DBE_Params.HeadroomdB = 0;
+ DBE_Params.VolumeControl = LVDBE_VOLUME_OFF;
+ DBE_Params.VolumedB = 0;
+
+ /*
+ * Make the changes
+ */
+ DBE_Status = LVDBE_Control(hDBEInstance,
+ &DBE_Params);
+
+
+ /*
+ * Quit if the changes were not accepted
+ */
+ if (DBE_Status != LVDBE_SUCCESS)
+ {
+ return((LVM_ReturnStatus_en)DBE_Status);
+ }
+
+
+ /*
+ * Set the control flag
+ */
+ pInstance->DBE_Active = LVM_TRUE;
+ }
+
+ /*
+ * Update the N-Band Equaliser
+ */
+ {
+ LVEQNB_ReturnStatus_en EQNB_Status;
+ LVEQNB_Params_t EQNB_Params;
+ LVEQNB_Handle_t *hEQNBInstance = pInstance->hEQNBInstance;
+
+
+ /*
+ * Set the new parameters
+ */
+
+ if(LocalParams.OperatingMode == LVM_MODE_OFF)
+ {
+ EQNB_Params.OperatingMode = LVEQNB_BYPASS;
+ }
+ else
+ {
+ EQNB_Params.OperatingMode = (LVEQNB_Mode_en)LocalParams.EQNB_OperatingMode;
+ }
+
+ EQNB_Params.SampleRate = (LVEQNB_Fs_en)LocalParams.SampleRate;
+ EQNB_Params.NBands = LocalParams.EQNB_NBands;
+ EQNB_Params.pBandDefinition = (LVEQNB_BandDef_t *)LocalParams.pEQNB_BandDefinition;
+ if (LocalParams.SourceFormat == LVM_STEREO) /* Mono format not supported */
+ {
+ EQNB_Params.SourceFormat = LVEQNB_STEREO;
+ }
+ else
+ {
+ EQNB_Params.SourceFormat = LVEQNB_MONOINSTEREO; /* Force to Mono-in-Stereo mode */
+ }
+
+
+ /*
+ * Set the control flag
+ */
+ if ((LocalParams.OperatingMode == LVM_MODE_ON) &&
+ (LocalParams.EQNB_OperatingMode == LVM_EQNB_ON))
+ {
+ pInstance->EQNB_Active = LVM_TRUE;
+ }
+ else
+ {
+ EQNB_Params.OperatingMode = LVEQNB_BYPASS;
+ }
+
+ /*
+ * Make the changes
+ */
+ EQNB_Status = LVEQNB_Control(hEQNBInstance,
+ &EQNB_Params);
+
+
+ /*
+ * Quit if the changes were not accepted
+ */
+ if (EQNB_Status != LVEQNB_SUCCESS)
+ {
+ return((LVM_ReturnStatus_en)EQNB_Status);
+ }
+
+ }
+
+
+ /*
+ * Update concert sound
+ */
+ {
+ LVCS_ReturnStatus_en CS_Status;
+ LVCS_Params_t CS_Params;
+ LVCS_Handle_t *hCSInstance = pInstance->hCSInstance;
+ LVM_Mode_en CompressorMode=LVM_MODE_ON;
+
+ /*
+ * Set the new parameters
+ */
+ if(LocalParams.VirtualizerOperatingMode == LVM_MODE_ON)
+ {
+ CS_Params.OperatingMode = LVCS_ON;
+ }
+ else
+ {
+ CS_Params.OperatingMode = LVCS_OFF;
+ }
+
+ if((LocalParams.TE_OperatingMode == LVM_TE_ON) && (LocalParams.TE_EffectLevel == LVM_TE_LOW_MIPS))
+ {
+ CS_Params.SpeakerType = LVCS_EX_HEADPHONES;
+ }
+ else
+ {
+ CS_Params.SpeakerType = LVCS_HEADPHONES;
+ }
+
+ if (LocalParams.SourceFormat == LVM_STEREO) /* Mono format not supported */
+ {
+ CS_Params.SourceFormat = LVCS_STEREO;
+ }
+ else
+ {
+ CS_Params.SourceFormat = LVCS_MONOINSTEREO; /* Force to Mono-in-Stereo mode */
+ }
+ CS_Params.SampleRate = LocalParams.SampleRate;
+ CS_Params.ReverbLevel = LocalParams.VirtualizerReverbLevel;
+ CS_Params.EffectLevel = LocalParams.CS_EffectLevel;
+
+
+ /*
+ * Set the control flag
+ */
+ if ((LocalParams.OperatingMode == LVM_MODE_ON) &&
+ (LocalParams.VirtualizerOperatingMode != LVCS_OFF))
+ {
+ pInstance->CS_Active = LVM_TRUE;
+ }
+ else
+ {
+ CS_Params.OperatingMode = LVCS_OFF;
+ }
+
+ CS_Params.CompressorMode=CompressorMode;
+
+ /*
+ * Make the changes
+ */
+ CS_Status = LVCS_Control(hCSInstance,
+ &CS_Params);
+
+
+ /*
+ * Quit if the changes were not accepted
+ */
+ if (CS_Status != LVCS_SUCCESS)
+ {
+ return((LVM_ReturnStatus_en)CS_Status);
+ }
+
+ }
+
+ /*
+ * Update the Power Spectrum Analyser
+ */
+ {
+ LVPSA_RETURN PSA_Status;
+ LVPSA_ControlParams_t PSA_Params;
+ pLVPSA_Handle_t *hPSAInstance = pInstance->hPSAInstance;
+
+
+ /*
+ * Set the new parameters
+ */
+ PSA_Params.Fs = LocalParams.SampleRate;
+ PSA_Params.LevelDetectionSpeed = (LVPSA_LevelDetectSpeed_en)LocalParams.PSA_PeakDecayRate;
+
+ /*
+ * Make the changes
+ */
+ if(pInstance->InstParams.PSA_Included==LVM_PSA_ON)
+ {
+ PSA_Status = LVPSA_Control(hPSAInstance,
+ &PSA_Params);
+
+ if (PSA_Status != LVPSA_OK)
+ {
+ return((LVM_ReturnStatus_en)PSA_Status);
+ }
+
+ /*
+ * Apply new settings
+ */
+ PSA_Status = LVPSA_ApplyNewSettings ((LVPSA_InstancePr_t*)hPSAInstance);
+ if(PSA_Status != LVPSA_OK)
+ {
+ return((LVM_ReturnStatus_en)PSA_Status);
+ }
+ }
+ }
+
+ /*
+ * Update the parameters and clear the flag
+ */
+ pInstance->Params = LocalParams;
+
+
+ return(LVM_SUCCESS);
+}
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_SetHeadroomParams */
+/* */
+/* DESCRIPTION: */
+/* This function is used to set the automatiuc headroom management parameters. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pHeadroomParams Pointer to headroom parameter structure */
+/* */
+/* RETURNS: */
+/* LVM_Success Succeeded */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+
+LVM_ReturnStatus_en LVM_SetHeadroomParams(LVM_Handle_t hInstance,
+ LVM_HeadroomParams_t *pHeadroomParams)
+{
+ LVM_Instance_t *pInstance =(LVM_Instance_t *)hInstance;
+ LVM_UINT16 ii, NBands;
+
+ /* Check for NULL pointers */
+ if ((hInstance == LVM_NULL) || (pHeadroomParams == LVM_NULL))
+ {
+ return (LVM_NULLADDRESS);
+ }
+ if ((pHeadroomParams->NHeadroomBands != 0) && (pHeadroomParams->pHeadroomDefinition == LVM_NULL))
+ {
+ return (LVM_NULLADDRESS);
+ }
+
+ /* Consider only the LVM_HEADROOM_MAX_NBANDS first bands*/
+ if (pHeadroomParams->NHeadroomBands > LVM_HEADROOM_MAX_NBANDS)
+ {
+ NBands = LVM_HEADROOM_MAX_NBANDS;
+ }
+ else
+ {
+ NBands = pHeadroomParams->NHeadroomBands;
+ }
+ pInstance->NewHeadroomParams.NHeadroomBands = NBands;
+
+ /* Copy settings in memory */
+ for(ii = 0; ii < NBands; ii++)
+ {
+ pInstance->pHeadroom_BandDefs[ii] = pHeadroomParams->pHeadroomDefinition[ii];
+ }
+
+ pInstance->NewHeadroomParams.pHeadroomDefinition = pInstance->pHeadroom_BandDefs;
+ pInstance->NewHeadroomParams.Headroom_OperatingMode = pHeadroomParams->Headroom_OperatingMode;
+ pInstance->ControlPending = LVM_TRUE;
+
+ return(LVM_SUCCESS);
+}
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_GetHeadroomParams */
+/* */
+/* DESCRIPTION: */
+/* This function is used to get the automatic headroom management parameters. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pHeadroomParams Pointer to headroom parameter structure (output) */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Succeeded */
+/* LVM_NULLADDRESS When hInstance or pHeadroomParams are NULL */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+
+LVM_ReturnStatus_en LVM_GetHeadroomParams(LVM_Handle_t hInstance,
+ LVM_HeadroomParams_t *pHeadroomParams)
+{
+ LVM_Instance_t *pInstance =(LVM_Instance_t *)hInstance;
+ LVM_UINT16 ii;
+
+ /* Check for NULL pointers */
+ if ((hInstance == LVM_NULL) || (pHeadroomParams == LVM_NULL))
+ {
+ return (LVM_NULLADDRESS);
+ }
+
+ pHeadroomParams->NHeadroomBands = pInstance->NewHeadroomParams.NHeadroomBands;
+
+
+ /* Copy settings in memory */
+ for(ii = 0; ii < pInstance->NewHeadroomParams.NHeadroomBands; ii++)
+ {
+ pInstance->pHeadroom_UserDefs[ii] = pInstance->pHeadroom_BandDefs[ii];
+ }
+
+
+ pHeadroomParams->pHeadroomDefinition = pInstance->pHeadroom_UserDefs;
+ pHeadroomParams->Headroom_OperatingMode = pInstance->NewHeadroomParams.Headroom_OperatingMode;
+ return(LVM_SUCCESS);
+}
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_AlgoCallBack */
+/* */
+/* DESCRIPTION: */
+/* This is the callback function of the algorithm. */
+/* */
+/* PARAMETERS: */
+/* pBundleHandle Pointer to the Instance Handle */
+/* pData Pointer to the data */
+/* callbackId ID of the callback */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+LVM_INT32 LVM_AlgoCallBack( void *pBundleHandle,
+ void *pData,
+ LVM_INT16 callbackId)
+{
+ LVM_Instance_t *pInstance =(LVM_Instance_t *)pBundleHandle;
+
+ (void) pData;
+
+ switch(callbackId & 0xFF00){
+ case ALGORITHM_CS_ID:
+ switch(callbackId & 0x00FF)
+ {
+ case LVCS_EVENT_ALGOFF:
+ pInstance->CS_Active = LVM_FALSE;
+ break;
+ default:
+ break;
+ }
+ break;
+ case ALGORITHM_EQNB_ID:
+ switch(callbackId & 0x00FF)
+ {
+ case LVEQNB_EVENT_ALGOFF:
+ pInstance->EQNB_Active = LVM_FALSE;
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_VCCallBack */
+/* */
+/* DESCRIPTION: */
+/* This is the callback function of the Volume control. */
+/* */
+/* PARAMETERS: */
+/* pBundleHandle Pointer to the Instance Handle */
+/* pGeneralPurpose Pointer to the data */
+/* CallBackParam ID of the callback */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+LVM_INT32 LVM_VCCallBack(void* pBundleHandle,
+ void* pGeneralPurpose,
+ short CallBackParam)
+{
+ LVM_Instance_t *pInstance =(LVM_Instance_t *)pBundleHandle;
+ LVM_INT32 Target;
+
+ (void) pGeneralPurpose;
+ (void) CallBackParam;
+
+ /* When volume mixer has reached 0 dB target then stop it to avoid
+ unnecessary processing. */
+ Target = LVC_Mixer_GetTarget(&pInstance->VC_Volume.MixerStream[0]);
+
+ if(Target == 0x7FFF)
+ {
+ pInstance->VC_Active = LVM_FALSE;
+ }
+ return 1;
+}
diff --git a/media/libeffects/lvm/lib/Bundle/src/LVM_Init.c b/media/libeffects/lvm/lib/Bundle/src/LVM_Init.c
new file mode 100755
index 0000000..7ac5685
--- /dev/null
+++ b/media/libeffects/lvm/lib/Bundle/src/LVM_Init.c
@@ -0,0 +1,1003 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/************************************************************************************
+
+ $Author: nxp007753 $
+ $Revision: 1255 $
+ $Date: 2010-07-16 17:07:29 +0200 (Fri, 16 Jul 2010) $
+
+*************************************************************************************/
+
+/************************************************************************************/
+/* */
+/* Includes */
+/* */
+/************************************************************************************/
+
+#include "LVM_Private.h"
+#include "LVM_Tables.h"
+#include "VectorArithmetic.h"
+#include "InstAlloc.h"
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_GetMemoryTable */
+/* */
+/* DESCRIPTION: */
+/* This function is used for memory allocation and free. It can be called in */
+/* two ways: */
+/* */
+/* hInstance = NULL Returns the memory requirements */
+/* hInstance = Instance handle Returns the memory requirements and */
+/* allocated base addresses for the instance */
+/* */
+/* When this function is called for memory allocation (hInstance=NULL) the memory */
+/* base address pointers are NULL on return. */
+/* */
+/* When the function is called for free (hInstance = Instance Handle) the memory */
+/* table returns the allocated memory and base addresses used during initialisation. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance Handle */
+/* pMemoryTable Pointer to an empty memory definition table */
+/* pCapabilities Pointer to the default capabilities */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Succeeded */
+/* LVM_NULLADDRESS When one of pMemoryTable or pInstParams is NULL */
+/* LVM_OUTOFRANGE When any of the Instance parameters are out of range */
+/* */
+/* NOTES: */
+/* 1. This function may be interrupted by the LVM_Process function */
+/* 2. The scratch memory is the largest required by any of the sub-modules plus any */
+/* additional scratch requirements of the bundle */
+/* */
+/****************************************************************************************/
+
+LVM_ReturnStatus_en LVM_GetMemoryTable(LVM_Handle_t hInstance,
+ LVM_MemTab_t *pMemoryTable,
+ LVM_InstParams_t *pInstParams)
+{
+
+ LVM_Instance_t *pInstance = (LVM_Instance_t *)hInstance;
+ LVM_UINT32 AlgScratchSize;
+ LVM_UINT32 BundleScratchSize;
+ LVM_UINT16 InternalBlockSize;
+ INST_ALLOC AllocMem[LVM_NR_MEMORY_REGIONS];
+ LVM_INT16 i;
+
+
+ /*
+ * Check parameters
+ */
+ if(pMemoryTable == LVM_NULL)
+ {
+ return LVM_NULLADDRESS;
+ }
+
+
+ /*
+ * Return memory table if the instance has already been created
+ */
+ if (hInstance != LVM_NULL)
+ {
+ /* Read back memory allocation table */
+ *pMemoryTable = pInstance->MemoryTable;
+ return(LVM_SUCCESS);
+ }
+
+ if(pInstParams == LVM_NULL)
+ {
+ return LVM_NULLADDRESS;
+ }
+
+ /*
+ * Power Spectrum Analyser
+ */
+ if(pInstParams->PSA_Included > LVM_PSA_ON)
+ {
+ return (LVM_OUTOFRANGE);
+ }
+
+ /*
+ * Check the instance parameters
+ */
+ if( (pInstParams->BufferMode != LVM_MANAGED_BUFFERS) && (pInstParams->BufferMode != LVM_UNMANAGED_BUFFERS) )
+ {
+ return (LVM_OUTOFRANGE);
+ }
+
+ /* N-Band Equalizer */
+ if( pInstParams->EQNB_NumBands > 32 )
+ {
+ return (LVM_OUTOFRANGE);
+ }
+
+ if(pInstParams->BufferMode == LVM_MANAGED_BUFFERS)
+ {
+ if( (pInstParams->MaxBlockSize < LVM_MIN_MAXBLOCKSIZE ) || (pInstParams->MaxBlockSize > LVM_MANAGED_MAX_MAXBLOCKSIZE ) )
+ {
+ return (LVM_OUTOFRANGE);
+ }
+ }
+ else
+ {
+ if( (pInstParams->MaxBlockSize < LVM_MIN_MAXBLOCKSIZE ) || (pInstParams->MaxBlockSize > LVM_UNMANAGED_MAX_MAXBLOCKSIZE) )
+ {
+ return (LVM_OUTOFRANGE);
+ }
+ }
+
+ /*
+ * Initialise the AllocMem structures
+ */
+ for (i=0; i<LVM_NR_MEMORY_REGIONS; i++)
+ {
+ InstAlloc_Init(&AllocMem[i], LVM_NULL);
+ }
+ InternalBlockSize = (LVM_UINT16)((pInstParams->MaxBlockSize) & MIN_INTERNAL_BLOCKMASK); /* Force to a multiple of MIN_INTERNAL_BLOCKSIZE */
+
+ if (InternalBlockSize < MIN_INTERNAL_BLOCKSIZE)
+ {
+ InternalBlockSize = MIN_INTERNAL_BLOCKSIZE;
+ }
+
+ /* Maximum Internal Black Size should not be more than MAX_INTERNAL_BLOCKSIZE*/
+ if(InternalBlockSize > MAX_INTERNAL_BLOCKSIZE)
+ {
+ InternalBlockSize = MAX_INTERNAL_BLOCKSIZE;
+ }
+
+ /*
+ * Bundle requirements
+ */
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_SLOW_DATA],
+ sizeof(LVM_Instance_t));
+
+
+ /*
+ * Set the algorithm and bundle scratch requirements
+ */
+ AlgScratchSize = 0;
+ if (pInstParams->BufferMode == LVM_MANAGED_BUFFERS)
+ {
+ BundleScratchSize = 6 * (MIN_INTERNAL_BLOCKSIZE + InternalBlockSize) * sizeof(LVM_INT16);
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_TEMPORARY_FAST], /* Scratch buffer */
+ BundleScratchSize);
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_SLOW_DATA],
+ sizeof(LVM_Buffer_t));
+ }
+
+ /*
+ * Treble Enhancement requirements
+ */
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA],
+ sizeof(LVM_TE_Data_t));
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_COEF],
+ sizeof(LVM_TE_Coefs_t));
+
+ /*
+ * N-Band Equalizer requirements
+ */
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA], /* Local storage */
+ (pInstParams->EQNB_NumBands * sizeof(LVM_EQNB_BandDef_t)));
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA], /* User storage */
+ (pInstParams->EQNB_NumBands * sizeof(LVM_EQNB_BandDef_t)));
+
+ /*
+ * Concert Sound requirements
+ */
+ {
+ LVCS_MemTab_t CS_MemTab;
+ LVCS_Capabilities_t CS_Capabilities;
+
+ /*
+ * Set the capabilities
+ */
+ CS_Capabilities.MaxBlockSize = InternalBlockSize;
+
+ /*
+ * Get the memory requirements
+ */
+ LVCS_Memory(LVM_NULL,
+ &CS_MemTab,
+ &CS_Capabilities);
+
+ /*
+ * Update the memory allocation structures
+ */
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA],
+ CS_MemTab.Region[LVM_MEMREGION_PERSISTENT_FAST_DATA].Size);
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_COEF],
+ CS_MemTab.Region[LVM_MEMREGION_PERSISTENT_FAST_COEF].Size);
+ if (CS_MemTab.Region[LVM_MEMREGION_TEMPORARY_FAST].Size > AlgScratchSize) AlgScratchSize = CS_MemTab.Region[LVM_MEMREGION_TEMPORARY_FAST].Size;
+
+ }
+
+
+ /*
+ * Dynamic Bass Enhancement requirements
+ */
+ {
+ LVDBE_MemTab_t DBE_MemTab;
+ LVDBE_Capabilities_t DBE_Capabilities;
+
+ /*
+ * Set the capabilities
+ */
+ DBE_Capabilities.SampleRate = LVDBE_CAP_FS_8000 | LVDBE_CAP_FS_11025 | LVDBE_CAP_FS_12000 | LVDBE_CAP_FS_16000 | LVDBE_CAP_FS_22050 | LVDBE_CAP_FS_24000 | LVDBE_CAP_FS_32000 | LVDBE_CAP_FS_44100 | LVDBE_CAP_FS_48000;
+ DBE_Capabilities.CentreFrequency = LVDBE_CAP_CENTRE_55Hz | LVDBE_CAP_CENTRE_55Hz | LVDBE_CAP_CENTRE_66Hz | LVDBE_CAP_CENTRE_78Hz | LVDBE_CAP_CENTRE_90Hz;
+ DBE_Capabilities.MaxBlockSize = InternalBlockSize;
+
+ /*
+ * Get the memory requirements
+ */
+ LVDBE_Memory(LVM_NULL,
+ &DBE_MemTab,
+
+ &DBE_Capabilities);
+ /*
+ * Update the bundle table
+ */
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA],
+ DBE_MemTab.Region[LVM_MEMREGION_PERSISTENT_FAST_DATA].Size);
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_COEF],
+ DBE_MemTab.Region[LVM_MEMREGION_PERSISTENT_FAST_COEF].Size);
+ if (DBE_MemTab.Region[LVM_MEMREGION_TEMPORARY_FAST].Size > AlgScratchSize) AlgScratchSize = DBE_MemTab.Region[LVM_MEMREGION_TEMPORARY_FAST].Size;
+
+ }
+
+
+ /*
+ * N-Band equaliser requirements
+ */
+ {
+ LVEQNB_MemTab_t EQNB_MemTab; /* For N-Band Equaliser */
+ LVEQNB_Capabilities_t EQNB_Capabilities;
+
+ /*
+ * Set the capabilities
+ */
+ EQNB_Capabilities.SampleRate = LVEQNB_CAP_FS_8000 | LVEQNB_CAP_FS_11025 | LVEQNB_CAP_FS_12000 | LVEQNB_CAP_FS_16000 | LVEQNB_CAP_FS_22050 | LVEQNB_CAP_FS_24000 | LVEQNB_CAP_FS_32000 | LVEQNB_CAP_FS_44100 | LVEQNB_CAP_FS_48000;
+ EQNB_Capabilities.SourceFormat = LVEQNB_CAP_STEREO | LVEQNB_CAP_MONOINSTEREO;
+ EQNB_Capabilities.MaxBlockSize = InternalBlockSize;
+ EQNB_Capabilities.MaxBands = pInstParams->EQNB_NumBands;
+
+ /*
+ * Get the memory requirements
+ */
+ LVEQNB_Memory(LVM_NULL,
+ &EQNB_MemTab,
+ &EQNB_Capabilities);
+
+ /*
+ * Update the bundle table
+ */
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA],
+ EQNB_MemTab.Region[LVM_MEMREGION_PERSISTENT_FAST_DATA].Size);
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_COEF],
+ EQNB_MemTab.Region[LVM_MEMREGION_PERSISTENT_FAST_COEF].Size);
+ if (EQNB_MemTab.Region[LVM_MEMREGION_TEMPORARY_FAST].Size > AlgScratchSize) AlgScratchSize = EQNB_MemTab.Region[LVM_MEMREGION_TEMPORARY_FAST].Size;
+
+ }
+
+ /*
+ * Headroom management memory allocation
+ */
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA],
+ (LVM_HEADROOM_MAX_NBANDS * sizeof(LVM_HeadroomBandDef_t)));
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA],
+ (LVM_HEADROOM_MAX_NBANDS * sizeof(LVM_HeadroomBandDef_t)));
+
+
+ /*
+ * Spectrum Analyzer memory requirements
+ */
+ {
+ pLVPSA_Handle_t hPSAInst = LVM_NULL;
+ LVPSA_MemTab_t PSA_MemTab;
+ LVPSA_InitParams_t PSA_InitParams;
+ LVPSA_FilterParam_t FiltersParams[9];
+ LVPSA_RETURN PSA_Status;
+
+ if(pInstParams->PSA_Included == LVM_PSA_ON)
+ {
+ PSA_InitParams.SpectralDataBufferDuration = (LVM_UINT16) 500;
+ PSA_InitParams.MaxInputBlockSize = (LVM_UINT16) 1000;
+ PSA_InitParams.nBands = (LVM_UINT16) 9;
+
+ PSA_InitParams.pFiltersParams = &FiltersParams[0];
+ for(i = 0; i < PSA_InitParams.nBands; i++)
+ {
+ FiltersParams[i].CenterFrequency = (LVM_UINT16) 1000;
+ FiltersParams[i].QFactor = (LVM_UINT16) 25;
+ FiltersParams[i].PostGain = (LVM_INT16) 0;
+ }
+
+ /*
+ * Get the memory requirements
+ */
+ PSA_Status = LVPSA_Memory (hPSAInst,
+ &PSA_MemTab,
+ &PSA_InitParams);
+
+ if (PSA_Status != LVPSA_OK)
+ {
+ return((LVM_ReturnStatus_en) LVM_ALGORITHMPSA);
+ }
+
+ /*
+ * Update the bundle table
+ */
+ /* Slow Data */
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_SLOW_DATA],
+ PSA_MemTab.Region[LVM_PERSISTENT_SLOW_DATA].Size);
+
+ /* Fast Data */
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA],
+ PSA_MemTab.Region[LVM_PERSISTENT_FAST_DATA].Size);
+
+ /* Fast Coef */
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_COEF],
+ PSA_MemTab.Region[LVM_PERSISTENT_FAST_COEF].Size);
+
+ /* Fast Temporary */
+ InstAlloc_AddMember(&AllocMem[LVM_TEMPORARY_FAST],
+ MAX_INTERNAL_BLOCKSIZE * sizeof(LVM_INT16));
+
+ if (PSA_MemTab.Region[LVM_TEMPORARY_FAST].Size > AlgScratchSize)
+ {
+ AlgScratchSize = PSA_MemTab.Region[LVM_TEMPORARY_FAST].Size;
+ }
+ }
+ }
+
+ /*
+ * Return the memory table
+ */
+ pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_SLOW_DATA].Size = InstAlloc_GetTotal(&AllocMem[LVM_MEMREGION_PERSISTENT_SLOW_DATA]);
+ pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_SLOW_DATA].Type = LVM_PERSISTENT_SLOW_DATA;
+ pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_SLOW_DATA].pBaseAddress = LVM_NULL;
+
+ pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_FAST_DATA].Size = InstAlloc_GetTotal(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA]);
+ pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_FAST_DATA].Type = LVM_PERSISTENT_FAST_DATA;
+ pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_FAST_DATA].pBaseAddress = LVM_NULL;
+ if (pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_FAST_DATA].Size < 4)
+ {
+ pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_FAST_DATA].Size = 0;
+ }
+
+ pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_FAST_COEF].Size = InstAlloc_GetTotal(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_COEF]);
+ pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_FAST_COEF].Type = LVM_PERSISTENT_FAST_COEF;
+ pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_FAST_COEF].pBaseAddress = LVM_NULL;
+ if (pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_FAST_COEF].Size < 4)
+ {
+ pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_FAST_COEF].Size = 0;
+ }
+
+ InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_TEMPORARY_FAST],
+ AlgScratchSize);
+ pMemoryTable->Region[LVM_MEMREGION_TEMPORARY_FAST].Size = InstAlloc_GetTotal(&AllocMem[LVM_MEMREGION_TEMPORARY_FAST]);
+ pMemoryTable->Region[LVM_MEMREGION_TEMPORARY_FAST].Type = LVM_TEMPORARY_FAST;
+ pMemoryTable->Region[LVM_MEMREGION_TEMPORARY_FAST].pBaseAddress = LVM_NULL;
+ if (pMemoryTable->Region[LVM_MEMREGION_TEMPORARY_FAST].Size < 4)
+ {
+ pMemoryTable->Region[LVM_MEMREGION_TEMPORARY_FAST].Size = 0;
+ }
+
+ return(LVM_SUCCESS);
+
+}
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_GetInstanceHandle */
+/* */
+/* DESCRIPTION: */
+/* This function is used to create a bundle instance. It returns the created instance */
+/* handle through phInstance. All parameters are set to their default, inactive state. */
+/* */
+/* PARAMETERS: */
+/* phInstance pointer to the instance handle */
+/* pMemoryTable Pointer to the memory definition table */
+/* pInstParams Pointer to the initialisation capabilities */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Initialisation succeeded */
+/* LVM_OUTOFRANGE When any of the Instance parameters are out of range */
+/* LVM_NULLADDRESS When one of phInstance, pMemoryTable or pInstParams are NULL*/
+/* */
+/* NOTES: */
+/* 1. This function must not be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+
+LVM_ReturnStatus_en LVM_GetInstanceHandle(LVM_Handle_t *phInstance,
+ LVM_MemTab_t *pMemoryTable,
+ LVM_InstParams_t *pInstParams)
+{
+
+ LVM_ReturnStatus_en Status = LVM_SUCCESS;
+ LVM_Instance_t *pInstance;
+ INST_ALLOC AllocMem[LVM_NR_MEMORY_REGIONS];
+ LVM_INT16 i;
+ LVM_UINT16 InternalBlockSize;
+ LVM_INT32 BundleScratchSize;
+
+
+ /*
+ * Check valid points have been given
+ */
+ if ((phInstance == LVM_NULL) || (pMemoryTable == LVM_NULL) || (pInstParams == LVM_NULL))
+ {
+ return (LVM_NULLADDRESS);
+ }
+
+ /*
+ * Check the memory table for NULL pointers
+ */
+ for (i=0; i<LVM_NR_MEMORY_REGIONS; i++)
+ {
+ if ((pMemoryTable->Region[i].Size != 0) &&
+ (pMemoryTable->Region[i].pBaseAddress==LVM_NULL))
+ {
+ return(LVM_NULLADDRESS);
+ }
+ }
+
+ /*
+ * Check the instance parameters
+ */
+ if( (pInstParams->BufferMode != LVM_MANAGED_BUFFERS) && (pInstParams->BufferMode != LVM_UNMANAGED_BUFFERS) )
+ {
+ return (LVM_OUTOFRANGE);
+ }
+
+ if( pInstParams->EQNB_NumBands > 32 )
+ {
+ return (LVM_OUTOFRANGE);
+ }
+
+ if(pInstParams->BufferMode == LVM_MANAGED_BUFFERS)
+ {
+ if( (pInstParams->MaxBlockSize < LVM_MIN_MAXBLOCKSIZE ) || (pInstParams->MaxBlockSize > LVM_MANAGED_MAX_MAXBLOCKSIZE ) )
+ {
+ return (LVM_OUTOFRANGE);
+ }
+ }
+ else
+ {
+ if( (pInstParams->MaxBlockSize < LVM_MIN_MAXBLOCKSIZE ) || (pInstParams->MaxBlockSize > LVM_UNMANAGED_MAX_MAXBLOCKSIZE) )
+ {
+ return (LVM_OUTOFRANGE);
+ }
+ }
+
+ if(pInstParams->PSA_Included > LVM_PSA_ON)
+ {
+ return (LVM_OUTOFRANGE);
+ }
+
+ /*
+ * Initialise the AllocMem structures
+ */
+ for (i=0; i<LVM_NR_MEMORY_REGIONS; i++)
+ {
+ InstAlloc_Init(&AllocMem[i],
+ pMemoryTable->Region[i].pBaseAddress);
+ }
+
+
+ /*
+ * Set the instance handle
+ */
+ *phInstance = (LVM_Handle_t)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_SLOW_DATA],
+ sizeof(LVM_Instance_t));
+ pInstance =(LVM_Instance_t *)*phInstance;
+
+
+ /*
+ * Save the memory table, parameters and capabilities
+ */
+ pInstance->MemoryTable = *pMemoryTable;
+ pInstance->InstParams = *pInstParams;
+
+
+ /*
+ * Set the bundle scratch memory and initialse the buffer management
+ */
+ InternalBlockSize = (LVM_UINT16)((pInstParams->MaxBlockSize) & MIN_INTERNAL_BLOCKMASK); /* Force to a multiple of MIN_INTERNAL_BLOCKSIZE */
+ if (InternalBlockSize < MIN_INTERNAL_BLOCKSIZE)
+ {
+ InternalBlockSize = MIN_INTERNAL_BLOCKSIZE;
+ }
+
+ /* Maximum Internal Black Size should not be more than MAX_INTERNAL_BLOCKSIZE*/
+ if(InternalBlockSize > MAX_INTERNAL_BLOCKSIZE)
+ {
+ InternalBlockSize = MAX_INTERNAL_BLOCKSIZE;
+ }
+ pInstance->InternalBlockSize = (LVM_INT16)InternalBlockSize;
+
+
+ /*
+ * Common settings for managed and unmanaged buffers
+ */
+ pInstance->SamplesToProcess = 0; /* No samples left to process */
+ if (pInstParams->BufferMode == LVM_MANAGED_BUFFERS)
+ {
+ /*
+ * Managed buffers required
+ */
+ pInstance->pBufferManagement = InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_SLOW_DATA],
+ sizeof(LVM_Buffer_t));
+ BundleScratchSize = (LVM_INT32)(6 * (MIN_INTERNAL_BLOCKSIZE + InternalBlockSize) * sizeof(LVM_INT16));
+ pInstance->pBufferManagement->pScratch = InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_TEMPORARY_FAST], /* Scratch 1 buffer */
+ (LVM_UINT32)BundleScratchSize);
+
+ LoadConst_16(0, /* Clear the input delay buffer */
+ (LVM_INT16 *)&pInstance->pBufferManagement->InDelayBuffer,
+ (LVM_INT16)(2 * MIN_INTERNAL_BLOCKSIZE));
+ pInstance->pBufferManagement->InDelaySamples = MIN_INTERNAL_BLOCKSIZE; /* Set the number of delay samples */
+ pInstance->pBufferManagement->OutDelaySamples = 0; /* No samples in the output buffer */
+ pInstance->pBufferManagement->BufferState = LVM_FIRSTCALL; /* Set the state ready for the first call */
+ }
+
+
+ /*
+ * Set default parameters
+ */
+ pInstance->Params.OperatingMode = LVM_MODE_OFF;
+ pInstance->Params.SampleRate = LVM_FS_8000;
+ pInstance->Params.SourceFormat = LVM_MONO;
+ pInstance->Params.SpeakerType = LVM_HEADPHONES;
+ pInstance->Params.VC_EffectLevel = 0;
+ pInstance->Params.VC_Balance = 0;
+
+ /*
+ * Set callback
+ */
+ pInstance->CallBack = LVM_AlgoCallBack;
+
+
+ /*
+ * DC removal filter
+ */
+ DC_2I_D16_TRC_WRA_01_Init(&pInstance->DC_RemovalInstance);
+
+
+ /*
+ * Treble Enhancement
+ */
+ pInstance->pTE_Taps = (LVM_TE_Data_t *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA],
+ sizeof(LVM_TE_Data_t));
+
+ pInstance->pTE_State = (LVM_TE_Coefs_t *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_COEF],
+ sizeof(LVM_TE_Coefs_t));
+ pInstance->Params.TE_OperatingMode = LVM_TE_OFF;
+ pInstance->Params.TE_EffectLevel = 0;
+ pInstance->TE_Active = LVM_FALSE;
+
+
+ /*
+ * Set the volume control and initialise Current to Target
+ */
+ pInstance->VC_Volume.MixerStream[0].CallbackParam = 0;
+ pInstance->VC_Volume.MixerStream[0].CallbackSet = 0;
+ pInstance->VC_Volume.MixerStream[0].pCallbackHandle = pInstance;
+ pInstance->VC_Volume.MixerStream[0].pCallBack = LVM_VCCallBack;
+
+ /* In managed buffering, start with low signal level as delay in buffer management causes a click*/
+ if (pInstParams->BufferMode == LVM_MANAGED_BUFFERS)
+ {
+ LVC_Mixer_Init(&pInstance->VC_Volume.MixerStream[0],0,0);
+ }
+ else
+ {
+ LVC_Mixer_Init(&pInstance->VC_Volume.MixerStream[0],LVM_MAXINT_16,LVM_MAXINT_16);
+ }
+
+ LVC_Mixer_SetTimeConstant(&pInstance->VC_Volume.MixerStream[0],0,LVM_FS_8000,2);
+
+ pInstance->VC_VolumedB = 0;
+ pInstance->VC_AVLFixedVolume = 0;
+ pInstance->VC_Active = LVM_FALSE;
+
+ pInstance->VC_BalanceMix.MixerStream[0].CallbackParam = 0;
+ pInstance->VC_BalanceMix.MixerStream[0].CallbackSet = 0;
+ pInstance->VC_BalanceMix.MixerStream[0].pCallbackHandle = pInstance;
+ pInstance->VC_BalanceMix.MixerStream[0].pCallBack = LVM_VCCallBack;
+ LVC_Mixer_Init(&pInstance->VC_BalanceMix.MixerStream[0],LVM_MAXINT_16,LVM_MAXINT_16);
+ LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->VC_BalanceMix.MixerStream[0],LVM_VC_MIXER_TIME,LVM_FS_8000,2);
+
+ pInstance->VC_BalanceMix.MixerStream[1].CallbackParam = 0;
+ pInstance->VC_BalanceMix.MixerStream[1].CallbackSet = 0;
+ pInstance->VC_BalanceMix.MixerStream[1].pCallbackHandle = pInstance;
+ pInstance->VC_BalanceMix.MixerStream[1].pCallBack = LVM_VCCallBack;
+ LVC_Mixer_Init(&pInstance->VC_BalanceMix.MixerStream[1],LVM_MAXINT_16,LVM_MAXINT_16);
+ LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->VC_BalanceMix.MixerStream[1],LVM_VC_MIXER_TIME,LVM_FS_8000,2);
+ /*
+ * Set the default EQNB pre-gain and pointer to the band definitions
+ */
+ pInstance->pEQNB_BandDefs = InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA],
+ (pInstParams->EQNB_NumBands * sizeof(LVM_EQNB_BandDef_t)));
+ pInstance->pEQNB_UserDefs = InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA],
+ (pInstParams->EQNB_NumBands * sizeof(LVM_EQNB_BandDef_t)));
+
+
+ /*
+ * Initialise the Concert Sound module
+ */
+ {
+ LVCS_Handle_t hCSInstance; /* Instance handle */
+ LVCS_MemTab_t CS_MemTab; /* Memory table */
+ LVCS_Capabilities_t CS_Capabilities; /* Initial capabilities */
+ LVCS_ReturnStatus_en LVCS_Status; /* Function call status */
+
+ /*
+ * Set default parameters
+ */
+ pInstance->Params.VirtualizerReverbLevel = 100;
+ pInstance->Params.VirtualizerType = LVM_CONCERTSOUND;
+ pInstance->Params.VirtualizerOperatingMode = LVM_MODE_OFF;
+ pInstance->CS_Active = LVM_FALSE;
+
+ /*
+ * Set the initialisation capabilities
+ */
+ CS_Capabilities.MaxBlockSize = (LVM_UINT16)InternalBlockSize;
+ CS_Capabilities.CallBack = pInstance->CallBack;
+ CS_Capabilities.pBundleInstance = (void*)pInstance;
+
+
+ /*
+ * Get the memory requirements and then set the address pointers, forcing alignment
+ */
+ LVCS_Status = LVCS_Memory(LVM_NULL, /* Get the memory requirements */
+ &CS_MemTab,
+ &CS_Capabilities);
+ CS_MemTab.Region[LVCS_MEMREGION_PERSISTENT_SLOW_DATA].pBaseAddress = &pInstance->CS_Instance;
+ CS_MemTab.Region[LVCS_MEMREGION_PERSISTENT_FAST_DATA].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA],
+ CS_MemTab.Region[LVCS_MEMREGION_PERSISTENT_FAST_DATA].Size);
+ CS_MemTab.Region[LVCS_MEMREGION_PERSISTENT_FAST_COEF].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_COEF],
+ CS_MemTab.Region[LVCS_MEMREGION_PERSISTENT_FAST_COEF].Size);
+ CS_MemTab.Region[LVCS_MEMREGION_TEMPORARY_FAST].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_TEMPORARY_FAST],
+ 0);
+
+ /*
+ * Initialise the Concert Sound instance and save the instance handle
+ */
+ hCSInstance = LVM_NULL; /* Set to NULL to return handle */
+ LVCS_Status = LVCS_Init(&hCSInstance, /* Initiailse */
+ &CS_MemTab,
+ &CS_Capabilities);
+ if (LVCS_Status != LVCS_SUCCESS) return((LVM_ReturnStatus_en)LVCS_Status);
+ pInstance->hCSInstance = hCSInstance; /* Save the instance handle */
+
+ }
+
+ /*
+ * Initialise the Bass Enhancement module
+ */
+ {
+ LVDBE_Handle_t hDBEInstance; /* Instance handle */
+ LVDBE_MemTab_t DBE_MemTab; /* Memory table */
+ LVDBE_Capabilities_t DBE_Capabilities; /* Initial capabilities */
+ LVDBE_ReturnStatus_en LVDBE_Status; /* Function call status */
+
+
+ /*
+ * Set the initialisation parameters
+ */
+ pInstance->Params.BE_OperatingMode = LVM_BE_OFF;
+ pInstance->Params.BE_CentreFreq = LVM_BE_CENTRE_55Hz;
+ pInstance->Params.BE_EffectLevel = 0;
+ pInstance->Params.BE_HPF = LVM_BE_HPF_OFF;
+
+ pInstance->DBE_Active = LVM_FALSE;
+
+
+
+ /*
+ * Set the initialisation capabilities
+ */
+ DBE_Capabilities.SampleRate = LVDBE_CAP_FS_8000 | LVDBE_CAP_FS_11025 | LVDBE_CAP_FS_12000 | LVDBE_CAP_FS_16000 | LVDBE_CAP_FS_22050 | LVDBE_CAP_FS_24000 | LVDBE_CAP_FS_32000 | LVDBE_CAP_FS_44100 | LVDBE_CAP_FS_48000;
+ DBE_Capabilities.CentreFrequency = LVDBE_CAP_CENTRE_55Hz | LVDBE_CAP_CENTRE_55Hz | LVDBE_CAP_CENTRE_66Hz | LVDBE_CAP_CENTRE_78Hz | LVDBE_CAP_CENTRE_90Hz;
+ DBE_Capabilities.MaxBlockSize = (LVM_UINT16)InternalBlockSize;
+
+
+ /*
+ * Get the memory requirements and then set the address pointers
+ */
+ LVDBE_Status = LVDBE_Memory(LVM_NULL, /* Get the memory requirements */
+ &DBE_MemTab,
+ &DBE_Capabilities);
+ DBE_MemTab.Region[LVDBE_MEMREGION_INSTANCE].pBaseAddress = &pInstance->DBE_Instance;
+ DBE_MemTab.Region[LVDBE_MEMREGION_PERSISTENT_DATA].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA],
+ DBE_MemTab.Region[LVDBE_MEMREGION_PERSISTENT_DATA].Size);
+ DBE_MemTab.Region[LVDBE_MEMREGION_PERSISTENT_COEF].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_COEF],
+ DBE_MemTab.Region[LVDBE_MEMREGION_PERSISTENT_COEF].Size);
+ DBE_MemTab.Region[LVDBE_MEMREGION_SCRATCH].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_TEMPORARY_FAST],
+ 0);
+
+
+ /*
+ * Initialise the Dynamic Bass Enhancement instance and save the instance handle
+ */
+ hDBEInstance = LVM_NULL; /* Set to NULL to return handle */
+ LVDBE_Status = LVDBE_Init(&hDBEInstance, /* Initiailse */
+ &DBE_MemTab,
+ &DBE_Capabilities);
+ if (LVDBE_Status != LVDBE_SUCCESS) return((LVM_ReturnStatus_en)LVDBE_Status);
+ pInstance->hDBEInstance = hDBEInstance; /* Save the instance handle */
+ }
+
+
+ /*
+ * Initialise the N-Band Equaliser module
+ */
+ {
+ LVEQNB_Handle_t hEQNBInstance; /* Instance handle */
+ LVEQNB_MemTab_t EQNB_MemTab; /* Memory table */
+ LVEQNB_Capabilities_t EQNB_Capabilities; /* Initial capabilities */
+ LVEQNB_ReturnStatus_en LVEQNB_Status; /* Function call status */
+
+
+ /*
+ * Set the initialisation parameters
+ */
+ pInstance->Params.EQNB_OperatingMode = LVM_EQNB_OFF;
+ pInstance->Params.EQNB_NBands = 0;
+ pInstance->Params.pEQNB_BandDefinition = LVM_NULL;
+ pInstance->EQNB_Active = LVM_FALSE;
+
+
+ /*
+ * Set the initialisation capabilities
+ */
+ EQNB_Capabilities.SampleRate = LVEQNB_CAP_FS_8000 | LVEQNB_CAP_FS_11025 | LVEQNB_CAP_FS_12000 | LVEQNB_CAP_FS_16000 | LVEQNB_CAP_FS_22050 | LVEQNB_CAP_FS_24000 | LVEQNB_CAP_FS_32000 | LVEQNB_CAP_FS_44100 | LVEQNB_CAP_FS_48000;
+ EQNB_Capabilities.MaxBlockSize = (LVM_UINT16)InternalBlockSize;
+ EQNB_Capabilities.MaxBands = pInstParams->EQNB_NumBands;
+ EQNB_Capabilities.SourceFormat = LVEQNB_CAP_STEREO | LVEQNB_CAP_MONOINSTEREO;
+ EQNB_Capabilities.CallBack = pInstance->CallBack;
+ EQNB_Capabilities.pBundleInstance = (void*)pInstance;
+
+
+ /*
+ * Get the memory requirements and then set the address pointers, forcing alignment
+ */
+ LVEQNB_Status = LVEQNB_Memory(LVM_NULL, /* Get the memory requirements */
+ &EQNB_MemTab,
+ &EQNB_Capabilities);
+ EQNB_MemTab.Region[LVEQNB_MEMREGION_INSTANCE].pBaseAddress = &pInstance->EQNB_Instance;
+ EQNB_MemTab.Region[LVEQNB_MEMREGION_PERSISTENT_DATA].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA],
+ EQNB_MemTab.Region[LVEQNB_MEMREGION_PERSISTENT_DATA].Size);
+ EQNB_MemTab.Region[LVEQNB_MEMREGION_PERSISTENT_COEF].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_COEF],
+ EQNB_MemTab.Region[LVEQNB_MEMREGION_PERSISTENT_COEF].Size);
+ EQNB_MemTab.Region[LVEQNB_MEMREGION_SCRATCH].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_TEMPORARY_FAST],
+ 0);
+
+
+ /*
+ * Initialise the Dynamic Bass Enhancement instance and save the instance handle
+ */
+ hEQNBInstance = LVM_NULL; /* Set to NULL to return handle */
+ LVEQNB_Status = LVEQNB_Init(&hEQNBInstance, /* Initiailse */
+ &EQNB_MemTab,
+ &EQNB_Capabilities);
+ if (LVEQNB_Status != LVEQNB_SUCCESS) return((LVM_ReturnStatus_en)LVEQNB_Status);
+ pInstance->hEQNBInstance = hEQNBInstance; /* Save the instance handle */
+ }
+
+ /*
+ * Headroom management memory allocation
+ */
+ {
+ pInstance->pHeadroom_BandDefs = InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA],
+ (LVM_HEADROOM_MAX_NBANDS * sizeof(LVM_HeadroomBandDef_t)));
+ pInstance->pHeadroom_UserDefs = InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA],
+ (LVM_HEADROOM_MAX_NBANDS * sizeof(LVM_HeadroomBandDef_t)));
+
+ /* Headroom management parameters initialisation */
+ pInstance->NewHeadroomParams.NHeadroomBands = 2;
+ pInstance->NewHeadroomParams.pHeadroomDefinition = pInstance->pHeadroom_BandDefs;
+ pInstance->NewHeadroomParams.pHeadroomDefinition[0].Limit_Low = 20;
+ pInstance->NewHeadroomParams.pHeadroomDefinition[0].Limit_High = 4999;
+ pInstance->NewHeadroomParams.pHeadroomDefinition[0].Headroom_Offset = 3;
+ pInstance->NewHeadroomParams.pHeadroomDefinition[1].Limit_Low = 5000;
+ pInstance->NewHeadroomParams.pHeadroomDefinition[1].Limit_High = 24000;
+ pInstance->NewHeadroomParams.pHeadroomDefinition[1].Headroom_Offset = 4;
+ pInstance->NewHeadroomParams.Headroom_OperatingMode = LVM_HEADROOM_ON;
+
+ pInstance->Headroom =0;
+ }
+
+
+ /*
+ * Initialise the PSA module
+ */
+ {
+ pLVPSA_Handle_t hPSAInstance = LVM_NULL; /* Instance handle */
+ LVPSA_MemTab_t PSA_MemTab;
+ LVPSA_RETURN PSA_Status; /* Function call status */
+ LVPSA_FilterParam_t FiltersParams[9];
+
+ if(pInstParams->PSA_Included==LVM_PSA_ON)
+ {
+ pInstance->PSA_InitParams.SpectralDataBufferDuration = (LVM_UINT16) 500;
+ pInstance->PSA_InitParams.MaxInputBlockSize = (LVM_UINT16) 2048;
+ pInstance->PSA_InitParams.nBands = (LVM_UINT16) 9;
+ pInstance->PSA_InitParams.pFiltersParams = &FiltersParams[0];
+ for(i = 0; i < pInstance->PSA_InitParams.nBands; i++)
+ {
+ FiltersParams[i].CenterFrequency = (LVM_UINT16) 1000;
+ FiltersParams[i].QFactor = (LVM_UINT16) 100;
+ FiltersParams[i].PostGain = (LVM_INT16) 0;
+ }
+
+ /*Get the memory requirements and then set the address pointers*/
+ PSA_Status = LVPSA_Memory (hPSAInstance,
+ &PSA_MemTab,
+ &pInstance->PSA_InitParams);
+
+ if (PSA_Status != LVPSA_OK)
+ {
+ return((LVM_ReturnStatus_en) LVM_ALGORITHMPSA);
+ }
+
+ /* Slow Data */
+ PSA_MemTab.Region[LVM_PERSISTENT_SLOW_DATA].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_SLOW_DATA],
+ PSA_MemTab.Region[LVM_PERSISTENT_SLOW_DATA].Size);
+
+
+ /* Fast Data */
+ PSA_MemTab.Region[LVM_PERSISTENT_FAST_DATA].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA],
+ PSA_MemTab.Region[LVM_PERSISTENT_FAST_DATA].Size);
+
+
+ /* Fast Coef */
+ PSA_MemTab.Region[LVM_PERSISTENT_FAST_COEF].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_COEF],
+ PSA_MemTab.Region[LVM_PERSISTENT_FAST_COEF].Size);
+
+ /* Fast Temporary */
+ pInstance->pPSAInput = InstAlloc_AddMember(&AllocMem[LVM_TEMPORARY_FAST],
+ (LVM_UINT32) MAX_INTERNAL_BLOCKSIZE * sizeof(LVM_INT16));
+
+ PSA_MemTab.Region[LVM_TEMPORARY_FAST].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_TEMPORARY_FAST],0);
+
+
+ /*Initialise PSA instance and save the instance handle*/
+ pInstance->PSA_ControlParams.Fs = LVM_FS_48000;
+ pInstance->PSA_ControlParams.LevelDetectionSpeed = LVPSA_SPEED_MEDIUM;
+ PSA_Status = LVPSA_Init (&hPSAInstance,
+ &pInstance->PSA_InitParams,
+ &pInstance->PSA_ControlParams,
+ &PSA_MemTab);
+
+ if (PSA_Status != LVPSA_OK)
+ {
+ return((LVM_ReturnStatus_en) LVM_ALGORITHMPSA);
+ }
+
+ pInstance->hPSAInstance = hPSAInstance; /* Save the instance handle */
+ pInstance->PSA_GainOffset = 0;
+ }
+ else
+ {
+ pInstance->hPSAInstance = LVM_NULL;
+ }
+
+ /*
+ * Set the initialisation parameters.
+ */
+ pInstance->Params.PSA_PeakDecayRate = LVM_PSA_SPEED_MEDIUM;
+ pInstance->Params.PSA_Enable = LVM_PSA_OFF;
+ }
+
+ /*
+ * Copy the initial parameters to the new parameters for correct readback of
+ * the settings.
+ */
+ pInstance->NewParams = pInstance->Params;
+
+
+ /*
+ * Create configuration number
+ */
+ pInstance->ConfigurationNumber = 0x00000000;
+ pInstance->ConfigurationNumber += LVM_CS_MASK;
+ pInstance->ConfigurationNumber += LVM_EQNB_MASK;
+ pInstance->ConfigurationNumber += LVM_DBE_MASK;
+ pInstance->ConfigurationNumber += LVM_VC_MASK;
+ pInstance->ConfigurationNumber += LVM_PSA_MASK;
+
+ if(((pInstance->ConfigurationNumber & LVM_CS_MASK)!=0) ||
+ ((pInstance->ConfigurationNumber & LVM_DBE_MASK)!=0) ||
+ ((pInstance->ConfigurationNumber & LVM_EQNB_MASK)!=0)||
+ ((pInstance->ConfigurationNumber & LVM_TE_MASK)!=0) ||
+ ((pInstance->ConfigurationNumber & LVM_VC_MASK)!=0))
+ {
+ pInstance->BlickSizeMultiple = 4;
+ }
+ else
+ {
+ pInstance->BlickSizeMultiple = 1;
+ }
+
+ return(Status);
+}
+
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_ClearAudioBuffers */
+/* */
+/* DESCRIPTION: */
+/* This function is used to clear the internal audio buffers of the bundle. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Initialisation succeeded */
+/* LVM_NULLADDRESS Instance or scratch memory has a NULL pointer */
+/* */
+/* NOTES: */
+/* 1. This function must not be interrupted by the LVM_Process function */
+/* */
+/****************************************************************************************/
+
+LVM_ReturnStatus_en LVM_ClearAudioBuffers(LVM_Handle_t hInstance)
+{
+ LVM_MemTab_t MemTab; /* Memory table */
+ LVM_InstParams_t InstParams; /* Instance parameters */
+ LVM_ControlParams_t Params; /* Control Parameters */
+ LVM_Instance_t *pInstance = (LVM_Instance_t *)hInstance; /* Pointer to Instance */
+
+
+ if(hInstance == LVM_NULL){
+ return LVM_NULLADDRESS;
+ }
+
+ /* Save the control parameters */ /* coverity[unchecked_value] */ /* Do not check return value internal function calls */
+ LVM_GetControlParameters(hInstance, &Params);
+
+ /* Retrieve allocated buffers in memtab */
+ LVM_GetMemoryTable(hInstance, &MemTab, LVM_NULL);
+
+ /* Save the instance parameters */
+ InstParams = pInstance->InstParams;
+
+ /* Call LVM_GetInstanceHandle to re-initialise the bundle */
+ LVM_GetInstanceHandle( &hInstance,
+ &MemTab,
+ &InstParams);
+
+ /* Restore control parameters */ /* coverity[unchecked_value] */ /* Do not check return value internal function calls */
+ LVM_SetControlParameters(hInstance, &Params);
+
+ /* DC removal filter */
+ DC_2I_D16_TRC_WRA_01_Init(&pInstance->DC_RemovalInstance);
+
+
+ return LVM_SUCCESS;
+}
+
+
+
diff --git a/media/libeffects/lvm/lib/Bundle/src/LVM_Private.h b/media/libeffects/lvm/lib/Bundle/src/LVM_Private.h
new file mode 100755
index 0000000..f70e473
--- /dev/null
+++ b/media/libeffects/lvm/lib/Bundle/src/LVM_Private.h
@@ -0,0 +1,292 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**********************************************************************************
+
+ $Author: nxp007753 $
+ $Revision: 1082 $
+ $Date: 2010-07-05 12:44:39 +0200 (Mon, 05 Jul 2010) $
+
+***********************************************************************************/
+
+/************************************************************************************/
+/* */
+/* Header file for the private layer interface of concert sound bundle */
+/* */
+/* This files includes all definitions, types, structures and function */
+/* prototypes required by the execution layer. */
+/* */
+/************************************************************************************/
+
+#ifndef __LVM_PRIVATE_H__
+#define __LVM_PRIVATE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/************************************************************************************/
+/* */
+/* Includes */
+/* */
+/************************************************************************************/
+
+#include "LVM.h" /* LifeVibes */
+#include "LVM_Common.h" /* LifeVibes common */
+#include "BIQUAD.h" /* Biquad library */
+#include "LVC_Mixer.h" /* Mixer library */
+#include "LVCS_Private.h" /* Concert Sound */
+#include "LVDBE_Private.h" /* Dynamic Bass Enhancement */
+#include "LVEQNB_Private.h" /* N-Band equaliser */
+#include "LVPSA_Private.h" /* Parametric Spectrum Analyzer */
+
+
+/************************************************************************************/
+/* */
+/* Defines */
+/* */
+/************************************************************************************/
+
+/* General */
+#define LVM_INVALID 0xFFFF /* Invalid init parameter */
+
+/* Memory */
+#define LVM_INSTANCE_ALIGN 4 /* 32-bit for structures */
+#define LVM_FIRSTCALL 0 /* First call to the buffer */
+#define LVM_MAXBLOCKCALL 1 /* Maximum block size calls to the buffer */
+#define LVM_LASTCALL 2 /* Last call to the buffer */
+#define LVM_FIRSTLASTCALL 3 /* Single call for small number of samples */
+
+/* Block Size */
+#define LVM_MIN_MAXBLOCKSIZE 16 /* Minimum MaxBlockSize Limit*/
+#define LVM_MANAGED_MAX_MAXBLOCKSIZE 8191 /* Maximum MaxBlockSzie Limit for Managed Buffer Mode*/
+#define LVM_UNMANAGED_MAX_MAXBLOCKSIZE 4096 /* Maximum MaxBlockSzie Limit for Unmanaged Buffer Mode */
+
+#define MAX_INTERNAL_BLOCKSIZE 8128 /* Maximum multiple of 64 below 8191*/
+
+#define MIN_INTERNAL_BLOCKSIZE 16 /* Minimum internal block size */
+#define MIN_INTERNAL_BLOCKSHIFT 4 /* Minimum internal block size as a power of 2 */
+#define MIN_INTERNAL_BLOCKMASK 0xFFF0 /* Minimum internal block size mask */
+
+#define LVM_PSA_DYNAMICRANGE 60 /* Spectral Dynamic range: used for offseting output*/
+#define LVM_PSA_BARHEIGHT 127 /* Spectral Bar Height*/
+
+#define LVM_TE_MIN_EFFECTLEVEL 0 /*TE Minimum EffectLevel*/
+#define LVM_TE_MAX_EFFECTLEVEL 15 /*TE Maximum Effect level*/
+
+#define LVM_VC_MIN_EFFECTLEVEL -96 /*VC Minimum EffectLevel*/
+#define LVM_VC_MAX_EFFECTLEVEL 0 /*VC Maximum Effect level*/
+
+#define LVM_BE_MIN_EFFECTLEVEL 0 /*BE Minimum EffectLevel*/
+#define LVM_BE_MAX_EFFECTLEVEL 15 /*BE Maximum Effect level*/
+
+#define LVM_EQNB_MIN_BAND_FREQ 20 /*EQNB Minimum Band Frequency*/
+#define LVM_EQNB_MAX_BAND_FREQ 24000 /*EQNB Maximum Band Frequency*/
+#define LVM_EQNB_MIN_BAND_GAIN -15 /*EQNB Minimum Band Frequency*/
+#define LVM_EQNB_MAX_BAND_GAIN 15 /*EQNB Maximum Band Frequency*/
+#define LVM_EQNB_MIN_QFACTOR 25 /*EQNB Minimum Q Factor*/
+#define LVM_EQNB_MAX_QFACTOR 1200 /*EQNB Maximum Q Factor*/
+#define LVM_EQNB_MIN_LPF_FREQ 1000 /*EQNB Minimum Low Pass Corner frequency*/
+#define LVM_EQNB_MIN_HPF_FREQ 20 /*EQNB Minimum High Pass Corner frequency*/
+#define LVM_EQNB_MAX_HPF_FREQ 1000 /*EQNB Maximum High Pass Corner frequency*/
+
+#define LVM_CS_MIN_EFFECT_LEVEL 0 /*CS Minimum Effect Level*/
+#define LVM_CS_MAX_REVERB_LEVEL 100 /*CS Maximum Reverb Level*/
+#define LVM_VIRTUALIZER_MAX_REVERB_LEVEL 100 /*Vitrualizer Maximum Reverb Level*/
+
+#define LVM_VC_MIXER_TIME 100 /*VC mixer time*/
+#define LVM_VC_BALANCE_MAX 96 /*VC balance max value*/
+#define LVM_VC_BALANCE_MIN -96 /*VC balance min value*/
+
+/* Algorithm masks */
+#define LVM_CS_MASK 1
+#define LVM_EQNB_MASK 2
+#define LVM_DBE_MASK 4
+#define LVM_VC_MASK 16
+#define LVM_TE_MASK 32
+#define LVM_PSA_MASK 2048
+
+
+/************************************************************************************/
+/* */
+/* Structures */
+/* */
+/************************************************************************************/
+
+/* Memory region definition */
+typedef struct
+{
+ LVM_UINT32 Size; /* Region size in bytes */
+ LVM_UINT16 Alignment; /* Byte alignment */
+ LVM_MemoryTypes_en Type; /* Region type */
+ void *pBaseAddress; /* Pointer to the region base address */
+} LVM_IntMemoryRegion_t;
+
+
+/* Memory table containing the region definitions */
+typedef struct
+{
+ LVM_IntMemoryRegion_t Region[LVM_NR_MEMORY_REGIONS]; /* One definition for each region */
+} LVM_IntMemTab_t;
+
+
+/* Buffer Management */
+typedef struct
+{
+ LVM_INT16 *pScratch; /* Bundle scratch buffer */
+
+ LVM_INT16 BufferState; /* Buffer status */
+ LVM_INT16 InDelayBuffer[6*MIN_INTERNAL_BLOCKSIZE]; /* Input buffer delay line, left and right */
+ LVM_INT16 InDelaySamples; /* Number of samples in the input delay buffer */
+
+ LVM_INT16 OutDelayBuffer[2*MIN_INTERNAL_BLOCKSIZE]; /* Output buffer delay line */
+ LVM_INT16 OutDelaySamples; /* Number of samples in the output delay buffer, left and right */
+ LVM_INT16 SamplesToOutput; /* Samples to write to the output */
+} LVM_Buffer_t;
+
+
+/* Filter taps */
+typedef struct
+{
+ Biquad_2I_Order1_Taps_t TrebleBoost_Taps; /* Treble boost Taps */
+} LVM_TE_Data_t;
+
+
+/* Coefficients */
+typedef struct
+{
+ Biquad_Instance_t TrebleBoost_State; /* State for the treble boost filter */
+} LVM_TE_Coefs_t;
+
+
+typedef struct
+{
+ /* Public parameters */
+ LVM_MemTab_t MemoryTable; /* Instance memory allocation table */
+ LVM_ControlParams_t Params; /* Control parameters */
+ LVM_InstParams_t InstParams; /* Instance parameters */
+
+ /* Private parameters */
+ LVM_UINT16 ControlPending; /* Control flag to indicate update pending */
+ LVM_ControlParams_t NewParams; /* New control parameters pending update */
+
+ /* Buffer control */
+ LVM_INT16 InternalBlockSize; /* Maximum internal block size */
+ LVM_Buffer_t *pBufferManagement; /* Buffer management variables */
+ LVM_INT16 SamplesToProcess; /* Input samples left to process */
+ LVM_INT16 *pInputSamples; /* External input sample pointer */
+ LVM_INT16 *pOutputSamples; /* External output sample pointer */
+
+ /* Configuration number */
+ LVM_INT32 ConfigurationNumber;
+ LVM_INT32 BlickSizeMultiple;
+
+ /* DC removal */
+ Biquad_Instance_t DC_RemovalInstance; /* DC removal filter instance */
+
+ /* Concert Sound */
+ LVCS_Handle_t hCSInstance; /* Concert Sound instance handle */
+ LVCS_Instance_t CS_Instance; /* Concert Sound instance */
+ LVM_INT16 CS_Active; /* Control flag */
+
+ /* Equalizer */
+ LVEQNB_Handle_t hEQNBInstance; /* N-Band Equaliser instance handle */
+ LVEQNB_Instance_t EQNB_Instance; /* N-Band Equaliser instance */
+ LVM_EQNB_BandDef_t *pEQNB_BandDefs; /* Local storage for new definitions */
+ LVM_EQNB_BandDef_t *pEQNB_UserDefs; /* Local storage for the user's definitions */
+ LVM_INT16 EQNB_Active; /* Control flag */
+
+ /* Dynamic Bass Enhancement */
+ LVDBE_Handle_t hDBEInstance; /* Dynamic Bass Enhancement instance handle */
+ LVDBE_Instance_t DBE_Instance; /* Dynamic Bass Enhancement instance */
+ LVM_INT16 DBE_Active; /* Control flag */
+
+ /* Volume Control */
+ LVMixer3_1St_st VC_Volume; /* Volume scaler */
+ LVMixer3_2St_st VC_BalanceMix; /* VC balance mixer */
+ LVM_INT16 VC_VolumedB; /* Gain in dB */
+ LVM_INT16 VC_Active; /* Control flag */
+ LVM_INT16 VC_AVLFixedVolume; /* AVL fixed volume */
+
+ /* Treble Enhancement */
+ LVM_TE_Data_t *pTE_Taps; /* Treble boost Taps */
+ LVM_TE_Coefs_t *pTE_State; /* State for the treble boost filter */
+ LVM_INT16 TE_Active; /* Control flag */
+
+ /* Headroom */
+ LVM_HeadroomParams_t NewHeadroomParams; /* New headroom parameters pending update */
+ LVM_HeadroomParams_t HeadroomParams; /* Headroom parameters */
+ LVM_HeadroomBandDef_t *pHeadroom_BandDefs; /* Local storage for new definitions */
+ LVM_HeadroomBandDef_t *pHeadroom_UserDefs; /* Local storage for the user's definitions */
+ LVM_UINT16 Headroom; /* Value of the current headroom */
+
+ /* Spectrum Analyzer */
+ pLVPSA_Handle_t hPSAInstance; /* Spectrum Analyzer instance handle */
+ LVPSA_InstancePr_t PSA_Instance; /* Spectrum Analyzer instance */
+ LVPSA_InitParams_t PSA_InitParams; /* Spectrum Analyzer initialization parameters */
+ LVPSA_ControlParams_t PSA_ControlParams; /* Spectrum Analyzer control parameters */
+ LVM_INT16 PSA_GainOffset; /* Tone control flag */
+ LVM_Callback CallBack;
+ LVM_INT16 *pPSAInput; /* PSA input pointer */
+
+ LVM_INT16 NoSmoothVolume; /* Enable or disable smooth volume changes*/
+
+} LVM_Instance_t;
+
+
+/************************************************************************************/
+/* */
+/* Function Prototypes */
+/* */
+/************************************************************************************/
+
+LVM_ReturnStatus_en LVM_ApplyNewSettings(LVM_Handle_t hInstance);
+
+void LVM_SetTrebleBoost( LVM_Instance_t *pInstance,
+ LVM_ControlParams_t *pParams);
+
+void LVM_SetVolume( LVM_Instance_t *pInstance,
+ LVM_ControlParams_t *pParams);
+
+LVM_INT32 LVM_VCCallBack(void* pBundleHandle,
+ void* pGeneralPurpose,
+ short CallBackParam);
+
+void LVM_SetHeadroom( LVM_Instance_t *pInstance,
+ LVM_ControlParams_t *pParams);
+
+void LVM_BufferIn( LVM_Handle_t hInstance,
+ const LVM_INT16 *pInData,
+ LVM_INT16 **pToProcess,
+ LVM_INT16 **pProcessed,
+ LVM_UINT16 *pNumSamples);
+
+void LVM_BufferOut( LVM_Handle_t hInstance,
+ LVM_INT16 *pOutData,
+ LVM_UINT16 *pNumSamples);
+
+LVM_INT32 LVM_AlgoCallBack( void *pBundleHandle,
+ void *pData,
+ LVM_INT16 callbackId);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __LVM_PRIVATE_H__ */
+
diff --git a/media/libeffects/lvm/lib/Bundle/src/LVM_Process.c b/media/libeffects/lvm/lib/Bundle/src/LVM_Process.c
new file mode 100755
index 0000000..bad9450
--- /dev/null
+++ b/media/libeffects/lvm/lib/Bundle/src/LVM_Process.c
@@ -0,0 +1,283 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/****************************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1002 $
+ $Date: 2010-06-28 13:40:09 +0200 (Mon, 28 Jun 2010) $
+
+*****************************************************************************************/
+
+
+/****************************************************************************************/
+/* */
+/* Includes */
+/* */
+/****************************************************************************************/
+
+#include "LVM_Private.h"
+#include "VectorArithmetic.h"
+#include "LVM_Coeffs.h"
+
+/****************************************************************************************/
+/* */
+/* FUNCTION: LVM_Process */
+/* */
+/* DESCRIPTION: */
+/* Process function for the LifeVibes module. */
+/* */
+/* PARAMETERS: */
+/* hInstance Instance handle */
+/* pInData Pointer to the input data */
+/* pOutData Pointer to the output data */
+/* NumSamples Number of samples in the input buffer */
+/* AudioTime Audio Time of the current input buffer in ms */
+/* */
+/* RETURNS: */
+/* LVM_SUCCESS Succeeded */
+/* LVM_INVALIDNUMSAMPLES When the NumSamples is not a valied multiple in unmanaged */
+/* buffer mode */
+/* LVM_ALIGNMENTERROR When either the input our output buffers are not 32-bit */
+/* aligned in unmanaged mode */
+/* LVM_NULLADDRESS When one of hInstance, pInData or pOutData is NULL */
+/* */
+/* NOTES: */
+/* */
+/****************************************************************************************/
+
+LVM_ReturnStatus_en LVM_Process(LVM_Handle_t hInstance,
+ const LVM_INT16 *pInData,
+ LVM_INT16 *pOutData,
+ LVM_UINT16 NumSamples,
+ LVM_UINT32 AudioTime)
+{
+
+ LVM_Instance_t *pInstance = (LVM_Instance_t *)hInstance;
+ LVM_UINT16 SampleCount = NumSamples;
+ LVM_INT16 *pInput = (LVM_INT16 *)pInData;
+ LVM_INT16 *pToProcess = (LVM_INT16 *)pInData;
+ LVM_INT16 *pProcessed = pOutData;
+ LVM_ReturnStatus_en Status;
+
+ /*
+ * Check if the number of samples is zero
+ */
+ if (NumSamples == 0)
+ {
+ return(LVM_SUCCESS);
+ }
+
+
+ /*
+ * Check valid points have been given
+ */
+ if ((hInstance == LVM_NULL) || (pInData == LVM_NULL) || (pOutData == LVM_NULL))
+ {
+ return (LVM_NULLADDRESS);
+ }
+
+ /*
+ * For unmanaged mode only
+ */
+ if(pInstance->InstParams.BufferMode == LVM_UNMANAGED_BUFFERS)
+ {
+ /*
+ * Check if the number of samples is a good multiple (unmanaged mode only)
+ */
+ if((NumSamples % pInstance->BlickSizeMultiple) != 0)
+ {
+ return(LVM_INVALIDNUMSAMPLES);
+ }
+
+ /*
+ * Check the buffer alignment
+ */
+ if((((LVM_UINT32)pInData % 4) != 0) || (((LVM_UINT32)pOutData % 4) != 0))
+ {
+ return(LVM_ALIGNMENTERROR);
+ }
+ }
+
+
+ /*
+ * Update new parameters if necessary
+ */
+ if (pInstance->ControlPending == LVM_TRUE)
+ {
+ Status = LVM_ApplyNewSettings(hInstance);
+
+ if(Status != LVM_SUCCESS)
+ {
+ return Status;
+ }
+ }
+
+
+ /*
+ * Convert from Mono if necessary
+ */
+ if (pInstance->Params.SourceFormat == LVM_MONO)
+ {
+ MonoTo2I_16(pInData, /* Source */
+ pOutData, /* Destination */
+ (LVM_INT16)NumSamples); /* Number of input samples */
+ pInput = pOutData;
+ pToProcess = pOutData;
+ }
+
+
+ /*
+ * Process the data with managed buffers
+ */
+ while (SampleCount != 0)
+ {
+ /*
+ * Manage the input buffer and frame processing
+ */
+ LVM_BufferIn(hInstance,
+ pInput,
+ &pToProcess,
+ &pProcessed,
+ &SampleCount);
+
+ /*
+ * Only process data when SampleCount is none zero, a zero count can occur when
+ * the BufferIn routine is working in managed mode.
+ */
+ if (SampleCount != 0)
+ {
+
+ /*
+ * Apply ConcertSound if required
+ */
+ if (pInstance->CS_Active == LVM_TRUE)
+ {
+ (void)LVCS_Process(pInstance->hCSInstance, /* Concert Sound instance handle */
+ pToProcess,
+ pProcessed,
+ SampleCount);
+ pToProcess = pProcessed;
+ }
+
+ /*
+ * Apply volume if required
+ */
+ if (pInstance->VC_Active!=0)
+ {
+ LVC_MixSoft_1St_D16C31_SAT(&pInstance->VC_Volume,
+ pToProcess,
+ pProcessed,
+ (LVM_INT16)(2*SampleCount)); /* Left and right*/
+ pToProcess = pProcessed;
+ }
+
+ /*
+ * Call N-Band equaliser if enabled
+ */
+ if (pInstance->EQNB_Active == LVM_TRUE)
+ {
+ LVEQNB_Process(pInstance->hEQNBInstance, /* N-Band equaliser instance handle */
+ pToProcess,
+ pProcessed,
+ SampleCount);
+ pToProcess = pProcessed;
+ }
+
+ /*
+ * Call bass enhancement if enabled
+ */
+ if (pInstance->DBE_Active == LVM_TRUE)
+ {
+ LVDBE_Process(pInstance->hDBEInstance, /* Dynamic Bass Enhancement instance handle */
+ pToProcess,
+ pProcessed,
+ SampleCount);
+ pToProcess = pProcessed;
+ }
+
+ /*
+ * Bypass mode or everything off, so copy the input to the output
+ */
+ if (pToProcess != pProcessed)
+ {
+ Copy_16(pToProcess, /* Source */
+ pProcessed, /* Destination */
+ (LVM_INT16)(2*SampleCount)); /* Left and right */
+ }
+
+ /*
+ * Apply treble boost if required
+ */
+ if (pInstance->TE_Active == LVM_TRUE)
+ {
+ /*
+ * Apply the filter
+ */
+ FO_2I_D16F32C15_LShx_TRC_WRA_01(&pInstance->pTE_State->TrebleBoost_State,
+ pProcessed,
+ pProcessed,
+ (LVM_INT16)SampleCount);
+
+ }
+
+ /*
+ * Volume balance
+ */
+ LVC_MixSoft_1St_2i_D16C31_SAT(&pInstance->VC_BalanceMix,
+ pProcessed,
+ pProcessed,
+ SampleCount);
+
+ /*
+ * Perform Parametric Spectum Analysis
+ */
+ if ((pInstance->Params.PSA_Enable == LVM_PSA_ON)&&(pInstance->InstParams.PSA_Included==LVM_PSA_ON))
+ {
+ From2iToMono_16(pProcessed,
+ pInstance->pPSAInput,
+ (LVM_INT16) (SampleCount));
+
+ LVPSA_Process(pInstance->hPSAInstance,
+ pInstance->pPSAInput,
+ (LVM_UINT16) (SampleCount),
+ AudioTime);
+ }
+
+
+ /*
+ * DC removal
+ */
+ DC_2I_D16_TRC_WRA_01(&pInstance->DC_RemovalInstance,
+ pProcessed,
+ pProcessed,
+ (LVM_INT16)SampleCount);
+
+
+ }
+
+ /*
+ * Manage the output buffer
+ */
+ LVM_BufferOut(hInstance,
+ pOutData,
+ &SampleCount);
+
+ }
+
+ return(LVM_SUCCESS);
+}
diff --git a/media/libeffects/lvm/lib/Bundle/src/LVM_Tables.c b/media/libeffects/lvm/lib/Bundle/src/LVM_Tables.c
new file mode 100755
index 0000000..cb33541
--- /dev/null
+++ b/media/libeffects/lvm/lib/Bundle/src/LVM_Tables.c
@@ -0,0 +1,397 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/************************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1002 $
+ $Date: 2010-06-28 13:40:09 +0200 (Mon, 28 Jun 2010) $
+
+*************************************************************************************/
+
+/************************************************************************************/
+/* */
+/* Includes */
+/* */
+/************************************************************************************/
+
+#include "LVM_Tables.h"
+#include "LVM_Coeffs.h"
+
+/************************************************************************************/
+/* */
+/* Treble Boost Filter Coefficients */
+/* */
+/************************************************************************************/
+
+FO_C16_LShx_Coefs_t LVM_TrebleBoostCoefs[] = {
+
+ /* 22kHz sampling rate */
+ {HPF_Fs22050_Gain1_A1, /* Gain setting 1 */
+ HPF_Fs22050_Gain1_A0,
+ -HPF_Fs22050_Gain1_B1,
+ HPF_Fs22050_Gain1_Shift},
+ {HPF_Fs22050_Gain2_A1, /* Gain setting 2 */
+ HPF_Fs22050_Gain2_A0,
+ -HPF_Fs22050_Gain2_B1,
+ HPF_Fs22050_Gain2_Shift},
+ {HPF_Fs22050_Gain3_A1, /* Gain setting 3 */
+ HPF_Fs22050_Gain3_A0,
+ -HPF_Fs22050_Gain3_B1,
+ HPF_Fs22050_Gain3_Shift},
+ {HPF_Fs22050_Gain4_A1, /* Gain setting 4 */
+ HPF_Fs22050_Gain4_A0,
+ -HPF_Fs22050_Gain4_B1,
+ HPF_Fs22050_Gain4_Shift},
+ {HPF_Fs22050_Gain5_A1, /* Gain setting 5 */
+ HPF_Fs22050_Gain5_A0,
+ -HPF_Fs22050_Gain5_B1,
+ HPF_Fs22050_Gain5_Shift},
+ {HPF_Fs22050_Gain6_A1, /* Gain setting 6 */
+ HPF_Fs22050_Gain6_A0,
+ -HPF_Fs22050_Gain6_B1,
+ HPF_Fs22050_Gain6_Shift},
+ {HPF_Fs22050_Gain7_A1, /* Gain setting 7 */
+ HPF_Fs22050_Gain7_A0,
+ -HPF_Fs22050_Gain7_B1,
+ HPF_Fs22050_Gain7_Shift},
+ {HPF_Fs22050_Gain8_A1, /* Gain setting 8 */
+ HPF_Fs22050_Gain8_A0,
+ -HPF_Fs22050_Gain8_B1,
+ HPF_Fs22050_Gain8_Shift},
+ {HPF_Fs22050_Gain9_A1, /* Gain setting 9 */
+ HPF_Fs22050_Gain9_A0,
+ -HPF_Fs22050_Gain9_B1,
+ HPF_Fs22050_Gain9_Shift},
+ {HPF_Fs22050_Gain10_A1, /* Gain setting 10 */
+ HPF_Fs22050_Gain10_A0,
+ -HPF_Fs22050_Gain10_B1,
+ HPF_Fs22050_Gain10_Shift},
+ {HPF_Fs22050_Gain11_A1, /* Gain setting 11 */
+ HPF_Fs22050_Gain11_A0,
+ -HPF_Fs22050_Gain11_B1,
+ HPF_Fs22050_Gain11_Shift},
+ {HPF_Fs22050_Gain12_A1, /* Gain setting 12 */
+ HPF_Fs22050_Gain12_A0,
+ -HPF_Fs22050_Gain12_B1,
+ HPF_Fs22050_Gain12_Shift},
+ {HPF_Fs22050_Gain13_A1, /* Gain setting 13 */
+ HPF_Fs22050_Gain13_A0,
+ -HPF_Fs22050_Gain13_B1,
+ HPF_Fs22050_Gain13_Shift},
+ {HPF_Fs22050_Gain14_A1, /* Gain setting 14 */
+ HPF_Fs22050_Gain14_A0,
+ -HPF_Fs22050_Gain14_B1,
+ HPF_Fs22050_Gain14_Shift},
+ {HPF_Fs22050_Gain15_A1, /* Gain setting 15 */
+ HPF_Fs22050_Gain15_A0,
+ -HPF_Fs22050_Gain15_B1,
+ HPF_Fs22050_Gain15_Shift},
+
+ /* 24kHz sampling rate */
+ {HPF_Fs24000_Gain1_A1, /* Gain setting 1 */
+ HPF_Fs24000_Gain1_A0,
+ -HPF_Fs24000_Gain1_B1,
+ HPF_Fs24000_Gain1_Shift},
+ {HPF_Fs24000_Gain2_A1, /* Gain setting 2 */
+ HPF_Fs24000_Gain2_A0,
+ -HPF_Fs24000_Gain2_B1,
+ HPF_Fs24000_Gain2_Shift},
+ {HPF_Fs24000_Gain3_A1, /* Gain setting 3 */
+ HPF_Fs24000_Gain3_A0,
+ -HPF_Fs24000_Gain3_B1,
+ HPF_Fs24000_Gain3_Shift},
+ {HPF_Fs24000_Gain4_A1, /* Gain setting 4 */
+ HPF_Fs24000_Gain4_A0,
+ -HPF_Fs24000_Gain4_B1,
+ HPF_Fs24000_Gain4_Shift},
+ {HPF_Fs24000_Gain5_A1, /* Gain setting 5 */
+ HPF_Fs24000_Gain5_A0,
+ -HPF_Fs24000_Gain5_B1,
+ HPF_Fs24000_Gain5_Shift},
+ {HPF_Fs24000_Gain6_A1, /* Gain setting 6 */
+ HPF_Fs24000_Gain6_A0,
+ -HPF_Fs24000_Gain6_B1,
+ HPF_Fs24000_Gain6_Shift},
+ {HPF_Fs24000_Gain7_A1, /* Gain setting 7 */
+ HPF_Fs24000_Gain7_A0,
+ -HPF_Fs24000_Gain7_B1,
+ HPF_Fs24000_Gain7_Shift},
+ {HPF_Fs24000_Gain8_A1, /* Gain setting 8 */
+ HPF_Fs24000_Gain8_A0,
+ -HPF_Fs24000_Gain8_B1,
+ HPF_Fs24000_Gain8_Shift},
+ {HPF_Fs24000_Gain9_A1, /* Gain setting 9 */
+ HPF_Fs24000_Gain9_A0,
+ -HPF_Fs24000_Gain9_B1,
+ HPF_Fs24000_Gain9_Shift},
+ {HPF_Fs24000_Gain10_A1, /* Gain setting 10 */
+ HPF_Fs24000_Gain10_A0,
+ -HPF_Fs24000_Gain10_B1,
+ HPF_Fs24000_Gain10_Shift},
+ {HPF_Fs24000_Gain11_A1, /* Gain setting 11 */
+ HPF_Fs24000_Gain11_A0,
+ -HPF_Fs24000_Gain11_B1,
+ HPF_Fs24000_Gain11_Shift},
+ {HPF_Fs24000_Gain12_A1, /* Gain setting 12 */
+ HPF_Fs24000_Gain12_A0,
+ -HPF_Fs24000_Gain12_B1,
+ HPF_Fs24000_Gain12_Shift},
+ {HPF_Fs24000_Gain13_A1, /* Gain setting 13 */
+ HPF_Fs24000_Gain13_A0,
+ -HPF_Fs24000_Gain13_B1,
+ HPF_Fs24000_Gain13_Shift},
+ {HPF_Fs24000_Gain14_A1, /* Gain setting 14 */
+ HPF_Fs24000_Gain14_A0,
+ -HPF_Fs24000_Gain14_B1,
+ HPF_Fs24000_Gain14_Shift},
+ {HPF_Fs24000_Gain15_A1, /* Gain setting 15 */
+ HPF_Fs24000_Gain15_A0,
+ -HPF_Fs24000_Gain15_B1,
+ HPF_Fs24000_Gain15_Shift},
+
+ /* 32kHz sampling rate */
+ {HPF_Fs32000_Gain1_A1, /* Gain setting 1 */
+ HPF_Fs32000_Gain1_A0,
+ -HPF_Fs32000_Gain1_B1,
+ HPF_Fs32000_Gain1_Shift},
+ {HPF_Fs32000_Gain2_A1, /* Gain setting 2 */
+ HPF_Fs32000_Gain2_A0,
+ -HPF_Fs32000_Gain2_B1,
+ HPF_Fs32000_Gain2_Shift},
+ {HPF_Fs32000_Gain3_A1, /* Gain setting 3 */
+ HPF_Fs32000_Gain3_A0,
+ -HPF_Fs32000_Gain3_B1,
+ HPF_Fs32000_Gain3_Shift},
+ {HPF_Fs32000_Gain4_A1, /* Gain setting 4 */
+ HPF_Fs32000_Gain4_A0,
+ -HPF_Fs32000_Gain4_B1,
+ HPF_Fs32000_Gain4_Shift},
+ {HPF_Fs32000_Gain5_A1, /* Gain setting 5 */
+ HPF_Fs32000_Gain5_A0,
+ -HPF_Fs32000_Gain5_B1,
+ HPF_Fs32000_Gain5_Shift},
+ {HPF_Fs32000_Gain6_A1, /* Gain setting 6 */
+ HPF_Fs32000_Gain6_A0,
+ -HPF_Fs32000_Gain6_B1,
+ HPF_Fs32000_Gain6_Shift},
+ {HPF_Fs32000_Gain7_A1, /* Gain setting 7 */
+ HPF_Fs32000_Gain7_A0,
+ -HPF_Fs32000_Gain7_B1,
+ HPF_Fs32000_Gain7_Shift},
+ {HPF_Fs32000_Gain8_A1, /* Gain setting 8 */
+ HPF_Fs32000_Gain8_A0,
+ -HPF_Fs32000_Gain8_B1,
+ HPF_Fs32000_Gain8_Shift},
+ {HPF_Fs32000_Gain9_A1, /* Gain setting 9 */
+ HPF_Fs32000_Gain9_A0,
+ -HPF_Fs32000_Gain9_B1,
+ HPF_Fs32000_Gain9_Shift},
+ {HPF_Fs32000_Gain10_A1, /* Gain setting 10 */
+ HPF_Fs32000_Gain10_A0,
+ -HPF_Fs32000_Gain10_B1,
+ HPF_Fs32000_Gain10_Shift},
+ {HPF_Fs32000_Gain11_A1, /* Gain setting 11 */
+ HPF_Fs32000_Gain11_A0,
+ -HPF_Fs32000_Gain11_B1,
+ HPF_Fs32000_Gain11_Shift},
+ {HPF_Fs32000_Gain12_A1, /* Gain setting 12 */
+ HPF_Fs32000_Gain12_A0,
+ -HPF_Fs32000_Gain12_B1,
+ HPF_Fs32000_Gain12_Shift},
+ {HPF_Fs32000_Gain13_A1, /* Gain setting 13 */
+ HPF_Fs32000_Gain13_A0,
+ -HPF_Fs32000_Gain13_B1,
+ HPF_Fs32000_Gain13_Shift},
+ {HPF_Fs32000_Gain14_A1, /* Gain setting 14 */
+ HPF_Fs32000_Gain14_A0,
+ -HPF_Fs32000_Gain14_B1,
+ HPF_Fs32000_Gain14_Shift},
+ {HPF_Fs32000_Gain15_A1, /* Gain setting 15 */
+ HPF_Fs32000_Gain15_A0,
+ -HPF_Fs32000_Gain15_B1,
+ HPF_Fs32000_Gain15_Shift},
+
+ /* 44kHz sampling rate */
+ {HPF_Fs44100_Gain1_A1, /* Gain setting 1 */
+ HPF_Fs44100_Gain1_A0,
+ -HPF_Fs44100_Gain1_B1,
+ HPF_Fs44100_Gain1_Shift},
+ {HPF_Fs44100_Gain2_A1, /* Gain setting 2 */
+ HPF_Fs44100_Gain2_A0,
+ -HPF_Fs44100_Gain2_B1,
+ HPF_Fs44100_Gain2_Shift},
+ {HPF_Fs44100_Gain3_A1, /* Gain setting 3 */
+ HPF_Fs44100_Gain3_A0,
+ -HPF_Fs44100_Gain3_B1,
+ HPF_Fs44100_Gain3_Shift},
+ {HPF_Fs44100_Gain4_A1, /* Gain setting 4 */
+ HPF_Fs44100_Gain4_A0,
+ -HPF_Fs44100_Gain4_B1,
+ HPF_Fs44100_Gain4_Shift},
+ {HPF_Fs44100_Gain5_A1, /* Gain setting 5 */
+ HPF_Fs44100_Gain5_A0,
+ -HPF_Fs44100_Gain5_B1,
+ HPF_Fs44100_Gain5_Shift},
+ {HPF_Fs44100_Gain6_A1, /* Gain setting 6 */
+ HPF_Fs44100_Gain6_A0,
+ -HPF_Fs44100_Gain6_B1,
+ HPF_Fs44100_Gain6_Shift},
+ {HPF_Fs44100_Gain7_A1, /* Gain setting 7 */
+ HPF_Fs44100_Gain7_A0,
+ -HPF_Fs44100_Gain7_B1,
+ HPF_Fs44100_Gain7_Shift},
+ {HPF_Fs44100_Gain8_A1, /* Gain setting 8 */
+ HPF_Fs44100_Gain8_A0,
+ -HPF_Fs44100_Gain8_B1,
+ HPF_Fs44100_Gain8_Shift},
+ {HPF_Fs44100_Gain9_A1, /* Gain setting 9 */
+ HPF_Fs44100_Gain9_A0,
+ -HPF_Fs44100_Gain9_B1,
+ HPF_Fs44100_Gain9_Shift},
+ {HPF_Fs44100_Gain10_A1, /* Gain setting 10 */
+ HPF_Fs44100_Gain10_A0,
+ -HPF_Fs44100_Gain10_B1,
+ HPF_Fs44100_Gain10_Shift},
+ {HPF_Fs44100_Gain11_A1, /* Gain setting 11 */
+ HPF_Fs44100_Gain11_A0,
+ -HPF_Fs44100_Gain11_B1,
+ HPF_Fs44100_Gain11_Shift},
+ {HPF_Fs44100_Gain12_A1, /* Gain setting 12 */
+ HPF_Fs44100_Gain12_A0,
+ -HPF_Fs44100_Gain12_B1,
+ HPF_Fs44100_Gain12_Shift},
+ {HPF_Fs44100_Gain13_A1, /* Gain setting 13 */
+ HPF_Fs44100_Gain13_A0,
+ -HPF_Fs44100_Gain13_B1,
+ HPF_Fs44100_Gain13_Shift},
+ {HPF_Fs44100_Gain14_A1, /* Gain setting 14 */
+ HPF_Fs44100_Gain14_A0,
+ -HPF_Fs44100_Gain14_B1,
+ HPF_Fs44100_Gain14_Shift},
+ {HPF_Fs44100_Gain15_A1, /* Gain setting 15 */
+ HPF_Fs44100_Gain15_A0,
+ -HPF_Fs44100_Gain15_B1,
+ HPF_Fs44100_Gain15_Shift},
+
+ /* 48kHz sampling rate */
+ {HPF_Fs48000_Gain1_A1, /* Gain setting 1 */
+ HPF_Fs48000_Gain1_A0,
+ -HPF_Fs48000_Gain1_B1,
+ HPF_Fs48000_Gain1_Shift},
+ {HPF_Fs48000_Gain2_A1, /* Gain setting 2 */
+ HPF_Fs48000_Gain2_A0,
+ -HPF_Fs48000_Gain2_B1,
+ HPF_Fs48000_Gain2_Shift},
+ {HPF_Fs48000_Gain3_A1, /* Gain setting 3 */
+ HPF_Fs48000_Gain3_A0,
+ -HPF_Fs48000_Gain3_B1,
+ HPF_Fs48000_Gain3_Shift},
+ {HPF_Fs48000_Gain4_A1, /* Gain setting 4 */
+ HPF_Fs48000_Gain4_A0,
+ -HPF_Fs48000_Gain4_B1,
+ HPF_Fs48000_Gain4_Shift},
+ {HPF_Fs48000_Gain5_A1, /* Gain setting 5 */
+ HPF_Fs48000_Gain5_A0,
+ -HPF_Fs48000_Gain5_B1,
+ HPF_Fs48000_Gain5_Shift},
+ {HPF_Fs48000_Gain6_A1, /* Gain setting 6 */
+ HPF_Fs48000_Gain6_A0,
+ -HPF_Fs48000_Gain6_B1,
+ HPF_Fs48000_Gain6_Shift},
+ {HPF_Fs48000_Gain7_A1, /* Gain setting 7 */
+ HPF_Fs48000_Gain7_A0,
+ -HPF_Fs48000_Gain7_B1,
+ HPF_Fs48000_Gain7_Shift},
+ {HPF_Fs48000_Gain8_A1, /* Gain setting 8 */
+ HPF_Fs48000_Gain8_A0,
+ -HPF_Fs48000_Gain8_B1,
+ HPF_Fs48000_Gain8_Shift},
+ {HPF_Fs48000_Gain9_A1, /* Gain setting 9 */
+ HPF_Fs48000_Gain9_A0,
+ -HPF_Fs48000_Gain9_B1,
+ HPF_Fs48000_Gain9_Shift},
+ {HPF_Fs48000_Gain10_A1, /* Gain setting 10 */
+ HPF_Fs48000_Gain10_A0,
+ -HPF_Fs48000_Gain10_B1,
+ HPF_Fs48000_Gain10_Shift},
+ {HPF_Fs48000_Gain11_A1, /* Gain setting 11 */
+ HPF_Fs48000_Gain11_A0,
+ -HPF_Fs48000_Gain11_B1,
+ HPF_Fs48000_Gain11_Shift},
+ {HPF_Fs48000_Gain12_A1, /* Gain setting 12 */
+ HPF_Fs48000_Gain12_A0,
+ -HPF_Fs48000_Gain12_B1,
+ HPF_Fs48000_Gain12_Shift},
+ {HPF_Fs48000_Gain13_A1, /* Gain setting 13 */
+ HPF_Fs48000_Gain13_A0,
+ -HPF_Fs48000_Gain13_B1,
+ HPF_Fs48000_Gain13_Shift},
+ {HPF_Fs48000_Gain14_A1, /* Gain setting 14 */
+ HPF_Fs48000_Gain14_A0,
+ -HPF_Fs48000_Gain14_B1,
+ HPF_Fs48000_Gain14_Shift},
+ {HPF_Fs48000_Gain15_A1, /* Gain setting 15 */
+ HPF_Fs48000_Gain15_A0,
+ -HPF_Fs48000_Gain15_B1,
+ HPF_Fs48000_Gain15_Shift}};
+
+
+/************************************************************************************/
+/* */
+/* Volume control gain and time constant tables */
+/* */
+/************************************************************************************/
+
+/* dB to linear conversion table */
+const LVM_INT16 LVM_VolumeTable[] = {
+ 0x7FFF, /* 0dB */
+ 0x7215, /* -1dB */
+ 0x65AD, /* -2dB */
+ 0x5A9E, /* -3dB */
+ 0x50C3, /* -4dB */
+ 0x47FB, /* -5dB */
+ 0x4000}; /* -6dB */
+
+/************************************************************************************/
+/* */
+/* Volume mixer time constants (100ms) */
+/* */
+/************************************************************************************/
+
+#define LVM_MIX_TC_Fs8000 32580 /* Floating point value 0.994262695 */
+#define LVM_MIX_TC_Fs11025 32632 /* Floating point value 0.995849609 */
+#define LVM_MIX_TC_Fs12000 32643 /* Floating point value 0.996185303 */
+#define LVM_MIX_TC_Fs16000 32674 /* Floating point value 0.997131348 */
+#define LVM_MIX_TC_Fs22050 32700 /* Floating point value 0.997924805 */
+#define LVM_MIX_TC_Fs24000 32705 /* Floating point value 0.998077393 */
+#define LVM_MIX_TC_Fs32000 32721 /* Floating point value 0.998565674 */
+#define LVM_MIX_TC_Fs44100 32734 /* Floating point value 0.998962402 */
+#define LVM_MIX_TC_Fs48000 32737 /* Floating point value 0.999053955 */
+
+
+const LVM_INT16 LVM_MixerTCTable[] = {
+ LVM_MIX_TC_Fs8000,
+ LVM_MIX_TC_Fs11025,
+ LVM_MIX_TC_Fs12000,
+ LVM_MIX_TC_Fs16000,
+ LVM_MIX_TC_Fs22050,
+ LVM_MIX_TC_Fs24000,
+ LVM_MIX_TC_Fs32000,
+ LVM_MIX_TC_Fs44100,
+ LVM_MIX_TC_Fs48000};
+
diff --git a/media/libeffects/lvm/lib/Bundle/src/LVM_Tables.h b/media/libeffects/lvm/lib/Bundle/src/LVM_Tables.h
new file mode 100755
index 0000000..574f641
--- /dev/null
+++ b/media/libeffects/lvm/lib/Bundle/src/LVM_Tables.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/************************************************************************************
+
+ $Author: beq07716 $
+ $Revision: 1002 $
+ $Date: 2010-06-28 13:40:09 +0200 (Mon, 28 Jun 2010) $
+
+*************************************************************************************/
+
+#ifndef __LVM_TABLES_H__
+#define __LVM_TABLES_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/************************************************************************************/
+/* */
+/* Includes */
+/* */
+/************************************************************************************/
+
+#include "BIQUAD.h"
+#include "LVM_Types.h"
+
+/************************************************************************************/
+/* */
+/* Treble Boost Filter Coefficients */
+/* */
+/************************************************************************************/
+
+extern FO_C16_LShx_Coefs_t LVM_TrebleBoostCoefs[];
+
+
+/************************************************************************************/
+/* */
+/* Volume control gain and time constant tables */
+/* */
+/************************************************************************************/
+
+extern const LVM_INT16 LVM_VolumeTable[];
+extern const LVM_INT16 LVM_MixerTCTable[];
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __LVM_TABLES_H__ */
+
+