diff options
Diffstat (limited to 'media/libeffects/lvm/lib/StereoWidening/src')
15 files changed, 3310 insertions, 0 deletions
diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_BypassMix.c b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_BypassMix.c new file mode 100755 index 0000000..2a83e89 --- /dev/null +++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_BypassMix.c @@ -0,0 +1,303 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************************ + + $Author: nxp007753 $ + $Revision: 1246 $ + $Date: 2010-07-16 11:07:10 +0200 (Fri, 16 Jul 2010) $ + +*************************************************************************************/ + +/************************************************************************************/ +/* */ +/* Includes */ +/* */ +/************************************************************************************/ + +#include "LVCS.h" +#include "LVCS_Private.h" +#include "LVCS_BypassMix.h" +#include "VectorArithmetic.h" +#include "LVCS_Tables.h" + +/****************************************************************************************/ +/* */ +/* Function Prototypes */ +/* */ +/****************************************************************************************/ +LVM_INT32 LVCS_MixerCallback( LVCS_Handle_t hInstance, + void *pGeneralPurpose, + LVM_INT16 CallbackParam); + +/************************************************************************************/ +/* */ +/* FUNCTION: LVCS_BypassMixInit */ +/* */ +/* DESCRIPTION: */ +/* Initialises the bypass mixer module */ +/* */ +/* The overall gain of the processed path is set by the gains in the individual */ +/* processing blocks and by the effect level gain. */ +/* */ +/* The unprocessed path must have matching gain for the processed path to ensure */ +/* as they are mixed together the correct effect is achieved, this is the value */ +/* UnprocLoss. */ +/* */ +/* The overall gain is corrected by a combination of a shift with saturation and a */ +/* linear scaler, loss. The loss ensures the sum in the mixer does not saturate */ +/* and also corrects for any excess gain in the shift. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance Handle */ +/* pParams Initialisation parameters */ +/* */ +/* RETURNS: */ +/* LVCS_Success Always succeeds */ +/* */ +/* NOTES: */ +/* */ +/************************************************************************************/ + +LVCS_ReturnStatus_en LVCS_BypassMixInit(LVCS_Handle_t hInstance, + LVCS_Params_t *pParams) +{ + + LVM_UINT16 Offset; + LVM_UINT32 Gain; + LVCS_Instance_t *pInstance = (LVCS_Instance_t *)hInstance; + LVCS_BypassMix_t *pConfig = (LVCS_BypassMix_t *)&pInstance->BypassMix; + const Gain_t *pOutputGainTable; + LVM_INT32 Current; + + + /* + * Set the transition gain + */ + if ((pParams->OperatingMode == LVCS_ON) && + (pInstance->bTimerDone == LVM_TRUE) + && (LVC_Mixer_GetTarget(&pInstance->MSBypassMixer.MixerStream[1]) != 0x7FFF) /* this indicates an off->on transtion */ + ) + { + pInstance->TransitionGain = pParams->EffectLevel; + } + else + { + /* Select no effect level */ + pInstance->TransitionGain = 0; + } + + /* + * Calculate the output gain table offset + */ + Offset = (LVM_UINT16)(pParams->SpeakerType + (pParams->SourceFormat*(1+LVCS_EX_HEADPHONES))); + pOutputGainTable = (Gain_t*)&LVCS_OutputGainTable[0]; + + /* + * Setup the mixer gain for the processed path + */ + Gain = (LVM_UINT32)(pOutputGainTable[Offset].Loss * pInstance->TransitionGain); + + pConfig->Mixer_Instance.MixerStream[0].CallbackParam = 0; + pConfig->Mixer_Instance.MixerStream[0].pCallbackHandle = LVM_NULL; + pConfig->Mixer_Instance.MixerStream[0].pCallBack = LVM_NULL; + pConfig->Mixer_Instance.MixerStream[0].CallbackSet=1; + Current = LVC_Mixer_GetCurrent(&pConfig->Mixer_Instance.MixerStream[0]); + LVC_Mixer_Init(&pConfig->Mixer_Instance.MixerStream[0],(LVM_INT32)(Gain >> 15),Current); + LVC_Mixer_VarSlope_SetTimeConstant(&pConfig->Mixer_Instance.MixerStream[0],LVCS_BYPASS_MIXER_TC,pParams->SampleRate,2); + /* + * Setup the mixer gain for the unprocessed path + */ + Gain = (LVM_UINT32)(pOutputGainTable[Offset].Loss * (0x7FFF - pInstance->TransitionGain)); + Gain = (LVM_UINT32)pOutputGainTable[Offset].UnprocLoss * (Gain >> 15); + Current = LVC_Mixer_GetCurrent(&pConfig->Mixer_Instance.MixerStream[1]); + LVC_Mixer_Init(&pConfig->Mixer_Instance.MixerStream[1],(LVM_INT32)(Gain >> 15),Current); + LVC_Mixer_VarSlope_SetTimeConstant(&pConfig->Mixer_Instance.MixerStream[1],LVCS_BYPASS_MIXER_TC,pParams->SampleRate,2); + pConfig->Mixer_Instance.MixerStream[1].CallbackParam = 0; + pConfig->Mixer_Instance.MixerStream[1].pCallbackHandle = hInstance; + pConfig->Mixer_Instance.MixerStream[1].CallbackSet=1; + pConfig->Mixer_Instance.MixerStream[1].pCallBack = LVCS_MixerCallback; + + /* + * Setup the output gain shift + */ + pConfig->Output_Shift = pOutputGainTable[Offset].Shift; + + + /* + * Correct gain for the effect level + */ + { + + LVM_INT16 GainCorrect; + LVM_INT32 Gain1; + LVM_INT32 Gain2; + + Gain1 = LVC_Mixer_GetTarget(&pConfig->Mixer_Instance.MixerStream[0]); + Gain2 = LVC_Mixer_GetTarget(&pConfig->Mixer_Instance.MixerStream[1]); + /* + * Calculate the gain correction + */ + if (pInstance->Params.CompressorMode == LVM_MODE_ON) + { + GainCorrect = (LVM_INT16)( pInstance->VolCorrect.GainMin + - (((LVM_INT32)pInstance->VolCorrect.GainMin * (LVM_INT32)pInstance->TransitionGain) >> 15) + + (((LVM_INT32)pInstance->VolCorrect.GainFull * (LVM_INT32)pInstance->TransitionGain) >> 15) ); + + /* + * Apply the gain correction and shift, note the result is in Q3.13 format + */ + Gain1 = (Gain1 * GainCorrect) << 4; + Gain2 = (Gain2 * GainCorrect) << 4; + } + else + { + Gain1 = Gain1 << 16; + Gain2 = Gain2 << 16; + } + + + + /* + * Set the gain values + */ + pConfig->Output_Shift = pConfig->Output_Shift; + LVC_Mixer_SetTarget(&pConfig->Mixer_Instance.MixerStream[0],Gain1>>16); + LVC_Mixer_VarSlope_SetTimeConstant(&pConfig->Mixer_Instance.MixerStream[0],LVCS_BYPASS_MIXER_TC,pParams->SampleRate,2); + LVC_Mixer_SetTarget(&pConfig->Mixer_Instance.MixerStream[1],Gain2>>16); + LVC_Mixer_VarSlope_SetTimeConstant(&pConfig->Mixer_Instance.MixerStream[1],LVCS_BYPASS_MIXER_TC,pParams->SampleRate,2); + } + + return(LVCS_SUCCESS); + +} + +/************************************************************************************/ +/* */ +/* FUNCTION: LVCS_BypassMixer */ +/* */ +/* DESCRIPTION: */ +/* Apply Bypass Mix. */ +/* */ +/* This mixes the processed and unprocessed data streams together to correct the */ +/* overall system gain and allow progressive control of the Concert Sound effect. */ +/* */ +/* When the bypass mixer is enabled the output is the processed signal only and */ +/* without gain correction. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance Handle */ +/* pProcessed Pointer to the processed data */ +/* pUnprocessed Pointer to the unprocessed data */ +/* pOutData Pointer to the output data */ +/* NumSamples Number of samples to process */ +/* */ +/* RETURNS: */ +/* LVCS_Success Always succeeds */ +/* */ +/* NOTES: */ +/* */ +/************************************************************************************/ + +LVCS_ReturnStatus_en LVCS_BypassMixer(LVCS_Handle_t hInstance, + const LVM_INT16 *pProcessed, + const LVM_INT16 *pUnprocessed, + LVM_INT16 *pOutData, + LVM_UINT16 NumSamples) +{ + + LVCS_Instance_t *pInstance = (LVCS_Instance_t *)hInstance; + LVCS_BypassMix_t *pConfig = (LVCS_BypassMix_t *)&pInstance->BypassMix; + + /* + * Check if the bypass mixer is enabled + */ + if ((pInstance->Params.OperatingMode & LVCS_BYPASSMIXSWITCH) != 0) + { + /* + * Apply the bypass mix + */ + LVC_MixSoft_2St_D16C31_SAT(&pConfig->Mixer_Instance, + pProcessed, + (LVM_INT16 *) pUnprocessed, + pOutData, + (LVM_INT16)(2*NumSamples)); + + /* + * Apply output gain correction shift + */ + Shift_Sat_v16xv16 ((LVM_INT16)pConfig->Output_Shift, + (LVM_INT16*)pOutData, + (LVM_INT16*)pOutData, + (LVM_INT16)(2*NumSamples)); /* Left and right*/ + } + + return(LVCS_SUCCESS); +} + + +/************************************************************************************/ +/* */ +/* FUNCTION: LVCS_MixerCallback */ +/* */ +/************************************************************************************/ +LVM_INT32 LVCS_MixerCallback(LVCS_Handle_t hInstance, + void *pGeneralPurpose, + LVM_INT16 CallbackParam) +{ + LVCS_Instance_t *pInstance = (LVCS_Instance_t *)hInstance; + LVM_INT32 Target1; + + Target1 = LVC_Mixer_GetTarget(&pInstance->MSBypassMixer.MixerStream[0]); + (void)pGeneralPurpose; + + /* + * Off transition has completed in Headphone mode + */ + if ((pInstance->OutputDevice == LVCS_HEADPHONE) && + (pInstance->bInOperatingModeTransition) && + (Target1 == 0x0000)&& /* this indicates an on->off transition */ + (CallbackParam == 0)) + { + /* Set operating mode to OFF */ + pInstance->Params.OperatingMode = LVCS_OFF; + + /* Exit transition state */ + pInstance->bInOperatingModeTransition = LVM_FALSE; + + /* Signal to the bundle */ + if((*pInstance->Capabilities.CallBack) != LVM_NULL){ + (*pInstance->Capabilities.CallBack)(pInstance->Capabilities.pBundleInstance, + LVM_NULL, + (ALGORITHM_CS_ID | LVCS_EVENT_ALGOFF)); + } + } + + + if ((pInstance->OutputDevice == LVCS_HEADPHONE) && + (Target1 == 1) && + (pInstance->bTimerDone == LVM_TRUE)){ + + /* Exit transition state */ + pInstance->bInOperatingModeTransition = LVM_FALSE; + } + + return 1; +} + + + diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_BypassMix.h b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_BypassMix.h new file mode 100755 index 0000000..79dff41 --- /dev/null +++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_BypassMix.h @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************************ + + $Author: beq07716 $ + $Revision: 1001 $ + $Date: 2010-06-28 13:23:02 +0200 (Mon, 28 Jun 2010) $ + +*************************************************************************************/ + +#ifndef __LVCS_BYPASSMIX_H__ +#define __LVCS_BYPASSMIX_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/************************************************************************************/ +/* */ +/* Includes */ +/* */ +/************************************************************************************/ + +#include "LVC_Mixer.h" + + +/************************************************************************************/ +/* */ +/* Structures */ +/* */ +/************************************************************************************/ + +/* Bypass mixer structure */ +typedef struct +{ + /* Mixer settings */ + LVMixer3_2St_st Mixer_Instance; /* Mixer instance */ + LVM_UINT16 Output_Shift; /* Correcting gain output shift */ + +} LVCS_BypassMix_t; + + +/* Output gain type */ +typedef struct +{ + /* Output gain settings, Gain = (Loss/32768) * 2^Shift */ + LVM_UINT16 Shift; /* Left shifts required */ + LVM_UINT16 Loss; /* Loss required */ + LVM_UINT16 UnprocLoss; /* Unprocessed path loss */ +} Gain_t; + + +/************************************************************************************/ +/* */ +/* Function prototypes */ +/* */ +/************************************************************************************/ + +LVCS_ReturnStatus_en LVCS_BypassMixInit(LVCS_Handle_t hInstance, + LVCS_Params_t *pParams); + + +LVCS_ReturnStatus_en LVCS_BypassMixer(LVCS_Handle_t hInstance, + const LVM_INT16 *pProcessed, + const LVM_INT16 *unProcessed, + LVM_INT16 *pOutData, + LVM_UINT16 NumSamples); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* BYPASSMIX_H */ diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Control.c b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Control.c new file mode 100755 index 0000000..5dfca25 --- /dev/null +++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Control.c @@ -0,0 +1,273 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************************ + + $Author: nxp007753 $ + $Revision: 1246 $ + $Date: 2010-07-16 11:07:10 +0200 (Fri, 16 Jul 2010) $ + +*************************************************************************************/ + +/************************************************************************************/ +/* */ +/* Includes */ +/* */ +/************************************************************************************/ + +#include "LVCS.h" +#include "LVCS_Private.h" +#include "LVCS_Tables.h" + +/************************************************************************************/ +/* */ +/* FUNCTION: LVCS_GetParameters */ +/* */ +/* DESCRIPTION: */ +/* Request the Concert Sound parameters. The current parameter set is returned */ +/* via the parameter pointer. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance handle */ +/* pParams Pointer to an empty parameter structure */ +/* */ +/* RETURNS: */ +/* LVCS_Success Always succeeds */ +/* */ +/* NOTES: */ +/* 1. This function may be interrupted by the LVCS_Process function */ +/* */ +/************************************************************************************/ + +LVCS_ReturnStatus_en LVCS_GetParameters(LVCS_Handle_t hInstance, + LVCS_Params_t *pParams) +{ + + LVCS_Instance_t *pInstance =(LVCS_Instance_t *)hInstance; + + *pParams = pInstance->Params; + + return(LVCS_SUCCESS); +} + + +/************************************************************************************/ +/* */ +/* FUNCTION: LVCS_Control */ +/* */ +/* DESCRIPTION: */ +/* Sets or changes the Concert Sound parameters. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance handle */ +/* pParams Pointer to a parameter structure */ +/* */ +/* RETURNS: */ +/* LVCS_Success Succeeded */ +/* */ +/* NOTES: */ +/* 1. This function must not be interrupted by the LVCS_Process function */ +/* */ +/************************************************************************************/ + +LVCS_ReturnStatus_en LVCS_Control(LVCS_Handle_t hInstance, + LVCS_Params_t *pParams) +{ + LVM_INT16 Offset; + LVCS_Instance_t *pInstance =(LVCS_Instance_t *)hInstance; + LVCS_ReturnStatus_en err; + LVCS_Modes_en OperatingModeSave = pInstance->Params.OperatingMode; + + if (pParams->SampleRate != pInstance->Params.SampleRate) + { + LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->MSBypassMixer.MixerStream[0],LVCS_BYPASS_MIXER_TC,pParams->SampleRate,2); + + LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->MSBypassMixer.MixerStream[1],LVCS_BYPASS_MIXER_TC,pParams->SampleRate,2); + pInstance->TimerParams.SamplingRate = LVCS_SampleRateTable[pParams->SampleRate]; + } + + /* + * If the reverb level has changed + */ + if(pInstance->Params.ReverbLevel != pParams->ReverbLevel) + { + err=LVCS_ReverbGeneratorInit(hInstance,pParams); + } + + /* + * If the sample rate or speaker has changed then perform a full re-initialisation + */ + if ((pInstance->Params.SampleRate != pParams->SampleRate) || + (pInstance->Params.SpeakerType != pParams->SpeakerType)) + { + const LVCS_VolCorrect_t *pLVCS_VolCorrectTable; + + /* + * Output device + */ + pInstance->OutputDevice = LVCS_HEADPHONE; + + /* + * Get the volume correction parameters + */ + /* Use internal coefficient table */ + pLVCS_VolCorrectTable = (LVCS_VolCorrect_t*)&LVCS_VolCorrectTable[0]; + Offset = (LVM_INT16)(pParams->SpeakerType + pParams->SourceFormat*(1+LVCS_EX_HEADPHONES)); + + pInstance->VolCorrect = pLVCS_VolCorrectTable[Offset]; + + err=LVCS_SEnhancerInit(hInstance, + pParams); + + err=LVCS_ReverbGeneratorInit(hInstance, + pParams); + + err=LVCS_EqualiserInit(hInstance, + pParams); + + err=LVCS_BypassMixInit(hInstance, + pParams); + + } + + + /* + * Check if the effect level or source format has changed + */ + else if ((pInstance->Params.EffectLevel != pParams->EffectLevel) || + (pInstance->Params.SourceFormat != pParams->SourceFormat)) + { + const LVCS_VolCorrect_t *pLVCS_VolCorrectTable; + + /* + * Get the volume correction parameters + */ + /* Use internal coefficient table */ + pLVCS_VolCorrectTable = (LVCS_VolCorrect_t*)&LVCS_VolCorrectTable[0]; + Offset = (LVM_INT16)(pParams->SpeakerType + pParams->SourceFormat*(1+LVCS_EX_HEADPHONES)); + + pInstance->VolCorrect = pLVCS_VolCorrectTable[Offset]; + + /* Update the effect level and alpha-mixer gains */ + err=LVCS_BypassMixInit(hInstance, + pParams); + + if(err != LVCS_SUCCESS) + { + return err; + } + } + else + { + pInstance->Params = *pParams; + } + + /* + * Update the instance parameters + */ + pInstance->Params = *pParams; + + /* Stay on the current operating mode until the transition is done */ + if((pParams->OperatingMode != OperatingModeSave) || + (pInstance->bInOperatingModeTransition == LVM_TRUE)){ + + /* Set the reverb delay timeout */ + if(pInstance->bInOperatingModeTransition != LVM_TRUE){ + pInstance->bTimerDone = LVM_FALSE; + pInstance->TimerParams.TimeInMs = (LVM_INT16)(((pInstance->Reverberation.DelaySize << 2)/pInstance->TimerParams.SamplingRate) + 1); + LVM_Timer_Init ( &pInstance->TimerInstance, + &pInstance->TimerParams); + } + + /* Update the effect level and alpha-mixer gains */ + err=LVCS_BypassMixInit(hInstance, + pParams); + + /* Change transition bypass mixer settings if needed depending on transition type */ + if(pParams->OperatingMode != LVCS_OFF){ + LVM_INT32 Current1; + LVM_INT32 Current2; + + Current1 = LVC_Mixer_GetCurrent(&pInstance->MSBypassMixer.MixerStream[0]); + Current2 = LVC_Mixer_GetCurrent(&pInstance->MSBypassMixer.MixerStream[1]); + + if(pInstance->bInOperatingModeTransition != LVM_TRUE) + { + Current1 = 0x00000000; + Current2 = LVM_MAXINT_16; + } + pInstance->MSBypassMixer.MixerStream[0].CallbackSet = 1; + pInstance->MSBypassMixer.MixerStream[1].CallbackSet = 1; + + LVC_Mixer_Init(&pInstance->MSBypassMixer.MixerStream[0],LVM_MAXINT_16,Current1); + LVC_Mixer_Init(&pInstance->MSBypassMixer.MixerStream[1],0,Current2); + } + else + { + LVM_INT32 Current1; + LVM_INT32 Current2; + + Current1 = LVC_Mixer_GetCurrent(&pInstance->MSBypassMixer.MixerStream[0]); + Current2 = LVC_Mixer_GetCurrent(&pInstance->MSBypassMixer.MixerStream[1]); + + if(pInstance->bInOperatingModeTransition != LVM_TRUE) + { + Current1 = LVM_MAXINT_16; + Current2 = 0x00000000; + } + pInstance->MSBypassMixer.MixerStream[0].CallbackSet = 1; + pInstance->MSBypassMixer.MixerStream[1].CallbackSet = 1; + pInstance->Params.OperatingMode = OperatingModeSave; + LVC_Mixer_Init(&pInstance->MSBypassMixer.MixerStream[0],0x00000000,Current1); + LVC_Mixer_Init(&pInstance->MSBypassMixer.MixerStream[1],LVM_MAXINT_16,Current2); + } + LVC_Mixer_SetTimeConstant(&pInstance->MSBypassMixer.MixerStream[0],LVCS_BYPASS_MIXER_TC,pParams->SampleRate,2); + LVC_Mixer_SetTimeConstant(&pInstance->MSBypassMixer.MixerStream[1],LVCS_BYPASS_MIXER_TC,pParams->SampleRate,2); + + + /* Set transition flag */ + pInstance->bInOperatingModeTransition = LVM_TRUE; + } + + return(LVCS_SUCCESS); +} + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVCS_TimerCallBack */ +/* */ +/* DESCRIPTION: */ +/* CallBack function of the Timer. */ +/* */ +/****************************************************************************************/ +void LVCS_TimerCallBack (void* hInstance, void* pCallBackParams, LVM_INT32 CallbackParam) +{ + LVCS_Instance_t *pInstance = (LVCS_Instance_t *)hInstance; + + /* Avoid warnings because pCallBackParams and CallbackParam are not used*/ + if((pCallBackParams != LVM_NULL) || (CallbackParam != 0)){ + pCallBackParams = hInstance; + CallbackParam = 0; + return; + } + + pInstance->bTimerDone = LVM_TRUE; + + + return; +} + diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Equaliser.c b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Equaliser.c new file mode 100755 index 0000000..ca615b0 --- /dev/null +++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Equaliser.c @@ -0,0 +1,167 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************************ + + $Author: beq07716 $ + $Revision: 1001 $ + $Date: 2010-06-28 13:23:02 +0200 (Mon, 28 Jun 2010) $ + +*************************************************************************************/ + +/************************************************************************************/ +/* */ +/* Includes */ +/* */ +/************************************************************************************/ + +#include "LVCS.h" +#include "LVCS_Private.h" +#include "LVCS_Equaliser.h" +#include "BIQUAD.h" +#include "VectorArithmetic.h" +#include "LVCS_Tables.h" + +/************************************************************************************/ +/* */ +/* FUNCTION: LVCS_EqualiserInit */ +/* */ +/* DESCRIPTION: */ +/* Initialises the equaliser module */ +/* */ +/* The function selects the coefficients for the filters and clears the data */ +/* history. It is also used for re-initialisation when one of the system control */ +/* parameters changes but will only change the coefficients and clear the history */ +/* if the sample rate or speaker type has changed. */ +/* */ +/* To avoid excessive testing during the sample processing the biquad type is */ +/* set as a callback function in the init routine. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance Handle */ +/* pParams Initialisation parameters */ +/* */ +/* RETURNS: */ +/* LVCS_Success Always succeeds */ +/* */ +/* NOTES: */ +/* */ +/************************************************************************************/ + +LVCS_ReturnStatus_en LVCS_EqualiserInit(LVCS_Handle_t hInstance, + LVCS_Params_t *pParams) +{ + + LVM_UINT16 Offset; + LVCS_Instance_t *pInstance = (LVCS_Instance_t *)hInstance; + LVCS_Equaliser_t *pConfig = (LVCS_Equaliser_t *)&pInstance->Equaliser; + LVCS_Data_t *pData = (LVCS_Data_t *)pInstance->MemoryTable.Region[LVCS_MEMREGION_PERSISTENT_FAST_DATA].pBaseAddress; + LVCS_Coefficient_t *pCoefficients = (LVCS_Coefficient_t *)pInstance->MemoryTable.Region[LVCS_MEMREGION_PERSISTENT_FAST_COEF].pBaseAddress; + BQ_C16_Coefs_t Coeffs; + const BiquadA012B12CoefsSP_t *pEqualiserCoefTable; + + /* + * If the sample rate changes re-initialise the filters + */ + if ((pInstance->Params.SampleRate != pParams->SampleRate) || + (pInstance->Params.SpeakerType != pParams->SpeakerType)) + { + /* + * Setup the filter coefficients and clear the history + */ + Offset = (LVM_UINT16)(pParams->SampleRate + (pParams->SpeakerType * (1+LVM_FS_48000))); + pEqualiserCoefTable = (BiquadA012B12CoefsSP_t*)&LVCS_EqualiserCoefTable[0]; + + /* Left and right filters */ + /* Convert incoming coefficients to the required format/ordering */ + Coeffs.A0 = (LVM_INT16) pEqualiserCoefTable[Offset].A0; + Coeffs.A1 = (LVM_INT16) pEqualiserCoefTable[Offset].A1; + Coeffs.A2 = (LVM_INT16) pEqualiserCoefTable[Offset].A2; + Coeffs.B1 = (LVM_INT16)-pEqualiserCoefTable[Offset].B1; + Coeffs.B2 = (LVM_INT16)-pEqualiserCoefTable[Offset].B2; + + LoadConst_16((LVM_INT16)0, /* Value */ + (LVM_INT16 *)&pData->EqualiserBiquadTaps, /* Destination */ + (LVM_UINT16)(sizeof(pData->EqualiserBiquadTaps)/sizeof(LVM_INT16))); /* Number of words */ + + BQ_2I_D16F32Css_TRC_WRA_01_Init(&pCoefficients->EqualiserBiquadInstance, + &pData->EqualiserBiquadTaps, + &Coeffs); + + /* Callbacks */ + switch(pEqualiserCoefTable[Offset].Scale) + { + case 13: + pConfig->pBiquadCallBack = BQ_2I_D16F32C13_TRC_WRA_01; + break; + case 14: + pConfig->pBiquadCallBack = BQ_2I_D16F32C14_TRC_WRA_01; + break; + case 15: + pConfig->pBiquadCallBack = BQ_2I_D16F32C15_TRC_WRA_01; + break; + } + } + + return(LVCS_SUCCESS); +} + +/************************************************************************************/ +/* */ +/* FUNCTION: LVCS_Equaliser */ +/* */ +/* DESCRIPTION: */ +/* Apply the equaliser filter. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance Handle */ +/* pInputOutput Pointer to the input/output buffer */ +/* NumSamples The number of samples to process */ +/* */ +/* RETURNS: */ +/* LVCS_Success Always succeeds */ +/* */ +/* NOTES: */ +/* 1. Always processes in place. */ +/* */ +/************************************************************************************/ + +LVCS_ReturnStatus_en LVCS_Equaliser(LVCS_Handle_t hInstance, + LVM_INT16 *pInputOutput, + LVM_UINT16 NumSamples) +{ + + LVCS_Instance_t *pInstance = (LVCS_Instance_t *)hInstance; + LVCS_Equaliser_t *pConfig = (LVCS_Equaliser_t *)&pInstance->Equaliser; + LVCS_Coefficient_t *pCoefficients = (LVCS_Coefficient_t *)pInstance->MemoryTable.Region[LVCS_MEMREGION_PERSISTENT_FAST_COEF].pBaseAddress; + + + /* + * Check if the equaliser is required + */ + if ((pInstance->Params.OperatingMode & LVCS_EQUALISERSWITCH) != 0) + { + /* Apply filter to the left and right channels */ + (pConfig->pBiquadCallBack)((Biquad_Instance_t*)&pCoefficients->EqualiserBiquadInstance, + (LVM_INT16 *)pInputOutput, + (LVM_INT16 *)pInputOutput, + (LVM_INT16)NumSamples); + } + + return(LVCS_SUCCESS); +} + diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Equaliser.h b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Equaliser.h new file mode 100755 index 0000000..10b02cc --- /dev/null +++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Equaliser.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. + */ + +/************************************************************************************ + + $Author: beq07716 $ + $Revision: 1001 $ + $Date: 2010-06-28 13:23:02 +0200 (Mon, 28 Jun 2010) $ + +*************************************************************************************/ + +#ifndef __LVCS_EQUALISER_H__ +#define __LVCS_EQUALISER_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/************************************************************************************/ +/* */ +/* Structures */ +/* */ +/************************************************************************************/ + +/* Equaliser structure */ +typedef struct +{ + void (*pBiquadCallBack) (Biquad_Instance_t*, LVM_INT16*, LVM_INT16*, LVM_INT16); + +} LVCS_Equaliser_t; + + +/************************************************************************************/ +/* */ +/* Function prototypes */ +/* */ +/************************************************************************************/ + +LVCS_ReturnStatus_en LVCS_EqualiserInit(LVCS_Handle_t hInstance, + LVCS_Params_t *pParams); + +LVCS_ReturnStatus_en LVCS_Equaliser(LVCS_Handle_t hInstance, + LVM_INT16 *pInputOutput, + LVM_UINT16 NumSamples); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* EQUALISER_H */ diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Headphone_Coeffs.h b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Headphone_Coeffs.h new file mode 100755 index 0000000..1d55281 --- /dev/null +++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Headphone_Coeffs.h @@ -0,0 +1,398 @@ +/* + * 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 __LVCS_HEADPHONE_COEFFS_H__ +#define __LVCS_HEADPHONE_COEFFS_H__ + + +/************************************************************************************/ +/* */ +/* The Stereo Enhancer */ +/* */ +/************************************************************************************/ + +/* Stereo Enhancer coefficients for 8000 Hz sample rate, scaled with 0.161258 */ +#define CS_MIDDLE_8000_A0 7462 /* Floating point value 0.227720 */ +#define CS_MIDDLE_8000_A1 -7049 /* Floating point value -0.215125 */ +#define CS_MIDDLE_8000_A2 0 /* Floating point value 0.000000 */ +#define CS_MIDDLE_8000_B1 -30209 /* Floating point value -0.921899 */ +#define CS_MIDDLE_8000_B2 0 /* Floating point value 0.000000 */ +#define CS_MIDDLE_8000_SCALE 15 +#define CS_SIDE_8000_A0 20036 /* Floating point value 0.611441 */ +#define CS_SIDE_8000_A1 -12463 /* Floating point value -0.380344 */ +#define CS_SIDE_8000_A2 -7573 /* Floating point value -0.231097 */ +#define CS_SIDE_8000_B1 -20397 /* Floating point value -0.622470 */ +#define CS_SIDE_8000_B2 -4285 /* Floating point value -0.130759 */ +#define CS_SIDE_8000_SCALE 15 + +/* Stereo Enhancer coefficients for 11025Hz sample rate, scaled with 0.162943 */ +#define CS_MIDDLE_11025_A0 7564 /* Floating point value 0.230838 */ +#define CS_MIDDLE_11025_A1 -7260 /* Floating point value -0.221559 */ +#define CS_MIDDLE_11025_A2 0 /* Floating point value 0.000000 */ +#define CS_MIDDLE_11025_B1 -30902 /* Floating point value -0.943056 */ +#define CS_MIDDLE_11025_B2 0 /* Floating point value 0.000000 */ +#define CS_MIDDLE_11025_SCALE 15 +#define CS_SIDE_11025_A0 18264 /* Floating point value 0.557372 */ +#define CS_SIDE_11025_A1 -12828 /* Floating point value -0.391490 */ +#define CS_SIDE_11025_A2 -5436 /* Floating point value -0.165881 */ +#define CS_SIDE_11025_B1 -28856 /* Floating point value -0.880608 */ +#define CS_SIDE_11025_B2 1062 /* Floating point value 0.032397 */ +#define CS_SIDE_11025_SCALE 15 + +/* Stereo Enhancer coefficients for 12000Hz sample rate, scaled with 0.162191 */ +#define CS_MIDDLE_12000_A0 7534 /* Floating point value 0.229932 */ +#define CS_MIDDLE_12000_A1 -7256 /* Floating point value -0.221436 */ +#define CS_MIDDLE_12000_A2 0 /* Floating point value 0.000000 */ +#define CS_MIDDLE_12000_B1 -31051 /* Floating point value -0.947616 */ +#define CS_MIDDLE_12000_B2 0 /* Floating point value 0.000000 */ +#define CS_MIDDLE_12000_SCALE 15 +#define CS_SIDE_12000_A0 18298 /* Floating point value 0.558398 */ +#define CS_SIDE_12000_A1 -12852 /* Floating point value -0.392211 */ +#define CS_SIDE_12000_A2 -5446 /* Floating point value -0.166187 */ +#define CS_SIDE_12000_B1 -29247 /* Floating point value -0.892550 */ +#define CS_SIDE_12000_B2 1077 /* Floating point value 0.032856 */ +#define CS_SIDE_12000_SCALE 15 + +/* Stereo Enhancer coefficients for 16000Hz sample rate, scaled with 0.162371 */ +#define CS_MIDDLE_16000_A0 7558 /* Floating point value 0.230638 */ +#define CS_MIDDLE_16000_A1 -7348 /* Floating point value -0.224232 */ +#define CS_MIDDLE_16000_A2 0 /* Floating point value 0.000000 */ +#define CS_MIDDLE_16000_B1 -31475 /* Floating point value -0.960550 */ +#define CS_MIDDLE_16000_B2 0 /* Floating point value 0.000000 */ +#define CS_MIDDLE_16000_SCALE 15 +#define CS_SIDE_16000_A0 8187 /* Floating point value 0.499695 */ +#define CS_SIDE_16000_A1 -5825 /* Floating point value -0.355543 */ +#define CS_SIDE_16000_A2 -2362 /* Floating point value -0.144152 */ +#define CS_SIDE_16000_B1 -17216 /* Floating point value -1.050788 */ +#define CS_SIDE_16000_B2 2361 /* Floating point value 0.144104 */ +#define CS_SIDE_16000_SCALE 14 + +/* Stereo Enhancer coefficients for 22050Hz sample rate, scaled with 0.160781 */ +#define CS_MIDDLE_22050_A0 7496 /* Floating point value 0.228749 */ +#define CS_MIDDLE_22050_A1 -7344 /* Floating point value -0.224128 */ +#define CS_MIDDLE_22050_A2 0 /* Floating point value 0.000000 */ +#define CS_MIDDLE_22050_B1 -31826 /* Floating point value -0.971262 */ +#define CS_MIDDLE_22050_B2 0 /* Floating point value 0.000000 */ +#define CS_MIDDLE_22050_SCALE 15 +#define CS_SIDE_22050_A0 7211 /* Floating point value 0.440112 */ +#define CS_SIDE_22050_A1 -4278 /* Floating point value -0.261096 */ +#define CS_SIDE_22050_A2 -2933 /* Floating point value -0.179016 */ +#define CS_SIDE_22050_B1 -18297 /* Floating point value -1.116786 */ +#define CS_SIDE_22050_B2 2990 /* Floating point value 0.182507 */ +#define CS_SIDE_22050_SCALE 14 + +/* Stereo Enhancer coefficients for 24000Hz sample rate, scaled with 0.161882 */ +#define CS_MIDDLE_24000_A0 7550 /* Floating point value 0.230395 */ +#define CS_MIDDLE_24000_A1 -7409 /* Floating point value -0.226117 */ +#define CS_MIDDLE_24000_A2 0 /* Floating point value 0.000000 */ +#define CS_MIDDLE_24000_B1 -31902 /* Floating point value -0.973573 */ +#define CS_MIDDLE_24000_B2 0 /* Floating point value 0.000000 */ +#define CS_MIDDLE_24000_SCALE 15 +#define CS_SIDE_24000_A0 6796 /* Floating point value 0.414770 */ +#define CS_SIDE_24000_A1 -4705 /* Floating point value -0.287182 */ +#define CS_SIDE_24000_A2 -2090 /* Floating point value -0.127588 */ +#define CS_SIDE_24000_B1 -20147 /* Floating point value -1.229648 */ +#define CS_SIDE_24000_B2 4623 /* Floating point value 0.282177 */ +#define CS_SIDE_24000_SCALE 14 + +/* Stereo Enhancer coefficients for 32000Hz sample rate, scaled with 0.160322 */ +#define CS_MIDDLE_32000_A0 7484 /* Floating point value 0.228400 */ +#define CS_MIDDLE_32000_A1 -7380 /* Floating point value -0.225214 */ +#define CS_MIDDLE_32000_A2 0 /* Floating point value 0.000000 */ +#define CS_MIDDLE_32000_B1 -32117 /* Floating point value -0.980126 */ +#define CS_MIDDLE_32000_B2 0 /* Floating point value 0.000000 */ +#define CS_MIDDLE_32000_SCALE 15 +#define CS_SIDE_32000_A0 5973 /* Floating point value 0.364579 */ +#define CS_SIDE_32000_A1 -3397 /* Floating point value -0.207355 */ +#define CS_SIDE_32000_A2 -2576 /* Floating point value -0.157224 */ +#define CS_SIDE_32000_B1 -20877 /* Floating point value -1.274231 */ +#define CS_SIDE_32000_B2 5120 /* Floating point value 0.312495 */ +#define CS_SIDE_32000_SCALE 14 + +/* Stereo Enhancer coefficients for 44100Hz sample rate, scaled with 0.163834 */ +#define CS_MIDDLE_44100_A0 7654 /* Floating point value 0.233593 */ +#define CS_MIDDLE_44100_A1 -7577 /* Floating point value -0.231225 */ +#define CS_MIDDLE_44100_A2 0 /* Floating point value 0.000000 */ +#define CS_MIDDLE_44100_B1 -32294 /* Floating point value -0.985545 */ +#define CS_MIDDLE_44100_B2 0 /* Floating point value 0.000000 */ +#define CS_MIDDLE_44100_SCALE 15 +#define CS_SIDE_44100_A0 4662 /* Floating point value 0.284573 */ +#define CS_SIDE_44100_A1 -4242 /* Floating point value -0.258910 */ +#define CS_SIDE_44100_A2 -420 /* Floating point value -0.025662 */ +#define CS_SIDE_44100_B1 -25760 /* Floating point value -1.572248 */ +#define CS_SIDE_44100_B2 9640 /* Floating point value 0.588399 */ +#define CS_SIDE_44100_SCALE 14 + +/* Stereo Enhancer coefficients for 48000Hz sample rate, scaled with 0.164402 */ +#define CS_MIDDLE_48000_A0 7682 /* Floating point value 0.234445 */ +#define CS_MIDDLE_48000_A1 -7611 /* Floating point value -0.232261 */ +#define CS_MIDDLE_48000_A2 0 /* Floating point value 0.000000 */ +#define CS_MIDDLE_48000_B1 -32333 /* Floating point value -0.986713 */ +#define CS_MIDDLE_48000_B2 0 /* Floating point value 0.000000 */ +#define CS_MIDDLE_48000_SCALE 15 +#define CS_SIDE_48000_A0 4466 /* Floating point value 0.272606 */ +#define CS_SIDE_48000_A1 -4374 /* Floating point value -0.266952 */ +#define CS_SIDE_48000_A2 -93 /* Floating point value -0.005654 */ +#define CS_SIDE_48000_B1 -26495 /* Floating point value -1.617141 */ +#define CS_SIDE_48000_B2 10329 /* Floating point value 0.630405 */ +#define CS_SIDE_48000_SCALE 14 + + +/************************************************************************************/ +/* */ +/* The Reverb Unit */ +/* */ +/************************************************************************************/ + +/* Reverb delay settings in samples */ +#define LVCS_STEREODELAY_CS_8KHZ 93 /* Sample rate 8kS/s */ +#define LVCS_STEREODELAY_CS_11KHZ 128 /* Sample rate 11kS/s */ +#define LVCS_STEREODELAY_CS_12KHZ 139 /* Sample rate 12kS/s */ +#define LVCS_STEREODELAY_CS_16KHZ 186 /* Sample rate 16kS/s */ +#define LVCS_STEREODELAY_CS_22KHZ 256 /* Sample rate 22kS/s */ +#define LVCS_STEREODELAY_CS_24KHZ 279 /* Sample rate 24kS/s */ +#define LVCS_STEREODELAY_CS_32KHZ 372 /* Sample rate 32kS/s */ +#define LVCS_STEREODELAY_CS_44KHZ 512 /* Sample rate 44kS/s */ +#define LVCS_STEREODELAY_CS_48KHZ 512 /* Sample rate 48kS/s */ + +/* Reverb coefficients for 8000 Hz sample rate, scaled with 1.038030 */ +#define CS_REVERB_8000_A0 21865 /* Floating point value 0.667271 */ +#define CS_REVERB_8000_A1 -21865 /* Floating point value -0.667271 */ +#define CS_REVERB_8000_A2 0 /* Floating point value 0.000000 */ +#define CS_REVERB_8000_B1 -21895 /* Floating point value -0.668179 */ +#define CS_REVERB_8000_B2 0 /* Floating point value 0.000000 */ +#define CS_REVERB_8000_SCALE 15 + +/* Reverb coefficients for 11025Hz sample rate, scaled with 1.038030 */ +#define CS_REVERB_11025_A0 22926 /* Floating point value 0.699638 */ +#define CS_REVERB_11025_A1 -22926 /* Floating point value -0.699638 */ +#define CS_REVERB_11025_A2 0 /* Floating point value 0.000000 */ +#define CS_REVERB_11025_B1 -24546 /* Floating point value -0.749096 */ +#define CS_REVERB_11025_B2 0 /* Floating point value 0.000000 */ +#define CS_REVERB_11025_SCALE 15 + +/* Reverb coefficients for 12000Hz sample rate, scaled with 1.038030 */ +#define CS_REVERB_12000_A0 23165 /* Floating point value 0.706931 */ +#define CS_REVERB_12000_A1 -23165 /* Floating point value -0.706931 */ +#define CS_REVERB_12000_A2 0 /* Floating point value 0.000000 */ +#define CS_REVERB_12000_B1 -25144 /* Floating point value -0.767327 */ +#define CS_REVERB_12000_B2 0 /* Floating point value 0.000000 */ +#define CS_REVERB_12000_SCALE 15 + +/* Reverb coefficients for 16000Hz sample rate, scaled with 1.038030 */ +#define CS_REVERB_16000_A0 23864 /* Floating point value 0.728272 */ +#define CS_REVERB_16000_A1 -23864 /* Floating point value -0.728272 */ +#define CS_REVERB_16000_A2 0 /* Floating point value 0.000000 */ +#define CS_REVERB_16000_B1 -26892 /* Floating point value -0.820679 */ +#define CS_REVERB_16000_B2 0 /* Floating point value 0.000000 */ +#define CS_REVERB_16000_SCALE 15 + +/* Reverb coefficients for 22050Hz sample rate, scaled with 1.038030 */ +#define CS_REVERB_22050_A0 16921 /* Floating point value 0.516396 */ +#define CS_REVERB_22050_A1 0 /* Floating point value 0.000000 */ +#define CS_REVERB_22050_A2 -16921 /* Floating point value -0.516396 */ +#define CS_REVERB_22050_B1 -16991 /* Floating point value -0.518512 */ +#define CS_REVERB_22050_B2 -9535 /* Floating point value -0.290990 */ +#define CS_REVERB_22050_SCALE 15 + +/* Reverb coefficients for 24000Hz sample rate, scaled with 1.038030 */ +#define CS_REVERB_24000_A0 15714 /* Floating point value 0.479565 */ +#define CS_REVERB_24000_A1 0 /* Floating point value 0.000000 */ +#define CS_REVERB_24000_A2 -15714 /* Floating point value -0.479565 */ +#define CS_REVERB_24000_B1 -20898 /* Floating point value -0.637745 */ +#define CS_REVERB_24000_B2 -6518 /* Floating point value -0.198912 */ +#define CS_REVERB_24000_SCALE 15 + +/* Reverb coefficients for 32000Hz sample rate, scaled with 1.038030 */ +#define CS_REVERB_32000_A0 12463 /* Floating point value 0.380349 */ +#define CS_REVERB_32000_A1 0 /* Floating point value 0.000000 */ +#define CS_REVERB_32000_A2 -12463 /* Floating point value -0.380349 */ +#define CS_REVERB_32000_B1 -31158 /* Floating point value -0.950873 */ +#define CS_REVERB_32000_B2 1610 /* Floating point value 0.049127 */ +#define CS_REVERB_32000_SCALE 15 + +/* Reverb coefficients for 44100Hz sample rate, scaled with 1.038030 */ +#define CS_REVERB_44100_A0 4872 /* Floating point value 0.297389 */ +#define CS_REVERB_44100_A1 0 /* Floating point value 0.000000 */ +#define CS_REVERB_44100_A2 -4872 /* Floating point value -0.297389 */ +#define CS_REVERB_44100_B1 -19668 /* Floating point value -1.200423 */ +#define CS_REVERB_44100_B2 4203 /* Floating point value 0.256529 */ +#define CS_REVERB_44100_SCALE 14 + +/* Reverb coefficients for 48000Hz sample rate, scaled with 1.038030 */ +#define CS_REVERB_48000_A0 4566 /* Floating point value 0.278661 */ +#define CS_REVERB_48000_A1 0 /* Floating point value 0.000000 */ +#define CS_REVERB_48000_A2 -4566 /* Floating point value -0.278661 */ +#define CS_REVERB_48000_B1 -20562 /* Floating point value -1.254993 */ +#define CS_REVERB_48000_B2 4970 /* Floating point value 0.303347 */ +#define CS_REVERB_48000_SCALE 14 + +/* Reverb Gain Settings */ +#define LVCS_HEADPHONE_DELAYGAIN 0.800000 /* Algorithm delay path gain */ +#define LVCS_HEADPHONE_OUTPUTGAIN 1.000000 /* Algorithm output gain */ +#define LVCS_HEADPHONE_PROCGAIN 18403 /* Processed path gain */ +#define LVCS_HEADPHONE_UNPROCGAIN 18403 /* Unprocessed path gain */ +#define LVCS_HEADPHONE_GAINCORRECT 1.009343 /* Delay mixer gain correction */ + + +/************************************************************************************/ +/* */ +/* The Equaliser */ +/* */ +/************************************************************************************/ + +/* Equaliser coefficients for 8000 Hz sample rate, CS scaled with 1.038497 and CSEX scaled with 0.775480 */ +#define CS_EQUALISER_8000_A0 20698 /* Floating point value 1.263312 */ +#define CS_EQUALISER_8000_A1 -9859 /* Floating point value -0.601748 */ +#define CS_EQUALISER_8000_A2 -4599 /* Floating point value -0.280681 */ +#define CS_EQUALISER_8000_B1 -7797 /* Floating point value -0.475865 */ +#define CS_EQUALISER_8000_B2 -6687 /* Floating point value -0.408154 */ +#define CS_EQUALISER_8000_SCALE 14 +#define CSEX_EQUALISER_8000_A0 30912 /* Floating point value 0.943357 */ +#define CSEX_EQUALISER_8000_A1 -14724 /* Floating point value -0.449345 */ +#define CSEX_EQUALISER_8000_A2 -6868 /* Floating point value -0.209594 */ +#define CSEX_EQUALISER_8000_B1 -15593 /* Floating point value -0.475865 */ +#define CSEX_EQUALISER_8000_B2 -13374 /* Floating point value -0.408154 */ +#define CSEX_EQUALISER_8000_SCALE 15 + +/* Equaliser coefficients for 11025Hz sample rate, CS scaled with 1.027761 and CSEX scaled with 0.767463 */ +#define CS_EQUALISER_11025_A0 18041 /* Floating point value 1.101145 */ +#define CS_EQUALISER_11025_A1 2278 /* Floating point value 0.139020 */ +#define CS_EQUALISER_11025_A2 -14163 /* Floating point value -0.864423 */ +#define CS_EQUALISER_11025_B1 402 /* Floating point value 0.024541 */ +#define CS_EQUALISER_11025_B2 -14892 /* Floating point value -0.908930 */ +#define CS_EQUALISER_11025_SCALE 14 +#define CSEX_EQUALISER_11025_A0 31983 /* Floating point value 0.976058 */ +#define CSEX_EQUALISER_11025_A1 -22784 /* Floating point value -0.695326 */ +#define CSEX_EQUALISER_11025_A2 -2976 /* Floating point value -0.090809 */ +#define CSEX_EQUALISER_11025_B1 -20008 /* Floating point value -0.610594 */ +#define CSEX_EQUALISER_11025_B2 -10196 /* Floating point value -0.311149 */ +#define CSEX_EQUALISER_11025_SCALE 15 + +/* Equaliser coefficients for 12000Hz sample rate, CS scaled with 1.032521 and CSEX scaled with 0.771017 */ +#define CS_EQUALISER_12000_A0 20917 /* Floating point value 1.276661 */ +#define CS_EQUALISER_12000_A1 -16671 /* Floating point value -1.017519 */ +#define CS_EQUALISER_12000_A2 -723 /* Floating point value -0.044128 */ +#define CS_EQUALISER_12000_B1 -11954 /* Floating point value -0.729616 */ +#define CS_EQUALISER_12000_B2 -3351 /* Floating point value -0.204532 */ +#define CS_EQUALISER_12000_SCALE 14 +#define CSEX_EQUALISER_12000_A0 16500 /* Floating point value 1.007095 */ +#define CSEX_EQUALISER_12000_A1 -14285 /* Floating point value -0.871912 */ +#define CSEX_EQUALISER_12000_A2 381 /* Floating point value 0.023232 */ +#define CSEX_EQUALISER_12000_B1 -12220 /* Floating point value -0.745857 */ +#define CSEX_EQUALISER_12000_B2 -3099 /* Floating point value -0.189171 */ +#define CSEX_EQUALISER_12000_SCALE 14 + +/* Equaliser coefficients for 16000Hz sample rate, CS scaled with 1.031378 and CSEX scaled with 0.770164 */ +#define CS_EQUALISER_16000_A0 20998 /* Floating point value 1.281629 */ +#define CS_EQUALISER_16000_A1 -17627 /* Floating point value -1.075872 */ +#define CS_EQUALISER_16000_A2 -678 /* Floating point value -0.041365 */ +#define CS_EQUALISER_16000_B1 -11882 /* Floating point value -0.725239 */ +#define CS_EQUALISER_16000_B2 -3676 /* Floating point value -0.224358 */ +#define CS_EQUALISER_16000_SCALE 14 +#define CSEX_EQUALISER_16000_A0 17713 /* Floating point value 1.081091 */ +#define CSEX_EQUALISER_16000_A1 -14208 /* Floating point value -0.867183 */ +#define CSEX_EQUALISER_16000_A2 -1151 /* Floating point value -0.070247 */ +#define CSEX_EQUALISER_16000_B1 -8440 /* Floating point value -0.515121 */ +#define CSEX_EQUALISER_16000_B2 -6978 /* Floating point value -0.425893 */ +#define CSEX_EQUALISER_16000_SCALE 14 + +/* Equaliser coefficients for 22050Hz sample rate, CS scaled with 1.041576 and CSEX scaled with 0.777779 */ +#define CS_EQUALISER_22050_A0 22751 /* Floating point value 1.388605 */ +#define CS_EQUALISER_22050_A1 -21394 /* Floating point value -1.305799 */ +#define CS_EQUALISER_22050_A2 654 /* Floating point value 0.039922 */ +#define CS_EQUALISER_22050_B1 -11788 /* Floating point value -0.719494 */ +#define CS_EQUALISER_22050_B2 -3985 /* Floating point value -0.243245 */ +#define CS_EQUALISER_22050_SCALE 14 +#define CSEX_EQUALISER_22050_A0 20855 /* Floating point value 1.272910 */ +#define CSEX_EQUALISER_22050_A1 -21971 /* Floating point value -1.341014 */ +#define CSEX_EQUALISER_22050_A2 2744 /* Floating point value 0.167462 */ +#define CSEX_EQUALISER_22050_B1 -10063 /* Floating point value -0.614219 */ +#define CSEX_EQUALISER_22050_B2 -5659 /* Floating point value -0.345384 */ +#define CSEX_EQUALISER_22050_SCALE 14 + +/* Equaliser coefficients for 24000Hz sample rate, CS scaled with 1.034495 and CSEX scaled with 0.772491 */ +#define CS_EQUALISER_24000_A0 23099 /* Floating point value 1.409832 */ +#define CS_EQUALISER_24000_A1 -23863 /* Floating point value -1.456506 */ +#define CS_EQUALISER_24000_A2 2481 /* Floating point value 0.151410 */ +#define CS_EQUALISER_24000_B1 -13176 /* Floating point value -0.804201 */ +#define CS_EQUALISER_24000_B2 -2683 /* Floating point value -0.163783 */ +#define CS_EQUALISER_24000_SCALE 14 +#define CSEX_EQUALISER_24000_A0 21286 /* Floating point value 1.299198 */ +#define CSEX_EQUALISER_24000_A1 -23797 /* Floating point value -1.452447 */ +#define CSEX_EQUALISER_24000_A2 3940 /* Floating point value 0.240489 */ +#define CSEX_EQUALISER_24000_B1 -10966 /* Floating point value -0.669303 */ +#define CSEX_EQUALISER_24000_B2 -4833 /* Floating point value -0.294984 */ +#define CSEX_EQUALISER_24000_SCALE 14 + +/* Equaliser coefficients for 32000Hz sample rate, CS scaled with 1.044559 and CSEX scaled with 0.780006 */ +#define CS_EQUALISER_32000_A0 25575 /* Floating point value 1.560988 */ +#define CS_EQUALISER_32000_A1 -30765 /* Floating point value -1.877724 */ +#define CS_EQUALISER_32000_A2 6386 /* Floating point value 0.389741 */ +#define CS_EQUALISER_32000_B1 -14867 /* Floating point value -0.907410 */ +#define CS_EQUALISER_32000_B2 -1155 /* Floating point value -0.070489 */ +#define CS_EQUALISER_32000_SCALE 14 +#define CSEX_EQUALISER_32000_A0 14623 /* Floating point value 1.785049 */ +#define CSEX_EQUALISER_32000_A1 -18297 /* Floating point value -2.233497 */ +#define CSEX_EQUALISER_32000_A2 4313 /* Floating point value 0.526431 */ +#define CSEX_EQUALISER_32000_B1 -3653 /* Floating point value -0.445939 */ +#define CSEX_EQUALISER_32000_B2 -4280 /* Floating point value -0.522446 */ +#define CSEX_EQUALISER_32000_SCALE 13 + +/* Equaliser coefficients for 44100Hz sample rate, CS scaled with 1.022170 and CSEX scaled with 0.763288 */ +#define CS_EQUALISER_44100_A0 13304 /* Floating point value 1.623993 */ +#define CS_EQUALISER_44100_A1 -18602 /* Floating point value -2.270743 */ +#define CS_EQUALISER_44100_A2 5643 /* Floating point value 0.688829 */ +#define CS_EQUALISER_44100_B1 -9152 /* Floating point value -1.117190 */ +#define CS_EQUALISER_44100_B2 1067 /* Floating point value 0.130208 */ +#define CS_EQUALISER_44100_SCALE 13 +#define CSEX_EQUALISER_44100_A0 16616 /* Floating point value 2.028315 */ +#define CSEX_EQUALISER_44100_A1 -23613 /* Floating point value -2.882459 */ +#define CSEX_EQUALISER_44100_A2 7410 /* Floating point value 0.904535 */ +#define CSEX_EQUALISER_44100_B1 -4860 /* Floating point value -0.593308 */ +#define CSEX_EQUALISER_44100_B2 -3161 /* Floating point value -0.385816 */ +#define CSEX_EQUALISER_44100_SCALE 13 + +/* Equaliser coefficients for 48000Hz sample rate, CS scaled with 1.018635 and CSEX scaled with 0.760648 */ +#define CS_EQUALISER_48000_A0 13445 /* Floating point value 1.641177 */ +#define CS_EQUALISER_48000_A1 -19372 /* Floating point value -2.364687 */ +#define CS_EQUALISER_48000_A2 6225 /* Floating point value 0.759910 */ +#define CS_EQUALISER_48000_B1 -9558 /* Floating point value -1.166774 */ +#define CS_EQUALISER_48000_B2 1459 /* Floating point value 0.178074 */ +#define CS_EQUALISER_48000_SCALE 13 +#define CSEX_EQUALISER_48000_A0 17200 /* Floating point value 2.099655 */ +#define CSEX_EQUALISER_48000_A1 -25110 /* Floating point value -3.065220 */ +#define CSEX_EQUALISER_48000_A2 8277 /* Floating point value 1.010417 */ +#define CSEX_EQUALISER_48000_B1 -5194 /* Floating point value -0.634021 */ +#define CSEX_EQUALISER_48000_B2 -2845 /* Floating point value -0.347332 */ +#define CSEX_EQUALISER_48000_SCALE 13 + + +/************************************************************************************/ +/* */ +/* The Output Gain Correction */ +/* */ +/************************************************************************************/ + +#define LVCS_HEADPHONE_SHIFT 2 /* Output Shift */ +#define LVCS_HEADPHONE_SHIFTLOSS 27779 /* Output Shift loss */ +#define LVCS_HEADPHONE_GAIN 6840 /* Unprocessed path gain */ +#define LVCS_EX_HEADPHONE_SHIFT 3 /* EX Output Shift */ +#define LVCS_EX_HEADPHONE_SHIFTLOSS 18600 /* EX Output Shift loss */ +#define LVCS_EX_HEADPHONE_GAIN 5108 /* EX Unprocessed path gain */ + +#endif diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Init.c b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Init.c new file mode 100755 index 0000000..4aa95d3 --- /dev/null +++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Init.c @@ -0,0 +1,233 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************************ + + $Author: beq07716 $ + $Revision: 1001 $ + $Date: 2010-06-28 13:23:02 +0200 (Mon, 28 Jun 2010) $ + +*************************************************************************************/ + +/************************************************************************************/ +/* */ +/* Includes */ +/* */ +/************************************************************************************/ + +#include "LVCS.h" +#include "LVCS_Private.h" +#include "LVCS_Tables.h" + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVCS_Memory */ +/* */ +/* DESCRIPTION: */ +/* This function is used for memory allocation and free. It can be called in */ +/* two ways: */ +/* */ +/* hInstance = NULL Returns the memory requirements */ +/* hInstance = Instance handle Returns the memory requirements and */ +/* allocated base addresses for the instance */ +/* */ +/* When this function is called for memory allocation (hInstance=NULL) it is */ +/* passed the default capabilities. */ +/* */ +/* When called for memory allocation the memory base address pointers are NULL on */ +/* return. */ +/* */ +/* When the function is called for free (hInstance = Instance Handle) the */ +/* capabilities are ignored and the memory table returns the allocated memory and */ +/* base addresses used during initialisation. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance Handle */ +/* pMemoryTable Pointer to an empty memory definition table */ +/* pCapabilities Pointer to the default capabilites */ +/* */ +/* RETURNS: */ +/* LVCS_Success Succeeded */ +/* */ +/* NOTES: */ +/* 1. This function may be interrupted by the LVCS_Process function */ +/* */ +/****************************************************************************************/ + +LVCS_ReturnStatus_en LVCS_Memory(LVCS_Handle_t hInstance, + LVCS_MemTab_t *pMemoryTable, + LVCS_Capabilities_t *pCapabilities) +{ + + LVM_UINT32 ScratchSize; + LVCS_Instance_t *pInstance = (LVCS_Instance_t *)hInstance; + + + /* + * Fill in the memory table + */ + if (hInstance == LVM_NULL) + { + /* + * Instance memory + */ + pMemoryTable->Region[LVCS_MEMREGION_PERSISTENT_SLOW_DATA].Size = (LVM_UINT32)sizeof(LVCS_Instance_t); + pMemoryTable->Region[LVCS_MEMREGION_PERSISTENT_SLOW_DATA].Type = LVCS_PERSISTENT; + pMemoryTable->Region[LVCS_MEMREGION_PERSISTENT_SLOW_DATA].pBaseAddress = LVM_NULL; + + /* + * Data memory + */ + pMemoryTable->Region[LVCS_MEMREGION_PERSISTENT_FAST_DATA].Size = (LVM_UINT32)sizeof(LVCS_Data_t); + pMemoryTable->Region[LVCS_MEMREGION_PERSISTENT_FAST_DATA].Type = LVCS_DATA; + pMemoryTable->Region[LVCS_MEMREGION_PERSISTENT_FAST_DATA].pBaseAddress = LVM_NULL; + + /* + * Coefficient memory + */ + pMemoryTable->Region[LVCS_MEMREGION_PERSISTENT_FAST_COEF].Size = (LVM_UINT32)sizeof(LVCS_Coefficient_t); + pMemoryTable->Region[LVCS_MEMREGION_PERSISTENT_FAST_COEF].Type = LVCS_COEFFICIENT; + pMemoryTable->Region[LVCS_MEMREGION_PERSISTENT_FAST_COEF].pBaseAddress = LVM_NULL; + + /* + * Scratch memory + */ + ScratchSize = (LVM_UINT32)(LVCS_SCRATCHBUFFERS*sizeof(LVM_INT16)*pCapabilities->MaxBlockSize); /* Inplace processing */ + pMemoryTable->Region[LVCS_MEMREGION_TEMPORARY_FAST].Size = ScratchSize; + pMemoryTable->Region[LVCS_MEMREGION_TEMPORARY_FAST].Type = LVCS_SCRATCH; + pMemoryTable->Region[LVCS_MEMREGION_TEMPORARY_FAST].pBaseAddress = LVM_NULL; + } + else + { + /* Read back memory allocation table */ + *pMemoryTable = pInstance->MemoryTable; + } + + return(LVCS_SUCCESS); +} + + +/************************************************************************************/ +/* */ +/* FUNCTION: LVCS_Init */ +/* */ +/* DESCRIPTION: */ +/* Create and initialisation function for the Concert Sound module */ +/* */ +/* This function can be used to create an algorithm instance by calling with */ +/* hInstance set to LVM_NULL. In this case the algorithm returns the new instance */ +/* handle. */ +/* */ +/* This function can be used to force a full re-initialisation of the algorithm */ +/* by calling with hInstance = Instance Handle. In this case the memory table */ +/* should be correct for the instance, this can be ensured by calling the function */ +/* LVCS_Memory before calling this function. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance handle */ +/* pMemoryTable Pointer to the memory definition table */ +/* pCapabilities Pointer to the capabilities structure */ +/* */ +/* RETURNS: */ +/* LVCS_Success Initialisation succeeded */ +/* */ +/* NOTES: */ +/* 1. The instance handle is the pointer to the base address of the first memory */ +/* region. */ +/* 2. This function must not be interrupted by the LVCS_Process function */ +/* 3. This function must be called with the same capabilities as used for the */ +/* call to the memory function */ +/* */ +/************************************************************************************/ + +LVCS_ReturnStatus_en LVCS_Init(LVCS_Handle_t *phInstance, + LVCS_MemTab_t *pMemoryTable, + LVCS_Capabilities_t *pCapabilities) +{ + + LVM_INT16 Offset; + LVCS_Instance_t *pInstance; + LVCS_VolCorrect_t *pLVCS_VolCorrectTable; + + + /* + * Set the instance handle if not already initialised + */ + if (*phInstance == LVM_NULL) + { + *phInstance = (LVCS_Handle_t)pMemoryTable->Region[LVCS_MEMREGION_PERSISTENT_SLOW_DATA].pBaseAddress; + } + pInstance =(LVCS_Instance_t *)*phInstance; + + + /* + * Save the capabilities in the instance structure + */ + pInstance->Capabilities = *pCapabilities; + + /* + * Save the memory table in the instance structure + */ + pInstance->MemoryTable = *pMemoryTable; + + + /* + * Set all initial parameters to invalid to force a full initialisation + */ + pInstance->Params.OperatingMode = LVCS_OFF; + pInstance->Params.SpeakerType = LVCS_SPEAKERTYPE_MAX; + pInstance->OutputDevice = LVCS_HEADPHONE; + pInstance->Params.SourceFormat = LVCS_SOURCEMAX; + pInstance->Params.CompressorMode = LVM_MODE_OFF; + pInstance->Params.SampleRate = LVM_FS_INVALID; + pInstance->Params.EffectLevel = 0; + pInstance->Params.ReverbLevel = (LVM_UINT16)0x8000; + pLVCS_VolCorrectTable = (LVCS_VolCorrect_t*)&LVCS_VolCorrectTable[0]; + Offset = (LVM_INT16)(pInstance->Params.SpeakerType + (pInstance->Params.SourceFormat*(1+LVCS_EX_HEADPHONES))); + pInstance->VolCorrect = pLVCS_VolCorrectTable[Offset]; + pInstance->TransitionGain = 0; + LVC_Mixer_Init(&pInstance->BypassMix.Mixer_Instance.MixerStream[0],0,0); + LVC_Mixer_Init(&pInstance->BypassMix.Mixer_Instance.MixerStream[1],0,0); + + /* + * Initialise the bypass variables + */ + pInstance->MSBypassMixer.MixerStream[0].CallbackParam = 0; + pInstance->MSBypassMixer.MixerStream[0].pCallbackHandle = LVM_NULL; + pInstance->MSBypassMixer.MixerStream[0].pCallBack = LVM_NULL; + pInstance->MSBypassMixer.MixerStream[0].CallbackSet = 0; + LVC_Mixer_Init(&pInstance->MSBypassMixer.MixerStream[0],0,0); + LVC_Mixer_SetTimeConstant(&pInstance->MSBypassMixer.MixerStream[0],0,LVM_FS_44100,2); + + + pInstance->MSBypassMixer.MixerStream[1].CallbackParam = 0; + pInstance->MSBypassMixer.MixerStream[1].pCallbackHandle = LVM_NULL; + pInstance->MSBypassMixer.MixerStream[1].pCallBack = LVM_NULL; + pInstance->MSBypassMixer.MixerStream[1].CallbackSet = 0; + LVC_Mixer_Init(&pInstance->MSBypassMixer.MixerStream[1],0,0); + LVC_Mixer_SetTimeConstant(&pInstance->MSBypassMixer.MixerStream[1],0,LVM_FS_44100,2); + + pInstance->bInOperatingModeTransition = LVM_FALSE; + pInstance->bTimerDone = LVM_FALSE; + pInstance->TimerParams.CallBackParam = 0; + pInstance->TimerParams.pCallBack = LVCS_TimerCallBack; + pInstance->TimerParams.pCallbackInstance = pInstance; + pInstance->TimerParams.pCallBackParams = LVM_NULL; + + return(LVCS_SUCCESS); +} + diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Private.h b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Private.h new file mode 100755 index 0000000..be30829 --- /dev/null +++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Private.h @@ -0,0 +1,171 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************************ + + $Author: beq07716 $ + $Revision: 1001 $ + $Date: 2010-06-28 13:23:02 +0200 (Mon, 28 Jun 2010) $ + +*************************************************************************************/ + +/************************************************************************************/ +/* */ +/* Header file for the private layer interface of concert sound. */ +/* */ +/* This files includes all definitions, types, structures and function */ +/* prototypes required by the execution layer. */ +/* */ +/************************************************************************************/ + +#ifndef __LVCS_PRIVATE_H__ +#define __LVCS_PRIVATE_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/************************************************************************************/ +/* */ +/* Includes */ +/* */ +/************************************************************************************/ + +#include "LVCS.h" /* Calling or Application layer definitions */ +#include "LVCS_StereoEnhancer.h" /* Stereo enhancer module definitions */ +#include "LVCS_ReverbGenerator.h" /* Reverberation module definitions */ +#include "LVCS_Equaliser.h" /* Equaliser module definitions */ +#include "LVCS_BypassMix.h" /* Bypass Mixer module definitions */ +#include "LVM_Timer.h" + + +/************************************************************************************/ +/* */ +/* Defines */ +/* */ +/************************************************************************************/ + +/* Configuration switch controls */ +#define LVCS_STEREOENHANCESWITCH 0x0001 /* Stereo enhancement enable control */ +#define LVCS_REVERBSWITCH 0x0002 /* Reverberation enable control */ +#define LVCS_EQUALISERSWITCH 0x0004 /* Equaliser enable control */ +#define LVCS_BYPASSMIXSWITCH 0x0008 /* Bypass mixer enable control */ + +/* Memory */ +#define LVCS_SCRATCHBUFFERS 6 /* Number of buffers required for inplace processing */ + +/* General */ +#define LVCS_INVALID 0xFFFF /* Invalid init parameter */ +#define LVCS_BYPASS_MIXER_TC 100 /* Bypass mixer time */ + +/* Access to external coefficients table */ +#define LVCS_NR_OF_FS 9 +#define LVCS_NR_OF_CHAN_CFG 2 + + +/************************************************************************************/ +/* */ +/* Types */ +/* */ +/************************************************************************************/ + +typedef LVM_UINT16 LVCS_Configuration_t; /* Internal algorithm configuration */ + +typedef enum +{ + LVCS_HEADPHONE = 0, + LVCS_DEVICE_MAX = LVM_MAXENUM +} LVCS_OutputDevice_en; + + +/************************************************************************************/ +/* */ +/* Structures */ +/* */ +/************************************************************************************/ + +/* Volume correction structure */ +typedef struct +{ + LVM_INT16 CompFull; /* Post CS compression 100% effect */ + LVM_INT16 CompMin; /* Post CS compression 0% effect */ + LVM_INT16 GainFull; /* CS gain correct 100% effect */ + LVM_INT16 GainMin; /* CS gain correct 0% effect */ +} LVCS_VolCorrect_t; + +/* Instance structure */ +typedef struct +{ + /* Public parameters */ + LVCS_MemTab_t MemoryTable; /* Instance memory allocation table */ + LVCS_Params_t Params; /* Instance parameters */ + LVCS_Capabilities_t Capabilities; /* Initialisation capabilities */ + + /* Private parameters */ + LVCS_OutputDevice_en OutputDevice; /* Selected output device type */ + LVCS_VolCorrect_t VolCorrect; /* Volume correction settings */ + LVM_INT16 TransitionGain; /* Transition gain */ + + /* Sub-block configurations */ + LVCS_StereoEnhancer_t StereoEnhancer; /* Stereo enhancer configuration */ + LVCS_ReverbGenerator_t Reverberation; /* Reverberation configuration */ + LVCS_Equaliser_t Equaliser; /* Equaliser configuration */ + LVCS_BypassMix_t BypassMix; /* Bypass mixer configuration */ + + /* Bypass variable */ + LVMixer3_2St_st MSBypassMixer; /* Bypass mixer used in transitions in MS mode */ + LVM_INT16 bInOperatingModeTransition; /* Operating mode transition flag */ + LVM_INT16 bTimerDone; /* Timer completion flag */ + LVM_Timer_Params_t TimerParams; /* Timer parameters */ + LVM_Timer_Instance_t TimerInstance; /* Timer instance */ + +} LVCS_Instance_t; + +/* Coefficient Structure */ +typedef struct +{ + Biquad_Instance_t EqualiserBiquadInstance; + Biquad_Instance_t ReverbBiquadInstance; + Biquad_Instance_t SEBiquadInstanceMid; + Biquad_Instance_t SEBiquadInstanceSide; + +} LVCS_Coefficient_t; + +/* Data Structure */ +typedef struct +{ + Biquad_2I_Order2_Taps_t EqualiserBiquadTaps; + Biquad_2I_Order2_Taps_t ReverbBiquadTaps; + Biquad_1I_Order1_Taps_t SEBiquadTapsMid; + Biquad_1I_Order2_Taps_t SEBiquadTapsSide; + +} LVCS_Data_t; + + +void LVCS_TimerCallBack ( void* hInstance, + void* pCallBackParams, + LVM_INT32 CallbackParam); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* PRIVATE_H */ + + diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Process.c b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Process.c new file mode 100755 index 0000000..999b8bb --- /dev/null +++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Process.c @@ -0,0 +1,271 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************************ + + $Author: beq07716 $ + $Revision: 1001 $ + $Date: 2010-06-28 13:23:02 +0200 (Mon, 28 Jun 2010) $ + +*************************************************************************************/ + + +/************************************************************************************/ +/* */ +/* Includes */ +/* */ +/************************************************************************************/ + +#include "LVCS.h" +#include "LVCS_Private.h" +#include "VectorArithmetic.h" +#include "CompLim.h" + +/************************************************************************************/ +/* */ +/* FUNCTION: LVCS_Process_CS */ +/* */ +/* DESCRIPTION: */ +/* Process function for the Concert Sound module based on the following block */ +/* diagram: */ +/* _________ ________ _____ _______ ___ ______ */ +/* | | | | | | | | | | | | */ +/* ----->| Stereo |->| Reverb |->| Equ |->| Alpha |-->| + |-| Gain |----> */ +/* | | Enhance | |________| |_____| |_______| |___| |______| */ +/* | |_________| | */ +/* | ___________ | */ +/* | | | | */ +/* |------------------------------->| 1 - Alpha |-----| */ +/* |___________| */ +/* */ +/* The Stereo Enhancer, Reverb and Equaliser blocks are each configured to have */ +/* their gain to give a near peak to peak output (-0.1dBFS) with a worst case */ +/* input signal. The gains of these blocks are re-combined in the Alpha mixer and */ +/* the gain block folloing the sum. */ +/* */ +/* The processing uses the output buffer for data storage after each processing */ +/* block. When processing is inplace a copy of the input signal is made in scratch */ +/* memory for the 1-Alpha path. */ +/* */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance handle */ +/* pInData Pointer to the input data */ +/* pOutData Pointer to the output data */ +/* NumSamples Number of samples in the input buffer */ +/* */ +/* RETURNS: */ +/* LVCS_Success Succeeded */ +/* */ +/* NOTES: */ +/* */ +/************************************************************************************/ + +LVCS_ReturnStatus_en LVCS_Process_CS(LVCS_Handle_t hInstance, + const LVM_INT16 *pInData, + LVM_INT16 *pOutData, + LVM_UINT16 NumSamples) +{ + const LVM_INT16 *pInput; + LVCS_Instance_t *pInstance = (LVCS_Instance_t *)hInstance; + LVM_INT16 *pScratch = (LVM_INT16 *)pInstance->MemoryTable.Region[LVCS_MEMREGION_TEMPORARY_FAST].pBaseAddress; + LVCS_ReturnStatus_en err; + + /* + * Check if the processing is inplace + */ + if (pInData == pOutData) + { + /* Processing inplace */ + pInput = pScratch + (2*NumSamples); + Copy_16((LVM_INT16 *)pInData, /* Source */ + (LVM_INT16 *)pInput, /* Destination */ + (LVM_INT16)(2*NumSamples)); /* Left and right */ + } + else + { + /* Processing outplace */ + pInput = pInData; + } + + /* + * Call the stereo enhancer + */ + err=LVCS_StereoEnhancer(hInstance, /* Instance handle */ + pInData, /* Pointer to the input data */ + pOutData, /* Pointer to the output data */ + NumSamples); /* Number of samples to process */ + + /* + * Call the reverb generator + */ + err=LVCS_ReverbGenerator(hInstance, /* Instance handle */ + pOutData, /* Pointer to the input data */ + pOutData, /* Pointer to the output data */ + NumSamples); /* Number of samples to process */ + + /* + * Call the equaliser + */ + err=LVCS_Equaliser(hInstance, /* Instance handle */ + pOutData, /* Pointer to the input data */ + NumSamples); /* Number of samples to process */ + + /* + * Call the bypass mixer + */ + err=LVCS_BypassMixer(hInstance, /* Instance handle */ + pOutData, /* Pointer to the processed data */ + pInput, /* Pointer to the input (unprocessed) data */ + pOutData, /* Pointer to the output data */ + NumSamples); /* Number of samples to process */ + + if(err !=LVCS_SUCCESS) + { + return err; + } + + return(LVCS_SUCCESS); +} + +/************************************************************************************/ +/* */ +/* FUNCTION: LVCS_Process */ +/* */ +/* DESCRIPTION: */ +/* Process function for the Concert Sound module. The implementation supports two */ +/* variants of the algorithm, one for headphones and one for mobile speakers. */ +/* */ +/* Data can be processed in two formats, stereo or mono-in-stereo. Data in mono */ +/* format is not supported, the calling routine must convert the mono stream to */ +/* mono-in-stereo. */ +/* */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance handle */ +/* pInData Pointer to the input data */ +/* pOutData Pointer to the output data */ +/* NumSamples Number of samples in the input buffer */ +/* */ +/* RETURNS: */ +/* LVCS_Success Succeeded */ +/* LVCS_TooManySamples NumSamples was larger than the maximum block size */ +/* */ +/* NOTES: */ +/* */ +/************************************************************************************/ + +LVCS_ReturnStatus_en LVCS_Process(LVCS_Handle_t hInstance, + const LVM_INT16 *pInData, + LVM_INT16 *pOutData, + LVM_UINT16 NumSamples) +{ + + LVCS_Instance_t *pInstance =(LVCS_Instance_t *)hInstance; + LVCS_ReturnStatus_en err; + + /* + * Check the number of samples is not too large + */ + if (NumSamples > pInstance->Capabilities.MaxBlockSize) + { + return(LVCS_TOOMANYSAMPLES); + } + + /* + * Check if the algorithm is enabled + */ + if (pInstance->Params.OperatingMode != LVCS_OFF) + { + /* + * Call CS process function + */ + err=LVCS_Process_CS(hInstance, + pInData, + pOutData, + NumSamples); + + /* + * Compress to reduce expansion effect of Concert Sound and correct volume + * differences for difference settings. Not applied in test modes + */ + if ((pInstance->Params.OperatingMode == LVCS_ON)&&(pInstance->Params.CompressorMode == LVM_MODE_ON)) + { + LVM_INT16 Gain = pInstance->VolCorrect.CompMin; + LVM_INT32 Current1; + + Current1 = LVC_Mixer_GetCurrent(&pInstance->BypassMix.Mixer_Instance.MixerStream[0]); + Gain = (LVM_INT16)( pInstance->VolCorrect.CompMin + - (((LVM_INT32)pInstance->VolCorrect.CompMin * (Current1)) >> 15) + + (((LVM_INT32)pInstance->VolCorrect.CompFull * (Current1)) >> 15) ); + + NonLinComp_D16(Gain, /* Compressor gain setting */ + pOutData, + pOutData, + (LVM_INT32)(2*NumSamples)); + } + + + if(pInstance->bInOperatingModeTransition == LVM_TRUE){ + + /* + * Re-init bypass mix when timer has completed + */ + if ((pInstance->bTimerDone == LVM_TRUE) && + (pInstance->BypassMix.Mixer_Instance.MixerStream[1].CallbackSet == 0)) + { + err=LVCS_BypassMixInit(hInstance, + &pInstance->Params); + + if(err != LVCS_SUCCESS) + { + return err; + } + + } + else{ + LVM_Timer ( &pInstance->TimerInstance, + (LVM_INT16)NumSamples); + } + } + } + else + { + if (pInData != pOutData) + { + /* + * The algorithm is disabled so just copy the data + */ + Copy_16((LVM_INT16 *)pInData, /* Source */ + (LVM_INT16 *)pOutData, /* Destination */ + (LVM_INT16)(2*NumSamples)); /* Left and right */ + } + } + + + return(LVCS_SUCCESS); +} + + + + + + + + + + diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_ReverbGenerator.c b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_ReverbGenerator.c new file mode 100755 index 0000000..2efef84 --- /dev/null +++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_ReverbGenerator.c @@ -0,0 +1,272 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************************ + + $Author: beq07716 $ + $Revision: 1001 $ + $Date: 2010-06-28 13:23:02 +0200 (Mon, 28 Jun 2010) $ + +*************************************************************************************/ + +/************************************************************************************/ +/* */ +/* Includes */ +/* */ +/************************************************************************************/ + +#include "LVCS.h" +#include "LVCS_Private.h" +#include "LVCS_ReverbGenerator.h" +#include "LVC_Mixer.h" +#include "VectorArithmetic.h" +#include "BIQUAD.h" +#include "LVCS_Tables.h" + +/************************************************************************************/ +/* */ +/* FUNCTION: LVCS_ReverbGeneratorInit */ +/* */ +/* DESCRIPTION: */ +/* Initialises the reverb module. The delay buffer size is configured for the */ +/* sample rate and the speaker type. */ +/* */ +/* The routine may also be called for re-initialisation, i.e. when one of the */ +/* control parameters has changed. In this case the delay and filters are only */ +/* re-initialised if one of the following two conditions is met: */ +/* - the sample rate has changed */ +/* - the speaker type changes to/from the mobile speaker */ +/* */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance Handle */ +/* pParams Pointer to the inialisation parameters */ +/* */ +/* RETURNS: */ +/* LVCS_Success Always succeeds */ +/* */ +/* NOTES: */ +/* 1. In the delay settings 'Samples' is the number of samples to the end of the */ +/* buffer. */ +/* 2. The numerator coefficients of the filter are negated to cause an inversion. */ +/* */ +/************************************************************************************/ + +LVCS_ReturnStatus_en LVCS_ReverbGeneratorInit(LVCS_Handle_t hInstance, + LVCS_Params_t *pParams) +{ + + LVM_UINT16 Delay; + LVM_UINT16 Offset; + LVCS_Instance_t *pInstance = (LVCS_Instance_t *)hInstance; + LVCS_ReverbGenerator_t *pConfig = (LVCS_ReverbGenerator_t *)&pInstance->Reverberation; + LVCS_Data_t *pData = (LVCS_Data_t *)pInstance->MemoryTable.Region[LVCS_MEMREGION_PERSISTENT_FAST_DATA].pBaseAddress; + LVCS_Coefficient_t *pCoefficients = (LVCS_Coefficient_t *)pInstance->MemoryTable.Region[LVCS_MEMREGION_PERSISTENT_FAST_COEF].pBaseAddress; + BQ_C16_Coefs_t Coeffs; + const BiquadA012B12CoefsSP_t *pReverbCoefTable; + + /* + * Initialise the delay and filters if: + * - the sample rate has changed + * - the speaker type has changed to or from the mobile speaker + */ + if(pInstance->Params.SampleRate != pParams->SampleRate ) /* Sample rate change test */ + + { + /* + * Setup the delay + */ + Delay = (LVM_UINT16)LVCS_StereoDelayCS[(LVM_UINT16)pParams->SampleRate]; + + + pConfig->DelaySize = (LVM_INT16)(2 * Delay); + pConfig->DelayOffset = 0; + LoadConst_16(0, /* Value */ + (LVM_INT16 *)&pConfig->StereoSamples[0], /* Destination */ + (LVM_UINT16)(sizeof(pConfig->StereoSamples)/sizeof(LVM_INT16))); /* Number of words */ + + /* + * Setup the filters + */ + Offset = (LVM_UINT16)pParams->SampleRate; + pReverbCoefTable = (BiquadA012B12CoefsSP_t*)&LVCS_ReverbCoefTable[0]; + + /* Convert incoming coefficients to the required format/ordering */ + Coeffs.A0 = (LVM_INT16)pReverbCoefTable[Offset].A0; + Coeffs.A1 = (LVM_INT16)pReverbCoefTable[Offset].A1; + Coeffs.A2 = (LVM_INT16)pReverbCoefTable[Offset].A2; + Coeffs.B1 = (LVM_INT16)-pReverbCoefTable[Offset].B1; + Coeffs.B2 = (LVM_INT16)-pReverbCoefTable[Offset].B2; + + LoadConst_16(0, /* Value */ + (LVM_INT16 *)&pData->ReverbBiquadTaps, /* Destination */ + (LVM_UINT16)(sizeof(pData->ReverbBiquadTaps)/sizeof(LVM_INT16))); /* Number of words */ + + BQ_2I_D16F16Css_TRC_WRA_01_Init(&pCoefficients->ReverbBiquadInstance, + &pData->ReverbBiquadTaps, + &Coeffs); + + /* Callbacks */ + switch(pReverbCoefTable[Offset].Scale) + { + case 14: + pConfig->pBiquadCallBack = BQ_2I_D16F16C14_TRC_WRA_01; + break; + case 15: + pConfig->pBiquadCallBack = BQ_2I_D16F16C15_TRC_WRA_01; + break; + } + + + /* + * Setup the mixer + */ + pConfig->ProcGain = (LVM_UINT16)(HEADPHONEGAINPROC); + pConfig->UnprocGain = (LVM_UINT16)(HEADPHONEGAINUNPROC); + } + + if(pInstance->Params.ReverbLevel != pParams->ReverbLevel) + { + LVM_INT32 ReverbPercentage=83886; // 1 Percent Reverb i.e 1/100 in Q 23 format + ReverbPercentage*=pParams->ReverbLevel; // Actual Reverb Level in Q 23 format + pConfig->ReverbLevel=(LVM_INT16)(ReverbPercentage>>8); // Reverb Level in Q 15 format + } + + return(LVCS_SUCCESS); +} + +/************************************************************************************/ +/* */ +/* FUNCTION: LVCS_Reverb */ +/* */ +/* DESCRIPTION: */ +/* Create reverb using the block of input samples based on the following block */ +/* diagram: */ +/* ________ ________ */ +/* | | | | */ +/* _____ _______ | |----------->| | ______ ___ */ +/* | | | | | Stereo | | L & R | | | | | */ +/* -->| LPF |-->| Delay |-->| to | ____ | to |-->| Gain |-->| + |--> */ +/* | |_____| |_______| | L & R | | | | Stereo | |______| |___| */ +/* | | |-->| -1 |-->| | | */ +/* | |________| |____| |________| | */ +/* | | */ +/* |-----------------------------------------------------------------------| */ +/* */ +/* The input buffer is broken in to sub-blocks of the size of the delay or less. */ +/* This allows the delay buffer to be treated as a circular buffer but processed */ +/* as a linear buffer. */ +/* */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance Handle */ +/* pInData Pointer to the input buffer */ +/* pOutData Pointer to the output buffer */ +/* NumSamples Number of samples to process */ +/* */ +/* RETURNS: */ +/* LVCS_Success Always succeeds */ +/* */ +/* NOTES: */ +/* 1. Process in blocks of samples the size of the delay where possible, if not */ +/* the number of samples left over */ +/* 2. The Gain is combined with the LPF and incorporated in to the coefficients */ +/* */ +/************************************************************************************/ + +LVCS_ReturnStatus_en LVCS_ReverbGenerator(LVCS_Handle_t hInstance, + const LVM_INT16 *pInData, + LVM_INT16 *pOutData, + LVM_UINT16 NumSamples) +{ + + LVCS_Instance_t *pInstance = (LVCS_Instance_t *)hInstance; + LVCS_ReverbGenerator_t *pConfig = (LVCS_ReverbGenerator_t *)&pInstance->Reverberation; + LVCS_Coefficient_t *pCoefficients = (LVCS_Coefficient_t *)pInstance->MemoryTable.Region[LVCS_MEMREGION_PERSISTENT_FAST_COEF].pBaseAddress; + LVM_INT16 *pScratch = (LVM_INT16 *)pInstance->MemoryTable.Region[LVCS_MEMREGION_TEMPORARY_FAST].pBaseAddress; + + + /* + * Copy the data to the output in outplace processing + */ + if (pInData != pOutData) + { + /* + * Reverb not required so just copy the data + */ + Copy_16((LVM_INT16 *)pInData, /* Source */ + (LVM_INT16 *)pOutData, /* Destination */ + (LVM_INT16)(2*NumSamples)); /* Left and right */ + } + + + /* + * Check if the reverb is required + */ + if (((pInstance->Params.SpeakerType == LVCS_HEADPHONE) || /* Disable when CS4MS in stereo mode */ + (pInstance->Params.SpeakerType == LVCS_EX_HEADPHONES) || + (pInstance->Params.SourceFormat != LVCS_STEREO)) && + ((pInstance->Params.OperatingMode & LVCS_REVERBSWITCH) !=0)) /* For validation testing */ + { + /********************************************************************************/ + /* */ + /* Copy the input data to scratch memory and filter it */ + /* */ + /********************************************************************************/ + + /* + * Copy the input data to the scratch memory + */ + Copy_16((LVM_INT16 *)pInData, /* Source */ + (LVM_INT16 *)pScratch, /* Destination */ + (LVM_INT16)(2*NumSamples)); /* Left and right */ + + + /* + * Filter the data + */ + (pConfig->pBiquadCallBack)((Biquad_Instance_t*)&pCoefficients->ReverbBiquadInstance, + (LVM_INT16 *)pScratch, + (LVM_INT16 *)pScratch, + (LVM_INT16)NumSamples); + + Mult3s_16x16( (LVM_INT16 *)pScratch, + pConfig->ReverbLevel, + (LVM_INT16 *)pScratch, + (LVM_INT16)(2*NumSamples)); + + + /* + * Apply the delay mix + */ + DelayMix_16x16((LVM_INT16 *)pScratch, + &pConfig->StereoSamples[0], + pConfig->DelaySize, + pOutData, + &pConfig->DelayOffset, + (LVM_INT16)NumSamples); + + + } + + return(LVCS_SUCCESS); +} + + + + + diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_ReverbGenerator.h b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_ReverbGenerator.h new file mode 100755 index 0000000..1164bce --- /dev/null +++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_ReverbGenerator.h @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************************ + + $Author: beq07716 $ + $Revision: 1001 $ + $Date: 2010-06-28 13:23:02 +0200 (Mon, 28 Jun 2010) $ + +*************************************************************************************/ + +#ifndef __LVCS_REVERBGENERATOR_H__ +#define __LVCS_REVERBGENERATOR_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/************************************************************************************/ +/* */ +/* Includes */ +/* */ +/************************************************************************************/ + +#include "LVC_Mixer.h" + + +/************************************************************************************/ +/* */ +/* Defines */ +/* */ +/************************************************************************************/ + +#define HEADPHONEGAINPROC LVCS_HEADPHONE_PROCGAIN +#define HEADPHONEGAINUNPROC LVCS_HEADPHONE_UNPROCGAIN + + +/************************************************************************************/ +/* */ +/* Structures */ +/* */ +/************************************************************************************/ + + +/* Reverberation module structure */ +typedef struct +{ + + /* Stereo delay */ + LVM_INT16 DelaySize; + LVM_INT16 DelayOffset; + LVM_INT16 ProcGain; + LVM_INT16 UnprocGain; + LVM_INT16 StereoSamples[2*LVCS_STEREODELAY_CS_48KHZ]; + + /* Reverb Level */ + LVM_INT16 ReverbLevel; + + /* Filter */ + void (*pBiquadCallBack) (Biquad_Instance_t*, LVM_INT16*, LVM_INT16*, LVM_INT16); + +} LVCS_ReverbGenerator_t; + + +/************************************************************************************/ +/* */ +/* Function prototypes */ +/* */ +/************************************************************************************/ + +LVCS_ReturnStatus_en LVCS_ReverbGeneratorInit(LVCS_Handle_t hInstance, + LVCS_Params_t *pParams); + +LVCS_ReturnStatus_en LVCS_ReverbGenerator(LVCS_Handle_t hInstance, + const LVM_INT16 *pInput, + LVM_INT16 *pOutput, + LVM_UINT16 NumSamples); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* REVERB_H */ diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_StereoEnhancer.c b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_StereoEnhancer.c new file mode 100755 index 0000000..4ff4716 --- /dev/null +++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_StereoEnhancer.c @@ -0,0 +1,266 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************************ + + $Author: beq07716 $ + $Revision: 1001 $ + $Date: 2010-06-28 13:23:02 +0200 (Mon, 28 Jun 2010) $ + +*************************************************************************************/ + +/************************************************************************************/ +/* */ +/* Includes */ +/* */ +/************************************************************************************/ + +#include "LVCS.h" +#include "LVCS_Private.h" +#include "LVCS_StereoEnhancer.h" +#include "VectorArithmetic.h" +#include "LVCS_Tables.h" + +/************************************************************************************/ +/* */ +/* FUNCTION: LVCS_StereoEnhanceInit */ +/* */ +/* DESCRIPTION: */ +/* Initialises the stereo enhancement module based on the sample rate. */ +/* */ +/* The function selects the coefficients for the filters and clears the data */ +/* history. It is also used for re-initialisation when one of the system control */ +/* parameters changes but will only change the coefficients and clear the history */ +/* if the sample rate or speaker type has changed. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance Handle */ +/* pParams Initialisation parameters */ +/* */ +/* RETURNS: */ +/* LVCS_Success Always succeeds */ +/* */ +/* NOTES: */ +/* */ +/************************************************************************************/ + +LVCS_ReturnStatus_en LVCS_SEnhancerInit(LVCS_Handle_t hInstance, + LVCS_Params_t *pParams) +{ + + LVM_UINT16 Offset; + LVCS_Instance_t *pInstance = (LVCS_Instance_t *)hInstance; + LVCS_StereoEnhancer_t *pConfig = (LVCS_StereoEnhancer_t *)&pInstance->StereoEnhancer; + LVCS_Data_t *pData = (LVCS_Data_t *)pInstance->MemoryTable.Region[LVCS_MEMREGION_PERSISTENT_FAST_DATA].pBaseAddress; + LVCS_Coefficient_t *pCoefficient = (LVCS_Coefficient_t *)pInstance->MemoryTable.Region[LVCS_MEMREGION_PERSISTENT_FAST_COEF].pBaseAddress; + FO_C16_Coefs_t CoeffsMid; + BQ_C16_Coefs_t CoeffsSide; + const BiquadA012B12CoefsSP_t *pSESideCoefs; + + /* + * If the sample rate or speaker type has changed update the filters + */ + if ((pInstance->Params.SampleRate != pParams->SampleRate) || + (pInstance->Params.SpeakerType != pParams->SpeakerType)) + { + /* + * Set the filter coefficients based on the sample rate + */ + /* Mid filter */ + Offset = (LVM_UINT16)pParams->SampleRate; + + /* Convert incoming coefficients to the required format/ordering */ + CoeffsMid.A0 = (LVM_INT16) LVCS_SEMidCoefTable[Offset].A0; + CoeffsMid.A1 = (LVM_INT16) LVCS_SEMidCoefTable[Offset].A1; + CoeffsMid.B1 = (LVM_INT16)-LVCS_SEMidCoefTable[Offset].B1; + + /* Clear the taps */ + LoadConst_16(0, /* Value */ + (LVM_INT16 *)&pData->SEBiquadTapsMid, /* Destination */ + (LVM_UINT16)(sizeof(pData->SEBiquadTapsMid)/sizeof(LVM_UINT16))); /* Number of words */ + + FO_1I_D16F16Css_TRC_WRA_01_Init(&pCoefficient->SEBiquadInstanceMid, + &pData->SEBiquadTapsMid, + &CoeffsMid); + + /* Callbacks */ + if(LVCS_SEMidCoefTable[Offset].Scale==15) + { + pConfig->pBiquadCallBack_Mid = FO_1I_D16F16C15_TRC_WRA_01; + } + + Offset = (LVM_UINT16)(pParams->SampleRate); + pSESideCoefs = (BiquadA012B12CoefsSP_t*)&LVCS_SESideCoefTable[0]; + + /* Side filter */ + /* Convert incoming coefficients to the required format/ordering */ + CoeffsSide.A0 = (LVM_INT16) pSESideCoefs[Offset].A0; + CoeffsSide.A1 = (LVM_INT16) pSESideCoefs[Offset].A1; + CoeffsSide.A2 = (LVM_INT16) pSESideCoefs[Offset].A2; + CoeffsSide.B1 = (LVM_INT16)-pSESideCoefs[Offset].B1; + CoeffsSide.B2 = (LVM_INT16)-pSESideCoefs[Offset].B2; + + /* Clear the taps */ + LoadConst_16(0, /* Value */ + (LVM_INT16 *)&pData->SEBiquadTapsSide, /* Destination */ + (LVM_UINT16)(sizeof(pData->SEBiquadTapsSide)/sizeof(LVM_UINT16))); /* Number of words */ + + + /* Callbacks */ + switch(pSESideCoefs[Offset].Scale) + { + case 14: + BQ_1I_D16F32Css_TRC_WRA_01_Init(&pCoefficient->SEBiquadInstanceSide, + &pData->SEBiquadTapsSide, + &CoeffsSide); + + pConfig->pBiquadCallBack_Side = BQ_1I_D16F32C14_TRC_WRA_01; + break; + case 15: + BQ_1I_D16F16Css_TRC_WRA_01_Init(&pCoefficient->SEBiquadInstanceSide, + &pData->SEBiquadTapsSide, + &CoeffsSide); + + pConfig->pBiquadCallBack_Side = BQ_1I_D16F16C15_TRC_WRA_01; + break; + } + + } + + + return(LVCS_SUCCESS); +} + +/************************************************************************************/ +/* */ +/* FUNCTION: LVCS_StereoEnhance */ +/* */ +/* DESCRIPTION: */ +/* Enhance the stereo image in the input samples based on the following block */ +/* diagram: */ +/* */ +/* ________ */ +/* ________ | | ________ */ +/* | | Middle | Treble | | | */ +/* | |---------->| Boost |-------->| | */ +/* | Stereo | |________| | M & S | */ +/* -->| to | ________ | to |--> */ +/* | M & S | Side | | | Stereo | */ +/* | |---------->| Side |-------->| | */ +/* |________| | Boost | |________| */ +/* |________| */ +/* */ +/* */ +/* If the input signal is a mono signal there will be no side signal and hence */ +/* the side filter will not be run. In mobile speaker mode the middle filter is */ +/* not required and the Trebble boost filter is replaced by a simple gain block. */ +/* */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance Handle */ +/* pInData Pointer to the input data */ +/* pOutData Pointer to the output data */ +/* NumSamples Number of samples to process */ +/* */ +/* RETURNS: */ +/* LVCS_Success Always succeeds */ +/* */ +/* NOTES: */ +/* 1. The side filter is not used in Mobile Speaker mode */ +/* */ +/************************************************************************************/ + +LVCS_ReturnStatus_en LVCS_StereoEnhancer(LVCS_Handle_t hInstance, + const LVM_INT16 *pInData, + LVM_INT16 *pOutData, + LVM_UINT16 NumSamples) +{ + + LVCS_Instance_t *pInstance = (LVCS_Instance_t *)hInstance; + LVCS_StereoEnhancer_t *pConfig = (LVCS_StereoEnhancer_t *)&pInstance->StereoEnhancer; + LVCS_Coefficient_t *pCoefficient = (LVCS_Coefficient_t *)pInstance->MemoryTable.Region[LVCS_MEMREGION_PERSISTENT_FAST_COEF].pBaseAddress; + LVM_INT16 *pScratch = (LVM_INT16 *)pInstance->MemoryTable.Region[LVCS_MEMREGION_TEMPORARY_FAST].pBaseAddress; + + /* + * Check if the Stereo Enhancer is enabled + */ + if ((pInstance->Params.OperatingMode & LVCS_STEREOENHANCESWITCH) != 0) + { + /* + * Convert from stereo to middle and side + */ + From2iToMS_16x16(pInData, + pScratch, + pScratch+NumSamples, + (LVM_INT16)NumSamples); + + /* + * Apply filter to the middle signal + */ + if (pInstance->OutputDevice == LVCS_HEADPHONE) + { + (pConfig->pBiquadCallBack_Mid)((Biquad_Instance_t*)&pCoefficient->SEBiquadInstanceMid, + (LVM_INT16 *)pScratch, + (LVM_INT16 *)pScratch, + (LVM_INT16)NumSamples); + } + else + { + Mult3s_16x16(pScratch, /* Source */ + (LVM_INT16)pConfig->MidGain, /* Gain */ + pScratch, /* Destination */ + (LVM_INT16)NumSamples); /* Number of samples */ + } + + /* + * Apply the filter the side signal only in stereo mode for headphones + * and in all modes for mobile speakers + */ + if (pInstance->Params.SourceFormat == LVCS_STEREO) + { + (pConfig->pBiquadCallBack_Side)((Biquad_Instance_t*)&pCoefficient->SEBiquadInstanceSide, + (LVM_INT16 *)(pScratch + NumSamples), + (LVM_INT16 *)(pScratch + NumSamples), + (LVM_INT16)NumSamples); + } + + /* + * Convert from middle and side to stereo + */ + MSTo2i_Sat_16x16(pScratch, + pScratch+NumSamples, + pOutData, + (LVM_INT16)NumSamples); + + } + else + { + /* + * The stereo enhancer is disabled so just copy the data + */ + Copy_16((LVM_INT16 *)pInData, /* Source */ + (LVM_INT16 *)pOutData, /* Destination */ + (LVM_INT16)(2*NumSamples)); /* Left and right */ + + } + + return(LVCS_SUCCESS); +} + + + + diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_StereoEnhancer.h b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_StereoEnhancer.h new file mode 100755 index 0000000..c3f6296 --- /dev/null +++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_StereoEnhancer.h @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************************ + + $Author: beq07716 $ + $Revision: 1001 $ + $Date: 2010-06-28 13:23:02 +0200 (Mon, 28 Jun 2010) $ + +*************************************************************************************/ + +#ifndef __LVCS_STEREOENHANCER_H__ +#define __LVCS_STEREOENHANCER_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/************************************************************************************/ +/* */ +/* Includes */ +/* */ +/************************************************************************************/ + +#include "Filters.h" /* Filter definitions */ +#include "LVCS_Headphone_Coeffs.h" /* Headphone coefficients */ +#include "BIQUAD.h" + + +/************************************************************************************/ +/* */ +/* Structures */ +/* */ +/************************************************************************************/ + +/* Stereo enhancer structure */ +typedef struct +{ + /* + * Middle filter + */ + void (*pBiquadCallBack_Mid)(Biquad_Instance_t*, LVM_INT16*, LVM_INT16*, LVM_INT16); + + /* + * Side filter + */ + void (*pBiquadCallBack_Side)(Biquad_Instance_t*, LVM_INT16*, LVM_INT16*, LVM_INT16); + + LVM_UINT16 MidGain; /* Middle gain in mobile speaker mode */ + +} LVCS_StereoEnhancer_t; + + +/************************************************************************************/ +/* */ +/* Function prototypes */ +/* */ +/************************************************************************************/ + +LVCS_ReturnStatus_en LVCS_SEnhancerInit(LVCS_Handle_t hInstance, + LVCS_Params_t *pParams); + +LVCS_ReturnStatus_en LVCS_StereoEnhancer(LVCS_Handle_t hInstance, + const LVM_INT16 *pInData, + LVM_INT16 *pOutData, + LVM_UINT16 NumSamples); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* STEREOENHANCE_H */ diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Tables.c b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Tables.c new file mode 100755 index 0000000..ad4eb1e --- /dev/null +++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Tables.c @@ -0,0 +1,456 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************************ + + $Author: beq07716 $ + $Revision: 1001 $ + $Date: 2010-06-28 13:23:02 +0200 (Mon, 28 Jun 2010) $ + +*************************************************************************************/ + + +/************************************************************************************/ +/* */ +/* Includes */ +/* */ +/************************************************************************************/ + +#include "LVCS_Private.h" +#include "Filters.h" /* Filter definitions */ +#include "BIQUAD.h" /* Biquad definitions */ +#include "LVCS_Headphone_Coeffs.h" /* Headphone coefficients */ + + +/************************************************************************************/ +/* */ +/* Stereo Enhancer coefficient constant tables */ +/* */ +/************************************************************************************/ + +/* Coefficient table for the middle filter */ +const BiquadA01B1CoefsSP_t LVCS_SEMidCoefTable[] = { + {CS_MIDDLE_8000_A0, /* 8kS/s coefficients */ + CS_MIDDLE_8000_A1, + CS_MIDDLE_8000_B1, + (LVM_UINT16 )CS_MIDDLE_8000_SCALE}, + {CS_MIDDLE_11025_A0, /* 11kS/s coefficients */ + CS_MIDDLE_11025_A1, + CS_MIDDLE_11025_B1, + (LVM_UINT16 )CS_MIDDLE_11025_SCALE}, + {CS_MIDDLE_12000_A0, /* 12kS/s coefficients */ + CS_MIDDLE_12000_A1, + CS_MIDDLE_12000_B1, + (LVM_UINT16 )CS_MIDDLE_12000_SCALE}, + {CS_MIDDLE_16000_A0, /* 16kS/s coefficients */ + CS_MIDDLE_16000_A1, + CS_MIDDLE_16000_B1, + (LVM_UINT16 )CS_MIDDLE_16000_SCALE}, + {CS_MIDDLE_22050_A0, /* 22kS/s coefficients */ + CS_MIDDLE_22050_A1, + CS_MIDDLE_22050_B1, + (LVM_UINT16 )CS_MIDDLE_22050_SCALE}, + {CS_MIDDLE_24000_A0, /* 24kS/s coefficients */ + CS_MIDDLE_24000_A1, + CS_MIDDLE_24000_B1, + (LVM_UINT16 )CS_MIDDLE_24000_SCALE}, + {CS_MIDDLE_32000_A0, /* 32kS/s coefficients */ + CS_MIDDLE_32000_A1, + CS_MIDDLE_32000_B1, + (LVM_UINT16 )CS_MIDDLE_32000_SCALE}, + {CS_MIDDLE_44100_A0, /* 44kS/s coefficients */ + CS_MIDDLE_44100_A1, + CS_MIDDLE_44100_B1, + (LVM_UINT16 )CS_MIDDLE_44100_SCALE}, + {CS_MIDDLE_48000_A0, /* 48kS/s coefficients */ + CS_MIDDLE_48000_A1, + CS_MIDDLE_48000_B1, + (LVM_UINT16 )CS_MIDDLE_48000_SCALE}}; + +/* Coefficient table for the side filter */ +const BiquadA012B12CoefsSP_t LVCS_SESideCoefTable[] = { + /* Headphone Side coefficients */ + {CS_SIDE_8000_A0, /* 8kS/s coefficients */ + CS_SIDE_8000_A1, + CS_SIDE_8000_A2, + CS_SIDE_8000_B1, + CS_SIDE_8000_B2, + (LVM_UINT16 )CS_SIDE_8000_SCALE}, + {CS_SIDE_11025_A0, /* 11kS/s coefficients */ + CS_SIDE_11025_A1, + CS_SIDE_11025_A2, + CS_SIDE_11025_B1, + CS_SIDE_11025_B2, + (LVM_UINT16 )CS_SIDE_11025_SCALE}, + {CS_SIDE_12000_A0, /* 12kS/s coefficients */ + CS_SIDE_12000_A1, + CS_SIDE_12000_A2, + CS_SIDE_12000_B1, + CS_SIDE_12000_B2, + (LVM_UINT16 )CS_SIDE_12000_SCALE}, + {CS_SIDE_16000_A0, /* 16kS/s coefficients */ + CS_SIDE_16000_A1, + CS_SIDE_16000_A2, + CS_SIDE_16000_B1, + CS_SIDE_16000_B2, + (LVM_UINT16 )CS_SIDE_16000_SCALE}, + {CS_SIDE_22050_A0, /* 22kS/s coefficients */ + CS_SIDE_22050_A1, + CS_SIDE_22050_A2, + CS_SIDE_22050_B1, + CS_SIDE_22050_B2, + (LVM_UINT16 )CS_SIDE_22050_SCALE}, + {CS_SIDE_24000_A0, /* 24kS/s coefficients */ + CS_SIDE_24000_A1, + CS_SIDE_24000_A2, + CS_SIDE_24000_B1, + CS_SIDE_24000_B2, + (LVM_UINT16 )CS_SIDE_24000_SCALE}, + {CS_SIDE_32000_A0, /* 32kS/s coefficients */ + CS_SIDE_32000_A1, + CS_SIDE_32000_A2, + CS_SIDE_32000_B1, + CS_SIDE_32000_B2, + (LVM_UINT16 )CS_SIDE_32000_SCALE}, + {CS_SIDE_44100_A0, /* 44kS/s coefficients */ + CS_SIDE_44100_A1, + CS_SIDE_44100_A2, + CS_SIDE_44100_B1, + CS_SIDE_44100_B2, + (LVM_UINT16 )CS_SIDE_44100_SCALE}, + {CS_SIDE_48000_A0, /* 48kS/s coefficients */ + CS_SIDE_48000_A1, + CS_SIDE_48000_A2, + CS_SIDE_48000_B1, + CS_SIDE_48000_B2, + (LVM_UINT16 )CS_SIDE_48000_SCALE} +}; + + +/************************************************************************************/ +/* */ +/* Equaliser coefficient constant tables */ +/* */ +/************************************************************************************/ + +const BiquadA012B12CoefsSP_t LVCS_EqualiserCoefTable[] = { + /* Headphone coefficients */ + {CS_EQUALISER_8000_A0, /* 8kS/s coefficients */ + CS_EQUALISER_8000_A1, + CS_EQUALISER_8000_A2, + CS_EQUALISER_8000_B1, + CS_EQUALISER_8000_B2, + (LVM_UINT16 )CS_EQUALISER_8000_SCALE}, + {CS_EQUALISER_11025_A0, /* 11kS/s coefficients */ + CS_EQUALISER_11025_A1, + CS_EQUALISER_11025_A2, + CS_EQUALISER_11025_B1, + CS_EQUALISER_11025_B2, + (LVM_UINT16 )CS_EQUALISER_11025_SCALE}, + {CS_EQUALISER_12000_A0, /* 12kS/s coefficients */ + CS_EQUALISER_12000_A1, + CS_EQUALISER_12000_A2, + CS_EQUALISER_12000_B1, + CS_EQUALISER_12000_B2, + (LVM_UINT16 )CS_EQUALISER_12000_SCALE}, + {CS_EQUALISER_16000_A0, /* 16kS/s coefficients */ + CS_EQUALISER_16000_A1, + CS_EQUALISER_16000_A2, + CS_EQUALISER_16000_B1, + CS_EQUALISER_16000_B2, + (LVM_UINT16 )CS_EQUALISER_16000_SCALE}, + {CS_EQUALISER_22050_A0, /* 22kS/s coefficients */ + CS_EQUALISER_22050_A1, + CS_EQUALISER_22050_A2, + CS_EQUALISER_22050_B1, + CS_EQUALISER_22050_B2, + (LVM_UINT16 )CS_EQUALISER_22050_SCALE}, + {CS_EQUALISER_24000_A0, /* 24kS/s coefficients */ + CS_EQUALISER_24000_A1, + CS_EQUALISER_24000_A2, + CS_EQUALISER_24000_B1, + CS_EQUALISER_24000_B2, + (LVM_UINT16 )CS_EQUALISER_24000_SCALE}, + {CS_EQUALISER_32000_A0, /* 32kS/s coefficients */ + CS_EQUALISER_32000_A1, + CS_EQUALISER_32000_A2, + CS_EQUALISER_32000_B1, + CS_EQUALISER_32000_B2, + (LVM_UINT16 )CS_EQUALISER_32000_SCALE}, + {CS_EQUALISER_44100_A0, /* 44kS/s coefficients */ + CS_EQUALISER_44100_A1, + CS_EQUALISER_44100_A2, + CS_EQUALISER_44100_B1, + CS_EQUALISER_44100_B2, + (LVM_UINT16 )CS_EQUALISER_44100_SCALE}, + {CS_EQUALISER_48000_A0, /* 48kS/s coefficients */ + CS_EQUALISER_48000_A1, + CS_EQUALISER_48000_A2, + CS_EQUALISER_48000_B1, + CS_EQUALISER_48000_B2, + (LVM_UINT16 )CS_EQUALISER_48000_SCALE}, + + /* Concert Sound EX Headphone coefficients */ + {CSEX_EQUALISER_8000_A0, /* 8kS/s coefficients */ + CSEX_EQUALISER_8000_A1, + CSEX_EQUALISER_8000_A2, + CSEX_EQUALISER_8000_B1, + CSEX_EQUALISER_8000_B2, + (LVM_UINT16 )CSEX_EQUALISER_8000_SCALE}, + {CSEX_EQUALISER_11025_A0, /* 11kS/s coefficients */ + CSEX_EQUALISER_11025_A1, + CSEX_EQUALISER_11025_A2, + CSEX_EQUALISER_11025_B1, + CSEX_EQUALISER_11025_B2, + (LVM_UINT16 )CSEX_EQUALISER_11025_SCALE}, + {CSEX_EQUALISER_12000_A0, /* 12kS/s coefficients */ + CSEX_EQUALISER_12000_A1, + CSEX_EQUALISER_12000_A2, + CSEX_EQUALISER_12000_B1, + CSEX_EQUALISER_12000_B2, + (LVM_UINT16 )CSEX_EQUALISER_12000_SCALE}, + {CSEX_EQUALISER_16000_A0, /* 16kS/s coefficients */ + CSEX_EQUALISER_16000_A1, + CSEX_EQUALISER_16000_A2, + CSEX_EQUALISER_16000_B1, + CSEX_EQUALISER_16000_B2, + (LVM_UINT16 )CSEX_EQUALISER_16000_SCALE}, + {CSEX_EQUALISER_22050_A0, /* 22kS/s coefficients */ + CSEX_EQUALISER_22050_A1, + CSEX_EQUALISER_22050_A2, + CSEX_EQUALISER_22050_B1, + CSEX_EQUALISER_22050_B2, + (LVM_UINT16 )CSEX_EQUALISER_22050_SCALE}, + {CSEX_EQUALISER_24000_A0, /* 24kS/s coefficients */ + CSEX_EQUALISER_24000_A1, + CSEX_EQUALISER_24000_A2, + CSEX_EQUALISER_24000_B1, + CSEX_EQUALISER_24000_B2, + (LVM_UINT16 )CSEX_EQUALISER_24000_SCALE}, + {CSEX_EQUALISER_32000_A0, /* 32kS/s coefficients */ + CSEX_EQUALISER_32000_A1, + CSEX_EQUALISER_32000_A2, + CSEX_EQUALISER_32000_B1, + CSEX_EQUALISER_32000_B2, + (LVM_UINT16 )CSEX_EQUALISER_32000_SCALE}, + {CSEX_EQUALISER_44100_A0, /* 44kS/s coefficients */ + CSEX_EQUALISER_44100_A1, + CSEX_EQUALISER_44100_A2, + CSEX_EQUALISER_44100_B1, + CSEX_EQUALISER_44100_B2, + (LVM_UINT16 )CSEX_EQUALISER_44100_SCALE}, + {CSEX_EQUALISER_48000_A0, /* 48kS/s coefficients */ + CSEX_EQUALISER_48000_A1, + CSEX_EQUALISER_48000_A2, + CSEX_EQUALISER_48000_B1, + CSEX_EQUALISER_48000_B2, + (LVM_UINT16 )CSEX_EQUALISER_48000_SCALE} +}; + + +/************************************************************************************/ +/* */ +/* Reverb delay constant tables */ +/* */ +/************************************************************************************/ + +/* Stereo delay table for Concert Sound */ +const LVM_UINT16 LVCS_StereoDelayCS[] = { + LVCS_STEREODELAY_CS_8KHZ, + LVCS_STEREODELAY_CS_11KHZ, + LVCS_STEREODELAY_CS_12KHZ, + LVCS_STEREODELAY_CS_16KHZ, + LVCS_STEREODELAY_CS_22KHZ, + LVCS_STEREODELAY_CS_24KHZ, + LVCS_STEREODELAY_CS_32KHZ, + LVCS_STEREODELAY_CS_44KHZ, + LVCS_STEREODELAY_CS_48KHZ}; + +/************************************************************************************/ +/* */ +/* Reverb coefficients constant table */ +/* */ +/************************************************************************************/ + +const BiquadA012B12CoefsSP_t LVCS_ReverbCoefTable[] = { + /* Headphone coefficients */ + {CS_REVERB_8000_A0, /* 8kS/s coefficients */ + CS_REVERB_8000_A1, + CS_REVERB_8000_A2, + CS_REVERB_8000_B1, + CS_REVERB_8000_B2, + (LVM_UINT16 )CS_REVERB_8000_SCALE}, + {CS_REVERB_11025_A0, /* 11kS/s coefficients */ + CS_REVERB_11025_A1, + CS_REVERB_11025_A2, + CS_REVERB_11025_B1, + CS_REVERB_11025_B2, + (LVM_UINT16 )CS_REVERB_11025_SCALE}, + {CS_REVERB_12000_A0, /* 12kS/s coefficients */ + CS_REVERB_12000_A1, + CS_REVERB_12000_A2, + CS_REVERB_12000_B1, + CS_REVERB_12000_B2, + (LVM_UINT16 )CS_REVERB_12000_SCALE}, + {CS_REVERB_16000_A0, /* 16kS/s coefficients */ + CS_REVERB_16000_A1, + CS_REVERB_16000_A2, + CS_REVERB_16000_B1, + CS_REVERB_16000_B2, + (LVM_UINT16 )CS_REVERB_16000_SCALE}, + {CS_REVERB_22050_A0, /* 22kS/s coefficients */ + CS_REVERB_22050_A1, + CS_REVERB_22050_A2, + CS_REVERB_22050_B1, + CS_REVERB_22050_B2, + (LVM_UINT16 )CS_REVERB_22050_SCALE}, + {CS_REVERB_24000_A0, /* 24kS/s coefficients */ + CS_REVERB_24000_A1, + CS_REVERB_24000_A2, + CS_REVERB_24000_B1, + CS_REVERB_24000_B2, + (LVM_UINT16 )CS_REVERB_24000_SCALE}, + {CS_REVERB_32000_A0, /* 32kS/s coefficients */ + CS_REVERB_32000_A1, + CS_REVERB_32000_A2, + CS_REVERB_32000_B1, + CS_REVERB_32000_B2, + (LVM_UINT16 )CS_REVERB_32000_SCALE}, + {CS_REVERB_44100_A0, /* 44kS/s coefficients */ + CS_REVERB_44100_A1, + CS_REVERB_44100_A2, + CS_REVERB_44100_B1, + CS_REVERB_44100_B2, + (LVM_UINT16 )CS_REVERB_44100_SCALE}, + {CS_REVERB_48000_A0, /* 48kS/s coefficients */ + CS_REVERB_48000_A1, + CS_REVERB_48000_A2, + CS_REVERB_48000_B1, + CS_REVERB_48000_B2, + (LVM_UINT16 )CS_REVERB_48000_SCALE} +}; + + +/************************************************************************************/ +/* */ +/* Bypass mixer constant tables */ +/* */ +/************************************************************************************/ + +const Gain_t LVCS_OutputGainTable[] = { + {LVCS_HEADPHONE_SHIFT, /* Headphone, stereo mode */ + LVCS_HEADPHONE_SHIFTLOSS, + LVCS_HEADPHONE_GAIN}, + {LVCS_EX_HEADPHONE_SHIFT, /* EX Headphone, stereo mode */ + LVCS_EX_HEADPHONE_SHIFTLOSS, + LVCS_EX_HEADPHONE_GAIN}, + {LVCS_HEADPHONE_SHIFT, /* Headphone, mono mode */ + LVCS_HEADPHONE_SHIFTLOSS, + LVCS_HEADPHONE_GAIN}, + {LVCS_EX_HEADPHONE_SHIFT, /* EX Headphone, mono mode */ + LVCS_EX_HEADPHONE_SHIFTLOSS, + LVCS_EX_HEADPHONE_GAIN} +}; + + +/************************************************************************************/ +/* */ +/* Volume correction table */ +/* */ +/* Coefficient order: */ +/* Compression 100% effect */ +/* Compression 0% effect */ +/* Gain 100% effect */ +/* Gain 0% effect */ +/* */ +/* The Compression gain is represented by a Q1.15 number to give a range of 0dB */ +/* to +6dB, E.g.: */ +/* 0 is 0dB compression (no effect) */ +/* 5461 is 1dB compression gain */ +/* 10923 is 2dB compression gain */ +/* 32767 is 6dB compression gain */ +/* */ +/* The Gain is represented as a Q3.13 number to give a range of +8 to -infinity */ +/* E.g.: */ +/* 0 is -infinity */ +/* 32767 is +18dB (x8) gain */ +/* 4096 is 0dB gain */ +/* 1024 is -12dB gain */ +/* */ +/************************************************************************************/ +const LVCS_VolCorrect_t LVCS_VolCorrectTable[] = { + {14200, /* Headphone, stereo mode */ + 0, + 4096, + 5786}, + {14200, /* EX Headphone, stereo mode */ + 0, + 4096, + 5786}, + {32767, /* Headphone, mono mode */ + 0, + 4096, + 5786}, + {32767, /* EX Headphone, mono mode */ + 0, + 4096, + 5786} +}; + +/************************************************************************************/ +/* */ +/* Mixer time constants, 100ms */ +/* */ +/************************************************************************************/ + +#define LVCS_VOL_TC_Fs8000 32580 /* Floating point value 0.994262695 */ +#define LVCS_VOL_TC_Fs11025 32632 /* Floating point value 0.995849609 */ +#define LVCS_VOL_TC_Fs12000 32643 /* Floating point value 0.996185303 */ +#define LVCS_VOL_TC_Fs16000 32674 /* Floating point value 0.997131348 */ +#define LVCS_VOL_TC_Fs22050 32700 /* Floating point value 0.997924805 */ +#define LVCS_VOL_TC_Fs24000 32705 /* Floating point value 0.998077393 */ +#define LVCS_VOL_TC_Fs32000 32721 /* Floating point value 0.998565674 */ +#define LVCS_VOL_TC_Fs44100 32734 /* Floating point value 0.998962402 */ +#define LVCS_VOL_TC_Fs48000 32737 /* Floating point value 0.999053955 */ + + +const LVM_INT16 LVCS_VolumeTCTable[9] = {LVCS_VOL_TC_Fs8000, + LVCS_VOL_TC_Fs11025, + LVCS_VOL_TC_Fs12000, + LVCS_VOL_TC_Fs16000, + LVCS_VOL_TC_Fs22050, + LVCS_VOL_TC_Fs24000, + LVCS_VOL_TC_Fs32000, + LVCS_VOL_TC_Fs44100, + LVCS_VOL_TC_Fs48000}; + +/************************************************************************************/ +/* */ +/* Sample rate table */ +/* */ +/************************************************************************************/ + +const LVM_INT32 LVCS_SampleRateTable[9] = {8000, + 11025, + 12000, + 16000, + 22050, + 24000, + 32000, + 44100, + 48000}; + diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Tables.h b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Tables.h new file mode 100755 index 0000000..72d6855 --- /dev/null +++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Tables.h @@ -0,0 +1,159 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************************ + + $Author: nxp27078 $ + $Revision: 672 $ + $Date: 2010-06-08 19:39:38 +0200 (Tue, 08 Jun 2010) $ + +*************************************************************************************/ +#ifndef __LVCS_TABLES_H__ +#define __LVCS_TABLES_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/************************************************************************************/ +/* */ +/* Includes */ +/* */ +/************************************************************************************/ + +#include "BIQUAD.h" /* Biquad definitions */ + +/************************************************************************************/ +/* */ +/* Stereo Enhancer coefficient constant tables */ +/* */ +/************************************************************************************/ + +/* Coefficient table for the middle filter */ +extern const BiquadA01B1CoefsSP_t LVCS_SEMidCoefTable[]; + +/* Coefficient table for the side filter */ +extern const BiquadA012B12CoefsSP_t LVCS_SESideCoefTable[]; + +/************************************************************************************/ +/* */ +/* Equaliser coefficient constant tables */ +/* */ +/************************************************************************************/ + +extern const BiquadA012B12CoefsSP_t LVCS_EqualiserCoefTable[]; + +/************************************************************************************/ +/* */ +/* Reverb delay constant tables */ +/* */ +/************************************************************************************/ + +/* Stereo delay table for Concert Sound */ +extern const LVM_UINT16 LVCS_StereoDelayCS[]; + +/************************************************************************************/ +/* */ +/* Reverb coefficients constant table */ +/* */ +/************************************************************************************/ + +extern const BiquadA012B12CoefsSP_t LVCS_ReverbCoefTable[]; + +/************************************************************************************/ +/* */ +/* Bypass mixer constant tables */ +/* */ +/************************************************************************************/ + +extern const Gain_t LVCS_OutputGainTable[]; + +/************************************************************************************/ +/* */ +/* Volume correction table */ +/* */ +/* Coefficient order: */ +/* Compression 100% effect */ +/* Compression 0% effect */ +/* Gain 100% effect */ +/* Gain 0% effect */ +/* */ +/* The Compression gain is represented by a Q1.15 number to give a range of 0dB */ +/* to +6dB, E.g.: */ +/* 0 is 0dB compression (no effect) */ +/* 5461 is 1dB compression gain */ +/* 10923 is 2dB compression gain */ +/* 32767 is 6dB compression gain */ +/* */ +/* The Gain is represented as a Q3.13 number to give a range of +8 to -infinity */ +/* E.g.: */ +/* 0 is -infinity */ +/* 32767 is +18dB (x8) gain */ +/* 4096 is 0dB gain */ +/* 1024 is -12dB gain */ +/* */ +/************************************************************************************/ + +extern const LVCS_VolCorrect_t LVCS_VolCorrectTable[]; +extern const LVM_INT16 LVCS_VolumeTCTable[]; + + +/************************************************************************************/ +/* */ +/* Sample rates */ +/* */ +/************************************************************************************/ + +extern LVM_INT32 LVCS_SampleRateTable[]; + + +/*Speaker coeffient tables*/ +extern LVM_UINT16 LVCS_MS_Small_SEMiddleGainTable[]; +extern BiquadA012B12CoefsSP_t LVCS_MS_Small_SESideCoefTable[]; +extern BiquadA012B12CoefsSP_t LVCS_MS_Small_EqualiserCoefTable[]; +extern BiquadA012B12CoefsSP_t LVCS_MS_Small_ReverbCoefTable[] ; +extern LVM_UINT16 LVCS_MS_Small_StereoDelayCS4MS[]; +extern Gain_t LVCS_MS_Small_OutputGainTable[]; +extern LVCS_VolCorrect_t LVCS_MS_Small_VolCorrectTable[]; +extern LVM_UINT16 LVCS_MS_Small_ReverbGainTable[]; + +extern LVM_UINT16 LVCS_MS_Medium_SEMiddleGainTable[]; +extern BiquadA012B12CoefsSP_t LVCS_MS_Medium_SESideCoefTable[]; +extern BiquadA012B12CoefsSP_t LVCS_MS_Medium_EqualiserCoefTable[]; +extern BiquadA012B12CoefsSP_t LVCS_MS_Medium_ReverbCoefTable[] ; +extern LVM_UINT16 LVCS_MS_Medium_StereoDelayCS4MS[]; +extern Gain_t LVCS_MS_Medium_OutputGainTable[]; +extern LVCS_VolCorrect_t LVCS_MS_Medium_VolCorrectTable[]; +extern LVM_UINT16 LVCS_MS_Medium_ReverbGainTable[]; + +extern LVM_UINT16 LVCS_MS_Large_SEMiddleGainTable[]; +extern BiquadA012B12CoefsSP_t LVCS_MS_Large_SESideCoefTable[]; +extern BiquadA012B12CoefsSP_t LVCS_MS_Large_EqualiserCoefTable[]; +extern BiquadA012B12CoefsSP_t LVCS_MS_Large_ReverbCoefTable[] ; +extern LVM_UINT16 LVCS_MS_Large_StereoDelayCS4MS[]; +extern Gain_t LVCS_MS_Large_OutputGainTable[]; +extern LVCS_VolCorrect_t LVCS_MS_Large_VolCorrectTable[]; +extern LVM_UINT16 LVCS_MS_Large_ReverbGainTable[]; + + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __LVCS_TABLES_H__ */ + |