M7350v1_en_gpl

This commit is contained in:
T
2024-09-09 08:52:07 +00:00
commit f9cc65cfda
65988 changed files with 26357421 additions and 0 deletions
@@ -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.
*/
#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__ */
@@ -0,0 +1,333 @@
/*
* 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 _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_ **/
@@ -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.
*/
#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 */
@@ -0,0 +1,62 @@
/*
* 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 _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_ **/
@@ -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.
*/
#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__ */
@@ -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.
*/
/****************************************************************************************/
/* */
/* 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__ */
@@ -0,0 +1,122 @@
/*
* 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_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 ******************************************************************/
@@ -0,0 +1,82 @@
/*
* 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__
#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__ */
@@ -0,0 +1,187 @@
/*
* 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.
*/
/****************************************************************************************/
/* */
/* 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 */
@@ -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.
*/
#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__ */
@@ -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.
*/
#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__ */
@@ -0,0 +1,181 @@
/*
* 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 _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_ */
/**********************************************************************************/
@@ -0,0 +1,196 @@
/*
* 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.
*/
/****************************************************************************************/
/* */
/* 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;
}
@@ -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.
*/
/*######################################################################################*/
/* 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;
}
@@ -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.
*/
/**********************************************************************************
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;
}
/**********************************************************************************/
@@ -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.
*/
/**********************************************************************************
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;
}
/**********************************************************************************/
@@ -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.
*/
#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
}
}
@@ -0,0 +1,54 @@
/*
* 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.
*/
/*-------------------------------------------------------------------------*/
#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 */
@@ -0,0 +1,30 @@
/*
* 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_
/* 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_*/
@@ -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.
*/
#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
}
}
@@ -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.
*/
/*-------------------------------------------------------------------------*/
#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 */
@@ -0,0 +1,30 @@
/*
* 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_
/* 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_*/
@@ -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.
*/
#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
}
}
@@ -0,0 +1,55 @@
/*
* 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.
*/
/*-------------------------------------------------------------------------*/
#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 */
@@ -0,0 +1,30 @@
/*
* 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_
/* 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_*/
@@ -0,0 +1,85 @@
/*
* 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.
*/
#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
}
}
@@ -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.
*/
/*-------------------------------------------------------------------------*/
#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 */
@@ -0,0 +1,30 @@
/*
* 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_
/* 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_ */
@@ -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.
*/
#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
}
}
@@ -0,0 +1,30 @@
/*
* 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_
/* 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_*/
@@ -0,0 +1,62 @@
/*
* 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.
*/
/*-------------------------------------------------------------------------*/
#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 */
@@ -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.
*/
#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
}
}
@@ -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.
*/
#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
}
}
@@ -0,0 +1,62 @@
/*
* 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.
*/
/*-------------------------------------------------------------------------*/
#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 */
@@ -0,0 +1,31 @@
/*
* 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_
/* 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_ */
@@ -0,0 +1,118 @@
/*
* 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.
*/
#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++;
}
}
@@ -0,0 +1,117 @@
/*
* 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.
*/
#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++;
}
}
@@ -0,0 +1,117 @@
/*
* 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.
*/
#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++;
}
}
@@ -0,0 +1,31 @@
/*
* 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_
/* 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_ */
@@ -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.
*/
#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 */
@@ -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.
*/
#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++;
}
}
@@ -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.
*/
/*-------------------------------------------------------------------------*/
#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 */
@@ -0,0 +1,32 @@
/*
* 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_
/* 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_*/
@@ -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.
*/
#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 ******************************************************************/
@@ -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.
*/
/**********************************************************************************
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;
}
/**********************************************************************************/
@@ -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.
*/
/**********************************************************************************
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;
}
}
/**********************************************************************************/
@@ -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.
*/
/**********************************************************************************
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;
}
}
}
/**********************************************************************************/
@@ -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.
*/
/**********************************************************************************
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++;
}
}
/**********************************************************************************/
@@ -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.
*/
#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;
}
@@ -0,0 +1,27 @@
/*
* 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.
*/
#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;
}
@@ -0,0 +1,34 @@
/*
* 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;
/* 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_ */
@@ -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.
*/
/**********************************************************************************
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;
}
/**********************************************************************************/
@@ -0,0 +1,73 @@
/*
* 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.
*/
/**********************************************************************************
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;
}
/**********************************************************************************/
@@ -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.
*/
/**********************************************************************************
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;
}
/**********************************************************************************/
@@ -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.
*/
#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
}
}
@@ -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.
*/
/*-------------------------------------------------------------------------*/
#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 */
@@ -0,0 +1,31 @@
/*
* 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_
/* 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_ */
@@ -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.
*/
#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
}
}
@@ -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.
*/
#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 */
@@ -0,0 +1,32 @@
/*
* 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_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_ */
@@ -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.
*/
#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;
}
}
@@ -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.
*/
/*-------------------------------------------------------------------------*/
#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 */
@@ -0,0 +1,32 @@
/*
* 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_
/* 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_ */
@@ -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.
*/
#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 */
@@ -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.
*/
/**********************************************************************************
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;
}
/**********************************************************************************/
@@ -0,0 +1,49 @@
/*
* 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.
*/
/**********************************************************************************
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;
}
/**********************************************************************************/
@@ -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.
*/
/**********************************************************************************
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;
}
/**********************************************************************************/
@@ -0,0 +1,186 @@
/*
* 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.
*/
#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]);
}
@@ -0,0 +1,48 @@
/*
* 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.
*/
/**********************************************************************************
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;
}
/**********************************************************************************/
@@ -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.
*/
/**********************************************************************************
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;
}
/**********************************************************************************/
@@ -0,0 +1,54 @@
/*
* 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.
*/
/**********************************************************************************
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;
}
/**********************************************************************************/
@@ -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.
*/
/**********************************************************************************
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;
}
}
/**********************************************************************************/
@@ -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.
*/
/**********************************************************************************
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;
}
}
/**********************************************************************************/
@@ -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.
*/
/**********************************************************************************
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;
}
/**********************************************************************************/
@@ -0,0 +1,143 @@
/*
* 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.
*/
/**********************************************************************************
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;
}
/**********************************************************************************/
@@ -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.
*/
/**********************************************************************************
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;
}
/**********************************************************************************/
@@ -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.
*/
/**********************************************************************************
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 );
}
}
}
}
/**********************************************************************************/
@@ -0,0 +1,152 @@
/*
* 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.
*/
/**********************************************************************************
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 );
}
}
}
}
/**********************************************************************************/
@@ -0,0 +1,111 @@
/*
* 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.
*/
/**********************************************************************************
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 );
}
}
}
}
/**********************************************************************************/
@@ -0,0 +1,70 @@
/*
* 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.
*/
/**********************************************************************************
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);
}
}
/**********************************************************************************/
@@ -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.
*/
#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__
@@ -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.
*/
#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;
}
@@ -0,0 +1,42 @@
/*
* 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.
*/
#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;
}
@@ -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.
*/
#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
}
@@ -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.
*/
#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__
@@ -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.
*/
#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
}
@@ -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.
*/
#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
}
@@ -0,0 +1,95 @@
/*
* 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.
*/
#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
}
@@ -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.
*/
#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;
}
@@ -0,0 +1,97 @@
/*
* 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.
*/
#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;
}
@@ -0,0 +1,70 @@
/*
* 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.
*/
#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;
}
@@ -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.
*/
/************************************************************************************/
/* */
/* 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
@@ -0,0 +1,156 @@
/*
* 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.
*/
#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;
}
@@ -0,0 +1,96 @@
/*
* 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.
*/
#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;
}
@@ -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.
*/
#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;
}
@@ -0,0 +1,48 @@
/*
* 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.
*/
/****************************************************************************************/
/* 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 */
/****************************************************************************************/
@@ -0,0 +1,54 @@
/*
* 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.
*/
/****************************************************************************************/
/* 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 */
/****************************************************************************************/
@@ -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.
*/
#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 */
@@ -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.
*/
/**********************************************************************************
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;
}
/**********************************************************************************/
@@ -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.
*/
/**********************************************************************************
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;
}
/**********************************************************************************/

Some files were not shown because too many files have changed in this diff Show More