diff options
author | Eric Laurent <elaurent@google.com> | 2010-07-09 12:28:50 -0700 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2010-07-17 06:33:00 -0700 |
commit | 2c8e5cab3faa6d360e222b7a6c40a80083d021ac (patch) | |
tree | fd19b8baa829edb78116b089d1122ea4ef0921e1 /media/libeffects/lvm/lib/Common | |
parent | ada2ac8e09b6d3f2b3c3155a852ba0fffae1b592 (diff) | |
download | frameworks_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/Common')
121 files changed, 10514 insertions, 0 deletions
diff --git a/media/libeffects/lvm/lib/Common/lib/AGC.h b/media/libeffects/lvm/lib/Common/lib/AGC.h new file mode 100755 index 0000000..980a8e3 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/lib/AGC.h @@ -0,0 +1,92 @@ +/* + * 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: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +#ifndef __AGC_H__ +#define __AGC_H__ + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/**********************************************************************************/ +/* */ +/* Includes */ +/* */ +/**********************************************************************************/ + +#include "LVM_Types.h" + + +/**********************************************************************************/ +/* */ +/* Types */ +/* */ +/**********************************************************************************/ + +typedef struct +{ + LVM_INT32 AGC_Gain; /* The current AGC gain */ + LVM_INT32 AGC_MaxGain; /* The maximum AGC gain */ + LVM_INT32 Volume; /* The current volume setting */ + LVM_INT32 Target; /* The target volume setting */ + LVM_INT32 AGC_Target; /* AGC target level */ + LVM_INT16 AGC_Attack; /* AGC attack scaler */ + LVM_INT16 AGC_Decay; /* AGC decay scaler */ + LVM_INT16 AGC_GainShift; /* The gain shift */ + LVM_INT16 VolumeShift; /* Volume shift scaling */ + LVM_INT16 VolumeTC; /* Volume update time constant */ + +} AGC_MIX_VOL_2St1Mon_D32_t; + + +/**********************************************************************************/ +/* */ +/* Function Prototypes */ +/* */ +/**********************************************************************************/ + +void AGC_MIX_VOL_2St1Mon_D32_WRA(AGC_MIX_VOL_2St1Mon_D32_t *pInstance, /* Instance pointer */ + const LVM_INT32 *pStSrc, /* Stereo source */ + const LVM_INT32 *pMonoSrc, /* Mono source */ + LVM_INT32 *pDst, /* Stereo destination */ + LVM_UINT16 n); /* Number of samples */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* __AGC_H__ */ + + + + + + + + + + diff --git a/media/libeffects/lvm/lib/Common/lib/BIQUAD.h b/media/libeffects/lvm/lib/Common/lib/BIQUAD.h new file mode 100755 index 0000000..08e5a6f --- /dev/null +++ b/media/libeffects/lvm/lib/Common/lib/BIQUAD.h @@ -0,0 +1,341 @@ +/* + * 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: 722 $ + $Date: 2010-06-10 15:12:34 +0200 (Thu, 10 Jun 2010) $ + +***********************************************************************************/ + +#ifndef _BIQUAD_H_ +#define _BIQUAD_H_ + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "LVM_Types.h" +/********************************************************************************** + INSTANCE MEMORY TYPE DEFINITION +***********************************************************************************/ + +typedef struct +{ + LVM_INT32 Storage[6]; + +} Biquad_Instance_t; + + +/********************************************************************************** + COEFFICIENT TYPE DEFINITIONS +***********************************************************************************/ + +/*** Biquad coefficients **********************************************************/ +typedef struct +{ + LVM_INT16 A2; /* a2 */ + LVM_INT16 A1; /* a1 */ + LVM_INT16 A0; /* a0 */ + LVM_INT16 B2; /* -b2! */ + LVM_INT16 B1; /* -b1! */ +} BQ_C16_Coefs_t; + +typedef struct +{ + LVM_INT32 A2; /* a2 */ + LVM_INT32 A1; /* a1 */ + LVM_INT32 A0; /* a0 */ + LVM_INT32 B2; /* -b2! */ + LVM_INT32 B1; /* -b1! */ +} BQ_C32_Coefs_t; + +/*** First order coefficients *****************************************************/ +typedef struct +{ + LVM_INT16 A1; /* a1 */ + LVM_INT16 A0; /* a0 */ + LVM_INT16 B1; /* -b1! */ +} FO_C16_Coefs_t; + +typedef struct +{ + LVM_INT32 A1; /* a1 */ + LVM_INT32 A0; /* a0 */ + LVM_INT32 B1; /* -b1! */ +} FO_C32_Coefs_t; + +/*** First order coefficients with Shift*****************************************************/ +typedef struct +{ + LVM_INT16 A1; /* a1 */ + LVM_INT16 A0; /* a0 */ + LVM_INT16 B1; /* -b1! */ + LVM_INT16 Shift; /* Shift */ +} FO_C16_LShx_Coefs_t; + +/*** Band pass coefficients *******************************************************/ +typedef struct +{ + LVM_INT16 A0; /* a0 */ + LVM_INT16 B2; /* -b2! */ + LVM_INT16 B1; /* -b1! */ +} BP_C16_Coefs_t; + +typedef struct +{ + LVM_INT32 A0; /* a0 */ + LVM_INT32 B2; /* -b2! */ + LVM_INT32 B1; /* -b1! */ +} BP_C32_Coefs_t; + +/*** Peaking coefficients *********************************************************/ +typedef struct +{ + LVM_INT16 A0; /* a0 */ + LVM_INT16 B2; /* -b2! */ + LVM_INT16 B1; /* -b1! */ + LVM_INT16 G; /* Gain */ +} PK_C16_Coefs_t; + +typedef struct +{ + LVM_INT32 A0; /* a0 */ + LVM_INT32 B2; /* -b2! */ + LVM_INT32 B1; /* -b1! */ + LVM_INT16 G; /* Gain */ +} PK_C32_Coefs_t; + + +/********************************************************************************** + TAPS TYPE DEFINITIONS +***********************************************************************************/ + +/*** Types used for first order and shelving filter *******************************/ + +typedef struct +{ + LVM_INT32 Storage[ (1*2) ]; /* One channel, two taps of size LVM_INT32 */ +} Biquad_1I_Order1_Taps_t; + +typedef struct +{ + LVM_INT32 Storage[ (2*2) ]; /* Two channels, two taps of size LVM_INT32 */ +} Biquad_2I_Order1_Taps_t; + + +/*** Types used for biquad, band pass and peaking filter **************************/ + +typedef struct +{ + LVM_INT32 Storage[ (1*4) ]; /* One channel, four taps of size LVM_INT32 */ +} Biquad_1I_Order2_Taps_t; + +typedef struct +{ + LVM_INT32 Storage[ (2*4) ]; /* Two channels, four taps of size LVM_INT32 */ +} Biquad_2I_Order2_Taps_t; + +/* The names of the functions are changed to satisfy QAC rules: Name should be Unique withing 16 characters*/ +#define BQ_2I_D32F32Cll_TRC_WRA_01_Init Init_BQ_2I_D32F32Cll_TRC_WRA_01 +#define BP_1I_D32F32C30_TRC_WRA_02 TWO_BP_1I_D32F32C30_TRC_WRA_02 + +/********************************************************************************** + FUNCTION PROTOTYPES: BIQUAD FILTERS +***********************************************************************************/ + +/*** 16 bit data path *************************************************************/ + +void BQ_2I_D16F32Css_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance, + Biquad_2I_Order2_Taps_t *pTaps, + BQ_C16_Coefs_t *pCoef); + +void BQ_2I_D16F32C15_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples); + +void BQ_2I_D16F32C14_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples); + +void BQ_2I_D16F32C13_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples); + +void BQ_2I_D16F16Css_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance, + Biquad_2I_Order2_Taps_t *pTaps, + BQ_C16_Coefs_t *pCoef); + +void BQ_2I_D16F16C15_TRC_WRA_01( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples); + +void BQ_2I_D16F16C14_TRC_WRA_01( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples); + +void BQ_1I_D16F16Css_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance, + Biquad_1I_Order2_Taps_t *pTaps, + BQ_C16_Coefs_t *pCoef); + +void BQ_1I_D16F16C15_TRC_WRA_01( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples); + +void BQ_1I_D16F32Css_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance, + Biquad_1I_Order2_Taps_t *pTaps, + BQ_C16_Coefs_t *pCoef); + +void BQ_1I_D16F32C14_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples); + +/*** 32 bit data path *************************************************************/ + +void BQ_2I_D32F32Cll_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance, + Biquad_2I_Order2_Taps_t *pTaps, + BQ_C32_Coefs_t *pCoef); + +void BQ_2I_D32F32C30_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT32 *pDataIn, + LVM_INT32 *pDataOut, + LVM_INT16 NrSamples); + +/********************************************************************************** + FUNCTION PROTOTYPES: FIRST ORDER FILTERS +***********************************************************************************/ + +/*** 16 bit data path *************************************************************/ + +void FO_1I_D16F16Css_TRC_WRA_01_Init( Biquad_Instance_t *pInstance, + Biquad_1I_Order1_Taps_t *pTaps, + FO_C16_Coefs_t *pCoef); + +void FO_1I_D16F16C15_TRC_WRA_01( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples); + +void FO_2I_D16F32Css_LShx_TRC_WRA_01_Init(Biquad_Instance_t *pInstance, + Biquad_2I_Order1_Taps_t *pTaps, + FO_C16_LShx_Coefs_t *pCoef); + +void FO_2I_D16F32C15_LShx_TRC_WRA_01(Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples); + +/*** 32 bit data path *************************************************************/ + +void FO_1I_D32F32Cll_TRC_WRA_01_Init( Biquad_Instance_t *pInstance, + Biquad_1I_Order1_Taps_t *pTaps, + FO_C32_Coefs_t *pCoef); + +void FO_1I_D32F32C31_TRC_WRA_01( Biquad_Instance_t *pInstance, + LVM_INT32 *pDataIn, + LVM_INT32 *pDataOut, + LVM_INT16 NrSamples); + +/********************************************************************************** + FUNCTION PROTOTYPES: BAND PASS FILTERS +***********************************************************************************/ + +/*** 16 bit data path *************************************************************/ + +void BP_1I_D16F16Css_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance, + Biquad_1I_Order2_Taps_t *pTaps, + BP_C16_Coefs_t *pCoef); + +void BP_1I_D16F16C14_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples); + +void BP_1I_D16F32Cll_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance, + Biquad_1I_Order2_Taps_t *pTaps, + BP_C32_Coefs_t *pCoef); + +void BP_1I_D16F32C30_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples); + + +/*** 32 bit data path *************************************************************/ + +void BP_1I_D32F32Cll_TRC_WRA_02_Init ( Biquad_Instance_t *pInstance, + Biquad_1I_Order2_Taps_t *pTaps, + BP_C32_Coefs_t *pCoef); + +void BP_1I_D32F32C30_TRC_WRA_02( Biquad_Instance_t *pInstance, + LVM_INT32 *pDataIn, + LVM_INT32 *pDataOut, + LVM_INT16 NrSamples); + + +/*** 32 bit data path STEREO ******************************************************/ + +void PK_2I_D32F32CllGss_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance, + Biquad_2I_Order2_Taps_t *pTaps, + PK_C32_Coefs_t *pCoef); + +void PK_2I_D32F32C30G11_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT32 *pDataIn, + LVM_INT32 *pDataOut, + LVM_INT16 NrSamples); + +void PK_2I_D32F32CssGss_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance, + Biquad_2I_Order2_Taps_t *pTaps, + PK_C16_Coefs_t *pCoef); + +void PK_2I_D32F32C14G11_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT32 *pDataIn, + LVM_INT32 *pDataOut, + LVM_INT16 NrSamples); + + +/********************************************************************************** + FUNCTION PROTOTYPES: DC REMOVAL FILTERS +***********************************************************************************/ + +/*** 16 bit data path STEREO ******************************************************/ + +void DC_2I_D16_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance); + +void DC_2I_D16_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/**********************************************************************************/ + +#endif /** _BIQUAD_H_ **/ + diff --git a/media/libeffects/lvm/lib/Common/lib/CompLim.h b/media/libeffects/lvm/lib/Common/lib/CompLim.h new file mode 100755 index 0000000..df9b583 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/lib/CompLim.h @@ -0,0 +1,91 @@ +/* + * 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: nxp27078 $ + $Revision: 672 $ + $Date: 2010-06-08 19:39:38 +0200 (Tue, 08 Jun 2010) $ + +***********************************************************************************/ + +#ifndef _COMP_LIM_H +#define _COMP_LIM_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/************************************************************************************/ +/* */ +/* Includes */ +/* */ +/************************************************************************************/ + +#include "LVM_Types.h" + + +/************************************************************************************/ +/* */ +/* Structures */ +/* */ +/************************************************************************************/ + +typedef struct /* Compressor state */ +{ + /* Normaliser */ + LVM_INT16 Norm_Attack; /* Attack time constant of the Normaliser integrator */ + LVM_INT16 Norm_Decay; /* Decay time constant of the Normaliser integrator */ + LVM_INT32 NormInt; /* Normaliser integrator current value */ + LVM_INT16 Shift; /* Shift gain */ + LVM_INT16 Threshold; /* Target threshold */ + + /* Compressor */ + LVM_INT16 Comp_Atten; /* Attenuation applied before soft knee compressor */ + LVM_INT16 Comp_Attack_S; /* Attack time constant of the slow integrator */ + LVM_INT16 Comp_Decay_S; /* Decay time constant of slow the integrator */ + LVM_INT16 Comp_Attack_F; /* Attack time constant of fast the integrator */ + LVM_INT16 Comp_Decay_F; /* Decay time constant of fast the integrator */ + LVM_INT16 SoftClipGain; /* Soft clip gain control */ + LVM_INT32 CompIntSlow; /* Compressor slow integrator current value */ + LVM_INT32 CompIntFast; /* Compressor fast integrator current value */ + + +} CompLim_Instance_t; + + +/************************************************************************************/ +/* */ +/* Function Prototypes */ +/* */ +/************************************************************************************/ + +void NonLinComp_D16(LVM_INT16 Gain, + LVM_INT16 *pSterBfIn, + LVM_INT16 *pSterBfOut, + LVM_INT32 BlockLength); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* #ifndef _COMP_LIM_H */ + + + diff --git a/media/libeffects/lvm/lib/Common/lib/Filter.h b/media/libeffects/lvm/lib/Common/lib/Filter.h new file mode 100755 index 0000000..93ccbcb --- /dev/null +++ b/media/libeffects/lvm/lib/Common/lib/Filter.h @@ -0,0 +1,71 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 771 $*/ +/* $Date: 2010-06-14 10:41:36 +0200 (Mon, 14 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#ifndef _FILTER_H_ +#define _FILTER_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/********************************************************************************** + INCLUDES +***********************************************************************************/ +#include "LVM_Types.h" +#include "BIQUAD.h" + + +/********************************************************************************** + DEFINES +***********************************************************************************/ +#define FILTER_LOSS 32730 /* -0.01dB loss to avoid wrapping due to band ripple */ + +/********************************************************************************** + FUNCTION PROTOTYPES +***********************************************************************************/ + +LVM_INT32 LVM_Polynomial(LVM_UINT16 N, + LVM_INT32 *pCoefficients, + LVM_INT32 X); + +LVM_INT32 LVM_Power10( LVM_INT32 X); + +LVM_INT32 LVM_FO_LPF( LVM_INT32 w, + FO_C32_Coefs_t *pCoeffs); + +LVM_INT32 LVM_FO_HPF( LVM_INT32 w, + FO_C32_Coefs_t *pCoeffs); + +LVM_INT32 LVM_GetOmega(LVM_UINT16 Fc, + LVM_Fs_en SampleRate); + +/**********************************************************************************/ +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /** _FILTER_H_ **/ + diff --git a/media/libeffects/lvm/lib/Common/lib/InstAlloc.h b/media/libeffects/lvm/lib/Common/lib/InstAlloc.h new file mode 100755 index 0000000..31409bf --- /dev/null +++ b/media/libeffects/lvm/lib/Common/lib/InstAlloc.h @@ -0,0 +1,99 @@ +/* + * 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: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ +#ifndef __INSTALLOC_H__ +#define __INSTALLOC_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "LVM_Types.h" +/*######################################################################################*/ +/* Type declarations */ +/*######################################################################################*/ +typedef struct +{ + LVM_UINT32 TotalSize; /* Accumulative total memory size */ + LVM_UINT32 pNextMember; /* Pointer to the next instance member to be allocated */ +} INST_ALLOC; + + +/*######################################################################################*/ +/* Function prototypes */ +/*######################################################################################*/ + +/**************************************************************************************** + * Name : InstAlloc_Init() + * Input : pms - Pointer to the INST_ALLOC instance + StartAddr - Base address of the instance memory + * Returns : Error code + * Description : Initializes the instance distribution and memory size calculation function + * Remarks : + ****************************************************************************************/ + +void InstAlloc_Init( INST_ALLOC *pms, void *StartAddr ); + + +/**************************************************************************************** + * Name : InstAlloc_AddMember() + * Input : pms - Pointer to the INST_ALLOC instance + Size - The size in bytes of the new added member + * Returns : A pointer to the new added member + * Description : Allocates space for a new member in the instance memory and returns + a pointer to this new member. The start address of all members will + be 32 bit alligned. + * Remarks : + ****************************************************************************************/ + +void* InstAlloc_AddMember( INST_ALLOC *pms, LVM_UINT32 Size ); + +/**************************************************************************************** + * Name : InstAlloc_GetTotal() + * Input : pms - Pointer to the INST_ALLOC instance + * Returns : The instance memory size + * Description : This functions returns the calculated instance memory size + * Remarks : + ****************************************************************************************/ + +LVM_UINT32 InstAlloc_GetTotal( INST_ALLOC *pms); + +void* InstAlloc_AddMemberAllRet( INST_ALLOC *pms, + LVM_UINT32 Size[], + void **ptr); + +void* InstAlloc_AddMemberAll( INST_ALLOC *pms, + LVM_UINT32 Size[], + LVM_MemoryTable_st *pMemoryTable); + +void InstAlloc_InitAll( INST_ALLOC *pms, + LVM_MemoryTable_st *pMemoryTable); + +void InstAlloc_InitAll_NULL( INST_ALLOC *pms); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __JBS_INSTALLOC_H__ */ diff --git a/media/libeffects/lvm/lib/Common/lib/LVM_Common.h b/media/libeffects/lvm/lib/Common/lib/LVM_Common.h new file mode 100755 index 0000000..f0f893d --- /dev/null +++ b/media/libeffects/lvm/lib/Common/lib/LVM_Common.h @@ -0,0 +1,69 @@ +/* + * 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: nxp27078 $ + $Revision: 672 $ + $Date: 2010-06-08 19:39:38 +0200 (Tue, 08 Jun 2010) $ + +*****************************************************************************************/ + +/****************************************************************************************/ +/* */ +/* Header file for the common definitions used within the bundle and its algorithms. */ +/* */ +/* This files includes all definitions, types, structures and function prototypes. */ +/* */ +/****************************************************************************************/ + + +#ifndef __LVM_COMMON_H__ +#define __LVM_COMMON_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/****************************************************************************************/ +/* */ +/* Includes */ +/* */ +/****************************************************************************************/ +#include "LVM_Types.h" + + +/****************************************************************************************/ +/* */ +/* Definitions */ +/* */ +/****************************************************************************************/ +/* Algorithm identification */ +#define ALGORITHM_NONE_ID 0x0000 +#define ALGORITHM_CS_ID 0x0100 +#define ALGORITHM_EQNB_ID 0x0200 +#define ALGORITHM_DBE_ID 0x0300 +#define ALGORITHM_VC_ID 0x0500 +#define ALGORITHM_TE_ID 0x0600 + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __LVM_COMMON_H__ */ + diff --git a/media/libeffects/lvm/lib/Common/lib/LVM_Macros.h b/media/libeffects/lvm/lib/Common/lib/LVM_Macros.h new file mode 100755 index 0000000..8bd363d --- /dev/null +++ b/media/libeffects/lvm/lib/Common/lib/LVM_Macros.h @@ -0,0 +1,130 @@ +/* + * 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: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +#ifndef _LVM_MACROS_H_ +#define _LVM_MACROS_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/********************************************************************************** + MUL32x32INTO32(A,B,C,ShiftR) + C = (A * B) >> ShiftR + + A, B and C are all 32 bit SIGNED numbers and ShiftR can vary from 0 to 64 + + The user has to take care that C does not overflow. The result in case + of overflow is undefined. + +***********************************************************************************/ +#ifndef MUL32x32INTO32 +#define MUL32x32INTO32(A,B,C,ShiftR) \ + {LVM_INT32 MUL32x32INTO32_temp,MUL32x32INTO32_temp2,MUL32x32INTO32_mask,MUL32x32INTO32_HH,MUL32x32INTO32_HL,MUL32x32INTO32_LH,MUL32x32INTO32_LL;\ + LVM_INT32 shiftValue;\ + shiftValue = (ShiftR);\ + MUL32x32INTO32_mask=0x0000FFFF;\ + MUL32x32INTO32_HH= ((LVM_INT32)((LVM_INT16)((A)>>16))*((LVM_INT16)((B)>>16)) );\ + MUL32x32INTO32_HL= ((LVM_INT32)((B)&MUL32x32INTO32_mask)*((LVM_INT16)((A)>>16))) ;\ + MUL32x32INTO32_LH= ((LVM_INT32)((A)&MUL32x32INTO32_mask)*((LVM_INT16)((B)>>16)));\ + MUL32x32INTO32_LL= (LVM_INT32)((A)&MUL32x32INTO32_mask)*(LVM_INT32)((B)&MUL32x32INTO32_mask);\ + MUL32x32INTO32_temp= (LVM_INT32)(MUL32x32INTO32_HL&MUL32x32INTO32_mask)+(LVM_INT32)(MUL32x32INTO32_LH&MUL32x32INTO32_mask)+(LVM_INT32)((MUL32x32INTO32_LL>>16)&MUL32x32INTO32_mask);\ + MUL32x32INTO32_HH= MUL32x32INTO32_HH+(LVM_INT32)(MUL32x32INTO32_HL>>16)+(LVM_INT32)(MUL32x32INTO32_LH>>16)+(LVM_INT32)(MUL32x32INTO32_temp>>16);\ + MUL32x32INTO32_LL=MUL32x32INTO32_LL+(LVM_INT32)(MUL32x32INTO32_HL<<16)+(LVM_INT32)(MUL32x32INTO32_LH<<16);\ + if(shiftValue<32)\ + {\ + MUL32x32INTO32_HH=MUL32x32INTO32_HH<<(32-shiftValue);\ + MUL32x32INTO32_mask=((LVM_INT32)1<<(32-shiftValue))-1;\ + MUL32x32INTO32_LL=(MUL32x32INTO32_LL>>shiftValue)&MUL32x32INTO32_mask;\ + MUL32x32INTO32_temp2=MUL32x32INTO32_HH|MUL32x32INTO32_LL;\ + }\ + else\ + {\ + MUL32x32INTO32_temp2=(LVM_INT32)MUL32x32INTO32_HH>>(shiftValue-32);\ + }\ + (C) = MUL32x32INTO32_temp2;\ + } +#endif + +/********************************************************************************** + MUL32x16INTO32(A,B,C,ShiftR) + C = (A * B) >> ShiftR + + A and C are 32 bit SIGNED numbers. B is a 16 bit SIGNED number. + ShiftR can vary from 0 to 48 + + The user has to take care that C does not overflow. The result in case + of overflow is undefined. + +***********************************************************************************/ +#ifndef MUL32x16INTO32 +#define MUL32x16INTO32(A,B,C,ShiftR) \ + {LVM_INT32 MUL32x16INTO32_mask,MUL32x16INTO32_HH,MUL32x16INTO32_LL;\ + LVM_INT32 shiftValue;\ + shiftValue = (ShiftR);\ + MUL32x16INTO32_mask=0x0000FFFF;\ + MUL32x16INTO32_HH= ((LVM_INT32)(B)*((LVM_INT16)((A)>>16)));\ + MUL32x16INTO32_LL= ((LVM_INT32)((A)&MUL32x16INTO32_mask)*(B));\ + if(shiftValue<16)\ + {\ + MUL32x16INTO32_HH=(LVM_INT32)((LVM_UINT32)MUL32x16INTO32_HH<<(16-shiftValue));\ + (C)=MUL32x16INTO32_HH+(LVM_INT32)(MUL32x16INTO32_LL>>shiftValue);\ + }\ + else if(shiftValue<32) {\ + MUL32x16INTO32_HH=(LVM_INT32)(MUL32x16INTO32_HH>>(shiftValue-16));\ + (C)=MUL32x16INTO32_HH+(LVM_INT32)(MUL32x16INTO32_LL>>shiftValue);\ + }\ + else {\ + (C)=MUL32x16INTO32_HH>>(shiftValue-16);}\ + } +#endif + +/********************************************************************************** + ADD2_SAT_32x32(A,B,C) + C = SAT(A + B) + + A,B and C are 32 bit SIGNED numbers. +***********************************************************************************/ +#ifndef ADD2_SAT_32x32 +#define ADD2_SAT_32x32(A,B,C) \ + {(C)=(A)+(B);\ + if ((((C) ^ (A)) & ((C) ^ (B))) >> 31)\ + {\ + if((A)<0)\ + (C)=0x80000000l;\ + else\ + (C)=0x7FFFFFFFl;\ + }\ + } +#endif + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _LVM_MACROS_H_ */ + +/*** End of file ******************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/lib/LVM_Timer.h b/media/libeffects/lvm/lib/Common/lib/LVM_Timer.h new file mode 100755 index 0000000..22a16d6 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/lib/LVM_Timer.h @@ -0,0 +1,89 @@ +/* + * 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_TIMER_H__ +#define __LVM_TIMER_H__ +/************************************************************************/ +/* */ +/* Project:: My Project */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ +#include "LVM_Types.h" + +/****************************************************************************************/ +/* */ +/* Header file for the LVM_Timer library */ +/* */ +/* Functionality: */ +/* The timer will count down a number of ms, based on the number of samples it */ +/* sees and the curent sampling rate. When the timer expires, a registered */ +/* callback function will be called. */ +/* The maximal number of sampless that can be called by the timer is 2^32, which */ +/* corresponds to 24.8 hours at a sampling rate of 48 kHz */ +/* The timer currently does not suport changes in sampling rate while timing. */ +/****************************************************************************************/ + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/****************************************************************************************/ +/* TYPE DEFINITIONS */ +/****************************************************************************************/ + +typedef struct +{ + LVM_INT32 Storage[6]; + +} LVM_Timer_Instance_t; + +typedef struct +{ + LVM_INT32 SamplingRate; + LVM_INT16 TimeInMs; + LVM_INT32 CallBackParam; + void *pCallBackParams; + void *pCallbackInstance; + void (*pCallBack)(void*,void*,LVM_INT32); + +} LVM_Timer_Params_t; + +/****************************************************************************************/ +/* FUNCTION PROTOTYPES */ +/****************************************************************************************/ + +void LVM_Timer_Init ( LVM_Timer_Instance_t *pInstance, + LVM_Timer_Params_t *pParams ); + + +void LVM_Timer ( LVM_Timer_Instance_t *pInstance, + LVM_INT16 BlockSize ); + + +/****************************************************************************************/ +/* END OF HEADER */ +/****************************************************************************************/ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __LVM_TIMER_H__ */ diff --git a/media/libeffects/lvm/lib/Common/lib/LVM_Types.h b/media/libeffects/lvm/lib/Common/lib/LVM_Types.h new file mode 100755 index 0000000..e4649ba --- /dev/null +++ b/media/libeffects/lvm/lib/Common/lib/LVM_Types.h @@ -0,0 +1,195 @@ +/* + * 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: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +*****************************************************************************************/ + +/****************************************************************************************/ +/* */ +/* Header file defining the standard LifeVibes types for use in the application layer */ +/* interface of all LifeVibes modules */ +/* */ +/****************************************************************************************/ + +#ifndef LVM_TYPES_H +#define LVM_TYPES_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/****************************************************************************************/ +/* */ +/* definitions */ +/* */ +/****************************************************************************************/ + +#define LVM_NULL 0 /* NULL pointer */ + +#define LVM_TRUE 1 /* Booleans */ +#define LVM_FALSE 0 + +#define LVM_MAXINT_8 127 /* Maximum positive integer size */ +#define LVM_MAXINT_16 32767 +#define LVM_MAXINT_32 2147483647 +#define LVM_MAXENUM 2147483647 + +#define LVM_MODULEID_MASK 0xFF00 /* Mask to extract the calling module ID from callbackId */ +#define LVM_EVENTID_MASK 0x00FF /* Mask to extract the callback event from callbackId */ + +/* Memory table*/ +#define LVM_MEMREGION_PERSISTENT_SLOW_DATA 0 /* Offset to the instance memory region */ +#define LVM_MEMREGION_PERSISTENT_FAST_DATA 1 /* Offset to the persistent data memory region */ +#define LVM_MEMREGION_PERSISTENT_FAST_COEF 2 /* Offset to the persistent coefficient memory region */ +#define LVM_MEMREGION_TEMPORARY_FAST 3 /* Offset to temporary memory region */ + +#define LVM_NR_MEMORY_REGIONS 4 /* Number of memory regions */ + +/* Memory partition type */ +#define LVM_MEM_PARTITION0 0 /* 1st memory partition */ +#define LVM_MEM_PARTITION1 1 /* 2nd memory partition */ +#define LVM_MEM_PARTITION2 2 /* 3rd memory partition */ +#define LVM_MEM_PARTITION3 3 /* 4th memory partition */ + +/* Use type */ +#define LVM_MEM_PERSISTENT 0 /* Persistent memory type */ +#define LVM_MEM_SCRATCH 4 /* Scratch memory type */ + +/* Access type */ +#define LVM_MEM_INTERNAL 0 /* Internal (fast) access memory */ +#define LVM_MEM_EXTERNAL 8 /* External (slow) access memory */ + +/* Platform specific */ +#define LVM_PERSISTENT LVM_MEM_PARTITION0+LVM_MEM_PERSISTENT+LVM_MEM_INTERNAL +#define LVM_PERSISTENT_DATA LVM_MEM_PARTITION1+LVM_MEM_PERSISTENT+LVM_MEM_INTERNAL +#define LVM_PERSISTENT_COEF LVM_MEM_PARTITION2+LVM_MEM_PERSISTENT+LVM_MEM_INTERNAL +#define LVM_SCRATCH LVM_MEM_PARTITION3+LVM_MEM_SCRATCH+LVM_MEM_INTERNAL + +/****************************************************************************************/ +/* */ +/* Basic types */ +/* */ +/****************************************************************************************/ + +typedef char LVM_CHAR; /* ASCII character */ + +typedef char LVM_INT8; /* Signed 8-bit word */ +typedef unsigned char LVM_UINT8; /* Unsigned 8-bit word */ + +typedef short LVM_INT16; /* Signed 16-bit word */ +typedef unsigned short LVM_UINT16; /* Unsigned 16-bit word */ + +typedef long LVM_INT32; /* Signed 32-bit word */ +typedef unsigned long LVM_UINT32; /* Unsigned 32-bit word */ + + +/****************************************************************************************/ +/* */ +/* Standard Enumerated types */ +/* */ +/****************************************************************************************/ + +/* Operating mode */ +typedef enum +{ + LVM_MODE_OFF = 0, + LVM_MODE_ON = 1, + LVM_MODE_DUMMY = LVM_MAXENUM +} LVM_Mode_en; + + +/* Format */ +typedef enum +{ + LVM_STEREO = 0, + LVM_MONOINSTEREO = 1, + LVM_MONO = 2, + LVM_SOURCE_DUMMY = LVM_MAXENUM +} LVM_Format_en; + + +/* LVM sampling rates */ +typedef enum +{ + LVM_FS_8000 = 0, + LVM_FS_11025 = 1, + LVM_FS_12000 = 2, + LVM_FS_16000 = 3, + LVM_FS_22050 = 4, + LVM_FS_24000 = 5, + LVM_FS_32000 = 6, + LVM_FS_44100 = 7, + LVM_FS_48000 = 8, + LVM_FS_INVALID = LVM_MAXENUM-1, + LVM_FS_DUMMY = LVM_MAXENUM +} LVM_Fs_en; + + +/* Memory Types */ +typedef enum +{ + LVM_PERSISTENT_SLOW_DATA = LVM_MEMREGION_PERSISTENT_SLOW_DATA, + LVM_PERSISTENT_FAST_DATA = LVM_MEMREGION_PERSISTENT_FAST_DATA, + LVM_PERSISTENT_FAST_COEF = LVM_MEMREGION_PERSISTENT_FAST_COEF, + LVM_TEMPORARY_FAST = LVM_MEMREGION_TEMPORARY_FAST, + LVM_MEMORYTYPE_DUMMY = LVM_MAXENUM +} LVM_MemoryTypes_en; + + +/* Memory region definition */ +typedef struct +{ + LVM_UINT32 Size; /* Region size in bytes */ + LVM_MemoryTypes_en Type; /* Region type */ + void *pBaseAddress; /* Pointer to the region base address */ +} LVM_MemoryRegion_st; + + +/* Memory table containing the region definitions */ +typedef struct +{ + LVM_MemoryRegion_st Region[LVM_NR_MEMORY_REGIONS]; /* One definition for each region */ +} LVM_MemoryTable_st; + + +/****************************************************************************************/ +/* */ +/* Standard Function Prototypes */ +/* */ +/****************************************************************************************/ +typedef LVM_INT32 (*LVM_Callback)(void *pCallbackData, /* Pointer to the callback data structure */ + void *pGeneralPurpose, /* General purpose pointer (e.g. to a data structure needed in the callback) */ + LVM_INT16 GeneralPurpose ); /* General purpose variable (e.g. to be used as callback ID) */ + + +/****************************************************************************************/ +/* */ +/* End of file */ +/* */ +/****************************************************************************************/ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* LVM_TYPES_H */ diff --git a/media/libeffects/lvm/lib/Common/lib/Mixer.h b/media/libeffects/lvm/lib/Common/lib/Mixer.h new file mode 100755 index 0000000..d741980 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/lib/Mixer.h @@ -0,0 +1,135 @@ +/* + * 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: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +#ifndef __MIXER_H__ +#define __MIXER_H__ + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +#include "LVM_Types.h" + +/********************************************************************************** + INSTANCE MEMORY TYPE DEFINITION +***********************************************************************************/ + +typedef struct +{ + LVM_INT32 Alpha; /* Time constant. Set by calling application. Can be changed at any time */ + LVM_INT32 Target; /* Target value. Set by calling application. Can be changed at any time */ + LVM_INT32 Current; /* Current value. Set by the mixer function. */ + LVM_INT16 CallbackSet; /* Boolean. Should be set by calling application each time the target value is updated */ + LVM_INT16 CallbackParam; /* Parameter that will be used in the calback function */ + void *pCallbackHandle; /* Pointer to the instance of the callback function */ + void *pGeneralPurpose; /* Pointer for general purpose usage */ + LVM_Callback pCallBack; /* Pointer to the callback function */ +} Mix_1St_Cll_t; + +typedef struct +{ + LVM_INT32 Alpha1; + LVM_INT32 Target1; + LVM_INT32 Current1; + LVM_INT16 CallbackSet1; + LVM_INT16 CallbackParam1; + void *pCallbackHandle1; + void *pGeneralPurpose1; + LVM_Callback pCallBack1; + + LVM_INT32 Alpha2; /* Warning the address of this location is passed as a pointer to Mix_1St_Cll_t in some functions */ + LVM_INT32 Target2; + LVM_INT32 Current2; + LVM_INT16 CallbackSet2; + LVM_INT16 CallbackParam2; + void *pCallbackHandle2; + void *pGeneralPurpose2; + LVM_Callback pCallBack2; + +} Mix_2St_Cll_t; + + +/*** General functions ************************************************************/ + +LVM_UINT32 LVM_Mixer_TimeConstant(LVM_UINT32 tc, + LVM_UINT16 Fs, + LVM_UINT16 NumChannels); + + +void MixSoft_1St_D32C31_WRA( Mix_1St_Cll_t *pInstance, + const LVM_INT32 *src, + LVM_INT32 *dst, + LVM_INT16 n); + +void MixSoft_2St_D32C31_SAT( Mix_2St_Cll_t *pInstance, + const LVM_INT32 *src1, + const LVM_INT32 *src2, + LVM_INT32 *dst, + LVM_INT16 n); + +void MixInSoft_D32C31_SAT( Mix_1St_Cll_t *pInstance, + const LVM_INT32 *src, + LVM_INT32 *dst, + LVM_INT16 n); + +/********************************************************************************** + FUNCTION PROTOTYPES (LOW LEVEL SUBFUNCTIONS) +***********************************************************************************/ + +void Core_MixSoft_1St_D32C31_WRA( Mix_1St_Cll_t *pInstance, + const LVM_INT32 *src, + LVM_INT32 *dst, + LVM_INT16 n); + +void Core_MixHard_2St_D32C31_SAT( Mix_2St_Cll_t *pInstance, + const LVM_INT32 *src1, + const LVM_INT32 *src2, + LVM_INT32 *dst, + LVM_INT16 n); + +void Core_MixInSoft_D32C31_SAT( Mix_1St_Cll_t *pInstance, + const LVM_INT32 *src, + LVM_INT32 *dst, + LVM_INT16 n); +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/**********************************************************************************/ + +#endif /* __MIXER_H__ */ + + + + + + + + + + diff --git a/media/libeffects/lvm/lib/Common/lib/ScalarArithmetic.h b/media/libeffects/lvm/lib/Common/lib/ScalarArithmetic.h new file mode 100755 index 0000000..c66e201 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/lib/ScalarArithmetic.h @@ -0,0 +1,68 @@ +/* + * 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: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#ifndef __SCALARARITHMETIC_H__ +#define __SCALARARITHMETIC_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/*######################################################################################*/ +/* Include files */ +/*######################################################################################*/ + +#include "LVM_Types.h" + +/*######################################################################################*/ +/* Extern function prototypes */ +/*######################################################################################*/ + +/* Absolute value including the corner case for the extreme negative value */ +LVM_INT32 Abs_32(LVM_INT32 input); + +/**************************************************************************************** + * Name : dB_to_Lin32() + * Input : Signed 16-bit integer + * MSB (16) = sign bit + * (15->05) = integer part + * (04->01) = decimal part + * Output : Signed 32-bit integer + * MSB (32) = sign bit + * (31->16) = integer part + * (15->01) = decimal part + * Returns : Lin value format 1.16.15 + ****************************************************************************************/ + +LVM_INT32 dB_to_Lin32(LVM_INT16 db_fix); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __SCALARARITHMETIC_H__ */ + + diff --git a/media/libeffects/lvm/lib/Common/lib/VectorArithmetic.h b/media/libeffects/lvm/lib/Common/lib/VectorArithmetic.h new file mode 100755 index 0000000..290a996 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/lib/VectorArithmetic.h @@ -0,0 +1,189 @@ +/* + * 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: 853 $ + $Date: 2010-06-16 15:10:28 +0200 (Wed, 16 Jun 2010) $ + +***********************************************************************************/ + +#ifndef _VECTOR_ARITHMETIC_H_ +#define _VECTOR_ARITHMETIC_H_ + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "LVM_Types.h" + +/********************************************************************************** + VARIOUS FUNCTIONS +***********************************************************************************/ + +void LoadConst_16( const LVM_INT16 val, + LVM_INT16 *dst, + LVM_INT16 n ); + +void LoadConst_32( const LVM_INT32 val, + LVM_INT32 *dst, + LVM_INT16 n ); + +void Copy_16( const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n ); + +/********************************************************************************* + * note: In Mult3s_16x16() saturation of result is not taken care when * + * overflow occurs. * + * For example when *src = 0x8000, val = *0x8000 * + * The function gives the output as 0x8000 instead of 0x7fff * + * This is the only case which will give wrong result. * + * For more information refer to Vector_Arithmetic.doc in /doc folder * + *********************************************************************************/ +void Mult3s_16x16( const LVM_INT16 *src, + const LVM_INT16 val, + LVM_INT16 *dst, + LVM_INT16 n); + +/********************************************************************************* + * note: In Mult3s_32x16() saturation of result is not taken care when * + * overflow occurs. * + * For example when *src = 0x8000000, val = *0x8000 * + * The function gives the output as 0x8000000 instead of 0x7fffffff * + * This is the only extreme condition which is giving unexpected result * + * For more information refer to Vector_Arithmetic.doc in /doc folder * + *********************************************************************************/ +void Mult3s_32x16( const LVM_INT32 *src, + const LVM_INT16 val, + LVM_INT32 *dst, + LVM_INT16 n); + +void DelayMix_16x16( const LVM_INT16 *src, + LVM_INT16 *delay, + LVM_INT16 size, + LVM_INT16 *dst, + LVM_INT16 *pOffset, + LVM_INT16 n); + +void DelayWrite_32( const LVM_INT32 *src, /* Source 1, to be delayed */ + LVM_INT32 *delay, /* Delay buffer */ + LVM_UINT16 size, /* Delay size */ + LVM_UINT16 *pOffset, /* Delay offset */ + LVM_INT16 n); + +void Add2_Sat_16x16( const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n ); + +void Add2_Sat_32x32( const LVM_INT32 *src, + LVM_INT32 *dst, + LVM_INT16 n ); + +void Mac3s_Sat_16x16( const LVM_INT16 *src, + const LVM_INT16 val, + LVM_INT16 *dst, + LVM_INT16 n); + +void Mac3s_Sat_32x16( const LVM_INT32 *src, + const LVM_INT16 val, + LVM_INT32 *dst, + LVM_INT16 n); + +void DelayAllPass_Sat_32x16To32( LVM_INT32 *delay, /* Delay buffer */ + LVM_UINT16 size, /* Delay size */ + LVM_INT16 coeff, /* All pass filter coefficient */ + LVM_UINT16 DelayOffset, /* Simple delay offset */ + LVM_UINT16 *pAllPassOffset, /* All pass filter delay offset */ + LVM_INT32 *dst, /* Source/destination */ + LVM_INT16 n); + +/********************************************************************************** + SHIFT FUNCTIONS +***********************************************************************************/ + +void Shift_Sat_v16xv16 ( const LVM_INT16 val, + const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n); + +void Shift_Sat_v32xv32 ( const LVM_INT16 val, + const LVM_INT32 *src, + LVM_INT32 *dst, + LVM_INT16 n); + +/********************************************************************************** + AUDIO FORMAT CONVERSION FUNCTIONS +***********************************************************************************/ + +void MonoTo2I_16( const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n); + +void MonoTo2I_32( const LVM_INT32 *src, + LVM_INT32 *dst, + LVM_INT16 n); + +void From2iToMono_32( const LVM_INT32 *src, + LVM_INT32 *dst, + LVM_INT16 n); + +void MSTo2i_Sat_16x16( const LVM_INT16 *srcM, + const LVM_INT16 *srcS, + LVM_INT16 *dst, + LVM_INT16 n ); + +void From2iToMS_16x16( const LVM_INT16 *src, + LVM_INT16 *dstM, + LVM_INT16 *dstS, + LVM_INT16 n ); + +void From2iToMono_16( const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n); + +void JoinTo2i_32x32( const LVM_INT32 *srcL, + const LVM_INT32 *srcR, + LVM_INT32 *dst, + LVM_INT16 n ); + +/********************************************************************************** + DATA TYPE CONVERSION FUNCTIONS +***********************************************************************************/ + +void Int16LShiftToInt32_16x32(const LVM_INT16 *src, + LVM_INT32 *dst, + LVM_INT16 n, + LVM_INT16 shift ); + +void Int32RShiftToInt16_Sat_32x16(const LVM_INT32 *src, + LVM_INT16 *dst, + LVM_INT16 n, + LVM_INT16 shift ); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/**********************************************************************************/ + +#endif /* _VECTOR_ARITHMETIC_H_ */ + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/AGC_MIX_VOL_2St1Mon_D32_WRA.c b/media/libeffects/lvm/lib/Common/src/AGC_MIX_VOL_2St1Mon_D32_WRA.c new file mode 100755 index 0000000..40e0dbf --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/AGC_MIX_VOL_2St1Mon_D32_WRA.c @@ -0,0 +1,204 @@ +/* + * 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: 1070 $ + $Date: 2010-07-02 11:22:18 +0200 (Fri, 02 Jul 2010) $ + +*****************************************************************************************/ + +/****************************************************************************************/ +/* */ +/* Includes */ +/* */ +/****************************************************************************************/ + +#include "AGC.h" +#include "ScalarArithmetic.h" + + +/****************************************************************************************/ +/* */ +/* Defines */ +/* */ +/****************************************************************************************/ + +#define VOL_TC_SHIFT 21 /* As a power of 2 */ +#define DECAY_SHIFT 10 /* As a power of 2 */ + + +/****************************************************************************************/ +/* */ +/* FUNCTION: AGC_MIX_VOL_2St1Mon_D32_WRA */ +/* */ +/* DESCRIPTION: */ +/* Apply AGC and mix signals */ +/* */ +/* */ +/* StSrc ------------------| */ +/* | */ +/* ______ _|_ ________ */ +/* | | | | | | */ +/* MonoSrc -->| AGC |---->| + |----->| Volume |------------------------------+---> */ +/* | Gain | |___| | Gain | | */ +/* |______| |________| | */ +/* /|\ __________ ________ | */ +/* | | | | | | */ +/* |-------------------------------| AGC Gain |<--| Peak |<--| */ +/* | Update | | Detect | */ +/* |__________| |________| */ +/* */ +/* */ +/* PARAMETERS: */ +/* pInstance Instance pointer */ +/* pStereoIn Stereo source */ +/* pMonoIn Mono band pass source */ +/* pStereoOut Stereo destination */ +/* */ +/* RETURNS: */ +/* Void */ +/* */ +/* NOTES: */ +/* */ +/****************************************************************************************/ + +void AGC_MIX_VOL_2St1Mon_D32_WRA(AGC_MIX_VOL_2St1Mon_D32_t *pInstance, /* Instance pointer */ + const LVM_INT32 *pStSrc, /* Stereo source */ + const LVM_INT32 *pMonoSrc, /* Mono source */ + LVM_INT32 *pDst, /* Stereo destination */ + LVM_UINT16 NumSamples) /* Number of samples */ +{ + + /* + * General variables + */ + LVM_UINT16 i; /* Sample index */ + LVM_INT32 Left; /* Left sample */ + LVM_INT32 Right; /* Right sample */ + LVM_INT32 Mono; /* Mono sample */ + LVM_INT32 AbsPeak; /* Absolute peak signal */ + LVM_INT32 HighWord; /* High word in intermediate calculations */ + LVM_INT32 LowWord; /* Low word in intermediate calculations */ + LVM_INT16 AGC_Mult; /* Short AGC gain */ + LVM_INT16 Vol_Mult; /* Short volume */ + + + /* + * Instance control variables + */ + LVM_INT32 AGC_Gain = pInstance->AGC_Gain; /* Get the current AGC gain */ + LVM_INT32 AGC_MaxGain = pInstance->AGC_MaxGain; /* Get maximum AGC gain */ + LVM_INT16 AGC_GainShift = pInstance->AGC_GainShift; /* Get the AGC shift */ + LVM_INT16 AGC_Attack = pInstance->AGC_Attack; /* Attack scaler */ + LVM_INT16 AGC_Decay = pInstance->AGC_Decay; /* Decay scaler */ + LVM_INT32 AGC_Target = pInstance->AGC_Target; /* Get the target level */ + LVM_INT32 Vol_Current = pInstance->Volume; /* Actual volume setting */ + LVM_INT32 Vol_Target = pInstance->Target; /* Target volume setting */ + LVM_INT16 Vol_Shift = pInstance->VolumeShift; /* Volume shift scaling */ + LVM_INT16 Vol_TC = pInstance->VolumeTC; /* Time constant */ + + + /* + * Process on a sample by sample basis + */ + for (i=0;i<NumSamples;i++) /* For each sample */ + { + + /* + * Get the short scalers + */ + AGC_Mult = (LVM_INT16)(AGC_Gain >> 16); /* Get the short AGC gain */ + Vol_Mult = (LVM_INT16)(Vol_Current >> 16); /* Get the short volume gain */ + + + /* + * Get the input samples + */ + Left = *pStSrc++; /* Get the left sample */ + Right = *pStSrc++; /* Get the right sample */ + Mono = *pMonoSrc++; /* Get the mono sample */ + + + /* + * Apply the AGC gain to the mono input and mix with the stereo signal + */ + HighWord = (AGC_Mult * (Mono >> 16)); /* signed long (Mono) by unsigned short (AGC_Mult) multiply */ + LowWord = (AGC_Mult * (Mono & 0xffff)); + Mono = (HighWord + (LowWord >> 16)) << (AGC_GainShift); + Left += Mono; /* Mix in the mono signal */ + Right += Mono; + + + /* + * Apply the volume and write to the output stream + */ + HighWord = (Vol_Mult * (Left >> 16)); /* signed long (Left) by unsigned short (Vol_Mult) multiply */ + LowWord = (Vol_Mult * (Left & 0xffff)); + Left = (HighWord + (LowWord >> 16)) << (Vol_Shift); + HighWord = (Vol_Mult * (Right >> 16)); /* signed long (Right) by unsigned short (Vol_Mult) multiply */ + LowWord = (Vol_Mult * (Right & 0xffff)); + Right = (HighWord + (LowWord >> 16)) << (Vol_Shift); + *pDst++ = Left; /* Save the results */ + *pDst++ = Right; + + + /* + * Update the AGC gain + */ + AbsPeak = (Abs_32(Left)>Abs_32(Right)) ? Abs_32(Left) : Abs_32(Right); /* Get the absolute peak */ + if (AbsPeak > AGC_Target) + { + /* + * The signal is too large so decrease the gain + */ + HighWord = (AGC_Attack * (AGC_Gain >> 16)); /* signed long (AGC_Gain) by unsigned short (AGC_Attack) multiply */ + LowWord = (AGC_Attack * (AGC_Gain & 0xffff)); + AGC_Gain = (HighWord + (LowWord >> 16)) << 1; + } + else + { + /* + * The signal is too small so increase the gain + */ + if (AGC_Gain > AGC_MaxGain) + { + AGC_Gain -= (AGC_Decay << DECAY_SHIFT); + } + else + { + AGC_Gain += (AGC_Decay << DECAY_SHIFT); + } + } + + /* + * Update the gain + */ + Vol_Current += Vol_TC * ((Vol_Target - Vol_Current) >> VOL_TC_SHIFT); + } + + + /* + * Update the parameters + */ + pInstance->Volume = Vol_Current; /* Actual volume setting */ + pInstance->AGC_Gain = AGC_Gain; + + return; +} + diff --git a/media/libeffects/lvm/lib/Common/src/Abs_32.c b/media/libeffects/lvm/lib/Common/src/Abs_32.c new file mode 100755 index 0000000..635315d --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/Abs_32.c @@ -0,0 +1,58 @@ +/* + * 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: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/*######################################################################################*/ +/* Include files */ +/*######################################################################################*/ + +#include "ScalarArithmetic.h" + +/**************************************************************************************** + * Name : Abs_32() + * Input : Signed 32-bit integer + * Output : + * Returns : Absolute value + * Description : Absolute value with maximum negative value corner case + * Remarks : + ****************************************************************************************/ + +LVM_INT32 Abs_32(LVM_INT32 input) +{ + if(input < 0) + { + if (input == (LVM_INT32)(0x80000000U)) + { + /* The corner case, so set to the maximum positive value */ + input=(LVM_INT32) 0x7fffffff; + } + else + { + /* Negative input, so invert */ + input = (LVM_INT32)(-input); + } + } + return input; +} + diff --git a/media/libeffects/lvm/lib/Common/src/Add2_Sat_16x16.c b/media/libeffects/lvm/lib/Common/src/Add2_Sat_16x16.c new file mode 100755 index 0000000..18026c5 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/Add2_Sat_16x16.c @@ -0,0 +1,64 @@ +/* + * 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: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION ADD2_SAT_16X16 +***********************************************************************************/ + +void Add2_Sat_16x16( const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n ) +{ + LVM_INT32 Temp; + LVM_INT16 ii; + for (ii = n; ii != 0; ii--) + { + Temp = ((LVM_INT32) *src) + ((LVM_INT32) *dst); + src++; + + if (Temp > 0x00007FFF) + { + *dst = 0x7FFF; + } + else if (Temp < -0x00008000) + { + *dst = - 0x8000; + } + else + { + *dst = (LVM_INT16)Temp; + } + dst++; + } + return; +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/Add2_Sat_32x32.c b/media/libeffects/lvm/lib/Common/src/Add2_Sat_32x32.c new file mode 100755 index 0000000..96fc7e6 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/Add2_Sat_32x32.c @@ -0,0 +1,69 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + + +/********************************************************************************** + FUNCTION ADD2_SAT_32X32 +***********************************************************************************/ + +void Add2_Sat_32x32( const LVM_INT32 *src, + LVM_INT32 *dst, + LVM_INT16 n ) +{ + LVM_INT32 a,b,c; + LVM_INT16 ii; + for (ii = n; ii != 0; ii--) + { + a=*src; + src++; + + b=*dst; + c=a+b; + if ((((c ^ a) & (c ^ b)) >> 31)!=0) /* overflow / underflow */ + { + if(a<0) + { + c=0x80000000l; + } + else + { + c=0x7FFFFFFFl; + } + } + + *dst = c; + dst++; + } + return; +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/BP_1I_D16F16C14_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/BP_1I_D16F16C14_TRC_WRA_01.c new file mode 100755 index 0000000..76d8e42 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BP_1I_D16F16C14_TRC_WRA_01.c @@ -0,0 +1,90 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "BP_1I_D16F16Css_TRC_WRA_01_Private.h" +#include "LVM_Macros.h" + + +/************************************************************************** + ASSUMPTIONS: + COEFS- + pBiquadState->coefs[0] is A0, + pBiquadState->coefs[1] is -B2, + pBiquadState->coefs[2] is -B1, these are in Q14 format + + DELAYS- + pBiquadState->pDelays[0] is x(n-1)L in Q0 format + pBiquadState->pDelays[1] is x(n-2)L in Q0 format + pBiquadState->pDelays[2] is y(n-1)L in Q0 format + pBiquadState->pDelays[3] is y(n-2)L in Q0 format +***************************************************************************/ + +void BP_1I_D16F16C14_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples) + + + { + LVM_INT32 ynL; + LVM_INT16 ii; + PFilter_State pBiquadState = (PFilter_State) pInstance; + + for (ii = NrSamples; ii != 0; ii--) + { + + + /************************************************************************** + PROCESSING OF THE LEFT CHANNEL + ***************************************************************************/ + // ynL= (A0 (Q14) * (x(n)L (Q0) - x(n-2)L (Q0) ) ) in Q14 + ynL=(LVM_INT32)pBiquadState->coefs[0]* ((*pDataIn)-pBiquadState->pDelays[1]); + + // ynL+= ((-B2 (Q14) * y(n-2)L (Q0) ) ) in Q14 + ynL+=(LVM_INT32)pBiquadState->coefs[1]*pBiquadState->pDelays[3]; + + // ynL+= ((-B1 (Q30) * y(n-1)L (Q0) ) ) in Q14 + ynL+=(LVM_INT32)pBiquadState->coefs[2]*pBiquadState->pDelays[2]; + + ynL=(LVM_INT16)(ynL>>14); // ynL in Q0 + /************************************************************************** + UPDATING THE DELAYS + ***************************************************************************/ + pBiquadState->pDelays[3]=pBiquadState->pDelays[2]; // y(n-2)L=y(n-1)L + pBiquadState->pDelays[1]=pBiquadState->pDelays[0]; // x(n-2)L=x(n-1)L + pBiquadState->pDelays[2]=ynL; // Update y(n-1)L in Q0 + pBiquadState->pDelays[0]=(*pDataIn++); // Update x(n-1)L in Q0 + + /************************************************************************** + WRITING THE OUTPUT + ***************************************************************************/ + *pDataOut++=(LVM_INT16)ynL; // Write Left output in Q0 + + } + + } + diff --git a/media/libeffects/lvm/lib/Common/src/BP_1I_D16F16Css_TRC_WRA_01_Init.c b/media/libeffects/lvm/lib/Common/src/BP_1I_D16F16Css_TRC_WRA_01_Init.c new file mode 100755 index 0000000..9338eb2 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BP_1I_D16F16Css_TRC_WRA_01_Init.c @@ -0,0 +1,59 @@ +/* + * 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: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/*-------------------------------------------------------------------------*/ +#include "BIQUAD.h" +#include "BP_1I_D16F16Css_TRC_WRA_01_Private.h" + + +/*-------------------------------------------------------------------------*/ +/* FUNCTION: */ +/* BP_1I_D16F16Css_TRC_WRA_01_Init */ +/* */ +/* DESCRIPTION: */ +/* These functions initializes a BIQUAD filter defined as a cascade of */ +/* biquadratic Filter Sections. */ +/* */ +/* PARAMETERS: */ +/* pInstance - output, returns the pointer to the State Variable */ +/* This state pointer must be passed to any subsequent */ +/* call to "Biquad" functions. */ +/* pTaps - input, pointer to the taps memory */ +/* pCoef - input, pointer to the coefficient structure */ +/* N - M coefficient factor of QM.N */ +/* RETURNS: */ +/* void return code */ +/*-------------------------------------------------------------------------*/ +void BP_1I_D16F16Css_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance, + Biquad_1I_Order2_Taps_t *pTaps, + BP_C16_Coefs_t *pCoef) +{ + PFilter_State pBiquadState = (PFilter_State) pInstance; + pBiquadState->pDelays =(LVM_INT32 *) pTaps; + + pBiquadState->coefs[0]=pCoef->A0; + pBiquadState->coefs[1]=pCoef->B2; + pBiquadState->coefs[2]=pCoef->B1; + } +/*-------------------------------------------------------------------------*/ +/* End Of File: BP_1I_D16F16Css_TRC_WRA_01_Init.c */ + diff --git a/media/libeffects/lvm/lib/Common/src/BP_1I_D16F16Css_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/BP_1I_D16F16Css_TRC_WRA_01_Private.h new file mode 100755 index 0000000..2a0d7d5 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BP_1I_D16F16Css_TRC_WRA_01_Private.h @@ -0,0 +1,38 @@ +/* + * 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 _BP_1I_D16F16CSS_TRC_WRA_01_PRIVATE_H_ +#define _BP_1I_D16F16CSS_TRC_WRA_01_PRIVATE_H_ +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/* The internal state variables are implemented in a (for the user) hidden structure */ +/* In this (private) file, the internal structure is declared fro private use. */ +typedef struct _Filter_State_ +{ + LVM_INT32 * pDelays; /* pointer to the delayed samples (data of 32 bits) */ + LVM_INT32 coefs[3]; /* pointer to the filter coefficients */ +}Filter_State; + +typedef Filter_State * PFilter_State ; + +#endif /*_BP_1I_D16F16CSS_TRC_WRA_01_PRIVATE_H_*/ diff --git a/media/libeffects/lvm/lib/Common/src/BP_1I_D16F32C30_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/BP_1I_D16F32C30_TRC_WRA_01.c new file mode 100755 index 0000000..f52d3db --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BP_1I_D16F32C30_TRC_WRA_01.c @@ -0,0 +1,92 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "BP_1I_D16F32Cll_TRC_WRA_01_Private.h" +#include "LVM_Macros.h" + + +/************************************************************************** + ASSUMPTIONS: + COEFS- + pBiquadState->coefs[0] is A0, + pBiquadState->coefs[1] is -B2, + pBiquadState->coefs[2] is -B1, these are in Q30 format + + DELAYS- + pBiquadState->pDelays[0] is x(n-1)L in Q0 format + pBiquadState->pDelays[1] is x(n-2)L in Q0 format + pBiquadState->pDelays[2] is y(n-1)L in Q16 format + pBiquadState->pDelays[3] is y(n-2)L in Q16 format +***************************************************************************/ + +void BP_1I_D16F32C30_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples) + + + { + LVM_INT32 ynL,templ; + LVM_INT16 ii; + PFilter_State pBiquadState = (PFilter_State) pInstance; + + for (ii = NrSamples; ii != 0; ii--) + { + + + /************************************************************************** + PROCESSING OF THE LEFT CHANNEL + ***************************************************************************/ + // ynL= (A0 (Q30) * (x(n)L (Q0) - x(n-2)L (Q0) ) >>14) in Q16 + templ= (LVM_INT32) *pDataIn-pBiquadState->pDelays[1]; + MUL32x32INTO32(pBiquadState->coefs[0],templ,ynL,14) + + // ynL+= ((-B2 (Q30) * y(n-2)L (Q16) ) >>30) in Q16 + MUL32x32INTO32(pBiquadState->coefs[1],pBiquadState->pDelays[3],templ,30) + ynL+=templ; + + // ynL+= ((-B1 (Q30) * y(n-1)L (Q16) ) >>30) in Q16 + MUL32x32INTO32(pBiquadState->coefs[2],pBiquadState->pDelays[2],templ,30) + ynL+=templ; + + /************************************************************************** + UPDATING THE DELAYS + ***************************************************************************/ + pBiquadState->pDelays[3]=pBiquadState->pDelays[2]; // y(n-2)L=y(n-1)L + pBiquadState->pDelays[1]=pBiquadState->pDelays[0]; // x(n-2)L=x(n-1)L + pBiquadState->pDelays[2]=ynL; // Update y(n-1)L in Q16 + pBiquadState->pDelays[0]=(*pDataIn++); // Update x(n-1)L in Q0 + + /************************************************************************** + WRITING THE OUTPUT + ***************************************************************************/ + *pDataOut++=(LVM_INT16)(ynL>>16); // Write Left output in Q0 + + } + + } + diff --git a/media/libeffects/lvm/lib/Common/src/BP_1I_D16F32Cll_TRC_WRA_01_Init.c b/media/libeffects/lvm/lib/Common/src/BP_1I_D16F32Cll_TRC_WRA_01_Init.c new file mode 100755 index 0000000..c560085 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BP_1I_D16F32Cll_TRC_WRA_01_Init.c @@ -0,0 +1,69 @@ +/* + * 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: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/*-------------------------------------------------------------------------*/ +#include "BIQUAD.h" +#include "BP_1I_D16F32Cll_TRC_WRA_01_Private.h" + + +/*-------------------------------------------------------------------------*/ +/* FUNCTION: */ +/* BP_1I_D16F32Cll_TRC_WRA_01_Init */ +/* */ +/* DESCRIPTION: */ +/* These functions initializes a Band pass filter (BIQUAD) */ +/* biquadratic Filter Sections. */ +/* */ +/* PARAMETERS: */ +/* pInstance - output, returns the pointer to the State Variable */ +/* This state pointer must be passed to any subsequent */ +/* call to "Biquad" functions. */ +/* pTaps - input, pointer to the taps memory */ +/* pCoef - input, pointer to the coefficient structure */ +/* N - M coefficient factor of QM.N */ +/* */ +/* The coefficients are modified in the init() function such that lower */ +/* half word is right shifted by one and most significant bit of the lower */ +/* word is made to be zero. */ +/* */ +/* Reason: For MIPS effciency,we are using DSP 32*16 multiplication */ +/* instruction. But we have 32*32 multiplication. This can be realized by two 32*16 */ +/* multiplication. But 16th bit in the 32 bit word is not a sign bit. So this is done */ +/* by putting 16th bit to zero and lossing one bit precision by division of lower */ +/* half word by 2. */ +/* RETURNS: */ +/* void return code */ +/*-------------------------------------------------------------------------*/ +void BP_1I_D16F32Cll_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance, + Biquad_1I_Order2_Taps_t *pTaps, + BP_C32_Coefs_t *pCoef) +{ + PFilter_State pBiquadState = (PFilter_State) pInstance; + pBiquadState->pDelays =(LVM_INT32 *) pTaps; + + pBiquadState->coefs[0] = pCoef->A0; + pBiquadState->coefs[1] = pCoef->B2; + pBiquadState->coefs[2] = pCoef->B1; +} +/*-------------------------------------------------------------------------*/ +/* End Of File: BP_1I_D16F32Cll_TRC_WRA_01_Init.c */ + diff --git a/media/libeffects/lvm/lib/Common/src/BP_1I_D16F32Cll_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/BP_1I_D16F32Cll_TRC_WRA_01_Private.h new file mode 100755 index 0000000..76777f6 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BP_1I_D16F32Cll_TRC_WRA_01_Private.h @@ -0,0 +1,38 @@ +/* + * 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 _BP_1I_D16F32CLL_TRC_WRA_01_PRIVATE_H_ +#define _BP_1I_D16F32CLL_TRC_WRA_01_PRIVATE_H_ +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/* The internal state variables are implemented in a (for the user) hidden structure */ +/* In this (private) file, the internal structure is declared fro private use. */ +typedef struct _Filter_State_ +{ + LVM_INT32 * pDelays; /* pointer to the delayed samples (data of 32 bits) */ + LVM_INT32 coefs[3]; /* pointer to the filter coefficients */ +}Filter_State; + +typedef Filter_State * PFilter_State ; + +#endif /*_BP_1I_D16F32CLL_TRC_WRA_01_PRIVATE_H_*/ diff --git a/media/libeffects/lvm/lib/Common/src/BP_1I_D32F32C30_TRC_WRA_02.c b/media/libeffects/lvm/lib/Common/src/BP_1I_D32F32C30_TRC_WRA_02.c new file mode 100755 index 0000000..2b3555f --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BP_1I_D32F32C30_TRC_WRA_02.c @@ -0,0 +1,90 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "BP_1I_D32F32Cll_TRC_WRA_02_Private.h" +#include "LVM_Macros.h" + + +/************************************************************************** + ASSUMPTIONS: + COEFS- + pBiquadState->coefs[0] is A0, + pBiquadState->coefs[1] is -B2, + pBiquadState->coefs[2] is -B1, these are in Q30 format + + DELAYS- + pBiquadState->pDelays[0] is x(n-1)L in Q0 format + pBiquadState->pDelays[1] is x(n-2)L in Q0 format + pBiquadState->pDelays[2] is y(n-1)L in Q0 format + pBiquadState->pDelays[3] is y(n-2)L in Q0 format +***************************************************************************/ + +void BP_1I_D32F32C30_TRC_WRA_02 ( Biquad_Instance_t *pInstance, + LVM_INT32 *pDataIn, + LVM_INT32 *pDataOut, + LVM_INT16 NrSamples) + { + LVM_INT32 ynL,templ; + LVM_INT16 ii; + PFilter_State pBiquadState = (PFilter_State) pInstance; + + for (ii = NrSamples; ii != 0; ii--) + { + + + /************************************************************************** + PROCESSING OF THE LEFT CHANNEL + ***************************************************************************/ + // ynL= (A0 (Q30) * (x(n)L (Q0) - x(n-2)L (Q0) ) >>30) in Q0 + templ=(*pDataIn)-pBiquadState->pDelays[1]; + MUL32x32INTO32(pBiquadState->coefs[0],templ,ynL,30) + + // ynL+= ((-B2 (Q30) * y(n-2)L (Q0) ) >>30) in Q0 + MUL32x32INTO32(pBiquadState->coefs[1],pBiquadState->pDelays[3],templ,30) + ynL+=templ; + + // ynL+= ((-B1 (Q30) * y(n-1)L (Q0) ) >>30) in Q0 + MUL32x32INTO32(pBiquadState->coefs[2],pBiquadState->pDelays[2],templ,30) + ynL+=templ; + + /************************************************************************** + UPDATING THE DELAYS + ***************************************************************************/ + pBiquadState->pDelays[3]=pBiquadState->pDelays[2]; // y(n-2)L=y(n-1)L + pBiquadState->pDelays[1]=pBiquadState->pDelays[0]; // x(n-2)L=x(n-1)L + pBiquadState->pDelays[2]=ynL; // Update y(n-1)L in Q0 + pBiquadState->pDelays[0]=(*pDataIn++); // Update x(n-1)L in Q0 + + /************************************************************************** + WRITING THE OUTPUT + ***************************************************************************/ + *pDataOut++=ynL; // Write Left output in Q0 + + } + + } + diff --git a/media/libeffects/lvm/lib/Common/src/BP_1I_D32F32Cll_TRC_WRA_02_Init.c b/media/libeffects/lvm/lib/Common/src/BP_1I_D32F32Cll_TRC_WRA_02_Init.c new file mode 100755 index 0000000..f3f4571 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BP_1I_D32F32Cll_TRC_WRA_02_Init.c @@ -0,0 +1,60 @@ +/* + * 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: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/*-------------------------------------------------------------------------*/ +#include "BIQUAD.h" +#include "BP_1I_D32F32Cll_TRC_WRA_02_Private.h" + +/*-------------------------------------------------------------------------*/ +/* FUNCTION: */ +/* BP_1I_D32F32Cll_TRC_WRA_02_Init */ +/* */ +/* DESCRIPTION: */ +/* These functions initializes a BIQUAD filter defined as a cascade of */ +/* biquadratic Filter Sections. */ +/* */ +/* PARAMETERS: */ +/* pInstance - output, returns the pointer to the State Variable */ +/* This state pointer must be passed to any subsequent */ +/* call to "Biquad" functions. */ +/* pTaps - input, pointer to the taps memory */ +/* pCoef - input, pointer to the coefficient structure */ +/* N - M coefficient factor of QM.N */ +/* RETURNS: */ +/* void return code */ +/*-------------------------------------------------------------------------*/ +void BP_1I_D32F32Cll_TRC_WRA_02_Init ( Biquad_Instance_t *pInstance, + Biquad_1I_Order2_Taps_t *pTaps, + BP_C32_Coefs_t *pCoef) +{ + PFilter_State pBiquadState = (PFilter_State) pInstance; + pBiquadState->pDelays =(LVM_INT32 *) pTaps; + + pBiquadState->coefs[0]=pCoef->A0; + + pBiquadState->coefs[1]=pCoef->B2; + + pBiquadState->coefs[2]=pCoef->B1; +} +/*-------------------------------------------------------------------------*/ +/* End Of File: BP_1I_D32F32Cll_TRC_WRA_02_Init.c */ + diff --git a/media/libeffects/lvm/lib/Common/src/BP_1I_D32F32Cll_TRC_WRA_02_Private.h b/media/libeffects/lvm/lib/Common/src/BP_1I_D32F32Cll_TRC_WRA_02_Private.h new file mode 100755 index 0000000..8884537 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BP_1I_D32F32Cll_TRC_WRA_02_Private.h @@ -0,0 +1,38 @@ +/* + * 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 _BP_1I_D32F32CLL_TRC_WRA_02_PRIVATE_H_ +#define _BP_1I_D32F32CLL_TRC_WRA_02_PRIVATE_H_ +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/* The internal state variables are implemented in a (for the user) hidden structure */ +/* In this (private) file, the internal structure is declared fro private use. */ +typedef struct _Filter_State_ +{ + LVM_INT32 * pDelays; /* pointer to the delayed samples (data of 32 bits) */ + LVM_INT32 coefs[3]; /* pointer to the filter coefficients */ +}Filter_State; + +typedef Filter_State * PFilter_State ; + +#endif /*_BP_1I_D32F32CLL_TRC_WRA_02_PRIVATE_H_*/ diff --git a/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F16C15_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F16C15_TRC_WRA_01.c new file mode 100755 index 0000000..00e3b52 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F16C15_TRC_WRA_01.c @@ -0,0 +1,94 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "BQ_1I_D16F16Css_TRC_WRA_01_Private.h" +#include "LVM_Macros.h" + +/************************************************************************** + ASSUMPTIONS: + COEFS- + pBiquadState->coefs[0] is A2, pBiquadState->coefs[1] is A1 + pBiquadState->coefs[2] is A0, pBiquadState->coefs[3] is -B2 + pBiquadState->coefs[4] is -B1, these are in Q15 format + + DELAYS- + pBiquadState->pDelays[0] is x(n-1)L in Q0 format + pBiquadState->pDelays[1] is x(n-2)L in Q0 format + pBiquadState->pDelays[2] is y(n-1)L in Q0 format + pBiquadState->pDelays[3] is y(n-2)L in Q0 format +***************************************************************************/ + +void BQ_1I_D16F16C15_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples) + { + LVM_INT32 ynL; + LVM_INT16 ii; + PFilter_State pBiquadState = (PFilter_State) pInstance; + + for (ii = NrSamples; ii != 0; ii--) + { + + + /************************************************************************** + PROCESSING OF THE LEFT CHANNEL + ***************************************************************************/ + // ynL=A2 (Q15) * x(n-2)L (Q0) in Q15 + ynL=(LVM_INT32)pBiquadState->coefs[0]* pBiquadState->pDelays[1]; + + // ynL+=A1 (Q15) * x(n-1)L (Q0) in Q15 + ynL+=(LVM_INT32)pBiquadState->coefs[1]* pBiquadState->pDelays[0]; + + // ynL+=A0 (Q15) * x(n)L (Q0) in Q15 + ynL+=(LVM_INT32)pBiquadState->coefs[2]* (*pDataIn); + + // ynL+= (-B2 (Q15) * y(n-2)L (Q0) ) in Q15 + ynL+=(LVM_INT32)pBiquadState->coefs[3]*pBiquadState->pDelays[3]; + + // ynL+= (-B1 (Q15) * y(n-1)L (Q0) ) in Q15 + ynL+=(LVM_INT32)pBiquadState->coefs[4]*pBiquadState->pDelays[2]; + + ynL=ynL>>15; // ynL in Q0 format + /************************************************************************** + UPDATING THE DELAYS + ***************************************************************************/ + pBiquadState->pDelays[3]=pBiquadState->pDelays[2]; // y(n-2)L=y(n-1)L + pBiquadState->pDelays[1]=pBiquadState->pDelays[0]; // x(n-2)L=x(n-1)L + pBiquadState->pDelays[2]=ynL; // Update y(n-1)L in Q0 + pBiquadState->pDelays[0]=(*pDataIn++); // Update x(n-1)L in Q0 + + /************************************************************************** + WRITING THE OUTPUT + ***************************************************************************/ + *pDataOut++=(LVM_INT16)ynL; // Write Left output in Q0 + + + } + + } + diff --git a/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F16Css_TRC_WRA_01_Init.c b/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F16Css_TRC_WRA_01_Init.c new file mode 100755 index 0000000..3fedc45 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F16Css_TRC_WRA_01_Init.c @@ -0,0 +1,66 @@ +/* + * 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: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/*-------------------------------------------------------------------------*/ +#include "BIQUAD.h" +#include "BQ_1I_D16F16Css_TRC_WRA_01_Private.h" + +/*-------------------------------------------------------------------------*/ +/* FUNCTION: */ +/* BQ_1I_D16F16Css_TRC_WRA_01_Init */ +/* */ +/* DESCRIPTION: */ +/* These functions initializes a BIQUAD filter defined as a cascade of */ +/* biquadratic Filter Sections. */ +/* */ +/* PARAMETERS: */ +/* pInstance - output, returns the pointer to the State Variable */ +/* This state pointer must be passed to any subsequent */ +/* call to "Biquad" functions. */ +/* pTaps - input, pointer to the taps memory */ +/* pCoef - input, pointer to the coefficient structure */ +/* N - M coefficient factor of QM.N */ +/* RETURNS: */ +/* void return code */ +/*-------------------------------------------------------------------------*/ +void BQ_1I_D16F16Css_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance, + Biquad_1I_Order2_Taps_t *pTaps, + BQ_C16_Coefs_t *pCoef) +{ + LVM_INT16 temp; + PFilter_State pBiquadState = (PFilter_State) pInstance; + pBiquadState->pDelays =(LVM_INT32 *) pTaps ; + + temp=pCoef->A2; + pBiquadState->coefs[0]=temp; + temp=pCoef->A1; + pBiquadState->coefs[1]=temp; + temp=pCoef->A0; + pBiquadState->coefs[2]=temp; + temp=pCoef->B2; + pBiquadState->coefs[3]=temp; + temp=pCoef->B1; + pBiquadState->coefs[4]=temp; +} +/*-------------------------------------------------------------------------*/ +/* End Of File: BQ_1I_D16F16Css_TRC_WRA_01_Init.c */ + diff --git a/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F16Css_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F16Css_TRC_WRA_01_Private.h new file mode 100755 index 0000000..18dacd3 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F16Css_TRC_WRA_01_Private.h @@ -0,0 +1,38 @@ +/* + * 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 _BQ_1I_D16F16CSS_TRC_WRA_01_PRIVATE_H_ +#define _BQ_1I_D16F16CSS_TRC_WRA_01_PRIVATE_H_ +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/* The internal state variables are implemented in a (for the user) hidden structure */ +/* In this (private) file, the internal structure is declared fro private use. */ +typedef struct _Filter_State_ +{ + LVM_INT32 * pDelays; /* pointer to the delayed samples (data of 32 bits) */ + LVM_INT16 coefs[5]; /* pointer to the filter coefficients */ +}Filter_State; + +typedef Filter_State * PFilter_State ; + +#endif /*_BQ_1I_D16F16CSS_TRC_WRA_01_PRIVATE_H_ */ diff --git a/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F32C14_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F32C14_TRC_WRA_01.c new file mode 100755 index 0000000..cdff1d9 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F32C14_TRC_WRA_01.c @@ -0,0 +1,93 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "BQ_1I_D16F32Css_TRC_WRA_01_Private.h" +#include "LVM_Macros.h" + +/************************************************************************** + ASSUMPTIONS: + COEFS- + pBiquadState->coefs[0] is A2, pBiquadState->coefs[1] is A1 + pBiquadState->coefs[2] is A0, pBiquadState->coefs[3] is -B2 + pBiquadState->coefs[4] is -B1, these are in Q14 format + + DELAYS- + pBiquadState->pDelays[0] is x(n-1)L in Q0 format + pBiquadState->pDelays[1] is x(n-2)L in Q0 format + pBiquadState->pDelays[2] is y(n-1)L in Q16 format + pBiquadState->pDelays[3] is y(n-2)L in Q16 format +***************************************************************************/ + +void BQ_1I_D16F32C14_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples) + { + LVM_INT32 ynL,templ; + LVM_INT16 ii; + PFilter_State pBiquadState = (PFilter_State) pInstance; + + for (ii = NrSamples; ii != 0; ii--) + { + + + /************************************************************************** + PROCESSING OF THE LEFT CHANNEL + ***************************************************************************/ + // ynL=A2 (Q14) * x(n-2)L (Q0) in Q14 + ynL=(LVM_INT32)pBiquadState->coefs[0]* pBiquadState->pDelays[1]; + + // ynL+=A1 (Q14) * x(n-1)L (Q0) in Q14 + ynL+=(LVM_INT32)pBiquadState->coefs[1]* pBiquadState->pDelays[0]; + + // ynL+=A0 (Q14) * x(n)L (Q0) in Q14 + ynL+=(LVM_INT32)pBiquadState->coefs[2]* (*pDataIn); + + // ynL+= ( (-B2 (Q14) * y(n-2)L (Q16) )>>16) in Q14 + MUL32x16INTO32(pBiquadState->pDelays[3],pBiquadState->coefs[3],templ,16) + ynL+=templ; + + // ynL+= ( (-B1 (Q14) * y(n-1)L (Q16) )>>16) in Q14 + MUL32x16INTO32(pBiquadState->pDelays[2],pBiquadState->coefs[4],templ,16) + ynL+=templ; + + /************************************************************************** + UPDATING THE DELAYS + ***************************************************************************/ + pBiquadState->pDelays[3]=pBiquadState->pDelays[2]; // y(n-2)L=y(n-1)L + pBiquadState->pDelays[1]=pBiquadState->pDelays[0]; // x(n-2)L=x(n-1)L + pBiquadState->pDelays[2]=ynL<<2; // Update y(n-1)L in Q16 + pBiquadState->pDelays[0]=(*pDataIn++); // Update x(n-1)L in Q0 + + /************************************************************************** + WRITING THE OUTPUT + ***************************************************************************/ + *pDataOut++=(LVM_INT16)(ynL>>14); // Write Left output in Q0 + + } + } + diff --git a/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F32Css_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F32Css_TRC_WRA_01_Private.h new file mode 100755 index 0000000..bc88847 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F32Css_TRC_WRA_01_Private.h @@ -0,0 +1,38 @@ +/* + * 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 _BQ_1I_D16F32CSS_TRC_WRA_01_PRIVATE_H_ +#define _BQ_1I_D16F32CSS_TRC_WRA_01_PRIVATE_H_ +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/* The internal state variables are implemented in a (for the user) hidden structure */ +/* In this (private) file, the internal structure is declared fro private use. */ +typedef struct _Filter_State_ +{ + LVM_INT32 * pDelays; /* pointer to the delayed samples (data of 32 bits) */ + LVM_INT16 coefs[5]; /* pointer to the filter coefficients */ +}Filter_State; + +typedef Filter_State * PFilter_State ; + +#endif /*_BQ_1I_D16F32CSS_TRC_WRA_01_PRIVATE_H_*/ diff --git a/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F32Css_TRC_WRA_01_init.c b/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F32Css_TRC_WRA_01_init.c new file mode 100755 index 0000000..520c969 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F32Css_TRC_WRA_01_init.c @@ -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: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/*-------------------------------------------------------------------------*/ +#include "BIQUAD.h" +#include "BQ_1I_D16F32Css_TRC_WRA_01_Private.h" + + +/*-------------------------------------------------------------------------*/ +/* FUNCTION: */ +/* BQ_1I_D16F32Css_TRC_WRA_01_Init */ +/* */ +/* DESCRIPTION: */ +/* These functions initializes a BIQUAD filter defined as a cascade of */ +/* biquadratic Filter Sections. */ +/* */ +/* PARAMETERS: */ +/* pInstance - output, returns the pointer to the State Variable */ +/* This state pointer must be passed to any subsequent */ +/* call to "Biquad" functions. */ +/* pTaps - input, pointer to the taps memory */ +/* pCoef - input, pointer to the coefficient structure */ +/* N - M coefficient factor of QM.N */ +/* RETURNS: */ +/* void return code */ +/*-------------------------------------------------------------------------*/ +void BQ_1I_D16F32Css_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance, + Biquad_1I_Order2_Taps_t *pTaps, + BQ_C16_Coefs_t *pCoef) +{ + LVM_INT16 temp; + PFilter_State pBiquadState = (PFilter_State) pInstance; + pBiquadState->pDelays =(LVM_INT32 *) pTaps ; + + temp=pCoef->A2; + pBiquadState->coefs[0]=temp; + temp=pCoef->A1; + pBiquadState->coefs[1]=temp; + temp=pCoef->A0; + pBiquadState->coefs[2]=temp; + temp=pCoef->B2; + pBiquadState->coefs[3]=temp; + temp=pCoef->B1; + pBiquadState->coefs[4]=temp; +} +/*-------------------------------------------------------------------------*/ +/* End Of File: BQ_1I_D16F32Css_TRC_WRA_01_Init */ + diff --git a/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16C14_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16C14_TRC_WRA_01.c new file mode 100755 index 0000000..c267a90 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16C14_TRC_WRA_01.c @@ -0,0 +1,123 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "BQ_2I_D16F16Css_TRC_WRA_01_Private.h" +#include "LVM_Macros.h" + + +/************************************************************************** + ASSUMPTIONS: + COEFS- + pBiquadState->coefs[0] is A2, pBiquadState->coefs[1] is A1 + pBiquadState->coefs[2] is A0, pBiquadState->coefs[3] is -B2 + pBiquadState->coefs[4] is -B1, these are in Q14 format + + DELAYS- + pBiquadState->pDelays[0] is x(n-1)L in Q0 format + pBiquadState->pDelays[1] is x(n-1)R in Q0 format + pBiquadState->pDelays[2] is x(n-2)L in Q0 format + pBiquadState->pDelays[3] is x(n-2)R in Q0 format + pBiquadState->pDelays[4] is y(n-1)L in Q0 format + pBiquadState->pDelays[5] is y(n-1)R in Q0 format + pBiquadState->pDelays[6] is y(n-2)L in Q0 format + pBiquadState->pDelays[7] is y(n-2)R in Q0 format +***************************************************************************/ + +void BQ_2I_D16F16C14_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples) + { + LVM_INT32 ynL,ynR; + LVM_INT16 ii; + PFilter_State pBiquadState = (PFilter_State) pInstance; + + for (ii = NrSamples; ii != 0; ii--) + { + + /************************************************************************** + PROCESSING OF THE LEFT CHANNEL + ***************************************************************************/ + // ynL=A2 (Q14) * x(n-2)L (Q0) in Q14 + ynL=(LVM_INT32)pBiquadState->coefs[0]* pBiquadState->pDelays[2]; + + // ynL+=A1 (Q14) * x(n-1)L (Q0) in Q14 + ynL+=(LVM_INT32)pBiquadState->coefs[1]* pBiquadState->pDelays[0]; + + // ynL+=A0 (Q14) * x(n)L (Q0) in Q14 + ynL+=(LVM_INT32)pBiquadState->coefs[2]* (*pDataIn); + + // ynL+= ( -B2 (Q14) * y(n-2)L (Q0) ) in Q14 + ynL+=(LVM_INT32)pBiquadState->coefs[3]*pBiquadState->pDelays[6]; + + // ynL+=( -B1 (Q14) * y(n-1)L (Q0) ) in Q14 + ynL+=(LVM_INT32)pBiquadState->coefs[4]*pBiquadState->pDelays[4]; + + ynL=ynL>>14; // ynL in Q0 format + + /************************************************************************** + PROCESSING OF THE RIGHT CHANNEL + ***************************************************************************/ + // ynR=A2 (Q14) * x(n-2)R (Q0) in Q14 + ynR=(LVM_INT32)pBiquadState->coefs[0]*pBiquadState->pDelays[3]; + + // ynR+=A1 (Q14) * x(n-1)R (Q0) in Q14 + ynR+=(LVM_INT32)pBiquadState->coefs[1]*pBiquadState->pDelays[1]; + + // ynR+=A0 (Q14) * x(n)R (Q0) in Q14 + ynR+=(LVM_INT32)pBiquadState->coefs[2]*(*(pDataIn+1)); + + // ynR+= ( -B2 (Q14) * y(n-2)R (Q0) ) in Q14 + ynR+=(LVM_INT32)pBiquadState->coefs[3]*pBiquadState->pDelays[7]; + + // ynR+=( -B1 (Q14) * y(n-1)R (Q0) ) in Q14 + ynR+=(LVM_INT32)pBiquadState->coefs[4]*pBiquadState->pDelays[5]; + + ynR=ynR>>14; // ynL in Q0 format + /************************************************************************** + UPDATING THE DELAYS + ***************************************************************************/ + pBiquadState->pDelays[7]=pBiquadState->pDelays[5]; // y(n-2)R=y(n-1)R + pBiquadState->pDelays[6]=pBiquadState->pDelays[4]; // y(n-2)L=y(n-1)L + pBiquadState->pDelays[3]=pBiquadState->pDelays[1]; // x(n-2)R=x(n-1)R + pBiquadState->pDelays[2]=pBiquadState->pDelays[0]; // x(n-2)L=x(n-1)L + pBiquadState->pDelays[5]=ynR; // Update y(n-1)R in Q0 + pBiquadState->pDelays[4]=ynL; // Update y(n-1)L in Q0 + pBiquadState->pDelays[0]=(*pDataIn++); // Update x(n-1)L in Q0 + pBiquadState->pDelays[1]=(*pDataIn++); // Update x(n-1)R in Q0 + + /************************************************************************** + WRITING THE OUTPUT + ***************************************************************************/ + *pDataOut++=(LVM_INT16)ynL; // Write Left output in Q0 + *pDataOut++=(LVM_INT16)ynR; // Write Right ouput in Q0 + + + } + + } + diff --git a/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16C15_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16C15_TRC_WRA_01.c new file mode 100755 index 0000000..ded2bb3 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16C15_TRC_WRA_01.c @@ -0,0 +1,123 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "BQ_2I_D16F16Css_TRC_WRA_01_Private.h" +#include "LVM_Macros.h" + + +/************************************************************************** + ASSUMPTIONS: + COEFS- + pBiquadState->coefs[0] is A2, pBiquadState->coefs[1] is A1 + pBiquadState->coefs[2] is A0, pBiquadState->coefs[3] is -B2 + pBiquadState->coefs[4] is -B1, these are in Q15 format + + DELAYS- + pBiquadState->pDelays[0] is x(n-1)L in Q0 format + pBiquadState->pDelays[1] is x(n-1)R in Q0 format + pBiquadState->pDelays[2] is x(n-2)L in Q0 format + pBiquadState->pDelays[3] is x(n-2)R in Q0 format + pBiquadState->pDelays[4] is y(n-1)L in Q0 format + pBiquadState->pDelays[5] is y(n-1)R in Q0 format + pBiquadState->pDelays[6] is y(n-2)L in Q0 format + pBiquadState->pDelays[7] is y(n-2)R in Q0 format +***************************************************************************/ + +void BQ_2I_D16F16C15_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples) + { + LVM_INT32 ynL,ynR; + LVM_INT16 ii; + PFilter_State pBiquadState = (PFilter_State) pInstance; + + for (ii = NrSamples; ii != 0; ii--) + { + + + /************************************************************************** + PROCESSING OF THE LEFT CHANNEL + ***************************************************************************/ + // ynL=A2 (Q15) * x(n-2)L (Q0) in Q15 + ynL=(LVM_INT32)pBiquadState->coefs[0]* pBiquadState->pDelays[2]; + + // ynL+=A1 (Q15) * x(n-1)L (Q0) in Q15 + ynL+=(LVM_INT32)pBiquadState->coefs[1]* pBiquadState->pDelays[0]; + + // ynL+=A0 (Q15) * x(n)L (Q0) in Q15 + ynL+=(LVM_INT32)pBiquadState->coefs[2]* (*pDataIn); + + // ynL+= ( -B2 (Q15) * y(n-2)L (Q0) ) in Q15 + ynL+=(LVM_INT32)pBiquadState->coefs[3]*pBiquadState->pDelays[6]; + + // ynL+=( -B1 (Q15) * y(n-1)L (Q0) ) in Q15 + ynL+=(LVM_INT32)pBiquadState->coefs[4]*pBiquadState->pDelays[4]; + + ynL=ynL>>15; // ynL in Q0 format + + /************************************************************************** + PROCESSING OF THE RIGHT CHANNEL + ***************************************************************************/ + // ynR=A2 (Q15) * x(n-2)R (Q0) in Q15 + ynR=(LVM_INT32)pBiquadState->coefs[0]*pBiquadState->pDelays[3]; + + // ynR+=A1 (Q15) * x(n-1)R (Q0) in Q15 + ynR+=(LVM_INT32)pBiquadState->coefs[1]*pBiquadState->pDelays[1]; + + // ynR+=A0 (Q15) * x(n)R (Q0) in Q15 + ynR+=(LVM_INT32)pBiquadState->coefs[2]*(*(pDataIn+1)); + + // ynR+= ( -B2 (Q15) * y(n-2)R (Q0) ) in Q15 + ynR+=(LVM_INT32)pBiquadState->coefs[3]*pBiquadState->pDelays[7]; + + // ynR+=( -B1 (Q15) * y(n-1)R (Q0) ) in Q15 + ynR+=(LVM_INT32)pBiquadState->coefs[4]*pBiquadState->pDelays[5]; + + ynR=ynR>>15; // ynL in Q0 format + /************************************************************************** + UPDATING THE DELAYS + ***************************************************************************/ + pBiquadState->pDelays[7]=pBiquadState->pDelays[5]; // y(n-2)R=y(n-1)R + pBiquadState->pDelays[6]=pBiquadState->pDelays[4]; // y(n-2)L=y(n-1)L + pBiquadState->pDelays[3]=pBiquadState->pDelays[1]; // x(n-2)R=x(n-1)R + pBiquadState->pDelays[2]=pBiquadState->pDelays[0]; // x(n-2)L=x(n-1)L + pBiquadState->pDelays[5]=ynR; // Update y(n-1)R in Q0 + pBiquadState->pDelays[4]=ynL; // Update y(n-1)L in Q0 + pBiquadState->pDelays[0]=(*pDataIn++); // Update x(n-1)L in Q0 + pBiquadState->pDelays[1]=(*pDataIn++); // Update x(n-1)R in Q0 + + /************************************************************************** + WRITING THE OUTPUT + ***************************************************************************/ + *pDataOut++=(LVM_INT16)ynL; // Write Left output in Q0 + *pDataOut++=(LVM_INT16)ynR; // Write Right ouput in Q0 + + } + + } + diff --git a/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16Css_TRC_WRA_01_Init.c b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16Css_TRC_WRA_01_Init.c new file mode 100755 index 0000000..b0cd1b9 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16Css_TRC_WRA_01_Init.c @@ -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: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/*-------------------------------------------------------------------------*/ +#include "BIQUAD.h" +#include "BQ_2I_D16F16Css_TRC_WRA_01_Private.h" + + +/*-------------------------------------------------------------------------*/ +/* FUNCTION: */ +/* BQ_2I_D16F16Css_TRC_WRA_01_Init */ +/* */ +/* DESCRIPTION: */ +/* These functions initializes a BIQUAD filter defined as a cascade of */ +/* biquadratic Filter Sections. */ +/* */ +/* PARAMETERS: */ +/* pInstance - output, returns the pointer to the State Variable */ +/* This state pointer must be passed to any subsequent */ +/* call to "Biquad" functions. */ +/* pTaps - input, pointer to the taps memory */ +/* pCoef - input, pointer to the coefficient structure */ +/* N - M coefficient factor of QM.N */ +/* RETURNS: */ +/* void return code */ +/*-------------------------------------------------------------------------*/ +void BQ_2I_D16F16Css_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance, + Biquad_2I_Order2_Taps_t *pTaps, + BQ_C16_Coefs_t *pCoef) +{ + LVM_INT16 temp; + PFilter_State pBiquadState = (PFilter_State) pInstance; + pBiquadState->pDelays =(LVM_INT32 *) pTaps ; + + temp=pCoef->A2; + pBiquadState->coefs[0]=temp; + temp=pCoef->A1; + pBiquadState->coefs[1]=temp; + temp=pCoef->A0; + pBiquadState->coefs[2]=temp; + temp=pCoef->B2; + pBiquadState->coefs[3]=temp; + temp=pCoef->B1; + pBiquadState->coefs[4]=temp; +} +/*-------------------------------------------------------------------------*/ +/* End Of File: BQ_2I_D16F16Css_TRC_WRA_01_Init.c */ + diff --git a/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16Css_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16Css_TRC_WRA_01_Private.h new file mode 100755 index 0000000..bcb0093 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16Css_TRC_WRA_01_Private.h @@ -0,0 +1,40 @@ +/* + * 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 _BQ_2I_D16F16CSS_TRC_WRA_01_PRIVATE_H_ +#define _BQ_2I_D16F16CSS_TRC_WRA_01_PRIVATE_H_ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/* The internal state variables are implemented in a (for the user) hidden structure */ +/* In this (private) file, the internal structure is declared fro private use. */ +typedef struct _Filter_State_ +{ + LVM_INT32 * pDelays; /* pointer to the delayed samples (data of 32 bits) */ + LVM_INT16 coefs[5]; /* pointer to the filter coefficients */ +}Filter_State; + +typedef Filter_State * PFilter_State ; + +#endif /* _BQ_2I_D16F16CSS_TRC_WRA_01_PRIVATE_H_ */ diff --git a/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32C13_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32C13_TRC_WRA_01.c new file mode 100755 index 0000000..ae743f2 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32C13_TRC_WRA_01.c @@ -0,0 +1,127 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "BQ_2I_D16F32Css_TRC_WRA_01_Private.h" +#include "LVM_Macros.h" + + +/************************************************************************** + ASSUMPTIONS: + COEFS- + pBiquadState->coefs[0] is A2, pBiquadState->coefs[1] is A1 + pBiquadState->coefs[2] is A0, pBiquadState->coefs[3] is -B2 + pBiquadState->coefs[4] is -B1, these are in Q13 format + + DELAYS- + pBiquadState->pDelays[0] is x(n-1)L in Q0 format + pBiquadState->pDelays[1] is x(n-1)R in Q0 format + pBiquadState->pDelays[2] is x(n-2)L in Q0 format + pBiquadState->pDelays[3] is x(n-2)R in Q0 format + pBiquadState->pDelays[4] is y(n-1)L in Q16 format + pBiquadState->pDelays[5] is y(n-1)R in Q16 format + pBiquadState->pDelays[6] is y(n-2)L in Q16 format + pBiquadState->pDelays[7] is y(n-2)R in Q16 format +***************************************************************************/ + +void BQ_2I_D16F32C13_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples) + { + LVM_INT32 ynL,ynR,templ; + LVM_INT16 ii; + PFilter_State pBiquadState = (PFilter_State) pInstance; + + for (ii = NrSamples; ii != 0; ii--) + { + + + /************************************************************************** + PROCESSING OF THE LEFT CHANNEL + ***************************************************************************/ + /* ynL=A2 (Q13) * x(n-2)L (Q0) in Q13*/ + ynL=(LVM_INT32)pBiquadState->coefs[0]* pBiquadState->pDelays[2]; + + /* ynL+=A1 (Q13) * x(n-1)L (Q0) in Q13*/ + ynL+=(LVM_INT32)pBiquadState->coefs[1]* pBiquadState->pDelays[0]; + + /* ynL+=A0 (Q13) * x(n)L (Q0) in Q13*/ + ynL+=(LVM_INT32)pBiquadState->coefs[2]* (*pDataIn); + + /* ynL+= ( (-B2 (Q13) * y(n-2)L (Q16) )>>16) in Q13 */ + MUL32x16INTO32(pBiquadState->pDelays[6],pBiquadState->coefs[3],templ,16) + ynL+=templ; + + /* ynL+=( (-B1 (Q13) * y(n-1)L (Q16) )>>16) in Q13 */ + MUL32x16INTO32(pBiquadState->pDelays[4],pBiquadState->coefs[4],templ,16) + ynL+=templ; + + /************************************************************************** + PROCESSING OF THE RIGHT CHANNEL + ***************************************************************************/ + /* ynR=A2 (Q13) * x(n-2)R (Q0) in Q13*/ + ynR=(LVM_INT32)pBiquadState->coefs[0]*pBiquadState->pDelays[3]; + + /* ynR+=A1 (Q13) * x(n-1)R (Q0) in Q13*/ + ynR+=(LVM_INT32)pBiquadState->coefs[1]*pBiquadState->pDelays[1]; + + /* ynR+=A0 (Q13) * x(n)R (Q0) in Q13*/ + ynR+=(LVM_INT32)pBiquadState->coefs[2]*(*(pDataIn+1)); + + /* ynR+= ( (-B2 (Q13) * y(n-2)R (Q16) )>>16) in Q13*/ + MUL32x16INTO32(pBiquadState->pDelays[7],pBiquadState->coefs[3],templ,16) + ynR+=templ; + + /* ynR+=( (-B1 (Q13) * y(n-1)R (Q16) )>>16) in Q13 */ + MUL32x16INTO32(pBiquadState->pDelays[5],pBiquadState->coefs[4],templ,16) + ynR+=templ; + + /************************************************************************** + UPDATING THE DELAYS + ***************************************************************************/ + pBiquadState->pDelays[7]=pBiquadState->pDelays[5]; /* y(n-2)R=y(n-1)R*/ + pBiquadState->pDelays[6]=pBiquadState->pDelays[4]; /* y(n-2)L=y(n-1)L*/ + pBiquadState->pDelays[3]=pBiquadState->pDelays[1]; /* x(n-2)R=x(n-1)R*/ + pBiquadState->pDelays[2]=pBiquadState->pDelays[0]; /* x(n-2)L=x(n-1)L*/ + pBiquadState->pDelays[5]=ynR<<3; /* Update y(n-1)R in Q16*/ + pBiquadState->pDelays[4]=ynL<<3; /* Update y(n-1)L in Q16*/ + pBiquadState->pDelays[0]=(*pDataIn); /* Update x(n-1)L in Q0*/ + pDataIn++; + pBiquadState->pDelays[1]=(*pDataIn); /* Update x(n-1)R in Q0*/ + pDataIn++; + + /************************************************************************** + WRITING THE OUTPUT + ***************************************************************************/ + *pDataOut=(LVM_INT16)(ynL>>13); /* Write Left output in Q0*/ + pDataOut++; + *pDataOut=(LVM_INT16)(ynR>>13); /* Write Right ouput in Q0*/ + pDataOut++; + } + + } + diff --git a/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32C14_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32C14_TRC_WRA_01.c new file mode 100755 index 0000000..a0ca2cc --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32C14_TRC_WRA_01.c @@ -0,0 +1,126 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "BQ_2I_D16F32Css_TRC_WRA_01_Private.h" +#include "LVM_Macros.h" + +/************************************************************************** + ASSUMPTIONS: + COEFS- + pBiquadState->coefs[0] is A2, pBiquadState->coefs[1] is A1 + pBiquadState->coefs[2] is A0, pBiquadState->coefs[3] is -B2 + pBiquadState->coefs[4] is -B1, these are in Q14 format + + DELAYS- + pBiquadState->pDelays[0] is x(n-1)L in Q0 format + pBiquadState->pDelays[1] is x(n-1)R in Q0 format + pBiquadState->pDelays[2] is x(n-2)L in Q0 format + pBiquadState->pDelays[3] is x(n-2)R in Q0 format + pBiquadState->pDelays[4] is y(n-1)L in Q16 format + pBiquadState->pDelays[5] is y(n-1)R in Q16 format + pBiquadState->pDelays[6] is y(n-2)L in Q16 format + pBiquadState->pDelays[7] is y(n-2)R in Q16 format +***************************************************************************/ + +void BQ_2I_D16F32C14_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples) + { + LVM_INT32 ynL,ynR,templ; + LVM_INT16 ii; + PFilter_State pBiquadState = (PFilter_State) pInstance; + + for (ii = NrSamples; ii != 0; ii--) + { + + + /************************************************************************** + PROCESSING OF THE LEFT CHANNEL + ***************************************************************************/ + /* ynL=A2 (Q14) * x(n-2)L (Q0) in Q14*/ + ynL=(LVM_INT32)pBiquadState->coefs[0]* pBiquadState->pDelays[2]; + + /* ynL+=A1 (Q14) * x(n-1)L (Q0) in Q14*/ + ynL+=(LVM_INT32)pBiquadState->coefs[1]* pBiquadState->pDelays[0]; + + /* ynL+=A0 (Q14) * x(n)L (Q0) in Q14*/ + ynL+=(LVM_INT32)pBiquadState->coefs[2]* (*pDataIn); + + /* ynL+= ( (-B2 (Q14) * y(n-2)L (Q16) )>>16) in Q14 */ + MUL32x16INTO32(pBiquadState->pDelays[6],pBiquadState->coefs[3],templ,16) + ynL+=templ; + + /* ynL+=( (-B1 (Q14) * y(n-1)L (Q16) )>>16) in Q14 */ + MUL32x16INTO32(pBiquadState->pDelays[4],pBiquadState->coefs[4],templ,16) + ynL+=templ; + + /************************************************************************** + PROCESSING OF THE RIGHT CHANNEL + ***************************************************************************/ + /* ynR=A2 (Q14) * x(n-2)R (Q0) in Q14*/ + ynR=(LVM_INT32)pBiquadState->coefs[0]*pBiquadState->pDelays[3]; + + /* ynR+=A1 (Q14) * x(n-1)R (Q0) in Q14*/ + ynR+=(LVM_INT32)pBiquadState->coefs[1]*pBiquadState->pDelays[1]; + + /* ynR+=A0 (Q14) * x(n)R (Q0) in Q14*/ + ynR+=(LVM_INT32)pBiquadState->coefs[2]*(*(pDataIn+1)); + + /* ynR+= ( (-B2 (Q14) * y(n-2)R (Q16) )>>16) in Q14*/ + MUL32x16INTO32(pBiquadState->pDelays[7],pBiquadState->coefs[3],templ,16) + ynR+=templ; + + /* ynR+=( (-B1 (Q14) * y(n-1)R (Q16) )>>16) in Q14 */ + MUL32x16INTO32(pBiquadState->pDelays[5],pBiquadState->coefs[4],templ,16) + ynR+=templ; + + /************************************************************************** + UPDATING THE DELAYS + ***************************************************************************/ + pBiquadState->pDelays[7]=pBiquadState->pDelays[5]; /* y(n-2)R=y(n-1)R*/ + pBiquadState->pDelays[6]=pBiquadState->pDelays[4]; /* y(n-2)L=y(n-1)L*/ + pBiquadState->pDelays[3]=pBiquadState->pDelays[1]; /* x(n-2)R=x(n-1)R*/ + pBiquadState->pDelays[2]=pBiquadState->pDelays[0]; /* x(n-2)L=x(n-1)L*/ + pBiquadState->pDelays[5]=ynR<<2; /* Update y(n-1)R in Q16*/ + pBiquadState->pDelays[4]=ynL<<2; /* Update y(n-1)L in Q16*/ + pBiquadState->pDelays[0]=(*pDataIn); /* Update x(n-1)L in Q0*/ + pDataIn++; + pBiquadState->pDelays[1]=(*pDataIn); /* Update x(n-1)R in Q0*/ + pDataIn++; + + /************************************************************************** + WRITING THE OUTPUT + ***************************************************************************/ + *pDataOut=(LVM_INT16)(ynL>>14); /* Write Left output in Q0*/ + pDataOut++; + *pDataOut=(LVM_INT16)(ynR>>14); /* Write Right ouput in Q0*/ + pDataOut++; + } + + } + diff --git a/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32C15_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32C15_TRC_WRA_01.c new file mode 100755 index 0000000..f1ab815 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32C15_TRC_WRA_01.c @@ -0,0 +1,126 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "BQ_2I_D16F32Css_TRC_WRA_01_Private.h" +#include "LVM_Macros.h" + +/************************************************************************** + ASSUMPTIONS: + COEFS- + pBiquadState->coefs[0] is A2, pBiquadState->coefs[1] is A1 + pBiquadState->coefs[2] is A0, pBiquadState->coefs[3] is -B2 + pBiquadState->coefs[4] is -B1, these are in Q15 format + + DELAYS- + pBiquadState->pDelays[0] is x(n-1)L in Q0 format + pBiquadState->pDelays[1] is x(n-1)R in Q0 format + pBiquadState->pDelays[2] is x(n-2)L in Q0 format + pBiquadState->pDelays[3] is x(n-2)R in Q0 format + pBiquadState->pDelays[4] is y(n-1)L in Q16 format + pBiquadState->pDelays[5] is y(n-1)R in Q16 format + pBiquadState->pDelays[6] is y(n-2)L in Q16 format + pBiquadState->pDelays[7] is y(n-2)R in Q16 format +***************************************************************************/ + +void BQ_2I_D16F32C15_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples) + { + LVM_INT32 ynL,ynR,templ; + LVM_INT16 ii; + PFilter_State pBiquadState = (PFilter_State) pInstance; + + for (ii = NrSamples; ii != 0; ii--) + { + + + /************************************************************************** + PROCESSING OF THE LEFT CHANNEL + ***************************************************************************/ + /* ynL=A2 (Q15) * x(n-2)L (Q0) in Q15*/ + ynL=(LVM_INT32)pBiquadState->coefs[0]* pBiquadState->pDelays[2]; + + /* ynL+=A1 (Q15) * x(n-1)L (Q0) in Q15*/ + ynL+=(LVM_INT32)pBiquadState->coefs[1]* pBiquadState->pDelays[0]; + + /* ynL+=A0 (Q15) * x(n)L (Q0) in Q15*/ + ynL+=(LVM_INT32)pBiquadState->coefs[2]* (*pDataIn); + + /* ynL+= ( (-B2 (Q15) * y(n-2)L (Q16) )>>16) in Q15 */ + MUL32x16INTO32(pBiquadState->pDelays[6],pBiquadState->coefs[3],templ,16) + ynL+=templ; + + /* ynL+=( (-B1 (Q15) * y(n-1)L (Q16) )>>16) in Q15 */ + MUL32x16INTO32(pBiquadState->pDelays[4],pBiquadState->coefs[4],templ,16) + ynL+=templ; + + /************************************************************************** + PROCESSING OF THE RIGHT CHANNEL + ***************************************************************************/ + /* ynR=A2 (Q15) * x(n-2)R (Q0) in Q15*/ + ynR=(LVM_INT32)pBiquadState->coefs[0]*pBiquadState->pDelays[3]; + + /* ynR+=A1 (Q15) * x(n-1)R (Q0) in Q15*/ + ynR+=(LVM_INT32)pBiquadState->coefs[1]*pBiquadState->pDelays[1]; + + /* ynR+=A0 (Q15) * x(n)R (Q0) in Q15*/ + ynR+=(LVM_INT32)pBiquadState->coefs[2]*(*(pDataIn+1)); + + /* ynR+= ( (-B2 (Q15) * y(n-2)R (Q16) )>>16) in Q15 */ + MUL32x16INTO32(pBiquadState->pDelays[7],pBiquadState->coefs[3],templ,16) + ynR+=templ; + + /* ynR+=( (-B1 (Q15) * y(n-1)R (Q16) )>>16) in Q15 */ + MUL32x16INTO32(pBiquadState->pDelays[5],pBiquadState->coefs[4],templ,16) + ynR+=templ; + + /************************************************************************** + UPDATING THE DELAYS + ***************************************************************************/ + pBiquadState->pDelays[7]=pBiquadState->pDelays[5]; /* y(n-2)R=y(n-1)R*/ + pBiquadState->pDelays[6]=pBiquadState->pDelays[4]; /* y(n-2)L=y(n-1)L*/ + pBiquadState->pDelays[3]=pBiquadState->pDelays[1]; /* x(n-2)R=x(n-1)R*/ + pBiquadState->pDelays[2]=pBiquadState->pDelays[0]; /* x(n-2)L=x(n-1)L*/ + pBiquadState->pDelays[5]=ynR<<1; /* Update y(n-1)R in Q16*/ + pBiquadState->pDelays[4]=ynL<<1; /* Update y(n-1)L in Q16*/ + pBiquadState->pDelays[0]=(*pDataIn); /* Update x(n-1)L in Q0*/ + pDataIn++; + pBiquadState->pDelays[1]=(*pDataIn); /* Update x(n-1)R in Q0*/ + pDataIn++; + + /************************************************************************** + WRITING THE OUTPUT + ***************************************************************************/ + *pDataOut=(LVM_INT16)(ynL>>15); /* Write Left output in Q0*/ + pDataOut++; + *pDataOut=(LVM_INT16)(ynR>>15); /* Write Right ouput in Q0*/ + pDataOut++; + } + + } + diff --git a/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32Css_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32Css_TRC_WRA_01_Private.h new file mode 100755 index 0000000..3cbb58b --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32Css_TRC_WRA_01_Private.h @@ -0,0 +1,40 @@ +/* + * 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 _BQ_2I_D16F32CSS_TRC_WRA_01_PRIVATE_H_ +#define _BQ_2I_D16F32CSS_TRC_WRA_01_PRIVATE_H_ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/* The internal state variables are implemented in a (for the user) hidden structure */ +/* In this (private) file, the internal structure is declared fro private use. */ +typedef struct _Filter_State_ +{ + LVM_INT32 * pDelays; /* pointer to the delayed samples (data of 32 bits) */ + LVM_INT16 coefs[5]; /* pointer to the filter coefficients */ +}Filter_State; + +typedef Filter_State * PFilter_State ; + +#endif /* _BQ_2I_D16F32CSS_TRC_WRA_01_PRIVATE_H_ */ diff --git a/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32Css_TRC_WRA_01_init.c b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32Css_TRC_WRA_01_init.c new file mode 100755 index 0000000..0c6b33e --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32Css_TRC_WRA_01_init.c @@ -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: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ +#include "BIQUAD.h" +#include "BQ_2I_D16F32Css_TRC_WRA_01_Private.h" + + +/*-------------------------------------------------------------------------*/ +/* FUNCTION: */ +/* BQ_2I_D16F32Css_TRC_WRA_01_Init */ +/* */ +/* DESCRIPTION: */ +/* These functions initializes a BIQUAD filter defined as a cascade of */ +/* biquadratic Filter Sections. */ +/* */ +/* PARAMETERS: */ +/* pInstance - output, returns the pointer to the State Variable */ +/* This state pointer must be passed to any subsequent */ +/* call to "Biquad" functions. */ +/* pTaps - input, pointer to the taps memory */ +/* pCoef - input, pointer to the coefficient structure */ +/* N - M coefficient factor of QM.N */ +/* RETURNS: */ +/* void return code */ +/*-------------------------------------------------------------------------*/ +void BQ_2I_D16F32Css_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance, + Biquad_2I_Order2_Taps_t *pTaps, + BQ_C16_Coefs_t *pCoef) +{ + LVM_INT16 temp; + PFilter_State pBiquadState = (PFilter_State) pInstance; + pBiquadState->pDelays =(LVM_INT32 *) pTaps ; + + temp=pCoef->A2; + pBiquadState->coefs[0]=temp; + temp=pCoef->A1; + pBiquadState->coefs[1]=temp; + temp=pCoef->A0; + pBiquadState->coefs[2]=temp; + temp=pCoef->B2; + pBiquadState->coefs[3]=temp; + temp=pCoef->B1; + pBiquadState->coefs[4]=temp; +} +/*-------------------------------------------------------------------------*/ +/* End Of File: BQ_2I_D16F32Css_TRC_WRA_01_Init */ + diff --git a/media/libeffects/lvm/lib/Common/src/BQ_2I_D32F32C30_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/BQ_2I_D32F32C30_TRC_WRA_01.c new file mode 100755 index 0000000..51278cf --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BQ_2I_D32F32C30_TRC_WRA_01.c @@ -0,0 +1,135 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "BQ_2I_D32F32Cll_TRC_WRA_01_Private.h" +#include "LVM_Macros.h" + +/************************************************************************** + ASSUMPTIONS: + COEFS- + pBiquadState->coefs[0] is A2, pBiquadState->coefs[1] is A1 + pBiquadState->coefs[2] is A0, pBiquadState->coefs[3] is -B2 + pBiquadState->coefs[4] is -B1, these are in Q30 format + + DELAYS- + pBiquadState->pDelays[0] is x(n-1)L in Q0 format + pBiquadState->pDelays[1] is x(n-1)R in Q0 format + pBiquadState->pDelays[2] is x(n-2)L in Q0 format + pBiquadState->pDelays[3] is x(n-2)R in Q0 format + pBiquadState->pDelays[4] is y(n-1)L in Q0 format + pBiquadState->pDelays[5] is y(n-1)R in Q0 format + pBiquadState->pDelays[6] is y(n-2)L in Q0 format + pBiquadState->pDelays[7] is y(n-2)R in Q0 format +***************************************************************************/ + +void BQ_2I_D32F32C30_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT32 *pDataIn, + LVM_INT32 *pDataOut, + LVM_INT16 NrSamples) + + + { + LVM_INT32 ynL,ynR,templ,tempd; + LVM_INT16 ii; + PFilter_State pBiquadState = (PFilter_State) pInstance; + + for (ii = NrSamples; ii != 0; ii--) + { + + + /************************************************************************** + PROCESSING OF THE LEFT CHANNEL + ***************************************************************************/ + /* ynL= ( A2 (Q30) * x(n-2)L (Q0) ) >>30 in Q0*/ + MUL32x32INTO32(pBiquadState->coefs[0],pBiquadState->pDelays[2],ynL,30) + + /* ynL+= ( A1 (Q30) * x(n-1)L (Q0) ) >> 30 in Q0*/ + MUL32x32INTO32(pBiquadState->coefs[1],pBiquadState->pDelays[0],templ,30) + ynL+=templ; + + /* ynL+= ( A0 (Q30) * x(n)L (Q0) ) >> 30 in Q0*/ + MUL32x32INTO32(pBiquadState->coefs[2],*pDataIn,templ,30) + ynL+=templ; + + /* ynL+= (-B2 (Q30) * y(n-2)L (Q0) ) >> 30 in Q0*/ + MUL32x32INTO32(pBiquadState->coefs[3],pBiquadState->pDelays[6],templ,30) + ynL+=templ; + + /* ynL+= (-B1 (Q30) * y(n-1)L (Q0) ) >> 30 in Q0 */ + MUL32x32INTO32(pBiquadState->coefs[4],pBiquadState->pDelays[4],templ,30) + ynL+=templ; + + /************************************************************************** + PROCESSING OF THE RIGHT CHANNEL + ***************************************************************************/ + /* ynR= ( A2 (Q30) * x(n-2)R (Q0) ) >> 30 in Q0*/ + MUL32x32INTO32(pBiquadState->coefs[0],pBiquadState->pDelays[3],ynR,30) + + /* ynR+= ( A1 (Q30) * x(n-1)R (Q0) ) >> 30 in Q0*/ + MUL32x32INTO32(pBiquadState->coefs[1],pBiquadState->pDelays[1],templ,30) + ynR+=templ; + + /* ynR+= ( A0 (Q30) * x(n)R (Q0) ) >> 30 in Q0*/ + tempd=*(pDataIn+1); + MUL32x32INTO32(pBiquadState->coefs[2],tempd,templ,30) + ynR+=templ; + + /* ynR+= (-B2 (Q30) * y(n-2)R (Q0) ) >> 30 in Q0*/ + MUL32x32INTO32(pBiquadState->coefs[3],pBiquadState->pDelays[7],templ,30) + ynR+=templ; + + /* ynR+= (-B1 (Q30) * y(n-1)R (Q0) ) >> 30 in Q0 */ + MUL32x32INTO32(pBiquadState->coefs[4],pBiquadState->pDelays[5],templ,30) + ynR+=templ; + + /************************************************************************** + UPDATING THE DELAYS + ***************************************************************************/ + pBiquadState->pDelays[7]=pBiquadState->pDelays[5]; /* y(n-2)R=y(n-1)R*/ + pBiquadState->pDelays[6]=pBiquadState->pDelays[4]; /* y(n-2)L=y(n-1)L*/ + pBiquadState->pDelays[3]=pBiquadState->pDelays[1]; /* x(n-2)R=x(n-1)R*/ + pBiquadState->pDelays[2]=pBiquadState->pDelays[0]; /* x(n-2)L=x(n-1)L*/ + pBiquadState->pDelays[5]=(LVM_INT32)ynR; /* Update y(n-1)R in Q0*/ + pBiquadState->pDelays[4]=(LVM_INT32)ynL; /* Update y(n-1)L in Q0*/ + pBiquadState->pDelays[0]=(*pDataIn); /* Update x(n-1)L in Q0*/ + pDataIn++; + pBiquadState->pDelays[1]=(*pDataIn); /* Update x(n-1)R in Q0*/ + pDataIn++; + + /************************************************************************** + WRITING THE OUTPUT + ***************************************************************************/ + *pDataOut=(LVM_INT32)ynL; /* Write Left output in Q0*/ + pDataOut++; + *pDataOut=(LVM_INT32)ynR; /* Write Right ouput in Q0*/ + pDataOut++; + + + } + + } + diff --git a/media/libeffects/lvm/lib/Common/src/BQ_2I_D32F32Cll_TRC_WRA_01_Init.c b/media/libeffects/lvm/lib/Common/src/BQ_2I_D32F32Cll_TRC_WRA_01_Init.c new file mode 100755 index 0000000..7c460d3 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BQ_2I_D32F32Cll_TRC_WRA_01_Init.c @@ -0,0 +1,66 @@ +/* + * 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: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/*-------------------------------------------------------------------------*/ +#include "BIQUAD.h" +#include "BQ_2I_D32F32Cll_TRC_WRA_01_Private.h" + +/*-------------------------------------------------------------------------*/ +/* FUNCTION: */ +/* BQ_2I_D32F32Cll_TRC_WRA_01_Init */ +/* */ +/* DESCRIPTION: */ +/* These functions initializes a BIQUAD filter defined as a cascade of */ +/* biquadratic Filter Sections. */ +/* */ +/* PARAMETERS: */ +/* pInstance - output, returns the pointer to the State Variable */ +/* This state pointer must be passed to any subsequent */ +/* call to "Biquad" functions. */ +/* pTaps - input, pointer to the taps memory */ +/* pCoef - input, pointer to the coefficient structure */ +/* N - M coefficient factor of QM.N */ +/* RETURNS: */ +/* void return code */ +/*-------------------------------------------------------------------------*/ +void BQ_2I_D32F32Cll_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance, + Biquad_2I_Order2_Taps_t *pTaps, + BQ_C32_Coefs_t *pCoef) +{ + LVM_INT32 temp; + PFilter_State pBiquadState = (PFilter_State) pInstance; + pBiquadState->pDelays =(LVM_INT32 *) pTaps ; + + temp=pCoef->A2; + pBiquadState->coefs[0]=temp; + temp=pCoef->A1; + pBiquadState->coefs[1]=temp; + temp=pCoef->A0; + pBiquadState->coefs[2]=temp; + temp=pCoef->B2; + pBiquadState->coefs[3]=temp; + temp=pCoef->B1; + pBiquadState->coefs[4]=temp; +} +/*-------------------------------------------------------------------------*/ +/* End Of File: BQ_2I_D32F32C32_TRC_WRA_01_Init.c */ + diff --git a/media/libeffects/lvm/lib/Common/src/BQ_2I_D32F32Cll_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/BQ_2I_D32F32Cll_TRC_WRA_01_Private.h new file mode 100755 index 0000000..fb4f2dd --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BQ_2I_D32F32Cll_TRC_WRA_01_Private.h @@ -0,0 +1,41 @@ +/* + * 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 _BQ_2I_D32F32CLL_TRC_WRA_01_PRIVATE_H_ +#define _BQ_2I_D32F32CLL_TRC_WRA_01_PRIVATE_H_ + + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/* The internal state variables are implemented in a (for the user) hidden structure */ +/* In this (private) file, the internal structure is declared fro private use. */ +typedef struct _Filter_State_ +{ + LVM_INT32 * pDelays; /* pointer to the delayed samples (data of 32 bits) */ + LVM_INT32 coefs[5]; /* pointer to the filter coefficients */ +}Filter_State; + +typedef Filter_State * PFilter_State ; + +#endif /* _BQ_2I_D32F32CLL_TRC_WRA_01_PRIVATE_H_*/ diff --git a/media/libeffects/lvm/lib/Common/src/CompLim_private.h b/media/libeffects/lvm/lib/Common/src/CompLim_private.h new file mode 100755 index 0000000..07a8833 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/CompLim_private.h @@ -0,0 +1,52 @@ +/* + * 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: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +#ifndef _COMP_LIM_PRIVATE_ +#define _COMP_LIM_PRIVATE_ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "CompLim.h" + +/********************************************************************************** + DEFINITIONS +***********************************************************************************/ + +#define FS_48K 48000 + +#define INTEGER_16 0xFFFF /* 65535*/ +#define INTEGER_15 0x7FFF /* 32767*/ + +#define GAIN_6DB 1 +#define GAIN_12DB 2 +#define GAIN_18DB 3 +#define GAIN_24DB 4 + +#endif /* #ifndef _COMP_LIM_PRIVATE_ */ + +/*** End of file ******************************************************************/ + diff --git a/media/libeffects/lvm/lib/Common/src/Copy_16.c b/media/libeffects/lvm/lib/Common/src/Copy_16.c new file mode 100755 index 0000000..6ee1ff6 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/Copy_16.c @@ -0,0 +1,66 @@ +/* + * 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: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION COPY_16 +***********************************************************************************/ + +void Copy_16( const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n ) +{ + LVM_INT16 ii; + + if (src > dst) + { + for (ii = n; ii != 0; ii--) + { + *dst = *src; + dst++; + src++; + } + } + else + { + src += n - 1; + dst += n - 1; + for (ii = n; ii != 0; ii--) + { + *dst = *src; + dst--; + src--; + } + } + + return; +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/Core_MixHard_2St_D32C31_SAT.c b/media/libeffects/lvm/lib/Common/src/Core_MixHard_2St_D32C31_SAT.c new file mode 100755 index 0000000..adac24f --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/Core_MixHard_2St_D32C31_SAT.c @@ -0,0 +1,69 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "Mixer_private.h" +#include "LVM_Macros.h" + +/********************************************************************************** + FUNCTION CORE_MIXHARD_2ST_D32C31_SAT +***********************************************************************************/ + +void Core_MixHard_2St_D32C31_SAT( Mix_2St_Cll_t *pInstance, + const LVM_INT32 *src1, + const LVM_INT32 *src2, + LVM_INT32 *dst, + LVM_INT16 n) +{ + LVM_INT32 Temp1,Temp2,Temp3; + LVM_INT16 ii; + LVM_INT16 Current1Short; + LVM_INT16 Current2Short; + + Current1Short = (LVM_INT16)(pInstance->Current1 >> 16); + Current2Short = (LVM_INT16)(pInstance->Current2 >> 16); + + for (ii = n; ii != 0; ii--){ + Temp1=*src1++; + MUL32x16INTO32(Temp1,Current1Short,Temp3,15) + Temp2=*src2++; + MUL32x16INTO32(Temp2,Current2Short,Temp1,15) + Temp2=(Temp1>>1)+(Temp3>>1); + if (Temp2 > 0x3FFFFFFF) + Temp2 = 0x7FFFFFFF; + else if (Temp2 < - 0x40000000) + Temp2 = 0x80000000; + else + Temp2=(Temp2<<1); + *dst++ = Temp2; + } +} + + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/Core_MixInSoft_D32C31_SAT.c b/media/libeffects/lvm/lib/Common/src/Core_MixInSoft_D32C31_SAT.c new file mode 100755 index 0000000..d557f6e --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/Core_MixInSoft_D32C31_SAT.c @@ -0,0 +1,103 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "Mixer_private.h" +#include "LVM_Macros.h" + +/********************************************************************************** + FUNCTION CORE_MIXSOFT_1ST_D32C31_WRA +***********************************************************************************/ + +void Core_MixInSoft_D32C31_SAT( Mix_1St_Cll_t *pInstance, + const LVM_INT32 *src, + LVM_INT32 *dst, + LVM_INT16 n) +{ + LVM_INT32 Temp1,Temp2,Temp3; + LVM_INT16 OutLoop; + LVM_INT16 InLoop; + LVM_INT32 TargetTimesOneMinAlpha; + LVM_INT32 CurrentTimesAlpha; + LVM_INT16 ii,jj; + LVM_INT16 CurrentShort; + + InLoop = (LVM_INT16)(n >> 2); /* Process per 4 samples */ + OutLoop = (LVM_INT16)(n - (InLoop << 2)); + + MUL32x32INTO32((0x7FFFFFFF-pInstance->Alpha),pInstance->Target,TargetTimesOneMinAlpha,31); /* Q31 * Q0 in Q0 */ + if (pInstance->Target >= pInstance->Current){ + TargetTimesOneMinAlpha +=2; /* Ceil*/ + } + + if (OutLoop){ + MUL32x32INTO32(pInstance->Current,pInstance->Alpha,CurrentTimesAlpha,31); /* Q0 * Q31 in Q0 */ + pInstance->Current = TargetTimesOneMinAlpha + CurrentTimesAlpha; /* Q0 + Q0 into Q0*/ + CurrentShort = (LVM_INT16)(pInstance->Current>>16); /* From Q31 to Q15*/ + + for (ii = OutLoop; ii != 0; ii--){ + Temp1=*src++; + Temp2=*dst; + MUL32x16INTO32(Temp1,CurrentShort,Temp3,15) + Temp1=(Temp2>>1)+(Temp3>>1); + + if (Temp1 > 0x3FFFFFFF) + Temp1 = 0x7FFFFFFF; + else if (Temp1 < - 0x40000000) + Temp1 = 0x80000000; + else + Temp1=(Temp1<<1); + *dst++ = Temp1; + } + } + + for (ii = InLoop; ii != 0; ii--){ + MUL32x32INTO32(pInstance->Current,pInstance->Alpha,CurrentTimesAlpha,31); /* Q0 * Q31 in Q0 */ + pInstance->Current = TargetTimesOneMinAlpha + CurrentTimesAlpha; /* Q0 + Q0 into Q0*/ + CurrentShort = (LVM_INT16)(pInstance->Current>>16); /* From Q31 to Q15*/ + + for (jj = 4; jj!=0 ; jj--){ + Temp1=*src++; + Temp2=*dst; + MUL32x16INTO32(Temp1,CurrentShort,Temp3,15) + Temp1=(Temp2>>1)+(Temp3>>1); + + if (Temp1 > 0x3FFFFFFF) + Temp1 = 0x7FFFFFFF; + else if (Temp1 < - 0x40000000) + Temp1 = 0x80000000; + else + Temp1=(Temp1<<1); + *dst++ = Temp1; + } + } +} + + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/Core_MixSoft_1St_D32C31_WRA.c b/media/libeffects/lvm/lib/Common/src/Core_MixSoft_1St_D32C31_WRA.c new file mode 100755 index 0000000..7b4e66d --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/Core_MixSoft_1St_D32C31_WRA.c @@ -0,0 +1,112 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "Mixer_private.h" +#include "LVM_Macros.h" + +/********************************************************************************** + FUNCTION CORE_MIXSOFT_1ST_D32C31_WRA +***********************************************************************************/ + +void Core_MixSoft_1St_D32C31_WRA( Mix_1St_Cll_t *pInstance, + const LVM_INT32 *src, + LVM_INT32 *dst, + LVM_INT16 n) +{ + LVM_INT32 Temp1,Temp2; + LVM_INT16 OutLoop; + LVM_INT16 InLoop; + LVM_INT32 TargetTimesOneMinAlpha; + LVM_INT32 CurrentTimesAlpha; + LVM_INT16 CurrentShort; + LVM_INT16 ii; + + InLoop = (LVM_INT16)(n >> 2); /* Process per 4 samples */ + OutLoop = (LVM_INT16)(n - (InLoop << 2)); + + MUL32x32INTO32((0x7FFFFFFF-pInstance->Alpha),pInstance->Target,TargetTimesOneMinAlpha,31) /* Q31 * Q31 in Q31 */ + if (pInstance->Target >= pInstance->Current) + { + TargetTimesOneMinAlpha +=2; /* Ceil*/ + } + + if (OutLoop!=0) + { + MUL32x32INTO32(pInstance->Current,pInstance->Alpha,CurrentTimesAlpha,31) /* Q31 * Q31 in Q31 */ + pInstance->Current = TargetTimesOneMinAlpha + CurrentTimesAlpha; /* Q31 + Q31 into Q31*/ + CurrentShort = (LVM_INT16)(pInstance->Current>>16); /* From Q31 to Q15*/ + + for (ii = OutLoop; ii != 0; ii--) + { + Temp1=*src; + src++; + + MUL32x16INTO32(Temp1,CurrentShort,Temp2,15) + *dst = Temp2; + dst++; + } + } + + for (ii = InLoop; ii != 0; ii--) + { + MUL32x32INTO32(pInstance->Current,pInstance->Alpha,CurrentTimesAlpha,31) /* Q31 * Q31 in Q31 */ + pInstance->Current = TargetTimesOneMinAlpha + CurrentTimesAlpha; /* Q31 + Q31 into Q31*/ + CurrentShort = (LVM_INT16)(pInstance->Current>>16); /* From Q31 to Q15*/ + Temp1=*src; + src++; + + MUL32x16INTO32(Temp1,CurrentShort,Temp2,15) + *dst = Temp2; + dst++; + + Temp1=*src; + src++; + + MUL32x16INTO32(Temp1,CurrentShort,Temp2,15) + *dst = Temp2; + dst++; + + Temp1=*src; + src++; + + MUL32x16INTO32(Temp1,CurrentShort,Temp2,15) + *dst = Temp2; + dst++; + + Temp1=*src; + src++; + MUL32x16INTO32(Temp1,CurrentShort,Temp2,15) + *dst = Temp2; + dst++; + } +} + + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/DC_2I_D16_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/DC_2I_D16_TRC_WRA_01.c new file mode 100755 index 0000000..187fe68 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/DC_2I_D16_TRC_WRA_01.c @@ -0,0 +1,76 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "DC_2I_D16_TRC_WRA_01_Private.h" +#include "LVM_Macros.h" + +void DC_2I_D16_TRC_WRA_01( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples) + { + LVM_INT32 LeftDC,RightDC; + LVM_INT32 Diff; + LVM_INT32 j; + PFilter_State pBiquadState = (PFilter_State) pInstance; + + LeftDC = pBiquadState->LeftDC; + RightDC = pBiquadState->RightDC; + for(j=NrSamples-1;j>=0;j--) + { + /* Subtract DC an saturate */ + Diff=*(pDataIn++)-(LeftDC>>16); + if (Diff > 32767) { + Diff = 32767; } + else if (Diff < -32768) { + Diff = -32768; } + *(pDataOut++)=(LVM_INT16)Diff; + if (Diff < 0) { + LeftDC -= DC_D16_STEP; } + else { + LeftDC += DC_D16_STEP; } + + + /* Subtract DC an saturate */ + Diff=*(pDataIn++)-(RightDC>>16); + if (Diff > 32767) { + Diff = 32767; } + else if (Diff < -32768) { + Diff = -32768; } + *(pDataOut++)=(LVM_INT16)Diff; + if (Diff < 0) { + RightDC -= DC_D16_STEP; } + else { + RightDC += DC_D16_STEP; } + + } + pBiquadState->LeftDC = LeftDC; + pBiquadState->RightDC = RightDC; + + + } + diff --git a/media/libeffects/lvm/lib/Common/src/DC_2I_D16_TRC_WRA_01_Init.c b/media/libeffects/lvm/lib/Common/src/DC_2I_D16_TRC_WRA_01_Init.c new file mode 100755 index 0000000..292641b --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/DC_2I_D16_TRC_WRA_01_Init.c @@ -0,0 +1,36 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "DC_2I_D16_TRC_WRA_01_Private.h" + +void DC_2I_D16_TRC_WRA_01_Init(Biquad_Instance_t *pInstance) +{ + PFilter_State pBiquadState = (PFilter_State) pInstance; + pBiquadState->LeftDC = 0; + pBiquadState->RightDC = 0; +} + diff --git a/media/libeffects/lvm/lib/Common/src/DC_2I_D16_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/DC_2I_D16_TRC_WRA_01_Private.h new file mode 100755 index 0000000..2514a77 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/DC_2I_D16_TRC_WRA_01_Private.h @@ -0,0 +1,43 @@ +/* + * 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 _DC_2I_D16_TRC_WRA_01_PRIVATE_H_ +#define _DC_2I_D16_TRC_WRA_01_PRIVATE_H_ + +#define DC_D16_STEP 0x200; + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + + +/* The internal state variables are implemented in a (for the user) hidden structure */ +/* In this (private) file, the internal structure is declared fro private use.*/ +typedef struct _Filter_State_ +{ + LVM_INT32 LeftDC; /* LeftDC */ + LVM_INT32 RightDC; /* RightDC */ +}Filter_State; + +typedef Filter_State * PFilter_State ; + +#endif /* _DC_2I_D16_TRC_WRA_01_PRIVATE_H_ */ diff --git a/media/libeffects/lvm/lib/Common/src/DelayAllPass_Sat_32x16To32.c b/media/libeffects/lvm/lib/Common/src/DelayAllPass_Sat_32x16To32.c new file mode 100755 index 0000000..cda72ac --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/DelayAllPass_Sat_32x16To32.c @@ -0,0 +1,113 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "LVM_Types.h" +#include "LVM_Macros.h" +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION DelayAllPass_32x32 +***********************************************************************************/ + +void DelayAllPass_Sat_32x16To32( LVM_INT32 *delay, /* Delay buffer */ + LVM_UINT16 size, /* Delay size */ + LVM_INT16 coeff, /* All pass filter coefficient */ + LVM_UINT16 DelayOffset, /* Simple delay offset */ + LVM_UINT16 *pAllPassOffset, /* All pass filter delay offset */ + LVM_INT32 *dst, /* Source/destination */ + LVM_INT16 n) /* Number of samples */ +{ + LVM_INT16 i; + LVM_UINT16 AllPassOffset = *pAllPassOffset; + LVM_INT32 temp; + LVM_INT32 a,b,c; + + for (i = 0; i < n; i++) + { + + MUL32x16INTO32(delay[AllPassOffset], coeff, temp, 15) + a = temp; + b = delay[DelayOffset]; + DelayOffset++; + + c = a + b; + if ((((c ^ a) & (c ^ b)) >> 31) != 0) /* overflow / underflow */ + { + if(a < 0) + { + c = 0x80000000l; + } + else + { + c = 0x7FFFFFFFl; + } + } + *dst = c; + dst++; + + + MUL32x16INTO32(c, -coeff, temp, 15) + a = temp; + b = delay[AllPassOffset]; + c = a + b; + if ((((c ^ a) & (c ^ b)) >> 31)!=0) /* overflow / underflow */ + { + if(a < 0) + { + c = 0x80000000l; + } + else + { + c = 0x7FFFFFFFl; + } + } + delay[AllPassOffset] = c; + AllPassOffset++; + + /* Make the delay buffer a circular buffer */ + if (DelayOffset >= size) + { + DelayOffset = 0; + } + + if (AllPassOffset >= size) + { + AllPassOffset = 0; + } + } + + /* Update the offset */ + *pAllPassOffset = AllPassOffset; + + return; +} + +/**********************************************************************************/ + diff --git a/media/libeffects/lvm/lib/Common/src/DelayMix_16x16.c b/media/libeffects/lvm/lib/Common/src/DelayMix_16x16.c new file mode 100755 index 0000000..ee41701 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/DelayMix_16x16.c @@ -0,0 +1,81 @@ +/* + * 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: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION DelayMix_16x16 +***********************************************************************************/ + +void DelayMix_16x16(const LVM_INT16 *src, /* Source 1, to be delayed */ + LVM_INT16 *delay, /* Delay buffer */ + LVM_INT16 size, /* Delay size */ + LVM_INT16 *dst, /* Source/destination */ + LVM_INT16 *pOffset, /* Delay offset */ + LVM_INT16 n) /* Number of stereo samples */ +{ + LVM_INT16 i; + LVM_INT16 Offset = *pOffset; + LVM_INT16 temp; + + for (i=0; i<n; i++) + { + /* Left channel */ + temp = (LVM_INT16)((LVM_UINT32)((LVM_INT32)(*dst) + (LVM_INT32)delay[Offset]) >> 1); + *dst = temp; + dst++; + + delay[Offset] = *src; + Offset++; + src++; + + + /* Right channel */ + temp = (LVM_INT16)((LVM_UINT32)((LVM_INT32)(*dst) - (LVM_INT32)delay[Offset]) >> 1); + *dst = temp; + dst++; + + delay[Offset] = *src; + Offset++; + src++; + + /* Make the reverb delay buffer a circular buffer */ + if (Offset >= size) + { + Offset = 0; + } + } + + /* Update the offset */ + *pOffset = Offset; + + return; +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/DelayWrite_32.c b/media/libeffects/lvm/lib/Common/src/DelayWrite_32.c new file mode 100755 index 0000000..0ae4c42 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/DelayWrite_32.c @@ -0,0 +1,66 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION DelayMix_16x16 +***********************************************************************************/ + +void DelayWrite_32(const LVM_INT32 *src, /* Source 1, to be delayed */ + LVM_INT32 *delay, /* Delay buffer */ + LVM_UINT16 size, /* Delay size */ + LVM_UINT16 *pOffset, /* Delay offset */ + LVM_INT16 n) /* Number of samples */ +{ + LVM_INT16 i; + LVM_INT16 Offset = (LVM_INT16)*pOffset; + + for (i=0; i<n; i++) + { + delay[Offset] = *src; + Offset++; + src++; + + /* Make the delay buffer a circular buffer */ + if (Offset >= size) + { + Offset = 0; + } + } + + /* Update the offset */ + *pOffset = (LVM_UINT16)Offset; + + return; +} + +/**********************************************************************************/ + diff --git a/media/libeffects/lvm/lib/Common/src/FO_1I_D16F16C15_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/FO_1I_D16F16C15_TRC_WRA_01.c new file mode 100755 index 0000000..831a115 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/FO_1I_D16F16C15_TRC_WRA_01.c @@ -0,0 +1,83 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "FO_1I_D16F16Css_TRC_WRA_01_Private.h" +#include "LVM_Macros.h" + +/************************************************************************** + ASSUMPTIONS: + COEFS- + pBiquadState->coefs[0] is A1, + pBiquadState->coefs[1] is A0, + pBiquadState->coefs[2] is -B1, these are in Q15 format + + DELAYS- + pBiquadState->pDelays[0] is x(n-1)L in Q0 format + pBiquadState->pDelays[1] is y(n-1)L in Q0 format +***************************************************************************/ + +void FO_1I_D16F16C15_TRC_WRA_01( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples) + { + LVM_INT32 ynL; + LVM_INT16 ii; + PFilter_State pBiquadState = (PFilter_State) pInstance; + + for (ii = NrSamples; ii != 0; ii--) + { + + /************************************************************************** + PROCESSING OF THE LEFT CHANNEL + ***************************************************************************/ + // ynL=A1 (Q15) * x(n-1)L (Q0) in Q15 + ynL=(LVM_INT32)pBiquadState->coefs[0]* pBiquadState->pDelays[0]; + + // ynL+=A0 (Q15) * x(n)L (Q0) in Q15 + ynL+=(LVM_INT32)pBiquadState->coefs[1]* (*pDataIn); + + // ynL+= (-B1 (Q15) * y(n-1)L (Q0) ) in Q15 + ynL+=(LVM_INT32)pBiquadState->coefs[2]*pBiquadState->pDelays[1]; + + + ynL=(LVM_INT16)(ynL>>15); // ynL in Q0 format + /************************************************************************** + UPDATING THE DELAYS + ***************************************************************************/ + pBiquadState->pDelays[1]=ynL; // Update y(n-1)L in Q0 + pBiquadState->pDelays[0]=(*pDataIn++); // Update x(n-1)L in Q0 + + /************************************************************************** + WRITING THE OUTPUT + ***************************************************************************/ + *pDataOut++=(LVM_INT16)ynL; // Write Left output in Q0 + + } + + } + diff --git a/media/libeffects/lvm/lib/Common/src/FO_1I_D16F16Css_TRC_WRA_01_Init.c b/media/libeffects/lvm/lib/Common/src/FO_1I_D16F16Css_TRC_WRA_01_Init.c new file mode 100755 index 0000000..4675084 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/FO_1I_D16F16Css_TRC_WRA_01_Init.c @@ -0,0 +1,63 @@ +/* + * 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: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/*-------------------------------------------------------------------------*/ +#include "BIQUAD.h" +#include "FO_1I_D16F16Css_TRC_WRA_01_Private.h" + + +/*-------------------------------------------------------------------------*/ +/* FUNCTION: */ +/* FO_1I_D16F16Css_TRC_WRA_01_Init */ +/* */ +/* DESCRIPTION: */ +/* These functions initializes a BIQUAD filter defined as a cascade of */ +/* biquadratic Filter Sections. */ +/* */ +/* PARAMETERS: */ +/* pInstance - output, returns the pointer to the State Variable */ +/* This state pointer must be passed to any subsequent */ +/* call to "Biquad" functions. */ +/* pTaps - input, pointer to the taps memory */ +/* pCoef - input, pointer to the coefficient structure */ +/* N - M coefficient factor of QM.N */ +/* RETURNS: */ +/* void return code */ +/*-------------------------------------------------------------------------*/ +void FO_1I_D16F16Css_TRC_WRA_01_Init( Biquad_Instance_t *pInstance, + Biquad_1I_Order1_Taps_t *pTaps, + FO_C16_Coefs_t *pCoef) +{ + LVM_INT16 temp; + PFilter_State pBiquadState = (PFilter_State) pInstance; + pBiquadState->pDelays =(LVM_INT32 *) pTaps; + + temp=pCoef->A1; + pBiquadState->coefs[0]=temp; + temp=pCoef->A0; + pBiquadState->coefs[1]=temp; + temp=pCoef->B1; + pBiquadState->coefs[2]=temp; +} +/*------------------------------------------------*/ +/* End Of File: FO_1I_D16F16Css_TRC_WRA_01_Init.c */ + diff --git a/media/libeffects/lvm/lib/Common/src/FO_1I_D16F16Css_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/FO_1I_D16F16Css_TRC_WRA_01_Private.h new file mode 100755 index 0000000..e1a818c --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/FO_1I_D16F16Css_TRC_WRA_01_Private.h @@ -0,0 +1,40 @@ +/* + * 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 _FO_1I_D16F16CSS_TRC_WRA_01_PRIVATE_H_ +#define _FO_1I_D16F16CSS_TRC_WRA_01_PRIVATE_H_ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ */ +/* */ +/************************************************************************/ + +/* The internal state variables are implemented in a (for the user) hidden structure */ +/* In this (private) file, the internal structure is declared fro private use. */ +typedef struct _Filter_State_ +{ + LVM_INT32* pDelays; /* pointer to the delayed samples (data of 32 bits) */ + LVM_INT16 coefs[3]; /* pointer to the filter coefficients */ +}Filter_State; + +typedef Filter_State * PFilter_State ; + +#endif /* _FO_1I_D16F16CSS_TRC_WRA_01_PRIVATE_H_ */ diff --git a/media/libeffects/lvm/lib/Common/src/FO_1I_D32F32C31_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/FO_1I_D32F32C31_TRC_WRA_01.c new file mode 100755 index 0000000..9bdc5b4 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/FO_1I_D32F32C31_TRC_WRA_01.c @@ -0,0 +1,83 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "FO_1I_D32F32Cll_TRC_WRA_01_Private.h" +#include "LVM_Macros.h" + + +/************************************************************************** + ASSUMPTIONS: + COEFS- + pBiquadState->coefs[0] is A1, + pBiquadState->coefs[1] is A0, + pBiquadState->coefs[2] is -B1, these are in Q31 format + + DELAYS- + pBiquadState->pDelays[0] is x(n-1)L in Q0 format + pBiquadState->pDelays[1] is y(n-1)L in Q0 format +***************************************************************************/ + +void FO_1I_D32F32C31_TRC_WRA_01( Biquad_Instance_t *pInstance, + LVM_INT32 *pDataIn, + LVM_INT32 *pDataOut, + LVM_INT16 NrSamples) + { + LVM_INT32 ynL,templ; + LVM_INT16 ii; + PFilter_State pBiquadState = (PFilter_State) pInstance; + + for (ii = NrSamples; ii != 0; ii--) + { + + /************************************************************************** + PROCESSING OF THE LEFT CHANNEL + ***************************************************************************/ + // ynL=A1 (Q31) * x(n-1)L (Q0) >>31 in Q0 + MUL32x32INTO32(pBiquadState->coefs[0],pBiquadState->pDelays[0],ynL,31) + + // ynL+=A0 (Q31) * x(n)L (Q0) >> 31 in Q0 + MUL32x32INTO32(pBiquadState->coefs[1],*pDataIn,templ,31) + ynL+=templ; + + // ynL+= (-B1 (Q31) * y(n-1)L (Q0) ) >> 31 in Q0 + MUL32x32INTO32(pBiquadState->coefs[2],pBiquadState->pDelays[1],templ,31) + ynL+=templ; + + /************************************************************************** + UPDATING THE DELAYS + ***************************************************************************/ + pBiquadState->pDelays[1]=ynL; // Update y(n-1)L in Q0 + pBiquadState->pDelays[0]=(*pDataIn++); // Update x(n-1)L in Q0 + + /************************************************************************** + WRITING THE OUTPUT + ***************************************************************************/ + *pDataOut++=(LVM_INT32)ynL; // Write Left output in Q0 + } + + } + diff --git a/media/libeffects/lvm/lib/Common/src/FO_1I_D32F32Cll_TRC_WRA_01_Init.c b/media/libeffects/lvm/lib/Common/src/FO_1I_D32F32Cll_TRC_WRA_01_Init.c new file mode 100755 index 0000000..eea0b64 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/FO_1I_D32F32Cll_TRC_WRA_01_Init.c @@ -0,0 +1,66 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "FO_1I_D32F32Cll_TRC_WRA_01_Private.h" + + +/*-------------------------------------------------------------------------*/ +/* FUNCTION: */ +/* FO_1I_D32F32Cll_TRC_WRA_01_Init */ +/* */ +/* DESCRIPTION: */ +/* These functions initializes a BIQUAD filter defined as a cascade of */ +/* biquadratic Filter Sections. */ +/* */ +/* PARAMETERS: */ +/* pInstance - output, returns the pointer to the State Variable */ +/* This state pointer must be passed to any subsequent */ +/* call to "Biquad" functions. */ +/* pTaps - input, pointer to the taps memory */ +/* pCoef - input, pointer to the coefficient structure */ +/* N - M coefficient factor of QM.N */ +/* RETURNS: */ +/* void return code */ +/*-------------------------------------------------------------------------*/ +void FO_1I_D32F32Cll_TRC_WRA_01_Init( Biquad_Instance_t *pInstance, + Biquad_1I_Order1_Taps_t *pTaps, + FO_C32_Coefs_t *pCoef) +{ + LVM_INT32 temp; + PFilter_State pBiquadState = (PFilter_State) pInstance; + pBiquadState->pDelays = (LVM_INT32 *) pTaps; + + temp=pCoef->A1; + pBiquadState->coefs[0]=temp; + temp=pCoef->A0; + pBiquadState->coefs[1]=temp; + temp=pCoef->B1; + pBiquadState->coefs[2]=temp; +} +/*------------------------------------------------*/ +/* End Of File: FO_1I_D32F32Cll_TRC_WRA_01_Init.c */ + diff --git a/media/libeffects/lvm/lib/Common/src/FO_1I_D32F32Cll_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/FO_1I_D32F32Cll_TRC_WRA_01_Private.h new file mode 100755 index 0000000..9329150 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/FO_1I_D32F32Cll_TRC_WRA_01_Private.h @@ -0,0 +1,41 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#ifndef _FO_1I_D32F32CLL_TRC_WRA_01_PRIVATE_H_ +#define _FO_1I_D32F32CLL_TRC_WRA_01_PRIVATE_H_ + + +/* The internal state variables are implemented in a (for the user) hidden structure */ +/* In this (private) file, the internal structure is declared fro private use. */ +typedef struct _Filter_State_ +{ + LVM_INT32 * pDelays; /* pointer to the delayed samples (data of 32 bits) */ + LVM_INT32 coefs[3]; /* pointer to the filter coefficients */ +}Filter_State; + +typedef Filter_State * PFilter_State ; + +#endif /* _FO_1I_D32F32CLL_TRC_WRA_01_PRIVATE_H_ */ diff --git a/media/libeffects/lvm/lib/Common/src/FO_2I_D16F32C15_LShx_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/FO_2I_D16F32C15_LShx_TRC_WRA_01.c new file mode 100755 index 0000000..4b219a2 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/FO_2I_D16F32C15_LShx_TRC_WRA_01.c @@ -0,0 +1,137 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "FO_2I_D16F32Css_LShx_TRC_WRA_01_Private.h" +#include "LVM_Macros.h" + +/************************************************************************** +ASSUMPTIONS: +COEFS- +pBiquadState->coefs[0] is A1, +pBiquadState->coefs[1] is A0, +pBiquadState->coefs[2] is -B1, these are in Q15 format +pBiquadState->Shift is Shift value +DELAYS- +pBiquadState->pDelays[0] is x(n-1)L in Q15 format +pBiquadState->pDelays[1] is y(n-1)L in Q30 format +pBiquadState->pDelays[2] is x(n-1)R in Q15 format +pBiquadState->pDelays[3] is y(n-1)R in Q30 format +***************************************************************************/ + +void FO_2I_D16F32C15_LShx_TRC_WRA_01(Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples) + { + LVM_INT32 ynL,ynR; + LVM_INT32 Temp; + LVM_INT32 NegSatValue; + LVM_INT16 ii; + LVM_INT16 Shift; + PFilter_State pBiquadState = (PFilter_State) pInstance; + + NegSatValue = LVM_MAXINT_16 +1; + NegSatValue = -NegSatValue; + + Shift = pBiquadState->Shift; + + + for (ii = NrSamples; ii != 0; ii--) + { + + /************************************************************************** + PROCESSING OF THE LEFT CHANNEL + ***************************************************************************/ + + // ynL =A1 (Q15) * x(n-1)L (Q15) in Q30 + ynL=(LVM_INT32)pBiquadState->coefs[0]* pBiquadState->pDelays[0]; + // ynR =A1 (Q15) * x(n-1)R (Q15) in Q30 + ynR=(LVM_INT32)pBiquadState->coefs[0]* pBiquadState->pDelays[2]; + + + // ynL+=A0 (Q15) * x(n)L (Q15) in Q30 + ynL+=(LVM_INT32)pBiquadState->coefs[1]* (*pDataIn); + // ynR+=A0 (Q15) * x(n)L (Q15) in Q30 + ynR+=(LVM_INT32)pBiquadState->coefs[1]* (*(pDataIn+1)); + + + // ynL += (-B1 (Q15) * y(n-1)L (Q30) ) in Q30 + MUL32x16INTO32(pBiquadState->pDelays[1],pBiquadState->coefs[2],Temp,15); + ynL +=Temp; + // ynR += (-B1 (Q15) * y(n-1)R (Q30) ) in Q30 + MUL32x16INTO32(pBiquadState->pDelays[3],pBiquadState->coefs[2],Temp,15); + ynR +=Temp; + + + /************************************************************************** + UPDATING THE DELAYS + ***************************************************************************/ + pBiquadState->pDelays[1]=ynL; // Update y(n-1)L in Q30 + pBiquadState->pDelays[0]=(*pDataIn++); // Update x(n-1)L in Q15 + + pBiquadState->pDelays[3]=ynR; // Update y(n-1)R in Q30 + pBiquadState->pDelays[2]=(*pDataIn++); // Update x(n-1)R in Q15 + + /************************************************************************** + WRITING THE OUTPUT + ***************************************************************************/ + /*Apply shift: Instead of left shift on 16-bit result, right shift of (15-shift) is applied + for better SNR*/ + ynL = ynL>>(15-Shift); + ynR = ynR>>(15-Shift); + + /*Saturate results*/ + if(ynL > LVM_MAXINT_16) + { + ynL = LVM_MAXINT_16; + } + else + { + if(ynL < NegSatValue) + { + ynL = NegSatValue; + } + } + + if(ynR > LVM_MAXINT_16) + { + ynR = LVM_MAXINT_16; + } + else + { + if(ynR < NegSatValue) + { + ynR = NegSatValue; + } + } + + *pDataOut++=(LVM_INT16)ynL; + *pDataOut++=(LVM_INT16)ynR; + } + + } + diff --git a/media/libeffects/lvm/lib/Common/src/FO_2I_D16F32Css_LShx_TRC_WRA_01_Init.c b/media/libeffects/lvm/lib/Common/src/FO_2I_D16F32Css_LShx_TRC_WRA_01_Init.c new file mode 100755 index 0000000..7f212f5 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/FO_2I_D16F32Css_LShx_TRC_WRA_01_Init.c @@ -0,0 +1,65 @@ +/* + * 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: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/*-------------------------------------------------------------------------*/ +#include "BIQUAD.h" +#include "FO_2I_D16F32Css_LShx_TRC_WRA_01_Private.h" + +/*-------------------------------------------------------------------------*/ +/* FUNCTION: */ +/* FO_2I_D16F32Css_LShx_TRC_WRA_01_Init */ +/* */ +/* DESCRIPTION: */ +/* These functions initializes a BIQUAD filter defined as a cascade of */ +/* biquadratic Filter Sections. */ +/* */ +/* PARAMETERS: */ +/* pInstance - output, returns the pointer to the State Variable */ +/* This state pointer must be passed to any subsequent */ +/* call to "Biquad" functions. */ +/* pTaps - input, pointer to the taps memory */ +/* pCoef - input, pointer to the coefficient structure */ +/* N - M coefficient factor of QM.N */ +/* RETURNS: */ +/* void return code */ +/*-------------------------------------------------------------------------*/ +void FO_2I_D16F32Css_LShx_TRC_WRA_01_Init(Biquad_Instance_t *pInstance, + Biquad_2I_Order1_Taps_t *pTaps, + FO_C16_LShx_Coefs_t *pCoef) +{ + LVM_INT16 temp; + PFilter_State pBiquadState = (PFilter_State) pInstance; + pBiquadState->pDelays =(LVM_INT32 *) pTaps ; + + temp=pCoef->A1; + pBiquadState->coefs[0]=temp; + temp=pCoef->A0; + pBiquadState->coefs[1]=temp; + temp=pCoef->B1; + pBiquadState->coefs[2]=temp; + + temp=pCoef->Shift; + pBiquadState->Shift = temp; +} +/*-------------------------------------------------------------------------*/ +/* End Of File: FO_2I_D16F32Css_LShx_TRC_WRA_01_Init.c */ + diff --git a/media/libeffects/lvm/lib/Common/src/FO_2I_D16F32Css_LShx_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/FO_2I_D16F32Css_LShx_TRC_WRA_01_Private.h new file mode 100755 index 0000000..6a4564a --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/FO_2I_D16F32Css_LShx_TRC_WRA_01_Private.h @@ -0,0 +1,41 @@ +/* + * 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 _FO_2I_D16F32CSS_LSHX_TRC_WRA_01_PRIVATE_H_ +#define _FO_2I_D16F32CSS_LSHX_TRC_WRA_01_PRIVATE_H_ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/* The internal state variables are implemented in a (for the user) hidden structure */ +/* In this (private) file, the internal structure is declared fro private use. */ +typedef struct _Filter_State_ +{ + LVM_INT32 *pDelays; /* pointer to the delayed samples (data of 32 bits) */ + LVM_INT16 coefs[3]; /* pointer to the filter coefficients */ + LVM_INT16 Shift; /* Shift value*/ +}Filter_State; + +typedef Filter_State * PFilter_State ; + +#endif /* _FO_2I_D16F32CSS_LSHX_TRC_WRA_01_PRIVATE_H_ */ diff --git a/media/libeffects/lvm/lib/Common/src/Filters.h b/media/libeffects/lvm/lib/Common/src/Filters.h new file mode 100755 index 0000000..a274f32 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/Filters.h @@ -0,0 +1,74 @@ +/* + * 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: 1001 $ + $Date: 2010-06-28 13:23:02 +0200 (Mon, 28 Jun 2010) $ + +*************************************************************************************/ + +#ifndef FILTERS_H +#define FILTERS_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "LVM_Types.h" + +/************************************************************************************/ +/* */ +/* Structures */ +/* */ +/************************************************************************************/ + +/* + * Biquad with coefficients A0, A1, A2, B1 and B2 coefficients + */ +/* Single precision (16-bit) Biquad section coefficients */ +typedef struct +{ + LVM_INT16 A0; + LVM_INT16 A1; + LVM_INT16 A2; + LVM_INT16 B1; + LVM_INT16 B2; + LVM_UINT16 Scale; +} BiquadA012B12CoefsSP_t; + + +/* + * Biquad with coefficients A0, A1 and B1 coefficients + */ +/* Single precision (16-bit) Biquad section coefficients */ +typedef struct +{ + LVM_INT16 A0; + LVM_INT16 A1; + LVM_INT16 B1; + LVM_UINT16 Scale; +} BiquadA01B1CoefsSP_t; + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* FILTERS_H */ + diff --git a/media/libeffects/lvm/lib/Common/src/From2iToMS_16x16.c b/media/libeffects/lvm/lib/Common/src/From2iToMS_16x16.c new file mode 100755 index 0000000..fb00768 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/From2iToMS_16x16.c @@ -0,0 +1,65 @@ +/* + * 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: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION From2iToMS_16x16 +***********************************************************************************/ + +void From2iToMS_16x16( const LVM_INT16 *src, + LVM_INT16 *dstM, + LVM_INT16 *dstS, + LVM_INT16 n ) +{ + LVM_INT32 temp1,left,right; + LVM_INT16 ii; + for (ii = n; ii != 0; ii--) + { + left = (LVM_INT32)*src; + src++; + + right = (LVM_INT32)*src; + src++; + + /* Compute M signal*/ + temp1 = (left+right)>>1; + *dstM = (LVM_INT16)temp1; + dstM++; + + /* Compute S signal*/ + temp1 = (left-right)>>1; + *dstS = (LVM_INT16)temp1; + dstS++; + } + + return; +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/From2iToMono_16.c b/media/libeffects/lvm/lib/Common/src/From2iToMono_16.c new file mode 100755 index 0000000..0ebb4ae --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/From2iToMono_16.c @@ -0,0 +1,57 @@ +/* + * 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: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION From2iToMono_16 +***********************************************************************************/ + +void From2iToMono_16( const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n) +{ + LVM_INT16 ii; + LVM_INT32 Temp; + for (ii = n; ii != 0; ii--) + { + Temp = (LVM_INT32)*src; + src++; + + Temp += (LVM_INT32)*src; + src++; + + *dst = (LVM_INT16)(Temp >>1); + dst++; + } + + return; +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/From2iToMono_32.c b/media/libeffects/lvm/lib/Common/src/From2iToMono_32.c new file mode 100755 index 0000000..5181368 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/From2iToMono_32.c @@ -0,0 +1,58 @@ +/* + * 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: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION From2iToMono_32 +***********************************************************************************/ + +void From2iToMono_32( const LVM_INT32 *src, + LVM_INT32 *dst, + LVM_INT16 n) +{ + LVM_INT16 ii; + LVM_INT32 Temp; + + for (ii = n; ii != 0; ii--) + { + Temp = (*src>>1); + src++; + + Temp +=(*src>>1); + src++; + + *dst = Temp; + dst++; + } + + return; +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/InstAlloc.c b/media/libeffects/lvm/lib/Common/src/InstAlloc.c new file mode 100755 index 0000000..ff900e0 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/InstAlloc.c @@ -0,0 +1,194 @@ +/* + * 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: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "InstAlloc.h" + +/**************************************************************************************** + * Name : InstAlloc_Init() + * Input : pms - Pointer to the INST_ALLOC instance + StartAddr - Base address of the instance memory + * Returns : Error code + * Description : Initializes the instance distribution and memory size calculation function + * Remarks : + ****************************************************************************************/ + +void InstAlloc_Init( INST_ALLOC *pms, + void *StartAddr ) +{ + pms->TotalSize = 3; + pms->pNextMember = (LVM_UINT32)(((LVM_UINT32)StartAddr + 3) & 0xFFFFFFFC);/* This code will fail if the platform address space is more than 32-bits*/ +} + + +/**************************************************************************************** + * Name : InstAlloc_AddMember() + * Input : pms - Pointer to the INST_ALLOC instance + Size - The size in bytes of the new added member + * Returns : A pointer to the new added member + * Description : Allocates space for a new member in the instance memory and returns + a pointer to this new member. The start address of all members will + be 32 bit alligned. + * Remarks : + ****************************************************************************************/ + +void* InstAlloc_AddMember( INST_ALLOC *pms, + LVM_UINT32 Size ) +{ + void *NewMemberAddress; /* Variable to temporarily store the return value */ + NewMemberAddress = (void*)pms->pNextMember; + + Size = ((Size + 3) & 0xFFFFFFFC); /* Ceil the size to a multiple of four */ + + pms->TotalSize += Size; + pms->pNextMember += Size; + + return(NewMemberAddress); +} + + +/**************************************************************************************** + * Name : InstAlloc_GetTotal() + * Input : pms - Pointer to the INST_ALLOC instance + * Returns : The instance memory size + * Description : This functions returns the calculated instance memory size + * Remarks : + ****************************************************************************************/ + +LVM_UINT32 InstAlloc_GetTotal( INST_ALLOC *pms) +{ + if (pms->TotalSize > 3) + { + return(pms->TotalSize); + } + else + { + return 0; /* No memory added */ + } +} + + +void InstAlloc_InitAll( INST_ALLOC *pms, + LVM_MemoryTable_st *pMemoryTable) +{ + LVM_UINT32 StartAddr; + + StartAddr = (LVM_UINT32)pMemoryTable->Region[LVM_PERSISTENT_SLOW_DATA].pBaseAddress; + + pms[0].TotalSize = 3; + pms[0].pNextMember = (LVM_UINT32)(((LVM_UINT32)StartAddr + 3) & 0xFFFFFFFC); + + + StartAddr = (LVM_UINT32)pMemoryTable->Region[LVM_PERSISTENT_FAST_DATA].pBaseAddress; + + pms[1].TotalSize = 3; + pms[1].pNextMember = (LVM_UINT32)(((LVM_UINT32)StartAddr + 3) & 0xFFFFFFFC); + + + StartAddr = (LVM_UINT32)pMemoryTable->Region[LVM_PERSISTENT_FAST_COEF].pBaseAddress; + + pms[2].TotalSize = 3; + pms[2].pNextMember = (LVM_UINT32)(((LVM_UINT32)StartAddr + 3) & 0xFFFFFFFC); + + + StartAddr = (LVM_UINT32)pMemoryTable->Region[LVM_TEMPORARY_FAST].pBaseAddress; + + pms[3].TotalSize = 3; + pms[3].pNextMember = (LVM_UINT32)(((LVM_UINT32)StartAddr + 3) & 0xFFFFFFFC); + +} + +/**************************************************************************************** + * Name : InstAlloc_InitAll_NULL() + * Input : pms - Pointer to array of four INST_ALLOC instances + * Returns : Nothing + * Description : This function reserves Size of 3 bytes for all memory regions and + * intializes pNextMember for all regions to 0 + * Remarks : + ****************************************************************************************/ + +void InstAlloc_InitAll_NULL( INST_ALLOC *pms) +{ + pms[0].TotalSize = 3; + pms[0].pNextMember = 0; + + + pms[1].TotalSize = 3; + pms[1].pNextMember = 0; + + pms[2].TotalSize = 3; + pms[2].pNextMember = 0; + + pms[3].TotalSize = 3; + pms[3].pNextMember = 0; + +} + + +void* InstAlloc_AddMemberAll( INST_ALLOC *pms, + LVM_UINT32 Size[], + LVM_MemoryTable_st *pMemoryTable) +{ + void *NewMemberAddress; /* Variable to temporarily store the return value */ + + /* coverity[returned_pointer] Ignore coverity warning that ptr is not used */ + NewMemberAddress = InstAlloc_AddMember(&pms[LVM_PERSISTENT_SLOW_DATA], Size[LVM_PERSISTENT_SLOW_DATA]); + + pMemoryTable->Region[LVM_PERSISTENT_SLOW_DATA].Size = InstAlloc_GetTotal(&pms[LVM_PERSISTENT_SLOW_DATA]); + pMemoryTable->Region[LVM_PERSISTENT_SLOW_DATA].Type = LVM_PERSISTENT_SLOW_DATA; + pMemoryTable->Region[LVM_PERSISTENT_SLOW_DATA].pBaseAddress = LVM_NULL; + + NewMemberAddress = InstAlloc_AddMember(&pms[LVM_PERSISTENT_FAST_DATA], Size[LVM_PERSISTENT_FAST_DATA]); + + pMemoryTable->Region[LVM_PERSISTENT_FAST_DATA].Size = InstAlloc_GetTotal(&pms[LVM_PERSISTENT_FAST_DATA]); + pMemoryTable->Region[LVM_PERSISTENT_FAST_DATA].Type = LVM_PERSISTENT_FAST_DATA; + pMemoryTable->Region[LVM_PERSISTENT_FAST_DATA].pBaseAddress = LVM_NULL; + + NewMemberAddress = InstAlloc_AddMember(&pms[LVM_PERSISTENT_FAST_COEF], Size[LVM_PERSISTENT_FAST_COEF]); + + pMemoryTable->Region[LVM_PERSISTENT_FAST_COEF].Size = InstAlloc_GetTotal(&pms[LVM_PERSISTENT_FAST_COEF]); + pMemoryTable->Region[LVM_PERSISTENT_FAST_COEF].Type = LVM_PERSISTENT_FAST_COEF; + pMemoryTable->Region[LVM_PERSISTENT_FAST_COEF].pBaseAddress = LVM_NULL; + + NewMemberAddress = InstAlloc_AddMember(&pms[LVM_TEMPORARY_FAST], Size[LVM_TEMPORARY_FAST]); + + pMemoryTable->Region[LVM_TEMPORARY_FAST].Size = InstAlloc_GetTotal(&pms[LVM_TEMPORARY_FAST]); + pMemoryTable->Region[LVM_TEMPORARY_FAST].Type = LVM_TEMPORARY_FAST; + pMemoryTable->Region[LVM_TEMPORARY_FAST].pBaseAddress = LVM_NULL; + + return(NewMemberAddress); +} + + +void* InstAlloc_AddMemberAllRet( INST_ALLOC *pms, + LVM_UINT32 Size[], + void **ptr) +{ + ptr[0] = InstAlloc_AddMember(&pms[LVM_PERSISTENT_SLOW_DATA], Size[LVM_PERSISTENT_SLOW_DATA]); + ptr[1] = InstAlloc_AddMember(&pms[LVM_PERSISTENT_FAST_DATA], Size[LVM_PERSISTENT_FAST_DATA]); + ptr[2] = InstAlloc_AddMember(&pms[LVM_PERSISTENT_FAST_COEF], Size[LVM_PERSISTENT_FAST_COEF]); + ptr[3] = InstAlloc_AddMember(&pms[LVM_TEMPORARY_FAST], Size[LVM_TEMPORARY_FAST]); + + return (ptr[0]); +} diff --git a/media/libeffects/lvm/lib/Common/src/Int16LShiftToInt32_16x32.c b/media/libeffects/lvm/lib/Common/src/Int16LShiftToInt32_16x32.c new file mode 100755 index 0000000..e6be756 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/Int16LShiftToInt32_16x32.c @@ -0,0 +1,56 @@ +/* + * 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: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION INT16LSHIFTTOINT32_16X32 +***********************************************************************************/ + +void Int16LShiftToInt32_16x32(const LVM_INT16 *src, + LVM_INT32 *dst, + LVM_INT16 n, + LVM_INT16 shift ) +{ + LVM_INT16 ii; + + src += n-1; + dst += n-1; + + for (ii = n; ii != 0; ii--) + { + *dst = ( ((LVM_INT32)*src) << shift); + src--; + dst--; + } + + return; +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/Int32RShiftToInt16_Sat_32x16.c b/media/libeffects/lvm/lib/Common/src/Int32RShiftToInt16_Sat_32x16.c new file mode 100755 index 0000000..b21eef5 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/Int32RShiftToInt16_Sat_32x16.c @@ -0,0 +1,68 @@ +/* + * 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: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION INT32RSHIFTTOINT16_SAT_32X16 +***********************************************************************************/ + +void Int32RShiftToInt16_Sat_32x16(const LVM_INT32 *src, + LVM_INT16 *dst, + LVM_INT16 n, + LVM_INT16 shift ) +{ + LVM_INT32 temp; + LVM_INT16 ii; + + for (ii = n; ii != 0; ii--) + { + temp = *src >> shift; + src++; + + if (temp > 0x00007FFF) + { + *dst = 0x7FFF; + } + else if (temp < -0x00008000) + { + *dst = - 0x8000; + } + else + { + *dst = (LVM_INT16)temp; + } + + dst++; + } + + return; +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/JoinTo2i_32x32.c b/media/libeffects/lvm/lib/Common/src/JoinTo2i_32x32.c new file mode 100755 index 0000000..e04f1c3 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/JoinTo2i_32x32.c @@ -0,0 +1,63 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION JoinTo2i_32x32 +***********************************************************************************/ + +void JoinTo2i_32x32( const LVM_INT32 *srcL, + const LVM_INT32 *srcR, + LVM_INT32 *dst, + LVM_INT16 n ) +{ + LVM_INT16 ii; + + srcL += n-1; + srcR += n-1; + dst += ((2*n)-1); + + for (ii = n; ii != 0; ii--) + { + *dst = *srcR; + dst--; + srcR--; + + *dst = *srcL; + dst--; + srcL--; + } + + return; +} + +/**********************************************************************************/ + diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Core_MixHard_1St_2i_D16C31_SAT.c b/media/libeffects/lvm/lib/Common/src/LVC_Core_MixHard_1St_2i_D16C31_SAT.c new file mode 100755 index 0000000..c1d2b2c --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVC_Core_MixHard_1St_2i_D16C31_SAT.c @@ -0,0 +1,77 @@ +/* + * 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: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "LVC_Mixer_Private.h" +#include "LVM_Macros.h" +#include "ScalarArithmetic.h" + + +/********************************************************************************** + FUNCTION LVC_Core_MixHard_1St_2i_D16C31_SAT +***********************************************************************************/ + +void LVC_Core_MixHard_1St_2i_D16C31_SAT( LVMixer3_st *ptrInstance1, + LVMixer3_st *ptrInstance2, + const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n) +{ + LVM_INT32 Temp; + LVM_INT16 ii; + LVM_INT16 Current1Short; + LVM_INT16 Current2Short; + Mix_Private_st *pInstance1=(Mix_Private_st *)(ptrInstance1->PrivateParams); + Mix_Private_st *pInstance2=(Mix_Private_st *)(ptrInstance2->PrivateParams); + + + Current1Short = (LVM_INT16)(pInstance1->Current >> 16); + Current2Short = (LVM_INT16)(pInstance2->Current >> 16); + + for (ii = n; ii != 0; ii--) + { + Temp = ((LVM_INT32)*(src++) * (LVM_INT32)Current1Short)>>15; + if (Temp > 0x00007FFF) + *dst++ = 0x7FFF; + else if (Temp < -0x00008000) + *dst++ = - 0x8000; + else + *dst++ = (LVM_INT16)Temp; + + Temp = ((LVM_INT32)*(src++) * (LVM_INT32)Current2Short)>>15; + if (Temp > 0x00007FFF) + *dst++ = 0x7FFF; + else if (Temp < -0x00008000) + *dst++ = - 0x8000; + else + *dst++ = (LVM_INT16)Temp; + } + + +} +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Core_MixHard_2St_D16C31_SAT.c b/media/libeffects/lvm/lib/Common/src/LVC_Core_MixHard_2St_D16C31_SAT.c new file mode 100755 index 0000000..2bb212c --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVC_Core_MixHard_2St_D16C31_SAT.c @@ -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: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "LVC_Mixer_Private.h" + +/********************************************************************************** + FUNCTION LVCore_MIXHARD_2ST_D16C31_SAT +***********************************************************************************/ + +void LVC_Core_MixHard_2St_D16C31_SAT( LVMixer3_st *ptrInstance1, + LVMixer3_st *ptrInstance2, + const LVM_INT16 *src1, + const LVM_INT16 *src2, + LVM_INT16 *dst, + LVM_INT16 n) +{ + LVM_INT32 Temp; + LVM_INT16 ii; + LVM_INT16 Current1Short; + LVM_INT16 Current2Short; + Mix_Private_st *pInstance1=(Mix_Private_st *)(ptrInstance1->PrivateParams); + Mix_Private_st *pInstance2=(Mix_Private_st *)(ptrInstance2->PrivateParams); + + + Current1Short = (LVM_INT16)(pInstance1->Current >> 16); + Current2Short = (LVM_INT16)(pInstance2->Current >> 16); + + for (ii = n; ii != 0; ii--){ + Temp = (((LVM_INT32)*(src1++) * (LVM_INT32)Current1Short)>>15) + + (((LVM_INT32)*(src2++) * (LVM_INT32)Current2Short)>>15); + if (Temp > 0x00007FFF) + *dst++ = 0x7FFF; + else if (Temp < -0x00008000) + *dst++ = - 0x8000; + else + *dst++ = (LVM_INT16)Temp; + } +} + + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Core_MixInSoft_D16C31_SAT.c b/media/libeffects/lvm/lib/Common/src/LVC_Core_MixInSoft_D16C31_SAT.c new file mode 100755 index 0000000..0408f42 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVC_Core_MixInSoft_D16C31_SAT.c @@ -0,0 +1,136 @@ +/* + * 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: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "LVC_Mixer_Private.h" +#include "LVM_Macros.h" + +/********************************************************************************** + FUNCTION LVCore_MIXSOFT_1ST_D16C31_WRA +***********************************************************************************/ + +void LVC_Core_MixInSoft_D16C31_SAT( LVMixer3_st *ptrInstance, + const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n) +{ + + LVM_INT16 OutLoop; + LVM_INT16 InLoop; + LVM_INT16 CurrentShort; + LVM_INT32 ii,jj; + Mix_Private_st *pInstance=(Mix_Private_st *)(ptrInstance->PrivateParams); + LVM_INT32 Delta=pInstance->Delta; + LVM_INT32 Current=pInstance->Current; + LVM_INT32 Target=pInstance->Target; + LVM_INT32 Temp; + + InLoop = (LVM_INT16)(n >> 2); /* Process per 4 samples */ + OutLoop = (LVM_INT16)(n - (InLoop << 2)); + + if(Current<Target){ + if (OutLoop){ + ADD2_SAT_32x32(Current,Delta,Temp); /* Q31 + Q31 into Q31*/ + Current=Temp; + if (Current > Target) + Current = Target; + + CurrentShort = (LVM_INT16)(Current>>16); /* From Q31 to Q15*/ + + for (ii = OutLoop; ii != 0; ii--){ + Temp = ((LVM_INT32)*dst) + (((LVM_INT32)*(src++) * CurrentShort)>>15); /* Q15 + Q15*Q15>>15 into Q15 */ + if (Temp > 0x00007FFF) + *dst++ = 0x7FFF; + else if (Temp < -0x00008000) + *dst++ = - 0x8000; + else + *dst++ = (LVM_INT16)Temp; + } + } + + for (ii = InLoop; ii != 0; ii--){ + ADD2_SAT_32x32(Current,Delta,Temp); /* Q31 + Q31 into Q31*/ + Current=Temp; + if (Current > Target) + Current = Target; + + CurrentShort = (LVM_INT16)(Current>>16); /* From Q31 to Q15*/ + + for (jj = 4; jj!=0 ; jj--){ + Temp = ((LVM_INT32)*dst) + (((LVM_INT32)*(src++) * CurrentShort)>>15); /* Q15 + Q15*Q15>>15 into Q15 */ + if (Temp > 0x00007FFF) + *dst++ = 0x7FFF; + else if (Temp < -0x00008000) + *dst++ = - 0x8000; + else + *dst++ = (LVM_INT16)Temp; + } + } + } + else{ + if (OutLoop){ + Current -= Delta; /* Q31 + Q31 into Q31*/ + if (Current < Target) + Current = Target; + + CurrentShort = (LVM_INT16)(Current>>16); /* From Q31 to Q15*/ + + for (ii = OutLoop; ii != 0; ii--){ + Temp = ((LVM_INT32)*dst) + (((LVM_INT32)*(src++) * CurrentShort)>>15); /* Q15 + Q15*Q15>>15 into Q15 */ + if (Temp > 0x00007FFF) + *dst++ = 0x7FFF; + else if (Temp < -0x00008000) + *dst++ = - 0x8000; + else + *dst++ = (LVM_INT16)Temp; + } + } + + for (ii = InLoop; ii != 0; ii--){ + Current -= Delta; /* Q31 + Q31 into Q31*/ + if (Current < Target) + Current = Target; + + CurrentShort = (LVM_INT16)(Current>>16); /* From Q31 to Q15*/ + + for (jj = 4; jj!=0 ; jj--){ + Temp = ((LVM_INT32)*dst) + (((LVM_INT32)*(src++) * CurrentShort)>>15); /* Q15 + Q15*Q15>>15 into Q15 */ + if (Temp > 0x00007FFF) + *dst++ = 0x7FFF; + else if (Temp < -0x00008000) + *dst++ = - 0x8000; + else + *dst++ = (LVM_INT16)Temp; + } + } + } + pInstance->Current=Current; +} + + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Core_MixSoft_1St_2i_D16C31_WRA.c b/media/libeffects/lvm/lib/Common/src/LVC_Core_MixSoft_1St_2i_D16C31_WRA.c new file mode 100755 index 0000000..2847d47 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVC_Core_MixSoft_1St_2i_D16C31_WRA.c @@ -0,0 +1,151 @@ +/* + * 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: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "LVC_Mixer_Private.h" +#include "ScalarArithmetic.h" +#include "LVM_Macros.h" + +/********************************************************************************** + FUNCTION LVC_Core_MixSoft_1St_2i_D16C31_WRA +***********************************************************************************/ + +void LVC_Core_MixSoft_1St_2i_D16C31_WRA( LVMixer3_st *ptrInstance1, + LVMixer3_st *ptrInstance2, + const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n) +{ + LVM_INT16 OutLoop; + LVM_INT16 InLoop; + LVM_INT16 CurrentShortL; + LVM_INT16 CurrentShortR; + LVM_INT32 ii; + Mix_Private_st *pInstanceL=(Mix_Private_st *)(ptrInstance1->PrivateParams); + Mix_Private_st *pInstanceR=(Mix_Private_st *)(ptrInstance2->PrivateParams); + + LVM_INT32 DeltaL=pInstanceL->Delta; + LVM_INT32 CurrentL=pInstanceL->Current; + LVM_INT32 TargetL=pInstanceL->Target; + + LVM_INT32 DeltaR=pInstanceR->Delta; + LVM_INT32 CurrentR=pInstanceR->Current; + LVM_INT32 TargetR=pInstanceR->Target; + + LVM_INT32 Temp; + + InLoop = (LVM_INT16)(n >> 2); /* Process per 4 samples */ + OutLoop = (LVM_INT16)(n - (InLoop << 2)); + + if (OutLoop) + { + if(CurrentL<TargetL) + { + ADD2_SAT_32x32(CurrentL,DeltaL,Temp); /* Q31 + Q31 into Q31*/ + CurrentL=Temp; + if (CurrentL > TargetL) + CurrentL = TargetL; + } + else + { + CurrentL -= DeltaL; /* Q31 + Q31 into Q31*/ + if (CurrentL < TargetL) + CurrentL = TargetL; + } + + if(CurrentR<TargetR) + { + ADD2_SAT_32x32(CurrentR,DeltaR,Temp); /* Q31 + Q31 into Q31*/ + CurrentR=Temp; + if (CurrentR > TargetR) + CurrentR = TargetR; + } + else + { + CurrentR -= DeltaR; /* Q31 + Q31 into Q31*/ + if (CurrentR < TargetR) + CurrentR = TargetR; + } + + CurrentShortL = (LVM_INT16)(CurrentL>>16); /* From Q31 to Q15*/ + CurrentShortR = (LVM_INT16)(CurrentR>>16); /* From Q31 to Q15*/ + + for (ii = OutLoop*2; ii != 0; ii-=2) + { + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShortL)>>15); /* Q15*Q15>>15 into Q15 */ + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShortR)>>15); /* Q15*Q15>>15 into Q15 */ + } + } + + for (ii = InLoop*2; ii != 0; ii-=2) + { + if(CurrentL<TargetL) + { + ADD2_SAT_32x32(CurrentL,DeltaL,Temp); /* Q31 + Q31 into Q31*/ + CurrentL=Temp; + if (CurrentL > TargetL) + CurrentL = TargetL; + } + else + { + CurrentL -= DeltaL; /* Q31 + Q31 into Q31*/ + if (CurrentL < TargetL) + CurrentL = TargetL; + } + + if(CurrentR<TargetR) + { + ADD2_SAT_32x32(CurrentR,DeltaR,Temp); /* Q31 + Q31 into Q31*/ + CurrentR=Temp; + if (CurrentR > TargetR) + CurrentR = TargetR; + } + else + { + CurrentR -= DeltaR; /* Q31 + Q31 into Q31*/ + if (CurrentR < TargetR) + CurrentR = TargetR; + } + + CurrentShortL = (LVM_INT16)(CurrentL>>16); /* From Q31 to Q15*/ + CurrentShortR = (LVM_INT16)(CurrentR>>16); /* From Q31 to Q15*/ + + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShortL)>>15); /* Q15*Q15>>15 into Q15 */ + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShortR)>>15); /* Q15*Q15>>15 into Q15 */ + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShortL)>>15); + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShortR)>>15); + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShortL)>>15); + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShortR)>>15); + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShortL)>>15); + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShortR)>>15); + } + pInstanceL->Current=CurrentL; + pInstanceR->Current=CurrentR; + +} +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Core_MixSoft_1St_D16C31_WRA.c b/media/libeffects/lvm/lib/Common/src/LVC_Core_MixSoft_1St_D16C31_WRA.c new file mode 100755 index 0000000..78f0122 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVC_Core_MixSoft_1St_D16C31_WRA.c @@ -0,0 +1,114 @@ +/* + * 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: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "LVC_Mixer_Private.h" +#include "LVM_Macros.h" +#include "ScalarArithmetic.h" + +/********************************************************************************** + FUNCTION LVCore_MIXSOFT_1ST_D16C31_WRA +***********************************************************************************/ + +void LVC_Core_MixSoft_1St_D16C31_WRA( LVMixer3_st *ptrInstance, + const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n) +{ + LVM_INT16 OutLoop; + LVM_INT16 InLoop; + LVM_INT16 CurrentShort; + LVM_INT32 ii; + Mix_Private_st *pInstance=(Mix_Private_st *)(ptrInstance->PrivateParams); + LVM_INT32 Delta=pInstance->Delta; + LVM_INT32 Current=pInstance->Current; + LVM_INT32 Target=pInstance->Target; + LVM_INT32 Temp; + + InLoop = (LVM_INT16)(n >> 2); /* Process per 4 samples */ + OutLoop = (LVM_INT16)(n - (InLoop << 2)); + + if(Current<Target){ + if (OutLoop){ + ADD2_SAT_32x32(Current,Delta,Temp); /* Q31 + Q31 into Q31*/ + Current=Temp; + if (Current > Target) + Current = Target; + + CurrentShort = (LVM_INT16)(Current>>16); /* From Q31 to Q15*/ + + for (ii = OutLoop; ii != 0; ii--){ + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShort)>>15); /* Q15*Q15>>15 into Q15 */ + } + } + + for (ii = InLoop; ii != 0; ii--){ + ADD2_SAT_32x32(Current,Delta,Temp); /* Q31 + Q31 into Q31*/ + Current=Temp; + if (Current > Target) + Current = Target; + + CurrentShort = (LVM_INT16)(Current>>16); /* From Q31 to Q15*/ + + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShort)>>15); /* Q15*Q15>>15 into Q15 */ + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShort)>>15); + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShort)>>15); + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShort)>>15); + } + } + else{ + if (OutLoop){ + Current -= Delta; /* Q31 + Q31 into Q31*/ + if (Current < Target) + Current = Target; + + CurrentShort = (LVM_INT16)(Current>>16); /* From Q31 to Q15*/ + + for (ii = OutLoop; ii != 0; ii--){ + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShort)>>15); /* Q15*Q15>>15 into Q15 */ + } + } + + for (ii = InLoop; ii != 0; ii--){ + Current -= Delta; /* Q31 + Q31 into Q31*/ + if (Current < Target) + Current = Target; + + CurrentShort = (LVM_INT16)(Current>>16); /* From Q31 to Q15*/ + + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShort)>>15); /* Q15*Q15>>15 into Q15 */ + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShort)>>15); + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShort)>>15); + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShort)>>15); + } + } + pInstance->Current=Current; +} + + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/LVC_MixInSoft_D16C31_SAT.c b/media/libeffects/lvm/lib/Common/src/LVC_MixInSoft_D16C31_SAT.c new file mode 100755 index 0000000..52be129 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVC_MixInSoft_D16C31_SAT.c @@ -0,0 +1,120 @@ +/* + * 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: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "LVC_Mixer_Private.h" +#include "VectorArithmetic.h" +#include "ScalarArithmetic.h" + +/********************************************************************************** + DEFINITIONS +***********************************************************************************/ + +#define TRUE 1 +#define FALSE 0 + +/********************************************************************************** + FUNCTION MIXINSOFT_D16C31_SAT +***********************************************************************************/ + +void LVC_MixInSoft_D16C31_SAT( LVMixer3_1St_st *ptrInstance, + LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n) +{ + char HardMixing = TRUE; + LVM_INT32 TargetGain; + Mix_Private_st *pInstance=(Mix_Private_st *)(ptrInstance->MixerStream[0].PrivateParams); + + if(n<=0) return; + + /****************************************************************************** + SOFT MIXING + *******************************************************************************/ + if (pInstance->Current != pInstance->Target) + { + if(pInstance->Delta == 0x7FFFFFFF){ + pInstance->Current = pInstance->Target; + TargetGain=pInstance->Target>>(16-pInstance->Shift); // TargetGain in Q16.15 format + LVC_Mixer_SetTarget(&(ptrInstance->MixerStream[0]),TargetGain); + }else if (Abs_32(pInstance->Current-pInstance->Target) < pInstance->Delta){ + pInstance->Current = pInstance->Target; /* Difference is not significant anymore. Make them equal. */ + TargetGain=pInstance->Target>>(16-pInstance->Shift); // TargetGain in Q16.15 format + LVC_Mixer_SetTarget(&(ptrInstance->MixerStream[0]),TargetGain); + }else{ + /* Soft mixing has to be applied */ + HardMixing = FALSE; + if(pInstance->Shift!=0){ + Shift_Sat_v16xv16 ((LVM_INT16)pInstance->Shift,src,src,n); + LVC_Core_MixInSoft_D16C31_SAT( &(ptrInstance->MixerStream[0]), src, dst, n); + } + else + LVC_Core_MixInSoft_D16C31_SAT( &(ptrInstance->MixerStream[0]), src, dst, n); + } + } + + /****************************************************************************** + HARD MIXING + *******************************************************************************/ + + if (HardMixing){ + if (pInstance->Target != 0){ /* Nothing to do in case Target = 0 */ + if ((pInstance->Target>>16) == 0x7FFF){ + if(pInstance->Shift!=0) + Shift_Sat_v16xv16 ((LVM_INT16)pInstance->Shift,src,src,n); + Add2_Sat_16x16( src, dst, n ); + } + else{ + if(pInstance->Shift!=0) + Shift_Sat_v16xv16 ((LVM_INT16)pInstance->Shift,src,src,n); + Mac3s_Sat_16x16(src,(LVM_INT16)(pInstance->Target>>16),dst,n); + pInstance->Current = pInstance->Target; /* In case the LVCore function would have changed the Current value */ + } + } + } + + + /****************************************************************************** + CALL BACK + *******************************************************************************/ + + if (ptrInstance->MixerStream[0].CallbackSet){ + if (Abs_32(pInstance->Current-pInstance->Target) < pInstance->Delta){ + pInstance->Current = pInstance->Target; /* Difference is not significant anymore. Make them equal. */ + TargetGain=pInstance->Target>>(16-pInstance->Shift); // TargetGain in Q16.15 format + LVC_Mixer_SetTarget(ptrInstance->MixerStream,TargetGain); + ptrInstance->MixerStream[0].CallbackSet = FALSE; + if (ptrInstance->MixerStream[0].pCallBack != 0){ + (*ptrInstance->MixerStream[0].pCallBack) ( ptrInstance->MixerStream[0].pCallbackHandle, ptrInstance->MixerStream[0].pGeneralPurpose,ptrInstance->MixerStream[0].CallbackParam ); + } + } + } + +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/LVC_MixSoft_1St_2i_D16C31_SAT.c b/media/libeffects/lvm/lib/Common/src/LVC_MixSoft_1St_2i_D16C31_SAT.c new file mode 100755 index 0000000..d832e06 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVC_MixSoft_1St_2i_D16C31_SAT.c @@ -0,0 +1,160 @@ +/* + * 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: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "LVC_Mixer_Private.h" +#include "VectorArithmetic.h" +#include "ScalarArithmetic.h" + +/********************************************************************************** + DEFINITIONS +***********************************************************************************/ + +#define TRUE 1 +#define FALSE 0 + +/********************************************************************************** + FUNCTION LVC_MixSoft_1St_2i_D16C31_SAT +***********************************************************************************/ + +void LVC_MixSoft_1St_2i_D16C31_SAT( LVMixer3_2St_st *ptrInstance, + const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n) +{ + char HardMixing = TRUE; + LVM_INT32 TargetGain; + Mix_Private_st *pInstance1=(Mix_Private_st *)(ptrInstance->MixerStream[0].PrivateParams); + Mix_Private_st *pInstance2=(Mix_Private_st *)(ptrInstance->MixerStream[1].PrivateParams); + + if(n<=0) return; + + /****************************************************************************** + SOFT MIXING + *******************************************************************************/ + if ((pInstance1->Current != pInstance1->Target)||(pInstance2->Current != pInstance2->Target)) + { + if(pInstance1->Delta == 0x7FFFFFFF) + { + pInstance1->Current = pInstance1->Target; + TargetGain=pInstance1->Target>>16; // TargetGain in Q16.15 format, no integer part + LVC_Mixer_SetTarget(&(ptrInstance->MixerStream[0]),TargetGain); + } + else if (Abs_32(pInstance1->Current-pInstance1->Target) < pInstance1->Delta) + { + pInstance1->Current = pInstance1->Target; /* Difference is not significant anymore. Make them equal. */ + TargetGain=pInstance1->Target>>16; // TargetGain in Q16.15 format, no integer part + LVC_Mixer_SetTarget(&(ptrInstance->MixerStream[0]),TargetGain); + } + else + { + /* Soft mixing has to be applied */ + HardMixing = FALSE; + } + + if(HardMixing == TRUE) + { + if(pInstance2->Delta == 0x7FFFFFFF) + { + pInstance2->Current = pInstance2->Target; + TargetGain=pInstance2->Target>>16; // TargetGain in Q16.15 format, no integer part + LVC_Mixer_SetTarget(&(ptrInstance->MixerStream[1]),TargetGain); + } + else if (Abs_32(pInstance2->Current-pInstance2->Target) < pInstance2->Delta) + { + pInstance2->Current = pInstance2->Target; /* Difference is not significant anymore. Make them equal. */ + TargetGain=pInstance2->Target>>16; // TargetGain in Q16.15 format, no integer part + LVC_Mixer_SetTarget(&(ptrInstance->MixerStream[1]),TargetGain); + } + else + { + /* Soft mixing has to be applied */ + HardMixing = FALSE; + } + } + + if(HardMixing == FALSE) + { + LVC_Core_MixSoft_1St_2i_D16C31_WRA( &(ptrInstance->MixerStream[0]),&(ptrInstance->MixerStream[1]), src, dst, n); + } + } + + /****************************************************************************** + HARD MIXING + *******************************************************************************/ + + if (HardMixing) + { + if (((pInstance1->Target>>16) == 0x7FFF)&&((pInstance2->Target>>16) == 0x7FFF)) + { + if(src!=dst) + { + Copy_16(src, dst, n); + } + } + else + { + LVC_Core_MixHard_1St_2i_D16C31_SAT(&(ptrInstance->MixerStream[0]),&(ptrInstance->MixerStream[1]), src, dst, n); + } + } + + /****************************************************************************** + CALL BACK + *******************************************************************************/ + + if (ptrInstance->MixerStream[0].CallbackSet) + { + if (Abs_32(pInstance1->Current-pInstance1->Target) < pInstance1->Delta) + { + pInstance1->Current = pInstance1->Target; /* Difference is not significant anymore. Make them equal. */ + TargetGain=pInstance1->Target>>(16-pInstance1->Shift); // TargetGain in Q16.15 format + LVC_Mixer_SetTarget(&ptrInstance->MixerStream[0],TargetGain); + ptrInstance->MixerStream[0].CallbackSet = FALSE; + if (ptrInstance->MixerStream[0].pCallBack != 0) + { + (*ptrInstance->MixerStream[0].pCallBack) ( ptrInstance->MixerStream[0].pCallbackHandle, ptrInstance->MixerStream[0].pGeneralPurpose,ptrInstance->MixerStream[0].CallbackParam ); + } + } + } + if (ptrInstance->MixerStream[1].CallbackSet) + { + if (Abs_32(pInstance2->Current-pInstance2->Target) < pInstance2->Delta) + { + pInstance2->Current = pInstance2->Target; /* Difference is not significant anymore. Make them equal. */ + TargetGain=pInstance2->Target>>(16-pInstance2->Shift); // TargetGain in Q16.15 format + LVC_Mixer_SetTarget(&ptrInstance->MixerStream[1],TargetGain); + ptrInstance->MixerStream[1].CallbackSet = FALSE; + if (ptrInstance->MixerStream[1].pCallBack != 0) + { + (*ptrInstance->MixerStream[1].pCallBack) ( ptrInstance->MixerStream[1].pCallbackHandle, ptrInstance->MixerStream[1].pGeneralPurpose,ptrInstance->MixerStream[1].CallbackParam ); + } + } + } +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/LVC_MixSoft_1St_D16C31_SAT.c b/media/libeffects/lvm/lib/Common/src/LVC_MixSoft_1St_D16C31_SAT.c new file mode 100755 index 0000000..cfb1239 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVC_MixSoft_1St_D16C31_SAT.c @@ -0,0 +1,119 @@ +/* + * 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: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "LVC_Mixer_Private.h" +#include "VectorArithmetic.h" +#include "ScalarArithmetic.h" + +/********************************************************************************** + DEFINITIONS +***********************************************************************************/ + +#define TRUE 1 +#define FALSE 0 + +/********************************************************************************** + FUNCTION LVMixer3_MIXSOFT_1ST_D16C31_SAT +***********************************************************************************/ + +void LVC_MixSoft_1St_D16C31_SAT( LVMixer3_1St_st *ptrInstance, + const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n) +{ + char HardMixing = TRUE; + LVM_INT32 TargetGain; + Mix_Private_st *pInstance=(Mix_Private_st *)(ptrInstance->MixerStream[0].PrivateParams); + + if(n<=0) return; + + /****************************************************************************** + SOFT MIXING + *******************************************************************************/ + if (pInstance->Current != pInstance->Target) + { + if(pInstance->Delta == 0x7FFFFFFF){ + pInstance->Current = pInstance->Target; + TargetGain=pInstance->Target>>(16-pInstance->Shift); // TargetGain in Q16.15 format + LVC_Mixer_SetTarget(&(ptrInstance->MixerStream[0]),TargetGain); + }else if (Abs_32(pInstance->Current-pInstance->Target) < pInstance->Delta){ + pInstance->Current = pInstance->Target; /* Difference is not significant anymore. Make them equal. */ + TargetGain=pInstance->Target>>(16-pInstance->Shift); // TargetGain in Q16.15 format + LVC_Mixer_SetTarget(&(ptrInstance->MixerStream[0]),TargetGain); + }else{ + /* Soft mixing has to be applied */ + HardMixing = FALSE; + if(pInstance->Shift!=0){ + Shift_Sat_v16xv16 ((LVM_INT16)pInstance->Shift,src,dst,n); + LVC_Core_MixSoft_1St_D16C31_WRA( &(ptrInstance->MixerStream[0]), dst, dst, n); + } + else + LVC_Core_MixSoft_1St_D16C31_WRA( &(ptrInstance->MixerStream[0]), src, dst, n); + } + } + + /****************************************************************************** + HARD MIXING + *******************************************************************************/ + + if (HardMixing){ + if (pInstance->Target == 0) + LoadConst_16(0, dst, n); + else if(pInstance->Shift!=0){ + Shift_Sat_v16xv16 ((LVM_INT16)pInstance->Shift,src,dst,n); + if ((pInstance->Target>>16) != 0x7FFF) + Mult3s_16x16( dst, (LVM_INT16)(pInstance->Target>>16), dst, n ); + } + else { + if ((pInstance->Target>>16) != 0x7FFF) + Mult3s_16x16( src, (LVM_INT16)(pInstance->Target>>16), dst, n ); + else if(src!=dst) + Copy_16(src, dst, n); + } + + } + + /****************************************************************************** + CALL BACK + *******************************************************************************/ + + if (ptrInstance->MixerStream[0].CallbackSet){ + if (Abs_32(pInstance->Current-pInstance->Target) < pInstance->Delta){ + pInstance->Current = pInstance->Target; /* Difference is not significant anymore. Make them equal. */ + TargetGain=pInstance->Target>>(16-pInstance->Shift); // TargetGain in Q16.15 format + LVC_Mixer_SetTarget(ptrInstance->MixerStream,TargetGain); + ptrInstance->MixerStream[0].CallbackSet = FALSE; + if (ptrInstance->MixerStream[0].pCallBack != 0){ + (*ptrInstance->MixerStream[0].pCallBack) ( ptrInstance->MixerStream[0].pCallbackHandle, ptrInstance->MixerStream[0].pGeneralPurpose,ptrInstance->MixerStream[0].CallbackParam ); + } + } + } +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/LVC_MixSoft_2St_D16C31_SAT.c b/media/libeffects/lvm/lib/Common/src/LVC_MixSoft_2St_D16C31_SAT.c new file mode 100755 index 0000000..6184736 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVC_MixSoft_2St_D16C31_SAT.c @@ -0,0 +1,78 @@ +/* + * 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: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "LVC_Mixer_Private.h" +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION LVC_MixSoft_2St_D16C31_SAT.c +***********************************************************************************/ + +void LVC_MixSoft_2St_D16C31_SAT( LVMixer3_2St_st *ptrInstance, + const LVM_INT16 *src1, + LVM_INT16 *src2, + LVM_INT16 *dst, + LVM_INT16 n) +{ + Mix_Private_st *pInstance1=(Mix_Private_st *)(ptrInstance->MixerStream[0].PrivateParams); + Mix_Private_st *pInstance2=(Mix_Private_st *)(ptrInstance->MixerStream[1].PrivateParams); + + if(n<=0) return; + + /****************************************************************************** + SOFT MIXING + *******************************************************************************/ + if ((pInstance1->Current == pInstance1->Target)&&(pInstance1->Current == 0)){ + LVC_MixSoft_1St_D16C31_SAT( (LVMixer3_1St_st *)(&ptrInstance->MixerStream[1]), src2, dst, n); + } + else if ((pInstance2->Current == pInstance2->Target)&&(pInstance2->Current == 0)){ + LVC_MixSoft_1St_D16C31_SAT( (LVMixer3_1St_st *)(&ptrInstance->MixerStream[0]), src1, dst, n); + } + else if ((pInstance1->Current != pInstance1->Target) || (pInstance2->Current != pInstance2->Target)) + { + LVC_MixSoft_1St_D16C31_SAT((LVMixer3_1St_st *)(&ptrInstance->MixerStream[0]), src1, dst, n); + LVC_MixInSoft_D16C31_SAT( (LVMixer3_1St_st *)(&ptrInstance->MixerStream[1]), src2, dst, n); + } + else{ + /****************************************************************************** + HARD MIXING + *******************************************************************************/ + if(pInstance2->Shift!=0) + Shift_Sat_v16xv16 ((LVM_INT16)pInstance2->Shift,src2,src2,n); + if(pInstance1->Shift!=0) + { + Shift_Sat_v16xv16 ((LVM_INT16)pInstance1->Shift,src1,dst,n); + LVC_Core_MixHard_2St_D16C31_SAT( &ptrInstance->MixerStream[0], &ptrInstance->MixerStream[1], dst, src2, dst, n); + } + else + LVC_Core_MixHard_2St_D16C31_SAT( &ptrInstance->MixerStream[0], &ptrInstance->MixerStream[1], src1, src2, dst, n); + } +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Mixer.h b/media/libeffects/lvm/lib/Common/src/LVC_Mixer.h new file mode 100755 index 0000000..3b32e21 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVC_Mixer.h @@ -0,0 +1,144 @@ +/* + * 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: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +#ifndef __LVC_MIXER_H__ +#define __LVC_MIXER_H__ + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +#include "LVM_Types.h" + +/********************************************************************************** + INSTANCE MEMORY TYPE DEFINITION +***********************************************************************************/ + +/* LVMixer3_st structure stores Instance parameters for one audio stream */ +typedef struct +{ + LVM_INT32 PrivateParams[4]; /* Private Instance params for Audio Stream */ + LVM_INT16 CallbackSet; /* Boolean. Should be set by calling application each time the target value is updated */ + LVM_INT16 CallbackParam; /* Parameter that will be used in the calback function */ + void *pCallbackHandle; /* Pointer to the instance of the callback function */ + void *pGeneralPurpose; /* Pointer for general purpose usage */ + LVM_Callback pCallBack; /* Pointer to the callback function */ +} LVMixer3_st; + +typedef struct +{ + LVMixer3_st MixerStream[1]; /* Instance Params for one Audio Stream */ +} LVMixer3_1St_st; + +typedef struct +{ + LVMixer3_st MixerStream[2]; /* Instance Params for two Audio Streams */ +} LVMixer3_2St_st; + +typedef struct +{ + LVMixer3_st MixerStream[3]; /* Instance Params for three Audio Streams */ +} LVMixer3_3St_st; + +/********************************************************************************** + FUNCTION PROTOTYPES (HIGH LEVEL FUNCTIONS) +***********************************************************************************/ + +/* Function names should be unique within first 16 characters */ +#define LVMixer3_MixSoft_1St_D16C31_SAT LVMixer3_1St_D16C31_SAT_MixSoft +#define LVMixer3_MixInSoft_D16C31_SAT LVMixer3_D16C31_SAT_MixInSoft +#define LVMixer3_MixSoft_2St_D16C31_SAT LVMixer3_2St_D16C31_SAT_MixSoft +#define LVMixer3_MixSoft_3St_D16C31_SAT LVMixer3_3St_D16C31_SAT_MixSoft + + +/*** General functions ************************************************************/ + +/**********************************************************************************/ +/* This time constant calculation function assumes the mixer will be called with */ +/* large block sizes. When the block size is small, especially if less than 4, */ +/* then the calculation will give an incorrect value for alpha, see the mixer */ +/* documentation for further details. */ +/* ********************************************************************************/ +void LVC_Mixer_SetTarget( LVMixer3_st *pStream, + LVM_INT32 TargetGain); + +LVM_INT32 LVC_Mixer_GetTarget( LVMixer3_st *pStream); + +LVM_INT32 LVC_Mixer_GetCurrent( LVMixer3_st *pStream); + +void LVC_Mixer_Init( LVMixer3_st *pStream, + LVM_INT32 TargetGain, + LVM_INT32 CurrentGain); + +void LVC_Mixer_SetTimeConstant( LVMixer3_st *pStream, + LVM_INT32 Tc_millisec, + LVM_Fs_en Fs, + LVM_INT16 NumChannels); + +void LVC_Mixer_VarSlope_SetTimeConstant( LVMixer3_st *pStream, + LVM_INT32 Tc_millisec, + LVM_Fs_en Fs, + LVM_INT16 NumChannels); + +/*** 16 bit functions *************************************************************/ + +void LVC_MixSoft_1St_D16C31_SAT( LVMixer3_1St_st *pInstance, + const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n); + +void LVC_MixInSoft_D16C31_SAT( LVMixer3_1St_st *pInstance, + LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n); + +void LVC_MixSoft_2St_D16C31_SAT( LVMixer3_2St_st *pInstance, + const LVM_INT16 *src1, + LVM_INT16 *src2, + LVM_INT16 *dst, /* dst cannot be equal to src2 */ + LVM_INT16 n); + +/**********************************************************************************/ +/* For applying different gains to Left and right chennals */ +/* MixerStream[0] applies to Left channel */ +/* MixerStream[1] applies to Right channel */ +/* Gain values should not be more that 1.0 */ +/**********************************************************************************/ +void LVC_MixSoft_1St_2i_D16C31_SAT( LVMixer3_2St_st *pInstance, + const LVM_INT16 *src, + LVM_INT16 *dst, /* dst can be equal to src */ + LVM_INT16 n); /* Number of stereo samples */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/**********************************************************************************/ + +#endif //#ifndef __LVC_MIXER_H__ + diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Mixer_GetCurrent.c b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_GetCurrent.c new file mode 100755 index 0000000..09658ba --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_GetCurrent.c @@ -0,0 +1,50 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 839 $*/ +/* $Date: 2010-06-16 14:15:52 +0200 (Wed, 16 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "LVM_Types.h" +#include "LVM_Macros.h" +#include "LVC_Mixer_Private.h" + + +/************************************************************************/ +/* FUNCTION: */ +/* LVMixer3_GetCurrent */ +/* */ +/* DESCRIPTION: */ +/* This function returns the CurrentGain in Q16.15 format */ +/* */ +/* RETURNS: */ +/* CurrentGain - CurrentGain value in Q 16.15 format */ +/* */ +/************************************************************************/ + +LVM_INT32 LVC_Mixer_GetCurrent( LVMixer3_st *pStream) +{ + LVM_INT32 CurrentGain; + Mix_Private_st *pInstance=(Mix_Private_st *)pStream->PrivateParams; + CurrentGain=pInstance->Current>>(16-pInstance->Shift); // CurrentGain in Q16.15 format + return CurrentGain; +} diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Mixer_GetTarget.c b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_GetTarget.c new file mode 100755 index 0000000..ed2cf94 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_GetTarget.c @@ -0,0 +1,51 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 839 $*/ +/* $Date: 2010-06-16 14:15:52 +0200 (Wed, 16 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "LVM_Types.h" +#include "LVM_Macros.h" +#include "LVC_Mixer_Private.h" + +/************************************************************************/ +/* FUNCTION: */ +/* LVMixer3_GetTarget */ +/* */ +/* DESCRIPTION: */ +/* This function returns the TargetGain in Q16.15 format */ +/* */ +/* RETURNS: */ +/* TargetGain - TargetGain value in Q 16.15 format */ +/* */ +/************************************************************************/ + +LVM_INT32 LVC_Mixer_GetTarget( LVMixer3_st *pStream) +{ + LVM_INT32 TargetGain; + Mix_Private_st *pInstance=(Mix_Private_st *)pStream->PrivateParams; + + TargetGain=pInstance->Target>>(16-pInstance->Shift); // TargetGain in Q16.15 format + + return TargetGain; +} diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Mixer_Init.c b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_Init.c new file mode 100755 index 0000000..c61e468 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_Init.c @@ -0,0 +1,76 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "LVM_Types.h" +#include "LVM_Macros.h" +#include "LVC_Mixer_Private.h" + +/************************************************************************/ +/* FUNCTION: */ +/* LVMixer3_Init */ +/* */ +/* DESCRIPTION: */ +/* This intialization function intializes the private instance */ +/* paramters for a given Audio Stream based on TargetGain and */ +/* CurrentGain */ +/* This function caclulates the "Shift" required to provide the */ +/* integer part of TargetGain and fractional gain values "Target" and */ +/* "Current" based on maximum(TargetGain,CurrentGain) */ +/* E.g. CurrentGain=1.9 and TargetGain=2.5 then based on */ +/* MaxGain of 2.5, Shift = 2, Current=1.9/4=0.475, Target=2.5/4=0.625 */ +/* Therefore integer gain of 4 is provided by Left Shift of 2 and */ +/* fraction gain is provided through Current=0.475 and Target=0.625 */ +/* PARAMETERS: */ +/* pStream - ptr to Instance Parameter Structure LVMixer3_st for an*/ +/* Audio Stream */ +/* TargetGain - TargetGain value in Q 16.15 format */ +/* CurrentGain - CurrentGain value in Q 16.15 format */ +/* */ +/* RETURNS: */ +/* void */ +/* */ +/************************************************************************/ + +void LVC_Mixer_Init( LVMixer3_st *pStream, + LVM_INT32 TargetGain, + LVM_INT32 CurrentGain) +{ + LVM_INT16 Shift=0; + LVM_INT32 MaxGain=TargetGain; // MaxGain is in Q16.15 format + Mix_Private_st *pInstance=(Mix_Private_st *)pStream->PrivateParams; + if(CurrentGain>MaxGain) + MaxGain=CurrentGain; // MaxGain=max(CurrentGain,TargetGain) + + MaxGain=MaxGain>>15; // MaxGain in Q31.0 format i.e Integer part only + while(MaxGain>0){ // Update Shift required to provide integer gain + Shift++; + MaxGain=MaxGain>>1; + } + pInstance->Target=TargetGain<<(16-Shift); // Update fractional gain Target + pInstance->Current=CurrentGain<<(16-Shift); // Update fractional gain Current + pInstance->Shift=Shift; // Update Shift +} + diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Mixer_Private.h b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_Private.h new file mode 100755 index 0000000..d61d670 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_Private.h @@ -0,0 +1,136 @@ +/* + * 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: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +#ifndef __LVC_MIXER_PRIVATE_H__ +#define __LVC_MIXER_PRIVATE_H__ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "LVC_Mixer.h" +#include "VectorArithmetic.h" + +/* Instance parameter structure */ +typedef struct +{ + /* General */ + LVM_INT32 Target; /* 32 bit number specifying fractional value of Target Gain */ + LVM_INT32 Current; /* 32 bit number specifying fractional valude of Current Gain */ + LVM_INT32 Shift; /* Left Shift for Integer part of Gain */ + LVM_INT32 Delta; /* 32 bit number specifying the fractional value of Delta Gain */ +} Mix_Private_st; + + + +/********************************************************************************** + DEFINITIONS +***********************************************************************************/ +#define LVCore_MixInSoft_D32C31_SAT LVCore_InSoft_D32C31_SAT +#define LVCore_MixSoft_1St_D32C31_WRA LVCore_Soft_1St_D32C31_WRA +#define LVCore_MixHard_2St_D32C31_SAT LVCore_Hard_2St_D32C31_SAT + +/********************************************************************************** + FUNCTION PROTOTYPES (LOW LEVEL SUBFUNCTIONS) +***********************************************************************************/ + +/*** 16 bit functions *************************************************************/ + +void LVC_Core_MixInSoft_D16C31_SAT( LVMixer3_st *pInstance, + const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n); + +void LVC_Core_MixSoft_1St_D16C31_WRA( LVMixer3_st *pInstance, + const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n); + +void LVC_Core_MixHard_2St_D16C31_SAT( LVMixer3_st *pInstance1, + LVMixer3_st *pInstance2, + const LVM_INT16 *src1, + const LVM_INT16 *src2, + LVM_INT16 *dst, + LVM_INT16 n); + +/**********************************************************************************/ +/* For applying different gains to Left and right chennals */ +/* ptrInstance1 applies to Left channel */ +/* ptrInstance2 applies to Right channel */ +/* Gain values should not be more that 1.0 */ +/**********************************************************************************/ + +void LVC_Core_MixSoft_1St_2i_D16C31_WRA( LVMixer3_st *ptrInstance1, + LVMixer3_st *ptrInstance2, + const LVM_INT16 *src, + LVM_INT16 *dst, /* dst can be equal to src */ + LVM_INT16 n); /* Number of stereo samples */ + +/**********************************************************************************/ +/* For applying different gains to Left and right chennals */ +/* ptrInstance1 applies to Left channel */ +/* ptrInstance2 applies to Right channel */ +/* Gain values should not be more that 1.0 */ +/**********************************************************************************/ +void LVC_Core_MixHard_1St_2i_D16C31_SAT( LVMixer3_st *ptrInstance1, + LVMixer3_st *ptrInstance2, + const LVM_INT16 *src, + LVM_INT16 *dst, /* dst can be equal to src */ + LVM_INT16 n); /* Number of stereo samples */ + + + +/*** 32 bit functions *************************************************************/ + +void LVC_Core_MixInSoft_D32C31_SAT( LVMixer3_st *pInstance, + const LVM_INT32 *src, + LVM_INT32 *dst, + LVM_INT16 n); + +void LVC_Core_MixSoft_1St_D32C31_WRA( LVMixer3_st *pInstance, + const LVM_INT32 *src, + LVM_INT32 *dst, + LVM_INT16 n); + +void LVC_Core_MixHard_2St_D32C31_SAT( LVMixer3_st *pInstance1, + LVMixer3_st *pInstance2, + const LVM_INT32 *src1, + const LVM_INT32 *src2, + LVM_INT32 *dst, + LVM_INT16 n); + +/**********************************************************************************/ + +#endif //#ifndef __LVC_MIXER_PRIVATE_H__ + + + + + + + + + + diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Mixer_SetTarget.c b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_SetTarget.c new file mode 100755 index 0000000..4d3fe0c --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_SetTarget.c @@ -0,0 +1,75 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "LVM_Types.h" +#include "LVM_Macros.h" +#include "LVC_Mixer_Private.h" + +/************************************************************************/ +/* FUNCTION: */ +/* LVMixer3_SetTarget */ +/* */ +/* DESCRIPTION: */ +/* This function updates the private instance parameters: Shift,Target,*/ +/* Current for a given Audio Stream based on new value of TargetGain */ +/* */ +/* This function caclulates the "Shift" required to provide the */ +/* integer part of TargetGain and fractional gain values "Target" and */ +/* "Current" based on maximum(TargetGain,CurrentGain) */ +/* E.g. CurrentGain=1.9 and TargetGain=2.5 then based on */ +/* MaxGain of 2.5, Shift = 2, Current=1.9/4=0.475, Target=2.5/4=0.625 */ +/* Therefore integer gain of 4 is provided by Left Shift of 2 and */ +/* fraction gain is provided through Current=0.475 and Target=0.625 */ +/* PARAMETERS: */ +/* pStream - ptr to Instance Parameter Structure LVMixer3_st */ +/* for an Audio Stream */ +/* TargetGain - TargetGain value in Q 16.15 format */ +/* */ +/* RETURNS: */ +/* void */ +/* */ +/************************************************************************/ + +void LVC_Mixer_SetTarget(LVMixer3_st *pStream, + LVM_INT32 TargetGain) +{ + LVM_INT32 Shift=0; + LVM_INT32 CurrentGain; + LVM_INT32 MaxGain=TargetGain; // MaxGain is in Q16.15 format + Mix_Private_st *pInstance=(Mix_Private_st *)pStream->PrivateParams; + CurrentGain=pInstance->Current>>(16-pInstance->Shift); // CurrentGain in Q16.15 format + if(CurrentGain>MaxGain) + MaxGain=CurrentGain; // MaxGain=max(CurrentGain,TargetGain) + + MaxGain=MaxGain>>15; // MaxGain in Q31.0 format i.e Integer part only + while(MaxGain>0){ // Update Shift required to provide integer gain + Shift++; + MaxGain=MaxGain>>1; + } + pInstance->Target=TargetGain<<(16-Shift); // Update fractional gain Target + pInstance->Current=CurrentGain<<(16-Shift); // Update fractional gain Current + pInstance->Shift=Shift; // Update Shift +} diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Mixer_SetTimeConstant.c b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_SetTimeConstant.c new file mode 100755 index 0000000..df0fd37 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_SetTimeConstant.c @@ -0,0 +1,84 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "LVM_Types.h" +#include "LVM_Macros.h" +#include "LVC_Mixer_Private.h" + +/************************************************************************/ +/* FUNCTION: */ +/* LVMixer3_SetTimeConstant */ +/* */ +/* DESCRIPTION: */ +/* This function calculates the step change for fractional gain for a */ +/* given time constant, sample rate and num channels */ +/* Delta=(2147483647*4*1000)/(NumChannels*SampleRate*Tc_millisec) */ +/* in Q 0.31 format */ +/* */ +/* PARAMETERS: */ +/* pStream - ptr to Instance Parameter Structure LVMixer3_st for an*/ +/* Audio Stream */ +/* Tc_millisec - TimeConstant i.e time required in milli second to */ +/* go from linear fractional gain of 0 to 0.99999999 */ +/* Fs - LVM_Fs_en enumerator for Sampling Frequency */ +/* NumChannels - Number of channels in Audio Stream 1=Mono, 2=Stereo */ +/* */ +/* UPDATES: */ +/* Delta - the step change for fractional gain per 4 samples */ +/* in Q0.31 format for a given Time Constant, */ +/* Sample Rate and NumChannels */ +/* RETURNS: */ +/* void */ +/************************************************************************/ + +void LVC_Mixer_SetTimeConstant(LVMixer3_st *pStream, + LVM_INT32 Tc_millisec, + LVM_Fs_en Fs, + LVM_INT16 NumChannels) +{ + LVM_INT32 DeltaTable[9]={1073741824, + 779132389, + 715827882, + 536870912, + 389566194, + 357913941, + 268435456, + 194783097, + 178956971}; + Mix_Private_st *pInstance=(Mix_Private_st *)pStream->PrivateParams; + LVM_INT32 Delta=DeltaTable[Fs]; + Delta=Delta>>(NumChannels-1); + + if(Tc_millisec==0) + Delta=0x7FFFFFFF; + else + Delta=Delta/Tc_millisec; + + if(Delta==0) + Delta=1; // If Time Constant is so large that Delta is 0, assign minimum value to Delta + + pInstance->Delta=Delta; // Delta=(2147483647*4*1000)/(NumChannels*SampleRate*Tc_millisec) in Q 0.31 format +} diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Mixer_VarSlope_SetTimeConstant.c b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_VarSlope_SetTimeConstant.c new file mode 100755 index 0000000..420af9a --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_VarSlope_SetTimeConstant.c @@ -0,0 +1,104 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "LVM_Types.h" +#include "LVM_Macros.h" +#include "LVC_Mixer_Private.h" + + +/************************************************************************/ +/* FUNCTION: */ +/* LVMixer3_VarSlope_SetTimeConstant */ +/* */ +/* DESCRIPTION: */ +/* This function calculates the step change for fractional gain for a */ +/* given time constant, sample rate and num channels */ +/* Delta=(2147483647*4*1000)/(NumChannels*SampleRate*Tc_millisec) */ +/* in Q 0.31 format */ +/* */ +/* PARAMETERS: */ +/* pStream - ptr to Instance Parameter Structure LVMixer3_st for an*/ +/* Audio Stream */ +/* Tc_millisec - TimeConstant i.e time required in milli second to */ +/* go from linear fractional gain of 0 to 0.99999999 */ +/* Fs - LVM_Fs_en enumerator for Sampling Frequency */ +/* NumChannels - Number of channels in Audio Stream 1=Mono, 2=Stereo */ +/* */ +/* UPDATES: */ +/* Delta - the step change for fractional gain per 4 samples */ +/* in Q0.31 format for a given Time Constant, */ +/* Sample Rate and NumChannels */ +/* RETURNS: */ +/* void */ +/************************************************************************/ + +void LVC_Mixer_VarSlope_SetTimeConstant( LVMixer3_st *pStream, + LVM_INT32 Tc_millisec, + LVM_Fs_en Fs, + LVM_INT16 NumChannels) +{ + LVM_INT32 DeltaTable[9]={1073741824, + 779132389, + 715827882, + 536870912, + 389566194, + 357913941, + 268435456, + 194783097, + 178956971}; + Mix_Private_st *pInstance=(Mix_Private_st *)pStream->PrivateParams; + LVM_INT32 Delta=DeltaTable[Fs]; + + LVM_INT32 Current; + LVM_INT32 Target; + + Delta=Delta>>(NumChannels-1); + + /* Get gain values */ + Current = LVC_Mixer_GetCurrent( pStream ); + Target = LVC_Mixer_GetTarget( pStream ); + + if (Current != Target) + { + Tc_millisec = Tc_millisec * 32767 / (Current - Target); + if (Tc_millisec<0) Tc_millisec = -Tc_millisec; + + if(Tc_millisec==0) + Delta=0x7FFFFFFF; + else + Delta=Delta/Tc_millisec; + + if(Delta==0) + Delta=1; // If Time Constant is so large that Delta is 0, assign minimum value to Delta + } + else + { + Delta =1; // Minimum value for proper call-backs (setting it to zero has some problems, to be corrected) + } + + + pInstance->Delta=Delta; // Delta=(2147483647*4*1000)/(NumChannels*SampleRate*Tc_millisec) in Q 0.31 format +} diff --git a/media/libeffects/lvm/lib/Common/src/LVM_FO_HPF.c b/media/libeffects/lvm/lib/Common/src/LVM_FO_HPF.c new file mode 100755 index 0000000..37c199e --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVM_FO_HPF.c @@ -0,0 +1,109 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: nxp27078 $*/ +/* $Revision: 762 $*/ +/* $Date: 2010-06-11 14:50:33 +0200 (vr, 11 jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "LVM_Types.h" +#include "LVM_Macros.h" +#include "ScalarArithmetic.h" +#include "BIQUAD.h" +#include "Filter.h" + + +/*-------------------------------------------------------------------------*/ +/* FUNCTION: */ +/* void LVM_FO_LPF( LVM_INT32 w , */ +/* FO_C32_Coefs_t *pCoeffs); */ +/* */ +/* */ +/* DESCRIPTION: */ +/* This function calculates the coefficient of first order low pass */ +/* filter. It uses the equations: */ +/* */ +/* B1 = (tan(w/2) - 1 ) / (tan(w/2) + 1 ) */ +/* A0 = (1 - B1) / 2 */ +/* A1 = A0 */ +/* */ +/* The value of B1 is then calculated directly from the value w by a */ +/* polynomial expansion using a 9th order polynomial. It uses the */ +/* following table of 32-bit integer polynomial coefficients: */ +/* */ +/* Coefficient Value */ +/* A0 -8388571 */ +/* A1 33547744 */ +/* A2 -66816791 */ +/* A3 173375308 */ +/* A4 -388437573 */ +/* A5 752975383 */ +/* A6 -1103016663 */ +/* A7 1121848567 */ +/* A8 -688078159 */ +/* A9 194669577 */ +/* A10 8 */ +/* */ +/* Y = (A0 + A1*X + A2*X2 + A3*X3 + ….. + AN*xN) << AN+1 */ +/* */ +/* */ +/* PARAMETERS: */ +/* */ +/* w Sample rate in radians, where: */ +/* w = 2 * Pi * Fc / Fs */ +/* Fc is the corner frequency in Hz */ +/* Fs is the sample rate in Hz */ +/* w is in Q2.29 format and data range is [0 Pi] */ +/* pCoeffs Points to the filter coefficients calculated here */ +/* in Q1.30 format */ +/* RETURNS: */ +/* */ +/*-------------------------------------------------------------------------*/ + +LVM_INT32 LVM_FO_HPF( LVM_INT32 w, + FO_C32_Coefs_t *pCoeffs) +{ + LVM_INT32 Y,Coefficients[13]={ -8388571, + 33547744, + -66816791, + 173375308, + -388437573, + 752975383, + -1103016663, + 1121848567, + -688078159, + 194669577, + 8, + 0, + 0}; + Y=LVM_Polynomial( (LVM_UINT16)9, + Coefficients, + w); + pCoeffs->B1=-Y; /* Store -B1 in filter structure instead of B1!*/ + /* A0=(1-B1)/2= B1/2 - 0.5*/ + Y=Y>>1; /* A0=Y=B1/2*/ + Y=Y-0x40000000; /* A0=Y=(B1/2 - 0.5)*/ + MUL32x16INTO32(Y, FILTER_LOSS ,pCoeffs->A0 ,15) /* Apply loss to avoid overflow*/ + pCoeffs->A1=-pCoeffs->A0; /* Store A1=-A0*/ + + return 1; +} + diff --git a/media/libeffects/lvm/lib/Common/src/LVM_FO_LPF.c b/media/libeffects/lvm/lib/Common/src/LVM_FO_LPF.c new file mode 100755 index 0000000..6c73d59 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVM_FO_LPF.c @@ -0,0 +1,106 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: nxp27078 $*/ +/* $Revision: 762 $*/ +/* $Date: 2010-06-11 14:50:33 +0200 (vr, 11 jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "LVM_Types.h" +#include "LVM_Macros.h" +#include "ScalarArithmetic.h" +#include "BIQUAD.h" +#include "Filter.h" + + +/*-------------------------------------------------------------------------*/ +/* FUNCTION: */ +/* void LVM_FO_LPF( LVM_INT32 w , */ +/* FO_C32_Coefs_t *pCoeffs); */ +/* */ +/* */ +/* DESCRIPTION: */ +/* This function calculates the coefficient of first order low pass */ +/* filter. It uses the equations: */ +/* */ +/* B1 = (tan(w/2) - 1 ) / (tan(w/2) + 1 ) */ +/* A0 = (1 + B1) / 2 */ +/* A1 = A0 */ +/* */ +/* The value of B1 is then calculated directly from the value w by a */ +/* polynomial expansion using a 9th order polynomial. It uses the */ +/* following table of 32-bit integer polynomial coefficients: */ +/* */ +/* Coefficient Value */ +/* A0 -8388571 */ +/* A1 33547744 */ +/* A2 -66816791 */ +/* A3 173375308 */ +/* A4 -388437573 */ +/* A5 752975383 */ +/* A6 -1103016663 */ +/* A7 1121848567 */ +/* A8 -688078159 */ +/* A9 194669577 */ +/* A10 8 */ +/* */ +/* Y = (A0 + A1*X + A2*X2 + A3*X3 + ….. + AN*xN) << AN+1 */ +/* */ +/* */ +/* PARAMETERS: */ +/* */ +/* w Sample rate in radians, where: */ +/* w = 2 * Pi * Fc / Fs */ +/* Fc is the corner frequency in Hz */ +/* Fs is the sample rate in Hz */ +/* w is in Q2.29 format and data range is [0 Pi] */ +/* pCoeffs Points to the filter coefficients calculated here */ +/* in Q1.30 format */ +/* RETURNS: */ +/* */ +/*-------------------------------------------------------------------------*/ + +LVM_INT32 LVM_FO_LPF( LVM_INT32 w, + FO_C32_Coefs_t *pCoeffs) +{ + LVM_INT32 Y,Coefficients[13]={ -8388571, + 33547744, + -66816791, + 173375308, + -388437573, + 752975383, + -1103016663, + 1121848567, + -688078159, + 194669577, + 8}; + Y=LVM_Polynomial( (LVM_UINT16)9, + Coefficients, + w); + pCoeffs->B1=-Y; // Store -B1 in filter structure instead of B1! + // A0=(1+B1)/2= B1/2 + 0.5 + Y=Y>>1; // A0=Y=B1/2 + Y=Y+0x40000000; // A0=Y=(B1/2 + 0.5) + MUL32x16INTO32(Y, FILTER_LOSS ,pCoeffs->A0 ,15) // Apply loss to avoid overflow + pCoeffs->A1=pCoeffs->A0; + return 1; +} + diff --git a/media/libeffects/lvm/lib/Common/src/LVM_GetOmega.c b/media/libeffects/lvm/lib/Common/src/LVM_GetOmega.c new file mode 100755 index 0000000..1cc10db --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVM_GetOmega.c @@ -0,0 +1,79 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: nxp27078 $*/ +/* $Revision: 762 $*/ +/* $Date: 2010-06-11 14:50:33 +0200 (vr, 11 jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "LVM_Types.h" +#include "Filter.h" +#include "LVM_Macros.h" + +/************************************************************************************/ +/* */ +/* Defines and Tables for 2*Pi/Fs */ +/* */ +/************************************************************************************/ + +#define LVVDL_2PiBy_8000 1727108826 /* In Q41 format */ +#define LVVDL_2PiBy_11025 1253230894 /* In Q41 format */ +#define LVVDL_2PiBy_12000 1151405884 /* In Q41 format */ + +#define LVVDL_2PiByFs_SHIFT1 12 /* Qformat shift for 8kHz, 11.025kHz and 12kHz i.e. 12=41-29 */ +#define LVVDL_2PiByFs_SHIFT2 13 /* Qformat shift for 16kHz, 22.050kHz and 24kHz i.e. 13=42-29 */ +#define LVVDL_2PiByFs_SHIFT3 14 /* Qformat shift for 32kHz, 44.1kHz and 48kHz i.e. 14=43-29 */ + +const LVM_INT32 LVVDL_2PiOnFsTable[] = {LVVDL_2PiBy_8000 , /* 8kHz in Q41, 16kHz in Q42, 32kHz in Q43 */ + LVVDL_2PiBy_11025, /* 11025 Hz in Q41, 22050Hz in Q42, 44100 Hz in Q43*/ + LVVDL_2PiBy_12000}; /* 12kHz in Q41, 24kHz in Q42, 48kHz in Q43 */ + + +const LVM_INT32 LVVDL_2PiOnFsShiftTable[]={LVVDL_2PiByFs_SHIFT1 , /* 8kHz, 11025Hz, 12kHz */ + LVVDL_2PiByFs_SHIFT2, /* 16kHz, 22050Hz, 24kHz*/ + LVVDL_2PiByFs_SHIFT3}; /* 32kHz, 44100Hz, 48kHz */ + +/*-------------------------------------------------------------------------*/ +/* FUNCTION: */ +/* LVM_GetOmega */ +/* */ +/* LVM_INT32 LVM_GetOmega(LVM_UINT16 Fc, */ +/* LVM_Fs_en Fs) */ +/* */ +/* DESCRIPTION: */ +/* This function calculates the value of w using Fc and Fs */ +/* */ +/* PARAMETERS: */ +/* */ +/* LVM_UINT16 Fc The corner frequency in Hz Q16.0 format */ +/* LVM_Fs_en Fs The SampleRate */ +/* RETURNS: */ +/* w=2*pi*Fc/Fs in Q2.29 format */ +/*-------------------------------------------------------------------------*/ + +LVM_INT32 LVM_GetOmega(LVM_UINT16 Fc, + LVM_Fs_en Fs) +{ + LVM_INT32 w; + MUL32x32INTO32((LVM_INT32)Fc,LVVDL_2PiOnFsTable[Fs%3],w,LVVDL_2PiOnFsShiftTable[Fs/3]) + return w; +} + diff --git a/media/libeffects/lvm/lib/Common/src/LVM_Mixer_FilterCoeffs.h b/media/libeffects/lvm/lib/Common/src/LVM_Mixer_FilterCoeffs.h new file mode 100755 index 0000000..00235e0 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVM_Mixer_FilterCoeffs.h @@ -0,0 +1,100 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/************************************************************************************/ +/* */ +/* Mixer library tables */ +/* */ +/* Coefficients and table values for the mixer library, generated by the Matlab */ +/* Script: Mixer_GenerateCoeffs.m */ +/* */ +/************************************************************************************/ + +#ifndef __LVM_MIXER_FILTER_COEFFS_H__ +#define __LVM_MIXER_FILTER_COEFFS_H__ + + +/************************************************************************************/ +/* */ +/* Alpha Time Constant table */ +/* */ +/************************************************************************************/ + +#define Alpha_TableSize 50 /* The number of table entires */ +#define ALPHA_0 2147480769 /* Floating point Alpha = 0.999999 */ +#define ALPHA_1 2147479577 /* Floating point Alpha = 0.999998 */ +#define ALPHA_2 2147477892 /* Floating point Alpha = 0.999997 */ +#define ALPHA_3 2147475510 /* Floating point Alpha = 0.999996 */ +#define ALPHA_4 2147472141 /* Floating point Alpha = 0.999995 */ +#define ALPHA_5 2147467377 /* Floating point Alpha = 0.999992 */ +#define ALPHA_6 2147460642 /* Floating point Alpha = 0.999989 */ +#define ALPHA_7 2147451118 /* Floating point Alpha = 0.999985 */ +#define ALPHA_8 2147437651 /* Floating point Alpha = 0.999979 */ +#define ALPHA_9 2147418608 /* Floating point Alpha = 0.999970 */ +#define ALPHA_10 2147391683 /* Floating point Alpha = 0.999957 */ +#define ALPHA_11 2147353611 /* Floating point Alpha = 0.999939 */ +#define ALPHA_12 2147299779 /* Floating point Alpha = 0.999914 */ +#define ALPHA_13 2147223662 /* Floating point Alpha = 0.999879 */ +#define ALPHA_14 2147116037 /* Floating point Alpha = 0.999829 */ +#define ALPHA_15 2146963865 /* Floating point Alpha = 0.999758 */ +#define ALPHA_16 2146748712 /* Floating point Alpha = 0.999658 */ +#define ALPHA_17 2146444522 /* Floating point Alpha = 0.999516 */ +#define ALPHA_18 2146014472 /* Floating point Alpha = 0.999316 */ +#define ALPHA_19 2145406527 /* Floating point Alpha = 0.999033 */ +#define ALPHA_20 2144547188 /* Floating point Alpha = 0.998633 */ +#define ALPHA_21 2143332669 /* Floating point Alpha = 0.998067 */ +#define ALPHA_22 2141616514 /* Floating point Alpha = 0.997268 */ +#define ALPHA_23 2139192215 /* Floating point Alpha = 0.996139 */ +#define ALPHA_24 2135768939 /* Floating point Alpha = 0.994545 */ +#define ALPHA_25 2130937774 /* Floating point Alpha = 0.992295 */ +#define ALPHA_26 2124125153 /* Floating point Alpha = 0.989123 */ +#define ALPHA_27 2114529263 /* Floating point Alpha = 0.984654 */ +#define ALPHA_28 2101034612 /* Floating point Alpha = 0.978370 */ +#define ALPHA_29 2082100030 /* Floating point Alpha = 0.969553 */ +#define ALPHA_30 2055617398 /* Floating point Alpha = 0.957221 */ +#define ALPHA_31 2018744824 /* Floating point Alpha = 0.940051 */ +#define ALPHA_32 1967733015 /* Floating point Alpha = 0.916297 */ +#define ALPHA_33 1897794587 /* Floating point Alpha = 0.883729 */ +#define ALPHA_34 1803123234 /* Floating point Alpha = 0.839645 */ +#define ALPHA_35 1677262220 /* Floating point Alpha = 0.781036 */ +#define ALPHA_36 1514142675 /* Floating point Alpha = 0.705078 */ +#define ALPHA_37 1310197875 /* Floating point Alpha = 0.610108 */ +#define ALPHA_38 1067813480 /* Floating point Alpha = 0.497239 */ +#define ALPHA_39 799601371 /* Floating point Alpha = 0.372343 */ +#define ALPHA_40 531183049 /* Floating point Alpha = 0.247351 */ +#define ALPHA_41 297904007 /* Floating point Alpha = 0.138722 */ +#define ALPHA_42 131499768 /* Floating point Alpha = 0.061234 */ +#define ALPHA_43 41375282 /* Floating point Alpha = 0.019267 */ +#define ALPHA_44 8065899 /* Floating point Alpha = 0.003756 */ +#define ALPHA_45 799076 /* Floating point Alpha = 0.000372 */ +#define ALPHA_46 30398 /* Floating point Alpha = 0.000014 */ +#define ALPHA_47 299 /* Floating point Alpha = 0.000000 */ +#define ALPHA_48 0 /* Floating point Alpha = 0.000000 */ +#define ALPHA_49 0 /* Floating point Alpha = 0.000000 */ +#define ALPHA_50 0 /* Floating point Alpha = 0.000000 */ + + +#endif diff --git a/media/libeffects/lvm/lib/Common/src/LVM_Mixer_TimeConstant.c b/media/libeffects/lvm/lib/Common/src/LVM_Mixer_TimeConstant.c new file mode 100755 index 0000000..db6975a --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVM_Mixer_TimeConstant.c @@ -0,0 +1,165 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "LVM_Types.h" +#include "LVM_Macros.h" +#include "Mixer.h" +#include "LVM_Mixer_FilterCoeffs.h" + + +/************************************************************************/ +/* FUNCTION: */ +/* LVM_Mix_GetTimeConstant */ +/* */ +/* DESCRIPTION: */ +/* This function calculates the filter coefficient using the following */ +/* equation: */ +/* Alpha = exp(ln(0.1)/ (tc * Update + 1.0)) */ +/* */ +/* This is to be used with the follow first order filter, called at a */ +/* rate of Update times a second. tc is the required time constant in */ +/* units of 100us. */ +/* */ +/* Output(n) = Alpha * Output(n-1) + (1 - Alpha) * Target(n) */ +/* */ +/* The function assumes the block size is large, i.e. the update rate */ +/* is approximately a fixed, and correct factor of the value of Fs */ +/* given in the call. This is especially not true when the block size */ +/* is very small, see the mixer documentation for further details. */ +/* */ +/* The function does not support all possible combinations of input */ +/* values: */ +/* */ +/* 1. NumChannels is limited to the values 1 (Mono) and 2 (Stereo) */ +/* 2. The product tc * Fs is limited approximately to the range */ +/* 8 < (tc * Fs) < 2^35 */ +/* */ +/* PARAMETERS: */ +/* tc - the time constant in 100us steps, i.e. 10 = 1ms */ +/* Fs - the filter update rate in Hz */ +/* NumChannels - Number of channels 1=Mono, 2=Stereo */ +/* */ +/* RETURNS: */ +/* Alpha - the filter coefficient Q31 format */ +/* */ +/************************************************************************/ + +LVM_UINT32 LVM_Mixer_TimeConstant(LVM_UINT32 tc, + LVM_UINT16 Fs, + LVM_UINT16 NumChannels) +{ + + LVM_UINT32 Product; + LVM_INT16 Interpolate; + LVM_UINT16 Shift; + LVM_INT32 Diff; + LVM_UINT32 Table[] = {ALPHA_0, /* Log spaced look-up table */ + ALPHA_1, + ALPHA_2, + ALPHA_3, + ALPHA_4, + ALPHA_5, + ALPHA_6, + ALPHA_7, + ALPHA_8, + ALPHA_9, + ALPHA_10, + ALPHA_11, + ALPHA_12, + ALPHA_13, + ALPHA_14, + ALPHA_15, + ALPHA_16, + ALPHA_17, + ALPHA_18, + ALPHA_19, + ALPHA_20, + ALPHA_21, + ALPHA_22, + ALPHA_23, + ALPHA_24, + ALPHA_25, + ALPHA_26, + ALPHA_27, + ALPHA_28, + ALPHA_29, + ALPHA_30, + ALPHA_31, + ALPHA_32, + ALPHA_33, + ALPHA_34, + ALPHA_35, + ALPHA_36, + ALPHA_37, + ALPHA_38, + ALPHA_39, + ALPHA_40, + ALPHA_41, + ALPHA_42, + ALPHA_43, + ALPHA_44, + ALPHA_45, + ALPHA_46, + ALPHA_47, + ALPHA_48, + ALPHA_49, + ALPHA_50}; + + + /* Calculate the product of the time constant and the sample rate */ + Product = ((tc >> 16) * (LVM_UINT32)Fs) << 13; /* Stereo value */ + Product = Product + (((tc & 0x0000FFFF) * (LVM_UINT32)Fs) >> 3); + + if (NumChannels == 1) + { + Product = Product >> 1; /* Mono value */ + } + + /* Normalize to get the table index and interpolation factor */ + for (Shift=0; Shift<((Alpha_TableSize-1)/2); Shift++) + { + if ((Product & 0x80000000)!=0) + { + break; + } + + Product = Product << 1; + } + Shift = (LVM_UINT16)((Shift << 1)); + + if ((Product & 0x40000000)==0) + { + Shift++; + } + + Interpolate = (LVM_INT16)((Product >> 15) & 0x00007FFF); + + Diff = (LVM_INT32)(Table[Shift] - Table[Shift+1]); + MUL32x16INTO32(Diff,Interpolate,Diff,15) + Product = Table[Shift+1] + (LVM_UINT32)Diff; + + return Product; +} diff --git a/media/libeffects/lvm/lib/Common/src/LVM_Polynomial.c b/media/libeffects/lvm/lib/Common/src/LVM_Polynomial.c new file mode 100755 index 0000000..b8cf4b4 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVM_Polynomial.c @@ -0,0 +1,105 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "LVM_Types.h" +#include "LVM_Macros.h" +#include "ScalarArithmetic.h" + +/*-------------------------------------------------------------------------*/ +/* FUNCTION: */ +/* LVM_Polynomial */ +/* */ +/* DESCRIPTION: */ +/* This function performs polynomial expansion */ +/* Y = (A0 + A1*X + A2*X2 + A3*X3 + ….. + AN*xN) << AN+1 */ +/* */ +/* LVM_INT32 LVM_Polynomial(LVM_UINT16 N, */ +/* LVM_INT32 *pCoefficients, */ +/* LVM_INT32 X) */ +/* */ +/* PARAMETERS: */ +/* */ +/* N is the polynomial order */ +/* pCoefficients is the ptr to polynomial coefficients A0,A1.. in Q.31 */ +/* X is the input variable */ +/* */ +/* RETURNS: */ +/* The result of the polynomial expansion in Q1.31 format */ +/*-------------------------------------------------------------------------*/ + +LVM_INT32 LVM_Polynomial(LVM_UINT16 N, + LVM_INT32 *pCoefficients, + LVM_INT32 X) +{ + LVM_INT32 i; + LVM_INT32 Y,A,XTemp,Temp,sign; + + Y=*pCoefficients; /* Y=A0*/ + pCoefficients++; + + if((LVM_UINT32)X==0x80000000) + { + Temp=-1; + sign=Temp; + for(i=1;i<=N;i++) + { + Y+=((*pCoefficients)*sign); + pCoefficients++; + sign*=Temp; + } + + + } + else + { + XTemp=X; + for(i=N-1;i>=0;i--) + { + A=*pCoefficients; + pCoefficients++; + + MUL32x32INTO32(A,XTemp,Temp,31) + Y+=Temp; + + MUL32x32INTO32(XTemp,X,Temp,31) + XTemp=Temp; + } + } + A=*pCoefficients; + pCoefficients++; + + if(A<0) + { + A=Abs_32(A); + Y=Y>>A; + } + else + { + Y = Y<<A; + } + return Y; +} + diff --git a/media/libeffects/lvm/lib/Common/src/LVM_Power10.c b/media/libeffects/lvm/lib/Common/src/LVM_Power10.c new file mode 100755 index 0000000..9a3f632 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVM_Power10.c @@ -0,0 +1,87 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "LVM_Types.h" +#include "LVM_Macros.h" +#include "ScalarArithmetic.h" +#include "Filter.h" + + +/*-------------------------------------------------------------------------*/ +/* FUNCTION: */ +/* LVM_Power10 */ +/* */ +/* DESCRIPTION: */ +/* This function calculates 10X using an 11th order polynomial. It uses */ +/* the following table of 32-bit integer polynomial coefficients: */ +/* */ +/* Coefficient Value */ +/* A0 67102543 */ +/* A1 309032995 */ +/* A2 712096127 */ +/* A3 1092797331 */ +/* A4 1251625137 */ +/* A5 1154649460 */ +/* A6 915654800 */ +/* A7 597883683 */ +/* A8 284378230 */ +/* A9 150262097 */ +/* A10 124894471 */ +/* A11 50477244 */ +/* A12 -2 */ +/* */ +/* Y = (A0 + A1*X + A2*X2 + A3*X3 + ….. + AN*xN) << AN+1 */ +/* */ +/* */ +/* PARAMETERS: */ +/* */ +/* X is the input variable in Q2.30 format */ +/* */ +/* RETURNS: */ +/* The result of the 10x expansion in Q8.24 format */ +/*-------------------------------------------------------------------------*/ + +LVM_INT32 LVM_Power10(LVM_INT32 X) +{ + LVM_INT32 Y,Coefficients[13]={ 16775636, + 77258249, + 178024032, + 273199333, + 312906284, + 288662365, + 228913700, + 149470921, + 71094558, + 37565524, + 31223618, + 12619311, + 0}; + Y=LVM_Polynomial((LVM_UINT16)11, + Coefficients, + X); + return Y; +} + diff --git a/media/libeffects/lvm/lib/Common/src/LVM_Timer.c b/media/libeffects/lvm/lib/Common/src/LVM_Timer.c new file mode 100755 index 0000000..d49aadc --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVM_Timer.c @@ -0,0 +1,57 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: My Project */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/****************************************************************************************/ +/* INCLUDE FILES */ +/****************************************************************************************/ + +#include "LVM_Timer.h" +#include "LVM_Timer_Private.h" + +/****************************************************************************************/ +/* TIMER FUNCTION */ +/****************************************************************************************/ + +void LVM_Timer ( LVM_Timer_Instance_t *pInstance, + LVM_INT16 BlockSize ){ + + LVM_Timer_Instance_Private_t *pInstancePr; + pInstancePr = (LVM_Timer_Instance_Private_t *)pInstance; + + if (pInstancePr->TimerArmed){ + pInstancePr->RemainingTimeInSamples -= BlockSize; + if (pInstancePr->RemainingTimeInSamples <= 0){ + pInstancePr->TimerArmed = 0; + (*pInstancePr->pCallBack) ( pInstancePr->pCallbackInstance, + pInstancePr->pCallBackParams, + pInstancePr->CallBackParam ); + } + } +} + +/****************************************************************************************/ +/* END OF FILE */ +/****************************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/LVM_Timer_Init.c b/media/libeffects/lvm/lib/Common/src/LVM_Timer_Init.c new file mode 100755 index 0000000..e473038 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVM_Timer_Init.c @@ -0,0 +1,63 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: My Project */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/****************************************************************************************/ +/* INCLUDE FILES */ +/****************************************************************************************/ + +#include "LVM_Timer.h" +#include "LVM_Timer_Private.h" +#include "LVM_Macros.h" + +/****************************************************************************************/ +/* DEFINITIONS */ +/****************************************************************************************/ + +#define OneOverThousandInQ24 16777 + +/****************************************************************************************/ +/* INIT FUNCTION */ +/****************************************************************************************/ + +void LVM_Timer_Init ( LVM_Timer_Instance_t *pInstance, + LVM_Timer_Params_t *pParams ){ + + LVM_Timer_Instance_Private_t *pInstancePr; + pInstancePr = (LVM_Timer_Instance_Private_t *)pInstance; + + pInstancePr->CallBackParam = pParams->CallBackParam; + pInstancePr->pCallBackParams = pParams->pCallBackParams; + pInstancePr->pCallbackInstance = pParams->pCallbackInstance; + pInstancePr->pCallBack = pParams->pCallBack; + pInstancePr->TimerArmed = 1; + + MUL32x16INTO32(pParams->SamplingRate,OneOverThousandInQ24,pInstancePr->RemainingTimeInSamples,16); /* (Q0 * Q24) >>16 into Q8*/ + MUL32x16INTO32(pInstancePr->RemainingTimeInSamples,pParams->TimeInMs,pInstancePr->RemainingTimeInSamples,8); /* (Q8 * Q0) >>8 into Q0*/ +} + +/****************************************************************************************/ +/* END OF FILE */ +/****************************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/LVM_Timer_Private.h b/media/libeffects/lvm/lib/Common/src/LVM_Timer_Private.h new file mode 100755 index 0000000..04d5af6 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVM_Timer_Private.h @@ -0,0 +1,61 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: My Project */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#ifndef LVM_TIMER_PRIVATE_H +#define LVM_TIMER_PRIVATE_H + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +#include "LVM_Types.h" + +/****************************************************************************************/ +/* TYPE DEFINITIONS */ +/****************************************************************************************/ + +typedef struct +{ + LVM_INT32 RemainingTimeInSamples; + LVM_INT32 CallBackParam; + LVM_INT32 *pCallBackParams; + void *pCallbackInstance; + void (*pCallBack)(void*,void*,LVM_INT32); + LVM_INT16 TimerArmed; /* Boolean, true between init and callback */ + +} LVM_Timer_Instance_Private_t; + +/****************************************************************************************/ +/* END OF HEADER */ +/****************************************************************************************/ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* LVM_TIMER_PRIVATE_H */ diff --git a/media/libeffects/lvm/lib/Common/src/LoadConst_16.c b/media/libeffects/lvm/lib/Common/src/LoadConst_16.c new file mode 100755 index 0000000..bc2735f --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LoadConst_16.c @@ -0,0 +1,51 @@ +/* + * 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: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION LoadConst_16 +***********************************************************************************/ + +void LoadConst_16(const LVM_INT16 val, + LVM_INT16 *dst, + LVM_INT16 n ) +{ + LVM_INT16 ii; + + for (ii = n; ii != 0; ii--) + { + *dst = val; + dst++; + } + + return; +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/LoadConst_32.c b/media/libeffects/lvm/lib/Common/src/LoadConst_32.c new file mode 100755 index 0000000..19d5d4e --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LoadConst_32.c @@ -0,0 +1,52 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION LoadConst_32 +***********************************************************************************/ + +void LoadConst_32(const LVM_INT32 val, + LVM_INT32 *dst, + LVM_INT16 n ) +{ + LVM_INT16 ii; + + for (ii = n; ii != 0; ii--) + { + *dst = val; + dst++; + } + + return; +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/MSTo2i_Sat_16x16.c b/media/libeffects/lvm/lib/Common/src/MSTo2i_Sat_16x16.c new file mode 100755 index 0000000..1949f3c --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/MSTo2i_Sat_16x16.c @@ -0,0 +1,88 @@ +/* + * 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: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION MSTO2I_SAT_16X16 +***********************************************************************************/ + +void MSTo2i_Sat_16x16(const LVM_INT16 *srcM, + const LVM_INT16 *srcS, + LVM_INT16 *dst, + LVM_INT16 n ) +{ + LVM_INT32 temp,mVal,sVal; + LVM_INT16 ii; + + + for (ii = n; ii != 0; ii--) + { + mVal=(LVM_INT32)*srcM; + srcM++; + + sVal=(LVM_INT32)*srcS; + srcS++; + + temp = mVal + sVal; + + if (temp > 0x00007FFF) + { + *dst = 0x7FFF; + } + else if (temp < -0x00008000) + { + *dst = - 0x8000; + } + else + { + *dst = (LVM_INT16)temp; + } + dst++; + + temp = mVal - sVal; + + if (temp > 0x00007FFF) + { + *dst = 0x7FFF; + } + else if (temp < -0x00008000) + { + *dst = - 0x8000; + } + else + { + *dst = (LVM_INT16)temp; + } + dst++; + } + + return; +} +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/Mac3s_Sat_16x16.c b/media/libeffects/lvm/lib/Common/src/Mac3s_Sat_16x16.c new file mode 100755 index 0000000..ef04ae8 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/Mac3s_Sat_16x16.c @@ -0,0 +1,81 @@ +/* + * 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. + */ + +/********************************************************************************** + + %created_by: sra % (CM/S) + %name: Mac3s_Sat_16x16.c % (CM/S) + %version: 1 % (CM/S) + %date_created: Fri Nov 13 12:07:13 2009 % (CM/S) + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" +#include "LVM_Macros.h" + +/********************************************************************************** + FUNCTION Mac3S_16X16 +***********************************************************************************/ + +void Mac3s_Sat_16x16( const LVM_INT16 *src, + const LVM_INT16 val, + LVM_INT16 *dst, + LVM_INT16 n) +{ + LVM_INT16 ii; + LVM_INT16 srcval; + LVM_INT32 Temp,dInVal; + + + for (ii = n; ii != 0; ii--) + { + srcval=*src; + src++; + + Temp = (srcval *val)>>15; + + dInVal = (LVM_INT32)*dst; + + Temp = Temp + dInVal; + + if (Temp > 0x00007FFF) + { + *dst = 0x7FFF; + } + else if (Temp < -0x00008000) + { + *dst = - 0x8000; + } + else + { + *dst = (LVM_INT16)Temp; + } + + dst++; + } + + return; +} + +/**********************************************************************************/ + + + diff --git a/media/libeffects/lvm/lib/Common/src/Mac3s_Sat_32x16.c b/media/libeffects/lvm/lib/Common/src/Mac3s_Sat_32x16.c new file mode 100755 index 0000000..746a273 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/Mac3s_Sat_32x16.c @@ -0,0 +1,80 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" +#include "LVM_Macros.h" + +/********************************************************************************** + FUNCTION MAC3S_16X16 +***********************************************************************************/ + +void Mac3s_Sat_32x16( const LVM_INT32 *src, + const LVM_INT16 val, + LVM_INT32 *dst, + LVM_INT16 n) +{ + LVM_INT16 ii; + LVM_INT32 srcval,temp, dInVal, dOutVal; + + + for (ii = n; ii != 0; ii--) + { + srcval=*src; + src++; + + MUL32x16INTO32(srcval,val,temp,15) + + dInVal = *dst; + dOutVal = temp + dInVal; + + + if ((((dOutVal ^ temp) & (dOutVal ^ dInVal)) >> 31)!=0) /* overflow / underflow */ + { + if(temp<0) + { + dOutVal=0x80000000l; + } + else + { + dOutVal=0x7FFFFFFFl; + } + } + + *dst = dOutVal; + dst++; + } + + return; +} + +/**********************************************************************************/ + + + diff --git a/media/libeffects/lvm/lib/Common/src/MixInSoft_D32C31_SAT.c b/media/libeffects/lvm/lib/Common/src/MixInSoft_D32C31_SAT.c new file mode 100755 index 0000000..36de6c1 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/MixInSoft_D32C31_SAT.c @@ -0,0 +1,104 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "Mixer_private.h" +#include "VectorArithmetic.h" + +/********************************************************************************** + DEFINITIONS +***********************************************************************************/ + +#define TRUE 1 +#define FALSE 0 + +/********************************************************************************** + FUNCTION MIXINSOFT_D32C31_SAT +***********************************************************************************/ + +void MixInSoft_D32C31_SAT( Mix_1St_Cll_t *pInstance, + const LVM_INT32 *src, + LVM_INT32 *dst, + LVM_INT16 n) +{ + char HardMixing = TRUE; + + if(n<=0) return; + + /****************************************************************************** + SOFT MIXING + *******************************************************************************/ + if (pInstance->Current != pInstance->Target) + { + if(pInstance->Alpha == 0){ + pInstance->Current = pInstance->Target; + }else if ((pInstance->Current-pInstance->Target <POINT_ZERO_ONE_DB)&& + (pInstance->Current-pInstance->Target > -POINT_ZERO_ONE_DB)){ + pInstance->Current = pInstance->Target; /* Difference is not significant anymore. Make them equal. */ + }else{ + /* Soft mixing has to be applied */ + HardMixing = FALSE; + Core_MixInSoft_D32C31_SAT( pInstance, src, dst, n); + } + } + + /****************************************************************************** + HARD MIXING + *******************************************************************************/ + + if (HardMixing){ + if (pInstance->Target != 0){ /* Nothing to do in case Target = 0 */ + if ((pInstance->Target>>16) == 0x7FFF) + Add2_Sat_32x32( src, dst, n ); + else{ + Core_MixInSoft_D32C31_SAT( pInstance, src, dst, n); + pInstance->Current = pInstance->Target; /* In case the core function would have changed the Current value */ + } + } + } + + /****************************************************************************** + CALL BACK + *******************************************************************************/ + /* Call back before the hard mixing, because in this case, hard mixing makes + use of the core soft mix function which can change the Current value! */ + + if (pInstance->CallbackSet){ + if ((pInstance->Current-pInstance->Target <POINT_ZERO_ONE_DB)&& + (pInstance->Current-pInstance->Target > -POINT_ZERO_ONE_DB)){ + pInstance->Current = pInstance->Target; /* Difference is not significant anymore. Make them equal. */ + pInstance->CallbackSet = FALSE; + if (pInstance->pCallBack != 0){ + (*pInstance->pCallBack) ( pInstance->pCallbackHandle, pInstance->pGeneralPurpose,pInstance->CallbackParam ); + } + } + } +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/MixSoft_1St_D32C31_WRA.c b/media/libeffects/lvm/lib/Common/src/MixSoft_1St_D32C31_WRA.c new file mode 100755 index 0000000..5cf1a29 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/MixSoft_1St_D32C31_WRA.c @@ -0,0 +1,104 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "Mixer_private.h" +#include "VectorArithmetic.h" + +/********************************************************************************** + DEFINITIONS +***********************************************************************************/ + +#define TRUE 1 +#define FALSE 0 + + + +/********************************************************************************** + FUNCTION MIXSOFT_1ST_D32C31_WRA +***********************************************************************************/ + +void MixSoft_1St_D32C31_WRA( Mix_1St_Cll_t *pInstance, + const LVM_INT32 *src, + LVM_INT32 *dst, + LVM_INT16 n) +{ + char HardMixing = TRUE; + + if(n<=0) return; + + /****************************************************************************** + SOFT MIXING + *******************************************************************************/ + if (pInstance->Current != pInstance->Target) + { + if(pInstance->Alpha == 0){ + pInstance->Current = pInstance->Target; + }else if ((pInstance->Current-pInstance->Target <POINT_ZERO_ONE_DB)&& + (pInstance->Current-pInstance->Target > -POINT_ZERO_ONE_DB)){ + pInstance->Current = pInstance->Target; /* Difference is not significant anymore. Make them equal. */ + }else{ + /* Soft mixing has to be applied */ + HardMixing = FALSE; + Core_MixSoft_1St_D32C31_WRA( pInstance, src, dst, n); + } + } + + /****************************************************************************** + HARD MIXING + *******************************************************************************/ + + if (HardMixing){ + if (pInstance->Target == 0) + LoadConst_32(0, dst, n); + else if ((pInstance->Target>>16) == 0x7FFF){ + if (src != dst) + Copy_16((LVM_INT16*)src, (LVM_INT16*)dst, (LVM_INT16)(n * 2)); + } + else + Mult3s_32x16( src, (LVM_INT16)(pInstance->Current>>16), dst, n ); + } + + /****************************************************************************** + CALL BACK + *******************************************************************************/ + + if (pInstance->CallbackSet){ + if ((pInstance->Current-pInstance->Target <POINT_ZERO_ONE_DB)&& + (pInstance->Current-pInstance->Target > -POINT_ZERO_ONE_DB)){ + pInstance->Current = pInstance->Target; /* Difference is not significant anymore. Make them equal. */ + pInstance->CallbackSet = FALSE; + if (pInstance->pCallBack != 0){ + (*pInstance->pCallBack) ( pInstance->pCallbackHandle, pInstance->pGeneralPurpose,pInstance->CallbackParam ); + } + } + } +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/MixSoft_2St_D32C31_SAT.c b/media/libeffects/lvm/lib/Common/src/MixSoft_2St_D32C31_SAT.c new file mode 100755 index 0000000..b03f0ba --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/MixSoft_2St_D32C31_SAT.c @@ -0,0 +1,72 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "Mixer_private.h" +#include "VectorArithmetic.h" + + +/********************************************************************************** + FUNCTION MIXSOFT_2ST_D32C31_SAT +***********************************************************************************/ + +void MixSoft_2St_D32C31_SAT( Mix_2St_Cll_t *pInstance, + const LVM_INT32 *src1, + const LVM_INT32 *src2, + LVM_INT32 *dst, + LVM_INT16 n) +{ + + if(n<=0) return; + + /****************************************************************************** + SOFT MIXING + *******************************************************************************/ + if ((pInstance->Current1 != pInstance->Target1) || (pInstance->Current2 != pInstance->Target2)) + { + MixSoft_1St_D32C31_WRA( (Mix_1St_Cll_t*) pInstance, src1, dst, n); + MixInSoft_D32C31_SAT( (Mix_1St_Cll_t*) &pInstance->Alpha2, src2, dst, n); + } + + /****************************************************************************** + HARD MIXING + *******************************************************************************/ + + else + { + if (pInstance->Current1 == 0) + MixSoft_1St_D32C31_WRA( (Mix_1St_Cll_t*) &pInstance->Alpha2, src2, dst, n); + else if (pInstance->Current2 == 0) + MixSoft_1St_D32C31_WRA( (Mix_1St_Cll_t*) pInstance, src1, dst, n); + else + Core_MixHard_2St_D32C31_SAT( pInstance, src1, src2, dst, n); + } +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/Mixer_private.h b/media/libeffects/lvm/lib/Common/src/Mixer_private.h new file mode 100755 index 0000000..d012548 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/Mixer_private.h @@ -0,0 +1,44 @@ +/* + * 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: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +#ifndef __MIXER_PRIVATE_H__ +#define __MIXER_PRIVATE_H__ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "Mixer.h" + +#define POINT_ZERO_ONE_DB 2473805 /* 0.01 dB on a full scale signal = (10^(0.01/20) -1) * 2^31 */ + +/********************************************************************************** + DEFINITIONS +***********************************************************************************/ + +/**********************************************************************************/ + +#endif //#ifndef __MIXER_PRIVATE_H__ + diff --git a/media/libeffects/lvm/lib/Common/src/MonoTo2I_16.c b/media/libeffects/lvm/lib/Common/src/MonoTo2I_16.c new file mode 100755 index 0000000..b053e55 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/MonoTo2I_16.c @@ -0,0 +1,57 @@ +/* + * 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: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION MonoTo2I_16 +***********************************************************************************/ + +void MonoTo2I_16( const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n) +{ + LVM_INT16 ii; + src += (n-1); + dst += ((n*2)-1); + + for (ii = n; ii != 0; ii--) + { + *dst = *src; + dst--; + + *dst = *src; + dst--; + src--; + } + + return; +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/MonoTo2I_32.c b/media/libeffects/lvm/lib/Common/src/MonoTo2I_32.c new file mode 100755 index 0000000..e8164bb --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/MonoTo2I_32.c @@ -0,0 +1,58 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION MonoTo2I_32 +***********************************************************************************/ + +void MonoTo2I_32( const LVM_INT32 *src, + LVM_INT32 *dst, + LVM_INT16 n) +{ + LVM_INT16 ii; + src += (n-1); + dst += ((n*2)-1); + + for (ii = n; ii != 0; ii--) + { + *dst = *src; + dst--; + + *dst = *src; + dst--; + src--; + } + + return; +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/Mult3s_32x16.c b/media/libeffects/lvm/lib/Common/src/Mult3s_32x16.c new file mode 100755 index 0000000..ee83524 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/Mult3s_32x16.c @@ -0,0 +1,60 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" +#include "LVM_Macros.h" + +/********************************************************************************** +FUNCTION MULT3S_16X16 +***********************************************************************************/ + +void Mult3s_32x16( const LVM_INT32 *src, + const LVM_INT16 val, + LVM_INT32 *dst, + LVM_INT16 n) +{ + LVM_INT16 ii; + LVM_INT32 srcval,temp; + + for (ii = n; ii != 0; ii--) + { + srcval=*src; + src++; + + MUL32x16INTO32(srcval,val,temp,15) + + *dst = temp; + dst++; + } + + return; +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/NonLinComp_D16.c b/media/libeffects/lvm/lib/Common/src/NonLinComp_D16.c new file mode 100755 index 0000000..1428777 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/NonLinComp_D16.c @@ -0,0 +1,125 @@ +/* + * 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: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/****************************************************************************************/ +/* */ +/* Includes */ +/* */ +/****************************************************************************************/ + +#include "CompLim_private.h" + +/****************************************************************************************/ +/* */ +/* FUNCTION: NonLinComp_D16 */ +/* */ +/* DESCRIPTION: */ +/* Non-linear compression by companding. The function works on a sample by sample */ +/* basis by increasing the level near the zero crossing. This gives a ttrade-off */ +/* between THD and compression. It uses the equation: */ +/* */ +/* Output = Input + K * (Input - Input^2) if Input > 0 */ +/* = Input + K * (Input + Input^2) if Input <= 0 */ +/* */ +/* The value of K controls the amount of compression and as a side effect the amount */ +/* distortion introduced. The amount of compression is signal dependent and the values */ +/* given below are approximate. */ +/* */ +/* Gain (fractional) Gain (integer) Compression Pk-Pk THD */ +/* 1.0 32767 +6dB 16dB */ +/* 0.78 25559 +5dB 19dB */ +/* 0.6 19661 +4dB 21dB */ +/* 0.41 13435 +3dB 24dB */ +/* 0.26 8520 +2dB 28dB */ +/* 0.12 3932 +1dB 34dB */ +/* 0.0 0 +0dB 98dB */ +/* */ +/* PARAMETERS: */ +/* Gain - compression control parameter */ +/* pDataIn - pointer to the input data buffer */ +/* pDataOut - pointer to the output data buffer */ +/* BlockLength - number of samples to process */ +/* */ +/* RETURNS: */ +/* None */ +/* */ +/* NOTES: */ +/* */ +/****************************************************************************************/ + +void NonLinComp_D16(LVM_INT16 Gain, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT32 BlockLength) +{ + + LVM_INT16 Sample; /* Input samples */ + LVM_INT32 SampleNo; /* Sample index */ + LVM_INT16 Temp; + + + /* + * Process a block of samples + */ + for(SampleNo = 0; SampleNo<BlockLength; SampleNo++) + { + + /* + * Read the input + */ + Sample = *pDataIn; + pDataIn++; + + + /* + * Apply the compander, this compresses the signal at the expense of + * harmonic distortion. The amount of compression is control by the + * gain factor + */ + if ((LVM_INT32)Sample != -32768) + { + Temp = (LVM_INT16)((Sample * Sample) >> 15); + if(Sample >0) + { + Sample = (LVM_INT16)(Sample + ((Gain * (Sample - Temp)) >> 15)); + } + else + { + Sample = (LVM_INT16)(Sample + ((Gain * (Sample + Temp)) >> 15)); + } + } + + + /* + * Save the output + */ + *pDataOut = Sample; + pDataOut++; + + + } + +} + diff --git a/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32C14G11_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32C14G11_TRC_WRA_01.c new file mode 100755 index 0000000..06cfe88 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32C14G11_TRC_WRA_01.c @@ -0,0 +1,130 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "PK_2I_D32F32CssGss_TRC_WRA_01_Private.h" +#include "LVM_Macros.h" + +/************************************************************************** + ASSUMPTIONS: + COEFS- + pBiquadState->coefs[0] is A0, + pBiquadState->coefs[1] is -B2, + pBiquadState->coefs[2] is -B1, these are in Q14 format + pBiquadState->coefs[3] is Gain, in Q11 format + + + DELAYS- + pBiquadState->pDelays[0] is x(n-1)L in Q0 format + pBiquadState->pDelays[1] is x(n-1)R in Q0 format + pBiquadState->pDelays[2] is x(n-2)L in Q0 format + pBiquadState->pDelays[3] is x(n-2)R in Q0 format + pBiquadState->pDelays[4] is y(n-1)L in Q0 format + pBiquadState->pDelays[5] is y(n-1)R in Q0 format + pBiquadState->pDelays[6] is y(n-2)L in Q0 format + pBiquadState->pDelays[7] is y(n-2)R in Q0 format +***************************************************************************/ +void PK_2I_D32F32C14G11_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT32 *pDataIn, + LVM_INT32 *pDataOut, + LVM_INT16 NrSamples) + { + LVM_INT32 ynL,ynR,ynLO,ynRO,templ; + LVM_INT16 ii; + PFilter_State pBiquadState = (PFilter_State) pInstance; + + for (ii = NrSamples; ii != 0; ii--) + { + + + /************************************************************************** + PROCESSING OF THE LEFT CHANNEL + ***************************************************************************/ + /* ynL= (A0 (Q14) * (x(n)L (Q0) - x(n-2)L (Q0) ) >>14) in Q0*/ + templ=(*pDataIn)-pBiquadState->pDelays[2]; + MUL32x16INTO32(templ,pBiquadState->coefs[0],ynL,14) + + /* ynL+= ((-B2 (Q14) * y(n-2)L (Q0) ) >>14) in Q0*/ + MUL32x16INTO32(pBiquadState->pDelays[6],pBiquadState->coefs[1],templ,14) + ynL+=templ; + + /* ynL+= ((-B1 (Q14) * y(n-1)L (Q0) ) >>14) in Q0 */ + MUL32x16INTO32(pBiquadState->pDelays[4],pBiquadState->coefs[2],templ,14) + ynL+=templ; + + /* ynLO= ((Gain (Q11) * ynL (Q0))>>11) in Q0*/ + MUL32x16INTO32(ynL,pBiquadState->coefs[3],ynLO,11) + + /* ynLO=( ynLO(Q0) + x(n)L (Q0) ) in Q0*/ + ynLO+= (*pDataIn); + + /************************************************************************** + PROCESSING OF THE RIGHT CHANNEL + ***************************************************************************/ + /* ynR= (A0 (Q14) * (x(n)R (Q0) - x(n-2)R (Q0) ) >>14) in Q0*/ + templ=(*(pDataIn+1))-pBiquadState->pDelays[3]; + MUL32x16INTO32(templ,pBiquadState->coefs[0],ynR,14) + + /* ynR+= ((-B2 (Q14) * y(n-2)R (Q0) ) >>14) in Q0*/ + MUL32x16INTO32(pBiquadState->pDelays[7],pBiquadState->coefs[1],templ,14) + ynR+=templ; + + /* ynR+= ((-B1 (Q14) * y(n-1)R (Q0) ) >>14) in Q0 */ + MUL32x16INTO32(pBiquadState->pDelays[5],pBiquadState->coefs[2],templ,14) + ynR+=templ; + + /* ynRO= ((Gain (Q11) * ynR (Q0))>>11) in Q0*/ + MUL32x16INTO32(ynR,pBiquadState->coefs[3],ynRO,11) + + /* ynRO=( ynRO(Q0) + x(n)R (Q0) ) in Q0*/ + ynRO+= (*(pDataIn+1)); + + /************************************************************************** + UPDATING THE DELAYS + ***************************************************************************/ + pBiquadState->pDelays[7]=pBiquadState->pDelays[5]; /* y(n-2)R=y(n-1)R*/ + pBiquadState->pDelays[6]=pBiquadState->pDelays[4]; /* y(n-2)L=y(n-1)L*/ + pBiquadState->pDelays[3]=pBiquadState->pDelays[1]; /* x(n-2)R=x(n-1)R*/ + pBiquadState->pDelays[2]=pBiquadState->pDelays[0]; /* x(n-2)L=x(n-1)L*/ + pBiquadState->pDelays[5]=ynR; /* Update y(n-1)R in Q0*/ + pBiquadState->pDelays[4]=ynL; /* Update y(n-1)L in Q0*/ + pBiquadState->pDelays[0]=(*pDataIn); /* Update x(n-1)L in Q0*/ + pDataIn++; + pBiquadState->pDelays[1]=(*pDataIn); /* Update x(n-1)R in Q0*/ + pDataIn++; + + /************************************************************************** + WRITING THE OUTPUT + ***************************************************************************/ + *pDataOut=ynLO; /* Write Left output in Q0*/ + pDataOut++; + *pDataOut=ynRO; /* Write Right ouput in Q0*/ + pDataOut++; + + } + + } + diff --git a/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32C30G11_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32C30G11_TRC_WRA_01.c new file mode 100755 index 0000000..5b78f62 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32C30G11_TRC_WRA_01.c @@ -0,0 +1,128 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "PK_2I_D32F32CllGss_TRC_WRA_01_Private.h" +#include "LVM_Macros.h" + +/************************************************************************** + ASSUMPTIONS: + COEFS- + pBiquadState->coefs[0] is A0, + pBiquadState->coefs[1] is -B2, + pBiquadState->coefs[2] is -B1, these are in Q30 format + pBiquadState->coefs[3] is Gain, in Q11 format + + + DELAYS- + pBiquadState->pDelays[0] is x(n-1)L in Q0 format + pBiquadState->pDelays[1] is x(n-1)R in Q0 format + pBiquadState->pDelays[2] is x(n-2)L in Q0 format + pBiquadState->pDelays[3] is x(n-2)R in Q0 format + pBiquadState->pDelays[4] is y(n-1)L in Q0 format + pBiquadState->pDelays[5] is y(n-1)R in Q0 format + pBiquadState->pDelays[6] is y(n-2)L in Q0 format + pBiquadState->pDelays[7] is y(n-2)R in Q0 format +***************************************************************************/ +void PK_2I_D32F32C30G11_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT32 *pDataIn, + LVM_INT32 *pDataOut, + LVM_INT16 NrSamples) + { + LVM_INT32 ynL,ynR,ynLO,ynRO,templ; + LVM_INT16 ii; + PFilter_State pBiquadState = (PFilter_State) pInstance; + + for (ii = NrSamples; ii != 0; ii--) + { + + + /************************************************************************** + PROCESSING OF THE LEFT CHANNEL + ***************************************************************************/ + /* ynL= (A0 (Q30) * (x(n)L (Q0) - x(n-2)L (Q0) ) >>30) in Q0*/ + templ=(*pDataIn)-pBiquadState->pDelays[2]; + MUL32x32INTO32(templ,pBiquadState->coefs[0],ynL,30) + + /* ynL+= ((-B2 (Q30) * y(n-2)L (Q0) ) >>30) in Q0*/ + MUL32x32INTO32(pBiquadState->pDelays[6],pBiquadState->coefs[1],templ,30) + ynL+=templ; + + /* ynL+= ((-B1 (Q30) * y(n-1)L (Q0) ) >>30) in Q0 */ + MUL32x32INTO32(pBiquadState->pDelays[4],pBiquadState->coefs[2],templ,30) + ynL+=templ; + + /* ynLO= ((Gain (Q11) * ynL (Q0))>>11) in Q0*/ + MUL32x16INTO32(ynL,pBiquadState->coefs[3],ynLO,11) + /* ynLO=( ynLO(Q0) + x(n)L (Q0) ) in Q0*/ + ynLO+= (*pDataIn); + + /************************************************************************** + PROCESSING OF THE RIGHT CHANNEL + ***************************************************************************/ + /* ynR= (A0 (Q30) * (x(n)R (Q0) - x(n-2)R (Q0) ) >>30) in Q0*/ + templ=(*(pDataIn+1))-pBiquadState->pDelays[3]; + MUL32x32INTO32(templ,pBiquadState->coefs[0],ynR,30) + + /* ynR+= ((-B2 (Q30) * y(n-2)R (Q0) ) >>30) in Q0*/ + MUL32x32INTO32(pBiquadState->pDelays[7],pBiquadState->coefs[1],templ,30) + ynR+=templ; + + /* ynR+= ((-B1 (Q30) * y(n-1)R (Q0) ) >>30) in Q0 */ + MUL32x32INTO32(pBiquadState->pDelays[5],pBiquadState->coefs[2],templ,30) + ynR+=templ; + + /* ynRO= ((Gain (Q11) * ynR (Q0))>>11) in Q0*/ + MUL32x16INTO32(ynR,pBiquadState->coefs[3],ynRO,11) + + /* ynRO=( ynRO(Q0) + x(n)R (Q0) ) in Q0*/ + ynRO+= (*(pDataIn+1)); + + /************************************************************************** + UPDATING THE DELAYS + ***************************************************************************/ + pBiquadState->pDelays[7]=pBiquadState->pDelays[5]; /* y(n-2)R=y(n-1)R*/ + pBiquadState->pDelays[6]=pBiquadState->pDelays[4]; /* y(n-2)L=y(n-1)L*/ + pBiquadState->pDelays[3]=pBiquadState->pDelays[1]; /* x(n-2)R=x(n-1)R*/ + pBiquadState->pDelays[2]=pBiquadState->pDelays[0]; /* x(n-2)L=x(n-1)L*/ + pBiquadState->pDelays[5]=ynR; /* Update y(n-1)R in Q0*/ + pBiquadState->pDelays[4]=ynL; /* Update y(n-1)L in Q0*/ + pBiquadState->pDelays[0]=(*pDataIn); /* Update x(n-1)L in Q0*/ + pDataIn++; + pBiquadState->pDelays[1]=(*pDataIn); /* Update x(n-1)R in Q0*/ + pDataIn++; + + /************************************************************************** + WRITING THE OUTPUT + ***************************************************************************/ + *pDataOut=ynLO; /* Write Left output in Q0*/ + pDataOut++; + *pDataOut=ynRO; /* Write Right ouput in Q0*/ + pDataOut++; + } + + } + diff --git a/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CllGss_TRC_WRA_01_Init.c b/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CllGss_TRC_WRA_01_Init.c new file mode 100755 index 0000000..e7bcd0c --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CllGss_TRC_WRA_01_Init.c @@ -0,0 +1,47 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "PK_2I_D32F32CllGss_TRC_WRA_01_Private.h" + + +void PK_2I_D32F32CllGss_TRC_WRA_01_Init(Biquad_Instance_t *pInstance, + Biquad_2I_Order2_Taps_t *pTaps, + PK_C32_Coefs_t *pCoef) +{ + PFilter_State pBiquadState = (PFilter_State) pInstance; + pBiquadState->pDelays =(LVM_INT32 *) pTaps; + + pBiquadState->coefs[0]=pCoef->A0; + + pBiquadState->coefs[1]=pCoef->B2; + + pBiquadState->coefs[2]=pCoef->B1; + + pBiquadState->coefs[3]=pCoef->G; + +} + diff --git a/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CllGss_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CllGss_TRC_WRA_01_Private.h new file mode 100755 index 0000000..741f504 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CllGss_TRC_WRA_01_Private.h @@ -0,0 +1,40 @@ +/* + * 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 _PK_2I_D32F32CLLGSS_TRC_WRA_01_PRIVATE_H_ +#define _PK_2I_D32F32CLLGSS_TRC_WRA_01_PRIVATE_H_ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/* The internal state variables are implemented in a (for the user) hidden structure */ +/* In this (private) file, the internal structure is declared fro private use. */ +typedef struct _Filter_State_ +{ + LVM_INT32 * pDelays; /* pointer to the delayed samples (data of 32 bits) */ + LVM_INT32 coefs[5]; /* pointer to the filter coefficients */ +}Filter_State; + +typedef Filter_State * PFilter_State ; + +#endif /* _PK_2I_D32F32CLLGSS_TRC_WRA_01_PRIVATE_H_ */ diff --git a/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CssGss_TRC_WRA_01_Init.c b/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CssGss_TRC_WRA_01_Init.c new file mode 100755 index 0000000..f02305e --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CssGss_TRC_WRA_01_Init.c @@ -0,0 +1,46 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "PK_2I_D32F32CssGss_TRC_WRA_01_Private.h" + +void PK_2I_D32F32CssGss_TRC_WRA_01_Init(Biquad_Instance_t *pInstance, + Biquad_2I_Order2_Taps_t *pTaps, + PK_C16_Coefs_t *pCoef) +{ + PFilter_State pBiquadState = (PFilter_State) pInstance; + pBiquadState->pDelays =(LVM_INT32 *) pTaps; + + pBiquadState->coefs[0]=pCoef->A0; + + pBiquadState->coefs[1]=pCoef->B2; + + pBiquadState->coefs[2]=pCoef->B1; + + pBiquadState->coefs[3]=pCoef->G; + +} + diff --git a/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CssGss_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CssGss_TRC_WRA_01_Private.h new file mode 100755 index 0000000..ca31669 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CssGss_TRC_WRA_01_Private.h @@ -0,0 +1,41 @@ +/* + * 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 _PK_2I_D32F32CSSGSS_TRC_WRA_01_PRIVATE_H_ +#define _PK_2I_D32F32CSSGSS_TRC_WRA_01_PRIVATE_H_ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + + +/* The internal state variables are implemented in a (for the user) hidden structure */ +/* In this (private) file, the internal structure is declared fro private use. */ +typedef struct _Filter_State_ +{ + LVM_INT32 * pDelays; /* pointer to the delayed samples (data of 32 bits) */ + LVM_INT32 coefs[5]; /* pointer to the filter coefficients */ +}Filter_State; + +typedef Filter_State * PFilter_State ; + +#endif /* _PK_2I_D32F32CSSGSS_TRC_WRA_01_PRIVATE_H_ */ diff --git a/media/libeffects/lvm/lib/Common/src/Shift_Sat_v16xv16.c b/media/libeffects/lvm/lib/Common/src/Shift_Sat_v16xv16.c new file mode 100755 index 0000000..e449a7f --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/Shift_Sat_v16xv16.c @@ -0,0 +1,89 @@ +/* + * 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: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION Shift_Sat_v16xv16 +***********************************************************************************/ + +void Shift_Sat_v16xv16 (const LVM_INT16 val, + const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n) +{ + LVM_INT32 temp; + LVM_INT32 ii; + LVM_INT16 RShift; + if(val>0) + { + for (ii = n; ii != 0; ii--) + { + temp = (LVM_INT32)*src; + src++; + + temp = temp << val; + + if (temp > 0x00007FFF) + { + *dst = 0x7FFF; + } + else if (temp < -0x00008000) + { + *dst = - 0x8000; + } + else + { + *dst = (LVM_INT16)temp; + } + dst++; + } + } + else if(val<0) + { + RShift=(LVM_INT16)(-val); + + for (ii = n; ii != 0; ii--) + { + *dst = (LVM_INT16)(*src >> RShift); + dst++; + src++; + } + } + else + { + if(src!=dst) + { + Copy_16(src,dst,n); + } + } + return; +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/Shift_Sat_v32xv32.c b/media/libeffects/lvm/lib/Common/src/Shift_Sat_v32xv32.c new file mode 100755 index 0000000..0ab98ea --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/Shift_Sat_v32xv32.c @@ -0,0 +1,92 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION Shift_Sat_v32xv32 +***********************************************************************************/ + +void Shift_Sat_v32xv32 (const LVM_INT16 val, + const LVM_INT32 *src, + LVM_INT32 *dst, + LVM_INT16 n) +{ + LVM_INT32 ii; + LVM_INT16 RShift; + + if(val>0) + { + LVM_INT32 a,b; + + for (ii = n; ii != 0; ii--) + { + a=*src; + src++; + + b=(a<<val); + + if( (b>>val) != a ) /* if overflow occured, right shift will show difference*/ + { + if(a<0) + { + b=0x80000000l; + } + else + { + b=0x7FFFFFFFl; + } + } + + *dst = b; + dst++; + } + } + else if(val<0) + { + RShift=(LVM_INT16)(-val); + for (ii = n; ii != 0; ii--) + { + *dst = (*src >> RShift); + dst++; + src++; + } + } + else + { + if(src!=dst) + { + Copy_16((LVM_INT16 *)src,(LVM_INT16 *)dst,(LVM_INT16)(n<<1)); + } + } + return; +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/dB_to_Lin32.c b/media/libeffects/lvm/lib/Common/src/dB_to_Lin32.c new file mode 100755 index 0000000..ac0343f --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/dB_to_Lin32.c @@ -0,0 +1,109 @@ +/* + * 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. + */ + +/************************************************************************/ +/* */ +/* %created_by: sra % (CM/S)*/ +/* %name: dB_to_Lin32.c % (CM/S)*/ +/* %version: 2 % (CM/S)*/ +/* %date_created: Wed Jun 18 11:27:46 2008 % (CM/S)*/ +/* */ +/************************************************************************/ + +/*######################################################################################*/ +/* Include files */ +/*######################################################################################*/ + +#include "ScalarArithmetic.h" + + +/**************************************************************************************** + * Name : dB_to_Lin32() + * Input : Signed 16-bit integer + * MSB (16) = sign bit + * (15->05) = integer part + * (04->01) = decimal part + * Output : Signed 32-bit integer + * MSB (32) = sign bit + * (31->16) = integer part + * (15->01) = decimal part + * Returns : Lin value format 1.16.15 + * Description : + * Remarks : Makes an approximation to the conversion by counting the number + * of 6dB steps for use as shifts and then interpolates with a remainder + * with the equation: + * + * Correction = (Remainder / 1.5029) - (Remainder^2 / 6) + * + * The two coefficients are scaled from 0x40000000 in 96 steps and calculated + * as follows: + * + * FIRST_COEF = 0x80000000 / (96 * 1.5029) + * SECOND_COEF = 0x80000000 / (96^2 * 6) + * + ****************************************************************************************/ + +#define FOUR_OVER_SIX 21846 /* (4 / 6) * 2^15 */ +#define SIX_DB 96 /* 6 * 16 or 6dB in Q11.4 format */ +#define FIRST_COEF_NEG 14884305 +#define FIRST_COEF_POS 7442152 /* FIRST_COEF_NEG / 2 */ +#define SECOND_COEF 38836 +#define MAX_VALUE 1536 /* 96 * 16 */ + +LVM_INT32 dB_to_Lin32(LVM_INT16 db_fix) +{ + LVM_INT32 Lin_val_32; + LVM_INT16 Shift; + LVM_INT32 Remain; + + + /* + * Check sign of the input + */ + if (db_fix<0) + { + if (db_fix > -MAX_VALUE) + { + Shift = (LVM_INT16)((((LVM_UINT32)(-db_fix) >> 4) * FOUR_OVER_SIX) >> 17); /* Number of 6dB steps in Q11.4 format */ + Remain = -db_fix - (Shift * SIX_DB); + Remain = (0x7FFFFFFF - (Remain * FIRST_COEF_NEG)) + (Remain * Remain * SECOND_COEF); + Lin_val_32 = (LVM_INT32)((LVM_UINT32)Remain >> (16 + Shift)); + } + else + { + Lin_val_32 = 0; + } + } + else + { + if (db_fix < MAX_VALUE) + { + Shift = (LVM_INT16)((((LVM_UINT32)db_fix >> 4) * FOUR_OVER_SIX) >> 17); /* Number of 6dB steps in Q11.4 format */ + Remain = db_fix - (Shift * SIX_DB); + Remain = 0x3FFFFFFF + (Remain * FIRST_COEF_POS) + (Remain * Remain * SECOND_COEF); + Lin_val_32 = (LVM_INT32)((LVM_UINT32)Remain >> (15 - Shift)); + } + else + { + Lin_val_32 = 0x7FFFFFFF; + } + } + + + return Lin_val_32; /* format 1.16.15 */ +} + diff --git a/media/libeffects/lvm/lib/Common/src/mult3s_16x16.c b/media/libeffects/lvm/lib/Common/src/mult3s_16x16.c new file mode 100755 index 0000000..b500979 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/mult3s_16x16.c @@ -0,0 +1,56 @@ +/* + * 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: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION MULT3S_16X16 +***********************************************************************************/ + +void Mult3s_16x16( const LVM_INT16 *src, + const LVM_INT16 val, + LVM_INT16 *dst, + LVM_INT16 n) +{ + LVM_INT16 ii; + LVM_INT32 temp; + + for (ii = n; ii != 0; ii--) + { + temp = (LVM_INT32)(*src) * (LVM_INT32)val; + src++; + + *dst = (LVM_INT16)(temp >> 15); + dst++; + } + + return; +} + +/**********************************************************************************/ |