From 2c8e5cab3faa6d360e222b7a6c40a80083d021ac Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Fri, 9 Jul 2010 12:28:50 -0700 Subject: First submission of audio effect library from NXP software. This CL contains the first open sourceable version of the audio effect library from NXP software. The effects implemented are: - Bass boost - Virtualizer (stereo widening) - Equalizer - Spectrum analyzer Source file for the effect engines are located under libeffects/lvm/lib The wrapper implementing the interface with the audio effect framework in under libeffects/lvm/wrapper The code of other effect libraries has also been reorganized fo clarity: - the effect factory is now under libeffects/factory - the test equalizer and reverb effects are under libeffect/testlibs - the visualizer is under libeffects/virtualizer Change-Id: I8d91e2181f81b89f8fc0c1e1e6bf552c5809b2eb --- media/libeffects/lvm/lib/Android.mk | 124 +++ media/libeffects/lvm/lib/Bass/lib/LVDBE.h | 472 +++++++++ media/libeffects/lvm/lib/Bass/src/LVDBE_Coeffs.h | 518 ++++++++++ media/libeffects/lvm/lib/Bass/src/LVDBE_Control.c | 377 +++++++ media/libeffects/lvm/lib/Bass/src/LVDBE_Init.c | 267 +++++ media/libeffects/lvm/lib/Bass/src/LVDBE_Private.h | 148 +++ media/libeffects/lvm/lib/Bass/src/LVDBE_Process.c | 205 ++++ media/libeffects/lvm/lib/Bass/src/LVDBE_Tables.c | 463 +++++++++ media/libeffects/lvm/lib/Bass/src/LVDBE_Tables.h | 93 ++ media/libeffects/lvm/lib/Bundle/lib/LVM.h | 637 ++++++++++++ .../lvm/lib/Bundle/src/LVM_API_Specials.c | 158 +++ media/libeffects/lvm/lib/Bundle/src/LVM_Buffers.c | 878 +++++++++++++++++ media/libeffects/lvm/lib/Bundle/src/LVM_Coeffs.h | 573 +++++++++++ media/libeffects/lvm/lib/Bundle/src/LVM_Control.c | 1032 ++++++++++++++++++++ media/libeffects/lvm/lib/Bundle/src/LVM_Init.c | 1003 +++++++++++++++++++ media/libeffects/lvm/lib/Bundle/src/LVM_Private.h | 292 ++++++ media/libeffects/lvm/lib/Bundle/src/LVM_Process.c | 283 ++++++ media/libeffects/lvm/lib/Bundle/src/LVM_Tables.c | 397 ++++++++ media/libeffects/lvm/lib/Bundle/src/LVM_Tables.h | 67 ++ media/libeffects/lvm/lib/Common/lib/AGC.h | 92 ++ media/libeffects/lvm/lib/Common/lib/BIQUAD.h | 341 +++++++ media/libeffects/lvm/lib/Common/lib/CompLim.h | 91 ++ media/libeffects/lvm/lib/Common/lib/Filter.h | 71 ++ media/libeffects/lvm/lib/Common/lib/InstAlloc.h | 99 ++ media/libeffects/lvm/lib/Common/lib/LVM_Common.h | 69 ++ media/libeffects/lvm/lib/Common/lib/LVM_Macros.h | 130 +++ media/libeffects/lvm/lib/Common/lib/LVM_Timer.h | 89 ++ media/libeffects/lvm/lib/Common/lib/LVM_Types.h | 195 ++++ media/libeffects/lvm/lib/Common/lib/Mixer.h | 135 +++ .../lvm/lib/Common/lib/ScalarArithmetic.h | 68 ++ .../lvm/lib/Common/lib/VectorArithmetic.h | 189 ++++ .../lib/Common/src/AGC_MIX_VOL_2St1Mon_D32_WRA.c | 204 ++++ media/libeffects/lvm/lib/Common/src/Abs_32.c | 58 ++ .../libeffects/lvm/lib/Common/src/Add2_Sat_16x16.c | 64 ++ .../libeffects/lvm/lib/Common/src/Add2_Sat_32x32.c | 69 ++ .../lib/Common/src/BP_1I_D16F16C14_TRC_WRA_01.c | 90 ++ .../Common/src/BP_1I_D16F16Css_TRC_WRA_01_Init.c | 59 ++ .../src/BP_1I_D16F16Css_TRC_WRA_01_Private.h | 38 + .../lib/Common/src/BP_1I_D16F32C30_TRC_WRA_01.c | 92 ++ .../Common/src/BP_1I_D16F32Cll_TRC_WRA_01_Init.c | 69 ++ .../src/BP_1I_D16F32Cll_TRC_WRA_01_Private.h | 38 + .../lib/Common/src/BP_1I_D32F32C30_TRC_WRA_02.c | 90 ++ .../Common/src/BP_1I_D32F32Cll_TRC_WRA_02_Init.c | 60 ++ .../src/BP_1I_D32F32Cll_TRC_WRA_02_Private.h | 38 + .../lib/Common/src/BQ_1I_D16F16C15_TRC_WRA_01.c | 94 ++ .../Common/src/BQ_1I_D16F16Css_TRC_WRA_01_Init.c | 66 ++ .../src/BQ_1I_D16F16Css_TRC_WRA_01_Private.h | 38 + .../lib/Common/src/BQ_1I_D16F32C14_TRC_WRA_01.c | 93 ++ .../src/BQ_1I_D16F32Css_TRC_WRA_01_Private.h | 38 + .../Common/src/BQ_1I_D16F32Css_TRC_WRA_01_init.c | 67 ++ .../lib/Common/src/BQ_2I_D16F16C14_TRC_WRA_01.c | 123 +++ .../lib/Common/src/BQ_2I_D16F16C15_TRC_WRA_01.c | 123 +++ .../Common/src/BQ_2I_D16F16Css_TRC_WRA_01_Init.c | 67 ++ .../src/BQ_2I_D16F16Css_TRC_WRA_01_Private.h | 40 + .../lib/Common/src/BQ_2I_D16F32C13_TRC_WRA_01.c | 127 +++ .../lib/Common/src/BQ_2I_D16F32C14_TRC_WRA_01.c | 126 +++ .../lib/Common/src/BQ_2I_D16F32C15_TRC_WRA_01.c | 126 +++ .../src/BQ_2I_D16F32Css_TRC_WRA_01_Private.h | 40 + .../Common/src/BQ_2I_D16F32Css_TRC_WRA_01_init.c | 67 ++ .../lib/Common/src/BQ_2I_D32F32C30_TRC_WRA_01.c | 135 +++ .../Common/src/BQ_2I_D32F32Cll_TRC_WRA_01_Init.c | 66 ++ .../src/BQ_2I_D32F32Cll_TRC_WRA_01_Private.h | 41 + .../lvm/lib/Common/src/CompLim_private.h | 52 + media/libeffects/lvm/lib/Common/src/Copy_16.c | 66 ++ .../lib/Common/src/Core_MixHard_2St_D32C31_SAT.c | 69 ++ .../lvm/lib/Common/src/Core_MixInSoft_D32C31_SAT.c | 103 ++ .../lib/Common/src/Core_MixSoft_1St_D32C31_WRA.c | 112 +++ .../lvm/lib/Common/src/DC_2I_D16_TRC_WRA_01.c | 76 ++ .../lvm/lib/Common/src/DC_2I_D16_TRC_WRA_01_Init.c | 36 + .../lib/Common/src/DC_2I_D16_TRC_WRA_01_Private.h | 43 + .../lib/Common/src/DelayAllPass_Sat_32x16To32.c | 113 +++ .../libeffects/lvm/lib/Common/src/DelayMix_16x16.c | 81 ++ .../libeffects/lvm/lib/Common/src/DelayWrite_32.c | 66 ++ .../lib/Common/src/FO_1I_D16F16C15_TRC_WRA_01.c | 83 ++ .../Common/src/FO_1I_D16F16Css_TRC_WRA_01_Init.c | 63 ++ .../src/FO_1I_D16F16Css_TRC_WRA_01_Private.h | 40 + .../lib/Common/src/FO_1I_D32F32C31_TRC_WRA_01.c | 83 ++ .../Common/src/FO_1I_D32F32Cll_TRC_WRA_01_Init.c | 66 ++ .../src/FO_1I_D32F32Cll_TRC_WRA_01_Private.h | 41 + .../Common/src/FO_2I_D16F32C15_LShx_TRC_WRA_01.c | 137 +++ .../src/FO_2I_D16F32Css_LShx_TRC_WRA_01_Init.c | 65 ++ .../src/FO_2I_D16F32Css_LShx_TRC_WRA_01_Private.h | 41 + media/libeffects/lvm/lib/Common/src/Filters.h | 74 ++ .../lvm/lib/Common/src/From2iToMS_16x16.c | 65 ++ .../lvm/lib/Common/src/From2iToMono_16.c | 57 ++ .../lvm/lib/Common/src/From2iToMono_32.c | 58 ++ media/libeffects/lvm/lib/Common/src/InstAlloc.c | 194 ++++ .../lvm/lib/Common/src/Int16LShiftToInt32_16x32.c | 56 ++ .../lib/Common/src/Int32RShiftToInt16_Sat_32x16.c | 68 ++ .../libeffects/lvm/lib/Common/src/JoinTo2i_32x32.c | 63 ++ .../src/LVC_Core_MixHard_1St_2i_D16C31_SAT.c | 77 ++ .../Common/src/LVC_Core_MixHard_2St_D16C31_SAT.c | 67 ++ .../lib/Common/src/LVC_Core_MixInSoft_D16C31_SAT.c | 136 +++ .../src/LVC_Core_MixSoft_1St_2i_D16C31_WRA.c | 151 +++ .../Common/src/LVC_Core_MixSoft_1St_D16C31_WRA.c | 114 +++ .../lvm/lib/Common/src/LVC_MixInSoft_D16C31_SAT.c | 120 +++ .../lib/Common/src/LVC_MixSoft_1St_2i_D16C31_SAT.c | 160 +++ .../lib/Common/src/LVC_MixSoft_1St_D16C31_SAT.c | 119 +++ .../lib/Common/src/LVC_MixSoft_2St_D16C31_SAT.c | 78 ++ media/libeffects/lvm/lib/Common/src/LVC_Mixer.h | 144 +++ .../lvm/lib/Common/src/LVC_Mixer_GetCurrent.c | 50 + .../lvm/lib/Common/src/LVC_Mixer_GetTarget.c | 51 + .../libeffects/lvm/lib/Common/src/LVC_Mixer_Init.c | 76 ++ .../lvm/lib/Common/src/LVC_Mixer_Private.h | 136 +++ .../lvm/lib/Common/src/LVC_Mixer_SetTarget.c | 75 ++ .../lvm/lib/Common/src/LVC_Mixer_SetTimeConstant.c | 84 ++ .../src/LVC_Mixer_VarSlope_SetTimeConstant.c | 104 ++ media/libeffects/lvm/lib/Common/src/LVM_FO_HPF.c | 109 +++ media/libeffects/lvm/lib/Common/src/LVM_FO_LPF.c | 106 ++ media/libeffects/lvm/lib/Common/src/LVM_GetOmega.c | 79 ++ .../lvm/lib/Common/src/LVM_Mixer_FilterCoeffs.h | 100 ++ .../lvm/lib/Common/src/LVM_Mixer_TimeConstant.c | 165 ++++ .../libeffects/lvm/lib/Common/src/LVM_Polynomial.c | 105 ++ media/libeffects/lvm/lib/Common/src/LVM_Power10.c | 87 ++ media/libeffects/lvm/lib/Common/src/LVM_Timer.c | 57 ++ .../libeffects/lvm/lib/Common/src/LVM_Timer_Init.c | 63 ++ .../lvm/lib/Common/src/LVM_Timer_Private.h | 61 ++ media/libeffects/lvm/lib/Common/src/LoadConst_16.c | 51 + media/libeffects/lvm/lib/Common/src/LoadConst_32.c | 52 + .../lvm/lib/Common/src/MSTo2i_Sat_16x16.c | 88 ++ .../lvm/lib/Common/src/Mac3s_Sat_16x16.c | 81 ++ .../lvm/lib/Common/src/Mac3s_Sat_32x16.c | 80 ++ .../lvm/lib/Common/src/MixInSoft_D32C31_SAT.c | 104 ++ .../lvm/lib/Common/src/MixSoft_1St_D32C31_WRA.c | 104 ++ .../lvm/lib/Common/src/MixSoft_2St_D32C31_SAT.c | 72 ++ .../libeffects/lvm/lib/Common/src/Mixer_private.h | 44 + media/libeffects/lvm/lib/Common/src/MonoTo2I_16.c | 57 ++ media/libeffects/lvm/lib/Common/src/MonoTo2I_32.c | 58 ++ media/libeffects/lvm/lib/Common/src/Mult3s_32x16.c | 60 ++ .../libeffects/lvm/lib/Common/src/NonLinComp_D16.c | 125 +++ .../lib/Common/src/PK_2I_D32F32C14G11_TRC_WRA_01.c | 130 +++ .../lib/Common/src/PK_2I_D32F32C30G11_TRC_WRA_01.c | 128 +++ .../src/PK_2I_D32F32CllGss_TRC_WRA_01_Init.c | 47 + .../src/PK_2I_D32F32CllGss_TRC_WRA_01_Private.h | 40 + .../src/PK_2I_D32F32CssGss_TRC_WRA_01_Init.c | 46 + .../src/PK_2I_D32F32CssGss_TRC_WRA_01_Private.h | 41 + .../lvm/lib/Common/src/Shift_Sat_v16xv16.c | 89 ++ .../lvm/lib/Common/src/Shift_Sat_v32xv32.c | 92 ++ media/libeffects/lvm/lib/Common/src/dB_to_Lin32.c | 109 +++ media/libeffects/lvm/lib/Common/src/mult3s_16x16.c | 56 ++ media/libeffects/lvm/lib/Eq/lib/LVEQNB.h | 484 +++++++++ media/libeffects/lvm/lib/Eq/src/LVEQNB_CalcCoef.c | 306 ++++++ media/libeffects/lvm/lib/Eq/src/LVEQNB_Coeffs.h | 106 ++ media/libeffects/lvm/lib/Eq/src/LVEQNB_Control.c | 501 ++++++++++ media/libeffects/lvm/lib/Eq/src/LVEQNB_Init.c | 329 +++++++ media/libeffects/lvm/lib/Eq/src/LVEQNB_Private.h | 141 +++ media/libeffects/lvm/lib/Eq/src/LVEQNB_Process.c | 208 ++++ media/libeffects/lvm/lib/Eq/src/LVEQNB_Tables.c | 203 ++++ .../lvm/lib/SpectrumAnalyzer/lib/LVPSA.h | 298 ++++++ .../lvm/lib/SpectrumAnalyzer/src/LVPSA_Control.c | 715 ++++++++++++++ .../lvm/lib/SpectrumAnalyzer/src/LVPSA_Init.c | 197 ++++ .../lvm/lib/SpectrumAnalyzer/src/LVPSA_Memory.c | 177 ++++ .../lvm/lib/SpectrumAnalyzer/src/LVPSA_Private.h | 159 +++ .../lvm/lib/SpectrumAnalyzer/src/LVPSA_Process.c | 260 +++++ .../lvm/lib/SpectrumAnalyzer/src/LVPSA_QPD.h | 98 ++ .../lvm/lib/SpectrumAnalyzer/src/LVPSA_QPD_Init.c | 50 + .../lib/SpectrumAnalyzer/src/LVPSA_QPD_Process.c | 220 +++++ .../lvm/lib/SpectrumAnalyzer/src/LVPSA_Tables.c | 250 +++++ media/libeffects/lvm/lib/StereoWidening/lib/LVCS.h | 396 ++++++++ .../lvm/lib/StereoWidening/src/LVCS_BypassMix.c | 303 ++++++ .../lvm/lib/StereoWidening/src/LVCS_BypassMix.h | 89 ++ .../lvm/lib/StereoWidening/src/LVCS_Control.c | 273 ++++++ .../lvm/lib/StereoWidening/src/LVCS_Equaliser.c | 167 ++++ .../lvm/lib/StereoWidening/src/LVCS_Equaliser.h | 66 ++ .../lib/StereoWidening/src/LVCS_Headphone_Coeffs.h | 398 ++++++++ .../lvm/lib/StereoWidening/src/LVCS_Init.c | 233 +++++ .../lvm/lib/StereoWidening/src/LVCS_Private.h | 171 ++++ .../lvm/lib/StereoWidening/src/LVCS_Process.c | 271 +++++ .../lib/StereoWidening/src/LVCS_ReverbGenerator.c | 272 ++++++ .../lib/StereoWidening/src/LVCS_ReverbGenerator.h | 98 ++ .../lib/StereoWidening/src/LVCS_StereoEnhancer.c | 266 +++++ .../lib/StereoWidening/src/LVCS_StereoEnhancer.h | 88 ++ .../lvm/lib/StereoWidening/src/LVCS_Tables.c | 456 +++++++++ .../lvm/lib/StereoWidening/src/LVCS_Tables.h | 159 +++ 174 files changed, 26909 insertions(+) create mode 100644 media/libeffects/lvm/lib/Android.mk create mode 100755 media/libeffects/lvm/lib/Bass/lib/LVDBE.h create mode 100755 media/libeffects/lvm/lib/Bass/src/LVDBE_Coeffs.h create mode 100755 media/libeffects/lvm/lib/Bass/src/LVDBE_Control.c create mode 100755 media/libeffects/lvm/lib/Bass/src/LVDBE_Init.c create mode 100755 media/libeffects/lvm/lib/Bass/src/LVDBE_Private.h create mode 100755 media/libeffects/lvm/lib/Bass/src/LVDBE_Process.c create mode 100755 media/libeffects/lvm/lib/Bass/src/LVDBE_Tables.c create mode 100755 media/libeffects/lvm/lib/Bass/src/LVDBE_Tables.h create mode 100755 media/libeffects/lvm/lib/Bundle/lib/LVM.h create mode 100755 media/libeffects/lvm/lib/Bundle/src/LVM_API_Specials.c create mode 100755 media/libeffects/lvm/lib/Bundle/src/LVM_Buffers.c create mode 100755 media/libeffects/lvm/lib/Bundle/src/LVM_Coeffs.h create mode 100755 media/libeffects/lvm/lib/Bundle/src/LVM_Control.c create mode 100755 media/libeffects/lvm/lib/Bundle/src/LVM_Init.c create mode 100755 media/libeffects/lvm/lib/Bundle/src/LVM_Private.h create mode 100755 media/libeffects/lvm/lib/Bundle/src/LVM_Process.c create mode 100755 media/libeffects/lvm/lib/Bundle/src/LVM_Tables.c create mode 100755 media/libeffects/lvm/lib/Bundle/src/LVM_Tables.h create mode 100755 media/libeffects/lvm/lib/Common/lib/AGC.h create mode 100755 media/libeffects/lvm/lib/Common/lib/BIQUAD.h create mode 100755 media/libeffects/lvm/lib/Common/lib/CompLim.h create mode 100755 media/libeffects/lvm/lib/Common/lib/Filter.h create mode 100755 media/libeffects/lvm/lib/Common/lib/InstAlloc.h create mode 100755 media/libeffects/lvm/lib/Common/lib/LVM_Common.h create mode 100755 media/libeffects/lvm/lib/Common/lib/LVM_Macros.h create mode 100755 media/libeffects/lvm/lib/Common/lib/LVM_Timer.h create mode 100755 media/libeffects/lvm/lib/Common/lib/LVM_Types.h create mode 100755 media/libeffects/lvm/lib/Common/lib/Mixer.h create mode 100755 media/libeffects/lvm/lib/Common/lib/ScalarArithmetic.h create mode 100755 media/libeffects/lvm/lib/Common/lib/VectorArithmetic.h create mode 100755 media/libeffects/lvm/lib/Common/src/AGC_MIX_VOL_2St1Mon_D32_WRA.c create mode 100755 media/libeffects/lvm/lib/Common/src/Abs_32.c create mode 100755 media/libeffects/lvm/lib/Common/src/Add2_Sat_16x16.c create mode 100755 media/libeffects/lvm/lib/Common/src/Add2_Sat_32x32.c create mode 100755 media/libeffects/lvm/lib/Common/src/BP_1I_D16F16C14_TRC_WRA_01.c create mode 100755 media/libeffects/lvm/lib/Common/src/BP_1I_D16F16Css_TRC_WRA_01_Init.c create mode 100755 media/libeffects/lvm/lib/Common/src/BP_1I_D16F16Css_TRC_WRA_01_Private.h create mode 100755 media/libeffects/lvm/lib/Common/src/BP_1I_D16F32C30_TRC_WRA_01.c create mode 100755 media/libeffects/lvm/lib/Common/src/BP_1I_D16F32Cll_TRC_WRA_01_Init.c create mode 100755 media/libeffects/lvm/lib/Common/src/BP_1I_D16F32Cll_TRC_WRA_01_Private.h create mode 100755 media/libeffects/lvm/lib/Common/src/BP_1I_D32F32C30_TRC_WRA_02.c create mode 100755 media/libeffects/lvm/lib/Common/src/BP_1I_D32F32Cll_TRC_WRA_02_Init.c create mode 100755 media/libeffects/lvm/lib/Common/src/BP_1I_D32F32Cll_TRC_WRA_02_Private.h create mode 100755 media/libeffects/lvm/lib/Common/src/BQ_1I_D16F16C15_TRC_WRA_01.c create mode 100755 media/libeffects/lvm/lib/Common/src/BQ_1I_D16F16Css_TRC_WRA_01_Init.c create mode 100755 media/libeffects/lvm/lib/Common/src/BQ_1I_D16F16Css_TRC_WRA_01_Private.h create mode 100755 media/libeffects/lvm/lib/Common/src/BQ_1I_D16F32C14_TRC_WRA_01.c create mode 100755 media/libeffects/lvm/lib/Common/src/BQ_1I_D16F32Css_TRC_WRA_01_Private.h create mode 100755 media/libeffects/lvm/lib/Common/src/BQ_1I_D16F32Css_TRC_WRA_01_init.c create mode 100755 media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16C14_TRC_WRA_01.c create mode 100755 media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16C15_TRC_WRA_01.c create mode 100755 media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16Css_TRC_WRA_01_Init.c create mode 100755 media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16Css_TRC_WRA_01_Private.h create mode 100755 media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32C13_TRC_WRA_01.c create mode 100755 media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32C14_TRC_WRA_01.c create mode 100755 media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32C15_TRC_WRA_01.c create mode 100755 media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32Css_TRC_WRA_01_Private.h create mode 100755 media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32Css_TRC_WRA_01_init.c create mode 100755 media/libeffects/lvm/lib/Common/src/BQ_2I_D32F32C30_TRC_WRA_01.c create mode 100755 media/libeffects/lvm/lib/Common/src/BQ_2I_D32F32Cll_TRC_WRA_01_Init.c create mode 100755 media/libeffects/lvm/lib/Common/src/BQ_2I_D32F32Cll_TRC_WRA_01_Private.h create mode 100755 media/libeffects/lvm/lib/Common/src/CompLim_private.h create mode 100755 media/libeffects/lvm/lib/Common/src/Copy_16.c create mode 100755 media/libeffects/lvm/lib/Common/src/Core_MixHard_2St_D32C31_SAT.c create mode 100755 media/libeffects/lvm/lib/Common/src/Core_MixInSoft_D32C31_SAT.c create mode 100755 media/libeffects/lvm/lib/Common/src/Core_MixSoft_1St_D32C31_WRA.c create mode 100755 media/libeffects/lvm/lib/Common/src/DC_2I_D16_TRC_WRA_01.c create mode 100755 media/libeffects/lvm/lib/Common/src/DC_2I_D16_TRC_WRA_01_Init.c create mode 100755 media/libeffects/lvm/lib/Common/src/DC_2I_D16_TRC_WRA_01_Private.h create mode 100755 media/libeffects/lvm/lib/Common/src/DelayAllPass_Sat_32x16To32.c create mode 100755 media/libeffects/lvm/lib/Common/src/DelayMix_16x16.c create mode 100755 media/libeffects/lvm/lib/Common/src/DelayWrite_32.c create mode 100755 media/libeffects/lvm/lib/Common/src/FO_1I_D16F16C15_TRC_WRA_01.c create mode 100755 media/libeffects/lvm/lib/Common/src/FO_1I_D16F16Css_TRC_WRA_01_Init.c create mode 100755 media/libeffects/lvm/lib/Common/src/FO_1I_D16F16Css_TRC_WRA_01_Private.h create mode 100755 media/libeffects/lvm/lib/Common/src/FO_1I_D32F32C31_TRC_WRA_01.c create mode 100755 media/libeffects/lvm/lib/Common/src/FO_1I_D32F32Cll_TRC_WRA_01_Init.c create mode 100755 media/libeffects/lvm/lib/Common/src/FO_1I_D32F32Cll_TRC_WRA_01_Private.h create mode 100755 media/libeffects/lvm/lib/Common/src/FO_2I_D16F32C15_LShx_TRC_WRA_01.c create mode 100755 media/libeffects/lvm/lib/Common/src/FO_2I_D16F32Css_LShx_TRC_WRA_01_Init.c create mode 100755 media/libeffects/lvm/lib/Common/src/FO_2I_D16F32Css_LShx_TRC_WRA_01_Private.h create mode 100755 media/libeffects/lvm/lib/Common/src/Filters.h create mode 100755 media/libeffects/lvm/lib/Common/src/From2iToMS_16x16.c create mode 100755 media/libeffects/lvm/lib/Common/src/From2iToMono_16.c create mode 100755 media/libeffects/lvm/lib/Common/src/From2iToMono_32.c create mode 100755 media/libeffects/lvm/lib/Common/src/InstAlloc.c create mode 100755 media/libeffects/lvm/lib/Common/src/Int16LShiftToInt32_16x32.c create mode 100755 media/libeffects/lvm/lib/Common/src/Int32RShiftToInt16_Sat_32x16.c create mode 100755 media/libeffects/lvm/lib/Common/src/JoinTo2i_32x32.c create mode 100755 media/libeffects/lvm/lib/Common/src/LVC_Core_MixHard_1St_2i_D16C31_SAT.c create mode 100755 media/libeffects/lvm/lib/Common/src/LVC_Core_MixHard_2St_D16C31_SAT.c create mode 100755 media/libeffects/lvm/lib/Common/src/LVC_Core_MixInSoft_D16C31_SAT.c create mode 100755 media/libeffects/lvm/lib/Common/src/LVC_Core_MixSoft_1St_2i_D16C31_WRA.c create mode 100755 media/libeffects/lvm/lib/Common/src/LVC_Core_MixSoft_1St_D16C31_WRA.c create mode 100755 media/libeffects/lvm/lib/Common/src/LVC_MixInSoft_D16C31_SAT.c create mode 100755 media/libeffects/lvm/lib/Common/src/LVC_MixSoft_1St_2i_D16C31_SAT.c create mode 100755 media/libeffects/lvm/lib/Common/src/LVC_MixSoft_1St_D16C31_SAT.c create mode 100755 media/libeffects/lvm/lib/Common/src/LVC_MixSoft_2St_D16C31_SAT.c create mode 100755 media/libeffects/lvm/lib/Common/src/LVC_Mixer.h create mode 100755 media/libeffects/lvm/lib/Common/src/LVC_Mixer_GetCurrent.c create mode 100755 media/libeffects/lvm/lib/Common/src/LVC_Mixer_GetTarget.c create mode 100755 media/libeffects/lvm/lib/Common/src/LVC_Mixer_Init.c create mode 100755 media/libeffects/lvm/lib/Common/src/LVC_Mixer_Private.h create mode 100755 media/libeffects/lvm/lib/Common/src/LVC_Mixer_SetTarget.c create mode 100755 media/libeffects/lvm/lib/Common/src/LVC_Mixer_SetTimeConstant.c create mode 100755 media/libeffects/lvm/lib/Common/src/LVC_Mixer_VarSlope_SetTimeConstant.c create mode 100755 media/libeffects/lvm/lib/Common/src/LVM_FO_HPF.c create mode 100755 media/libeffects/lvm/lib/Common/src/LVM_FO_LPF.c create mode 100755 media/libeffects/lvm/lib/Common/src/LVM_GetOmega.c create mode 100755 media/libeffects/lvm/lib/Common/src/LVM_Mixer_FilterCoeffs.h create mode 100755 media/libeffects/lvm/lib/Common/src/LVM_Mixer_TimeConstant.c create mode 100755 media/libeffects/lvm/lib/Common/src/LVM_Polynomial.c create mode 100755 media/libeffects/lvm/lib/Common/src/LVM_Power10.c create mode 100755 media/libeffects/lvm/lib/Common/src/LVM_Timer.c create mode 100755 media/libeffects/lvm/lib/Common/src/LVM_Timer_Init.c create mode 100755 media/libeffects/lvm/lib/Common/src/LVM_Timer_Private.h create mode 100755 media/libeffects/lvm/lib/Common/src/LoadConst_16.c create mode 100755 media/libeffects/lvm/lib/Common/src/LoadConst_32.c create mode 100755 media/libeffects/lvm/lib/Common/src/MSTo2i_Sat_16x16.c create mode 100755 media/libeffects/lvm/lib/Common/src/Mac3s_Sat_16x16.c create mode 100755 media/libeffects/lvm/lib/Common/src/Mac3s_Sat_32x16.c create mode 100755 media/libeffects/lvm/lib/Common/src/MixInSoft_D32C31_SAT.c create mode 100755 media/libeffects/lvm/lib/Common/src/MixSoft_1St_D32C31_WRA.c create mode 100755 media/libeffects/lvm/lib/Common/src/MixSoft_2St_D32C31_SAT.c create mode 100755 media/libeffects/lvm/lib/Common/src/Mixer_private.h create mode 100755 media/libeffects/lvm/lib/Common/src/MonoTo2I_16.c create mode 100755 media/libeffects/lvm/lib/Common/src/MonoTo2I_32.c create mode 100755 media/libeffects/lvm/lib/Common/src/Mult3s_32x16.c create mode 100755 media/libeffects/lvm/lib/Common/src/NonLinComp_D16.c create mode 100755 media/libeffects/lvm/lib/Common/src/PK_2I_D32F32C14G11_TRC_WRA_01.c create mode 100755 media/libeffects/lvm/lib/Common/src/PK_2I_D32F32C30G11_TRC_WRA_01.c create mode 100755 media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CllGss_TRC_WRA_01_Init.c create mode 100755 media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CllGss_TRC_WRA_01_Private.h create mode 100755 media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CssGss_TRC_WRA_01_Init.c create mode 100755 media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CssGss_TRC_WRA_01_Private.h create mode 100755 media/libeffects/lvm/lib/Common/src/Shift_Sat_v16xv16.c create mode 100755 media/libeffects/lvm/lib/Common/src/Shift_Sat_v32xv32.c create mode 100755 media/libeffects/lvm/lib/Common/src/dB_to_Lin32.c create mode 100755 media/libeffects/lvm/lib/Common/src/mult3s_16x16.c create mode 100755 media/libeffects/lvm/lib/Eq/lib/LVEQNB.h create mode 100755 media/libeffects/lvm/lib/Eq/src/LVEQNB_CalcCoef.c create mode 100755 media/libeffects/lvm/lib/Eq/src/LVEQNB_Coeffs.h create mode 100755 media/libeffects/lvm/lib/Eq/src/LVEQNB_Control.c create mode 100755 media/libeffects/lvm/lib/Eq/src/LVEQNB_Init.c create mode 100755 media/libeffects/lvm/lib/Eq/src/LVEQNB_Private.h create mode 100755 media/libeffects/lvm/lib/Eq/src/LVEQNB_Process.c create mode 100755 media/libeffects/lvm/lib/Eq/src/LVEQNB_Tables.c create mode 100755 media/libeffects/lvm/lib/SpectrumAnalyzer/lib/LVPSA.h create mode 100755 media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Control.c create mode 100755 media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Init.c create mode 100755 media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Memory.c create mode 100755 media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Private.h create mode 100755 media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Process.c create mode 100755 media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_QPD.h create mode 100755 media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_QPD_Init.c create mode 100755 media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_QPD_Process.c create mode 100755 media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Tables.c create mode 100755 media/libeffects/lvm/lib/StereoWidening/lib/LVCS.h create mode 100755 media/libeffects/lvm/lib/StereoWidening/src/LVCS_BypassMix.c create mode 100755 media/libeffects/lvm/lib/StereoWidening/src/LVCS_BypassMix.h create mode 100755 media/libeffects/lvm/lib/StereoWidening/src/LVCS_Control.c create mode 100755 media/libeffects/lvm/lib/StereoWidening/src/LVCS_Equaliser.c create mode 100755 media/libeffects/lvm/lib/StereoWidening/src/LVCS_Equaliser.h create mode 100755 media/libeffects/lvm/lib/StereoWidening/src/LVCS_Headphone_Coeffs.h create mode 100755 media/libeffects/lvm/lib/StereoWidening/src/LVCS_Init.c create mode 100755 media/libeffects/lvm/lib/StereoWidening/src/LVCS_Private.h create mode 100755 media/libeffects/lvm/lib/StereoWidening/src/LVCS_Process.c create mode 100755 media/libeffects/lvm/lib/StereoWidening/src/LVCS_ReverbGenerator.c create mode 100755 media/libeffects/lvm/lib/StereoWidening/src/LVCS_ReverbGenerator.h create mode 100755 media/libeffects/lvm/lib/StereoWidening/src/LVCS_StereoEnhancer.c create mode 100755 media/libeffects/lvm/lib/StereoWidening/src/LVCS_StereoEnhancer.h create mode 100755 media/libeffects/lvm/lib/StereoWidening/src/LVCS_Tables.c create mode 100755 media/libeffects/lvm/lib/StereoWidening/src/LVCS_Tables.h (limited to 'media/libeffects/lvm/lib') diff --git a/media/libeffects/lvm/lib/Android.mk b/media/libeffects/lvm/lib/Android.mk new file mode 100644 index 0000000..a944212 --- /dev/null +++ b/media/libeffects/lvm/lib/Android.mk @@ -0,0 +1,124 @@ +LOCAL_PATH:= $(call my-dir) + +# Music bundle + +include $(CLEAR_VARS) + +LOCAL_ARM_MODE := arm + +LOCAL_SRC_FILES:= \ + StereoWidening/src/LVCS_BypassMix.c \ + StereoWidening/src/LVCS_Control.c \ + StereoWidening/src/LVCS_Equaliser.c \ + StereoWidening/src/LVCS_Init.c \ + StereoWidening/src/LVCS_Process.c \ + StereoWidening/src/LVCS_ReverbGenerator.c \ + StereoWidening/src/LVCS_StereoEnhancer.c \ + StereoWidening/src/LVCS_Tables.c \ + Bass/src/LVDBE_Control.c \ + Bass/src/LVDBE_Init.c \ + Bass/src/LVDBE_Process.c \ + Bass/src/LVDBE_Tables.c \ + Bundle/src/LVM_API_Specials.c \ + Bundle/src/LVM_Buffers.c \ + Bundle/src/LVM_Init.c \ + Bundle/src/LVM_Process.c \ + Bundle/src/LVM_Tables.c \ + Bundle/src/LVM_Control.c \ + SpectrumAnalyzer/src/LVPSA_Control.c \ + SpectrumAnalyzer/src/LVPSA_Init.c \ + SpectrumAnalyzer/src/LVPSA_Memory.c \ + SpectrumAnalyzer/src/LVPSA_Process.c \ + SpectrumAnalyzer/src/LVPSA_QPD_Init.c \ + SpectrumAnalyzer/src/LVPSA_QPD_Process.c \ + SpectrumAnalyzer/src/LVPSA_Tables.c \ + Eq/src/LVEQNB_CalcCoef.c \ + Eq/src/LVEQNB_Control.c \ + Eq/src/LVEQNB_Init.c \ + Eq/src/LVEQNB_Process.c \ + Eq/src/LVEQNB_Tables.c \ + Common/src/InstAlloc.c \ + Common/src/DC_2I_D16_TRC_WRA_01.c \ + Common/src/DC_2I_D16_TRC_WRA_01_Init.c \ + Common/src/FO_2I_D16F32C15_LShx_TRC_WRA_01.c \ + Common/src/FO_2I_D16F32Css_LShx_TRC_WRA_01_Init.c \ + Common/src/FO_1I_D16F16C15_TRC_WRA_01.c \ + Common/src/FO_1I_D16F16Css_TRC_WRA_01_Init.c \ + Common/src/BP_1I_D16F32C30_TRC_WRA_01.c \ + Common/src/BP_1I_D16F16C14_TRC_WRA_01.c \ + Common/src/BP_1I_D32F32C30_TRC_WRA_02.c \ + Common/src/BP_1I_D16F16Css_TRC_WRA_01_Init.c \ + Common/src/BP_1I_D16F32Cll_TRC_WRA_01_Init.c \ + Common/src/BP_1I_D32F32Cll_TRC_WRA_02_Init.c \ + Common/src/BQ_2I_D32F32Cll_TRC_WRA_01_Init.c \ + Common/src/BQ_2I_D32F32C30_TRC_WRA_01.c \ + Common/src/BQ_2I_D16F32C15_TRC_WRA_01.c \ + Common/src/BQ_2I_D16F32C14_TRC_WRA_01.c \ + Common/src/BQ_2I_D16F32C13_TRC_WRA_01.c \ + Common/src/BQ_2I_D16F32Css_TRC_WRA_01_init.c \ + Common/src/BQ_2I_D16F16C15_TRC_WRA_01.c \ + Common/src/BQ_2I_D16F16C14_TRC_WRA_01.c \ + Common/src/BQ_2I_D16F16Css_TRC_WRA_01_Init.c \ + Common/src/BQ_1I_D16F16C15_TRC_WRA_01.c \ + Common/src/BQ_1I_D16F16Css_TRC_WRA_01_Init.c \ + Common/src/BQ_1I_D16F32C14_TRC_WRA_01.c \ + Common/src/BQ_1I_D16F32Css_TRC_WRA_01_init.c \ + Common/src/PK_2I_D32F32C30G11_TRC_WRA_01.c \ + Common/src/PK_2I_D32F32C14G11_TRC_WRA_01.c \ + Common/src/PK_2I_D32F32CssGss_TRC_WRA_01_Init.c \ + Common/src/PK_2I_D32F32CllGss_TRC_WRA_01_Init.c \ + Common/src/Int16LShiftToInt32_16x32.c \ + Common/src/From2iToMono_16.c \ + Common/src/Copy_16.c \ + Common/src/MonoTo2I_16.c \ + Common/src/LoadConst_16.c \ + Common/src/dB_to_Lin32.c \ + Common/src/Shift_Sat_v16xv16.c \ + Common/src/Abs_32.c \ + Common/src/Int32RShiftToInt16_Sat_32x16.c \ + Common/src/From2iToMono_32.c \ + Common/src/mult3s_16x16.c \ + Common/src/NonLinComp_D16.c \ + Common/src/DelayMix_16x16.c \ + Common/src/MSTo2i_Sat_16x16.c \ + Common/src/From2iToMS_16x16.c \ + Common/src/Mac3s_Sat_16x16.c \ + Common/src/Add2_Sat_16x16.c \ + Common/src/LVC_MixSoft_1St_2i_D16C31_SAT.c \ + Common/src/LVC_MixSoft_1St_D16C31_SAT.c \ + Common/src/LVC_Mixer_VarSlope_SetTimeConstant.c \ + Common/src/LVC_Mixer_SetTimeConstant.c \ + Common/src/LVC_Mixer_SetTarget.c \ + Common/src/LVC_Mixer_GetTarget.c \ + Common/src/LVC_Mixer_Init.c \ + Common/src/LVC_Core_MixHard_1St_2i_D16C31_SAT.c \ + Common/src/LVC_Core_MixSoft_1St_2i_D16C31_WRA.c \ + Common/src/LVC_Core_MixInSoft_D16C31_SAT.c \ + Common/src/LVC_Mixer_GetCurrent.c \ + Common/src/LVC_MixSoft_2St_D16C31_SAT.c \ + Common/src/LVC_Core_MixSoft_1St_D16C31_WRA.c \ + Common/src/LVC_Core_MixHard_2St_D16C31_SAT.c \ + Common/src/LVC_MixInSoft_D16C31_SAT.c \ + Common/src/AGC_MIX_VOL_2St1Mon_D32_WRA.c \ + Common/src/LVM_Timer.c \ + Common/src/LVM_Timer_Init.c + +LOCAL_MODULE:= libmusicbundle + +LOCAL_PRELINK_MODULE := false + +LOCAL_C_INCLUDES += \ + $(LOCAL_PATH)/Eq/lib \ + $(LOCAL_PATH)/Eq/src \ + $(LOCAL_PATH)/Bass/lib \ + $(LOCAL_PATH)/Bass/src \ + $(LOCAL_PATH)/Common/lib \ + $(LOCAL_PATH)/Common/src \ + $(LOCAL_PATH)/Bundle/lib \ + $(LOCAL_PATH)/Bundle/src \ + $(LOCAL_PATH)/SpectrumAnalyzer/lib \ + $(LOCAL_PATH)/SpectrumAnalyzer/src \ + $(LOCAL_PATH)/StereoWidening/src \ + $(LOCAL_PATH)/StereoWidening/lib + +include $(BUILD_STATIC_LIBRARY) diff --git a/media/libeffects/lvm/lib/Bass/lib/LVDBE.h b/media/libeffects/lvm/lib/Bass/lib/LVDBE.h new file mode 100755 index 0000000..48731df --- /dev/null +++ b/media/libeffects/lvm/lib/Bass/lib/LVDBE.h @@ -0,0 +1,472 @@ +/* + * 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: 1081 $ + $Date: 2010-07-05 11:48:44 +0200 (Mon, 05 Jul 2010) $ + +*****************************************************************************************/ + +/****************************************************************************************/ +/* */ +/* Header file for the application layer interface of Dynamic Bass Enhancement */ +/* module. */ +/* */ +/* This files includes all definitions, types, structures and function */ +/* prototypes required by the calling layer. All other types, structures and */ +/* functions are private. */ +/* */ +/****************************************************************************************/ +/* */ +/* Note: 1 */ +/* ======= */ +/* The algorithm can execute either with separate input and output buffers or with */ +/* a common buffer, i.e. the data is processed in-place. */ +/* */ +/****************************************************************************************/ +/* */ +/* Note: 2 */ +/* ======= */ +/* The Dynamic Bass Enhancement algorithm always processes data as stereo input. Mono*/ +/* format data is not supported. The data is interleaved as follows: */ +/* */ +/* Byte Offset Stereo Input Mono-In-Stereo Input */ +/* =========== ============ ==================== */ +/* 0 Left Sample #1 Mono Sample #1 */ +/* 2 Right Sample #1 Mono Sample #1 */ +/* 4 Left Sample #2 Mono Sample #2 */ +/* 6 Right Sample #2 Mono Sample #2 */ +/* . . . */ +/* . . . */ +/* */ +/* Mono format data is not supported, the calling routine must convert a Mono stream */ +/* in to Mono-In-Stereo format. */ +/* */ +/****************************************************************************************/ + +#ifndef __LVDBE_H__ +#define __LVDBE_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/****************************************************************************************/ +/* */ +/* Includes */ +/* */ +/****************************************************************************************/ + +#include "LVM_Types.h" + + +/****************************************************************************************/ +/* */ +/* Definitions */ +/* */ +/****************************************************************************************/ + +/* Memory table*/ +#define LVDBE_NR_MEMORY_REGIONS 4 /* Number of memory regions */ + +/* Bass Enhancement effect level */ +#define LVDBE_EFFECT_03DB 3 /* Effect defines for backwards compatibility */ +#define LVDBE_EFFECT_06DB 6 +#define LVDBE_EFFECT_09DB 9 +#define LVDBE_EFFECT_12DB 12 +#define LVDBE_EFFECT_15DB 15 + + +/****************************************************************************************/ +/* */ +/* Types */ +/* */ +/****************************************************************************************/ + +/* Instance handle */ +typedef void *LVDBE_Handle_t; + + +/* Operating modes */ +typedef enum +{ + LVDBE_OFF = 0, + LVDBE_ON = 1, + LVDBE_MODE_MAX = LVM_MAXINT_32 +} LVDBE_Mode_en; + + +/* High pass filter */ +typedef enum +{ + LVDBE_HPF_OFF = 0, + LVDBE_HPF_ON = 1, + LVDBE_HPF_MAX = LVM_MAXINT_32 +} LVDBE_FilterSelect_en; + + +/* Volume control */ +typedef enum +{ + LVDBE_VOLUME_OFF = 0, + LVDBE_VOLUME_ON = 1, + LVDBE_VOLUME_MAX = LVM_MAXINT_32 +} LVDBE_Volume_en; + + +/* Memory Types */ +typedef enum +{ + LVDBE_PERSISTENT = 0, + LVDBE_PERSISTENT_DATA = 1, + LVDBE_PERSISTENT_COEF = 2, + LVDBE_SCRATCH = 3, + LVDBE_MEMORY_MAX = LVM_MAXINT_32 + +} LVDBE_MemoryTypes_en; + + +/* Function return status */ +typedef enum +{ + LVDBE_SUCCESS = 0, /* Successful return from a routine */ + LVDBE_ALIGNMENTERROR = 1, /* Memory alignment error */ + LVDBE_NULLADDRESS = 2, /* NULL allocation address */ + LVDBE_TOOMANYSAMPLES = 3, /* Maximum block size exceeded */ + LVDBE_SIZEERROR = 4, /* Incorrect structure size */ + LVDBE_STATUS_MAX = LVM_MAXINT_32 +} LVDBE_ReturnStatus_en; + + +/****************************************************************************************/ +/* */ +/* Linked enumerated type and capability definitions */ +/* */ +/* The capability definitions are used to define the required capabilities at */ +/* initialisation, these are added together to give the capability word. The */ +/* enumerated type is used to select the mode through a control function at run time. */ +/* */ +/* The capability definition is related to the enumerated type value by the equation: */ +/* */ +/* Capability_value = 2^Enumerated_value */ +/* */ +/* For example, a module could be configurd at initialisation to support two sample */ +/* rates only by calling the init function with the value: */ +/* Capabilities.SampleRate = LVDBE_CAP_32000 + LVCS_DBE_44100; */ +/* */ +/* and at run time it would be passed the value LVDBE_FS_32000 through the control */ +/* function to select operation at 32kHz */ +/* */ +/****************************************************************************************/ + +/* + * Bass Enhancement centre frequency + */ +#define LVDBE_CAP_CENTRE_55Hz 1 +#define LVDBE_CAP_CENTRE_66Hz 2 +#define LVDBE_CAP_CENTRE_78Hz 4 +#define LVDBE_CAP_CENTRE_90Hz 8 + +typedef enum +{ + LVDBE_CENTRE_55HZ = 0, + LVDBE_CENTRE_66HZ = 1, + LVDBE_CENTRE_78HZ = 2, + LVDBE_CENTRE_90HZ = 3, + LVDBE_CENTRE_MAX = LVM_MAXINT_32 +} LVDBE_CentreFreq_en; + + +/* + * Supported sample rates in samples per second + */ +#define LVDBE_CAP_FS_8000 1 +#define LVDBE_CAP_FS_11025 2 +#define LVDBE_CAP_FS_12000 4 +#define LVDBE_CAP_FS_16000 8 +#define LVDBE_CAP_FS_22050 16 +#define LVDBE_CAP_FS_24000 32 +#define LVDBE_CAP_FS_32000 64 +#define LVDBE_CAP_FS_44100 128 +#define LVDBE_CAP_FS_48000 256 + +typedef enum +{ + LVDBE_FS_8000 = 0, + LVDBE_FS_11025 = 1, + LVDBE_FS_12000 = 2, + LVDBE_FS_16000 = 3, + LVDBE_FS_22050 = 4, + LVDBE_FS_24000 = 5, + LVDBE_FS_32000 = 6, + LVDBE_FS_44100 = 7, + LVDBE_FS_48000 = 8, + LVDBE_FS_MAX = LVM_MAXINT_32 +} LVDBE_Fs_en; + + +/****************************************************************************************/ +/* */ +/* Structures */ +/* */ +/****************************************************************************************/ + +/* Memory region definition */ +typedef struct +{ + LVM_UINT32 Size; /* Region size in bytes */ + LVM_UINT16 Alignment; /* Region alignment in bytes */ + LVDBE_MemoryTypes_en Type; /* Region type */ + void *pBaseAddress; /* Pointer to the region base address */ +} LVDBE_MemoryRegion_t; + + +/* Memory table containing the region definitions */ +typedef struct +{ + LVDBE_MemoryRegion_t Region[LVDBE_NR_MEMORY_REGIONS]; /* One definition for each region */ +} LVDBE_MemTab_t; + + +/* Parameter structure */ +typedef struct +{ + LVDBE_Mode_en OperatingMode; + LVDBE_Fs_en SampleRate; + LVM_INT16 EffectLevel; + LVDBE_CentreFreq_en CentreFrequency; + LVDBE_FilterSelect_en HPFSelect; + LVDBE_Volume_en VolumeControl; + LVM_INT16 VolumedB; + LVM_INT16 HeadroomdB; + +} LVDBE_Params_t; + + +/* Capability structure */ +typedef struct +{ + LVM_UINT16 SampleRate; /* Sampling rate capabilities */ + LVM_UINT16 CentreFrequency; /* Centre frequency capabilities */ + LVM_UINT16 MaxBlockSize; /* Maximum block size in sample pairs */ +} LVDBE_Capabilities_t; + + +/****************************************************************************************/ +/* */ +/* Function Prototypes */ +/* */ +/****************************************************************************************/ + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVDBE_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) the memory */ +/* base address pointers are NULL on return. */ +/* */ +/* When the function is called for free (hInstance = Instance Handle) the memory */ +/* table returns the allocated memory and base addresses used during initialisation. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance Handle */ +/* pMemoryTable Pointer to an empty memory definition table */ +/* pCapabilities Pointer to the default capabilites */ +/* */ +/* RETURNS: */ +/* LVDBE_SUCCESS Succeeded */ +/* */ +/* NOTES: */ +/* 1. This function may be interrupted by the LVDBE_Process function */ +/* */ +/****************************************************************************************/ + +LVDBE_ReturnStatus_en LVDBE_Memory(LVDBE_Handle_t hInstance, + LVDBE_MemTab_t *pMemoryTable, + LVDBE_Capabilities_t *pCapabilities); + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVDBE_Init */ +/* */ +/* DESCRIPTION: */ +/* Create and initialisation function for the Bass Enhancement module */ +/* */ +/* This function can be used to create an algorithm instance by calling with */ +/* hInstance set to 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 */ +/* LVDBE_Memory before calling this function. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance handle */ +/* pMemoryTable Pointer to the memory definition table */ +/* pCapabilities Pointer to the initialisation capabilities */ +/* */ +/* RETURNS: */ +/* LVDBE_SUCCESS Initialisation succeeded */ +/* LVDBE_ALIGNMENTERROR Instance or scratch memory on incorrect alignment */ +/* LVDBE_NULLADDRESS One or more memory has a NULL pointer */ +/* */ +/* 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 LVDBE_Process function */ +/* */ +/****************************************************************************************/ + +LVDBE_ReturnStatus_en LVDBE_Init(LVDBE_Handle_t *phInstance, + LVDBE_MemTab_t *pMemoryTable, + LVDBE_Capabilities_t *pCapabilities); + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVDBE_GetParameters */ +/* */ +/* DESCRIPTION: */ +/* Request the Bass Enhancement parameters. The current parameter set is returned */ +/* via the parameter pointer. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance handle */ +/* pParams Pointer to an empty parameter structure */ +/* */ +/* RETURNS: */ +/* LVDBE_SUCCESS Always succeeds */ +/* */ +/* NOTES: */ +/* 1. This function may be interrupted by the LVDBE_Process function */ +/* */ +/****************************************************************************************/ + +LVDBE_ReturnStatus_en LVDBE_GetParameters(LVDBE_Handle_t hInstance, + LVDBE_Params_t *pParams); + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVDBE_GetCapabilities */ +/* */ +/* DESCRIPTION: */ +/* Request the Dynamic Bass Enhancement capabilities. The initial capabilities are */ +/* returned via the pointer. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance handle */ +/* pCapabilities Pointer to an empty capabilitiy structure */ +/* */ +/* RETURNS: */ +/* LVDBE_Success Always succeeds */ +/* */ +/* NOTES: */ +/* 1. This function may be interrupted by the LVDBE_Process function */ +/* */ +/****************************************************************************************/ + +LVDBE_ReturnStatus_en LVDBE_GetCapabilities(LVDBE_Handle_t hInstance, + LVDBE_Capabilities_t *pCapabilities); + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVDBE_Control */ +/* */ +/* DESCRIPTION: */ +/* Sets or changes the Bass Enhancement parameters. Changing the parameters while the */ +/* module is processing signals may have the following side effects: */ +/* */ +/* General parameters: */ +/* =================== */ +/* OperatingMode: Changing the mode of operation may cause a change in volume */ +/* level. */ +/* */ +/* SampleRate: Changing the sample rate may cause pops and clicks. */ +/* */ +/* EffectLevel: Changing the effect level setting will have no side effects */ +/* */ +/* CentreFrequency: Changing the centre frequency may cause pops and clicks */ +/* */ +/* HPFSelect: Selecting/de-selecting the high pass filter may cause pops and */ +/* clicks */ +/* */ +/* VolumedB Changing the volume setting will have no side effects */ +/* */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance handle */ +/* pParams Pointer to a parameter structure */ +/* */ +/* RETURNS: */ +/* LVDBE_SUCCESS Always succeeds */ +/* */ +/* NOTES: */ +/* 1. This function must not be interrupted by the LVDBE_Process function */ +/* */ +/****************************************************************************************/ + +LVDBE_ReturnStatus_en LVDBE_Control(LVDBE_Handle_t hInstance, + LVDBE_Params_t *pParams); + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVDBE_Process */ +/* */ +/* DESCRIPTION: */ +/* Process function for the Bass Enhancement module. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance handle */ +/* pInData Pointer to the input data */ +/* pOutData Pointer to the output data */ +/* NumSamples Number of samples in the input buffer */ +/* */ +/* RETURNS: */ +/* LVDBE_SUCCESS Succeeded */ +/* LVDBE_TOOMANYSAMPLES NumSamples was larger than the maximum block size */ +/* */ +/* NOTES: */ +/* */ +/****************************************************************************************/ + +LVDBE_ReturnStatus_en LVDBE_Process(LVDBE_Handle_t hInstance, + const LVM_INT16 *pInData, + LVM_INT16 *pOutData, + LVM_UINT16 NumSamples); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __LVDBE_H__ */ diff --git a/media/libeffects/lvm/lib/Bass/src/LVDBE_Coeffs.h b/media/libeffects/lvm/lib/Bass/src/LVDBE_Coeffs.h new file mode 100755 index 0000000..94a7869 --- /dev/null +++ b/media/libeffects/lvm/lib/Bass/src/LVDBE_Coeffs.h @@ -0,0 +1,518 @@ +/* + * 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 __LVDBE_COEFFS_H__ +#define __LVDBE_COEFFS_H__ + + +/************************************************************************************/ +/* */ +/* General */ +/* */ +/************************************************************************************/ + +#define LVDBE_SCALESHIFT 10 /* As a power of 2 */ + + +/************************************************************************************/ +/* */ +/* High Pass Filter coefficients */ +/* */ +/************************************************************************************/ + + /* Coefficients for centre frequency 55Hz */ +#define HPF_Fs8000_Fc55_A0 1029556328 /* Floating point value 0.958849 */ +#define HPF_Fs8000_Fc55_A1 -2059112655 /* Floating point value -1.917698 */ +#define HPF_Fs8000_Fc55_A2 1029556328 /* Floating point value 0.958849 */ +#define HPF_Fs8000_Fc55_B1 -2081986375 /* Floating point value -1.939001 */ +#define HPF_Fs8000_Fc55_B2 1010183914 /* Floating point value 0.940807 */ +#define HPF_Fs11025_Fc55_A0 1038210831 /* Floating point value 0.966909 */ +#define HPF_Fs11025_Fc55_A1 -2076421662 /* Floating point value -1.933818 */ +#define HPF_Fs11025_Fc55_A2 1038210831 /* Floating point value 0.966909 */ +#define HPF_Fs11025_Fc55_B1 -2099950710 /* Floating point value -1.955732 */ +#define HPF_Fs11025_Fc55_B2 1027238450 /* Floating point value 0.956690 */ +#define HPF_Fs12000_Fc55_A0 1040079943 /* Floating point value 0.968650 */ +#define HPF_Fs12000_Fc55_A1 -2080159885 /* Floating point value -1.937300 */ +#define HPF_Fs12000_Fc55_A2 1040079943 /* Floating point value 0.968650 */ +#define HPF_Fs12000_Fc55_B1 -2103811702 /* Floating point value -1.959327 */ +#define HPF_Fs12000_Fc55_B2 1030940477 /* Floating point value 0.960138 */ +#define HPF_Fs16000_Fc55_A0 1045381988 /* Floating point value 0.973588 */ +#define HPF_Fs16000_Fc55_A1 -2090763976 /* Floating point value -1.947176 */ +#define HPF_Fs16000_Fc55_A2 1045381988 /* Floating point value 0.973588 */ +#define HPF_Fs16000_Fc55_B1 -2114727793 /* Floating point value -1.969494 */ +#define HPF_Fs16000_Fc55_B2 1041478147 /* Floating point value 0.969952 */ +#define HPF_Fs22050_Fc55_A0 1049766523 /* Floating point value 0.977671 */ +#define HPF_Fs22050_Fc55_A1 -2099533046 /* Floating point value -1.955343 */ +#define HPF_Fs22050_Fc55_A2 1049766523 /* Floating point value 0.977671 */ +#define HPF_Fs22050_Fc55_B1 -2123714381 /* Floating point value -1.977863 */ +#define HPF_Fs22050_Fc55_B2 1050232780 /* Floating point value 0.978105 */ +#define HPF_Fs24000_Fc55_A0 1050711051 /* Floating point value 0.978551 */ +#define HPF_Fs24000_Fc55_A1 -2101422103 /* Floating point value -1.957102 */ +#define HPF_Fs24000_Fc55_A2 1050711051 /* Floating point value 0.978551 */ +#define HPF_Fs24000_Fc55_B1 -2125645498 /* Floating point value -1.979662 */ +#define HPF_Fs24000_Fc55_B2 1052123526 /* Floating point value 0.979866 */ +#define HPF_Fs32000_Fc55_A0 1053385759 /* Floating point value 0.981042 */ +#define HPF_Fs32000_Fc55_A1 -2106771519 /* Floating point value -1.962084 */ +#define HPF_Fs32000_Fc55_A2 1053385759 /* Floating point value 0.981042 */ +#define HPF_Fs32000_Fc55_B1 -2131104794 /* Floating point value -1.984746 */ +#define HPF_Fs32000_Fc55_B2 1057486949 /* Floating point value 0.984861 */ +#define HPF_Fs44100_Fc55_A0 1055592498 /* Floating point value 0.983097 */ +#define HPF_Fs44100_Fc55_A1 -2111184995 /* Floating point value -1.966194 */ +#define HPF_Fs44100_Fc55_A2 1055592498 /* Floating point value 0.983097 */ +#define HPF_Fs44100_Fc55_B1 -2135598658 /* Floating point value -1.988931 */ +#define HPF_Fs44100_Fc55_B2 1061922249 /* Floating point value 0.988992 */ +#define HPF_Fs48000_Fc55_A0 1056067276 /* Floating point value 0.983539 */ +#define HPF_Fs48000_Fc55_A1 -2112134551 /* Floating point value -1.967079 */ +#define HPF_Fs48000_Fc55_A2 1056067276 /* Floating point value 0.983539 */ +#define HPF_Fs48000_Fc55_B1 -2136564296 /* Floating point value -1.989831 */ +#define HPF_Fs48000_Fc55_B2 1062877714 /* Floating point value 0.989882 */ + + /* Coefficients for centre frequency 66Hz */ +#define HPF_Fs8000_Fc66_A0 1023293271 /* Floating point value 0.953016 */ +#define HPF_Fs8000_Fc66_A1 -2046586542 /* Floating point value -1.906032 */ +#define HPF_Fs8000_Fc66_A2 1023293271 /* Floating point value 0.953016 */ +#define HPF_Fs8000_Fc66_B1 -2068896860 /* Floating point value -1.926810 */ +#define HPF_Fs8000_Fc66_B2 997931110 /* Floating point value 0.929396 */ +#define HPF_Fs11025_Fc66_A0 1033624228 /* Floating point value 0.962638 */ +#define HPF_Fs11025_Fc66_A1 -2067248455 /* Floating point value -1.925275 */ +#define HPF_Fs11025_Fc66_A2 1033624228 /* Floating point value 0.962638 */ +#define HPF_Fs11025_Fc66_B1 -2090448000 /* Floating point value -1.946881 */ +#define HPF_Fs11025_Fc66_B2 1018182305 /* Floating point value 0.948256 */ +#define HPF_Fs12000_Fc66_A0 1035857662 /* Floating point value 0.964718 */ +#define HPF_Fs12000_Fc66_A1 -2071715325 /* Floating point value -1.929435 */ +#define HPF_Fs12000_Fc66_A2 1035857662 /* Floating point value 0.964718 */ +#define HPF_Fs12000_Fc66_B1 -2095080333 /* Floating point value -1.951196 */ +#define HPF_Fs12000_Fc66_B2 1022587158 /* Floating point value 0.952359 */ +#define HPF_Fs16000_Fc66_A0 1042197528 /* Floating point value 0.970622 */ +#define HPF_Fs16000_Fc66_A1 -2084395056 /* Floating point value -1.941244 */ +#define HPF_Fs16000_Fc66_A2 1042197528 /* Floating point value 0.970622 */ +#define HPF_Fs16000_Fc66_B1 -2108177912 /* Floating point value -1.963394 */ +#define HPF_Fs16000_Fc66_B2 1035142690 /* Floating point value 0.964052 */ +#define HPF_Fs22050_Fc66_A0 1047445145 /* Floating point value 0.975509 */ +#define HPF_Fs22050_Fc66_A1 -2094890289 /* Floating point value -1.951019 */ +#define HPF_Fs22050_Fc66_A2 1047445145 /* Floating point value 0.975509 */ +#define HPF_Fs22050_Fc66_B1 -2118961025 /* Floating point value -1.973436 */ +#define HPF_Fs22050_Fc66_B2 1045593102 /* Floating point value 0.973784 */ +#define HPF_Fs24000_Fc66_A0 1048576175 /* Floating point value 0.976563 */ +#define HPF_Fs24000_Fc66_A1 -2097152349 /* Floating point value -1.953125 */ +#define HPF_Fs24000_Fc66_A2 1048576175 /* Floating point value 0.976563 */ +#define HPF_Fs24000_Fc66_B1 -2121278255 /* Floating point value -1.975594 */ +#define HPF_Fs24000_Fc66_B2 1047852379 /* Floating point value 0.975889 */ +#define HPF_Fs32000_Fc66_A0 1051780119 /* Floating point value 0.979547 */ +#define HPF_Fs32000_Fc66_A1 -2103560237 /* Floating point value -1.959093 */ +#define HPF_Fs32000_Fc66_A2 1051780119 /* Floating point value 0.979547 */ +#define HPF_Fs32000_Fc66_B1 -2127829187 /* Floating point value -1.981695 */ +#define HPF_Fs32000_Fc66_B2 1054265623 /* Floating point value 0.981861 */ +#define HPF_Fs44100_Fc66_A0 1054424722 /* Floating point value 0.982010 */ +#define HPF_Fs44100_Fc66_A1 -2108849444 /* Floating point value -1.964019 */ +#define HPF_Fs44100_Fc66_A2 1054424722 /* Floating point value 0.982010 */ +#define HPF_Fs44100_Fc66_B1 -2133221723 /* Floating point value -1.986718 */ +#define HPF_Fs44100_Fc66_B2 1059573993 /* Floating point value 0.986805 */ +#define HPF_Fs48000_Fc66_A0 1054993851 /* Floating point value 0.982540 */ +#define HPF_Fs48000_Fc66_A1 -2109987702 /* Floating point value -1.965079 */ +#define HPF_Fs48000_Fc66_A2 1054993851 /* Floating point value 0.982540 */ +#define HPF_Fs48000_Fc66_B1 -2134380475 /* Floating point value -1.987797 */ +#define HPF_Fs48000_Fc66_B2 1060718118 /* Floating point value 0.987871 */ + + /* Coefficients for centre frequency 78Hz */ +#define HPF_Fs8000_Fc78_A0 1016504203 /* Floating point value 0.946693 */ +#define HPF_Fs8000_Fc78_A1 -2033008405 /* Floating point value -1.893387 */ +#define HPF_Fs8000_Fc78_A2 1016504203 /* Floating point value 0.946693 */ +#define HPF_Fs8000_Fc78_B1 -2054623390 /* Floating point value -1.913517 */ +#define HPF_Fs8000_Fc78_B2 984733853 /* Floating point value 0.917105 */ +#define HPF_Fs11025_Fc78_A0 1028643741 /* Floating point value 0.957999 */ +#define HPF_Fs11025_Fc78_A1 -2057287482 /* Floating point value -1.915998 */ +#define HPF_Fs11025_Fc78_A2 1028643741 /* Floating point value 0.957999 */ +#define HPF_Fs11025_Fc78_B1 -2080083769 /* Floating point value -1.937229 */ +#define HPF_Fs11025_Fc78_B2 1008393904 /* Floating point value 0.939140 */ +#define HPF_Fs12000_Fc78_A0 1031271067 /* Floating point value 0.960446 */ +#define HPF_Fs12000_Fc78_A1 -2062542133 /* Floating point value -1.920892 */ +#define HPF_Fs12000_Fc78_A2 1031271067 /* Floating point value 0.960446 */ +#define HPF_Fs12000_Fc78_B1 -2085557048 /* Floating point value -1.942326 */ +#define HPF_Fs12000_Fc78_B2 1013551620 /* Floating point value 0.943944 */ +#define HPF_Fs16000_Fc78_A0 1038734628 /* Floating point value 0.967397 */ +#define HPF_Fs16000_Fc78_A1 -2077469256 /* Floating point value -1.934794 */ +#define HPF_Fs16000_Fc78_A2 1038734628 /* Floating point value 0.967397 */ +#define HPF_Fs16000_Fc78_B1 -2101033380 /* Floating point value -1.956740 */ +#define HPF_Fs16000_Fc78_B2 1028275228 /* Floating point value 0.957656 */ +#define HPF_Fs22050_Fc78_A0 1044918584 /* Floating point value 0.973156 */ +#define HPF_Fs22050_Fc78_A1 -2089837169 /* Floating point value -1.946313 */ +#define HPF_Fs22050_Fc78_A2 1044918584 /* Floating point value 0.973156 */ +#define HPF_Fs22050_Fc78_B1 -2113775854 /* Floating point value -1.968607 */ +#define HPF_Fs22050_Fc78_B2 1040555007 /* Floating point value 0.969092 */ +#define HPF_Fs24000_Fc78_A0 1046252164 /* Floating point value 0.974398 */ +#define HPF_Fs24000_Fc78_A1 -2092504328 /* Floating point value -1.948797 */ +#define HPF_Fs24000_Fc78_A2 1046252164 /* Floating point value 0.974398 */ +#define HPF_Fs24000_Fc78_B1 -2116514229 /* Floating point value -1.971157 */ +#define HPF_Fs24000_Fc78_B2 1043212719 /* Floating point value 0.971568 */ +#define HPF_Fs32000_Fc78_A0 1050031301 /* Floating point value 0.977918 */ +#define HPF_Fs32000_Fc78_A1 -2100062603 /* Floating point value -1.955836 */ +#define HPF_Fs32000_Fc78_A2 1050031301 /* Floating point value 0.977918 */ +#define HPF_Fs32000_Fc78_B1 -2124255900 /* Floating point value -1.978367 */ +#define HPF_Fs32000_Fc78_B2 1050762639 /* Floating point value 0.978599 */ +#define HPF_Fs44100_Fc78_A0 1053152258 /* Floating point value 0.980824 */ +#define HPF_Fs44100_Fc78_A1 -2106304516 /* Floating point value -1.961649 */ +#define HPF_Fs44100_Fc78_A2 1053152258 /* Floating point value 0.980824 */ +#define HPF_Fs44100_Fc78_B1 -2130628742 /* Floating point value -1.984303 */ +#define HPF_Fs44100_Fc78_B2 1057018180 /* Floating point value 0.984425 */ +#define HPF_Fs48000_Fc78_A0 1053824087 /* Floating point value 0.981450 */ +#define HPF_Fs48000_Fc78_A1 -2107648173 /* Floating point value -1.962900 */ +#define HPF_Fs48000_Fc78_A2 1053824087 /* Floating point value 0.981450 */ +#define HPF_Fs48000_Fc78_B1 -2131998154 /* Floating point value -1.985578 */ +#define HPF_Fs48000_Fc78_B2 1058367200 /* Floating point value 0.985681 */ + + /* Coefficients for centre frequency 90Hz */ +#define HPF_Fs8000_Fc90_A0 1009760053 /* Floating point value 0.940412 */ +#define HPF_Fs8000_Fc90_A1 -2019520105 /* Floating point value -1.880825 */ +#define HPF_Fs8000_Fc90_A2 1009760053 /* Floating point value 0.940412 */ +#define HPF_Fs8000_Fc90_B1 -2040357139 /* Floating point value -1.900231 */ +#define HPF_Fs8000_Fc90_B2 971711129 /* Floating point value 0.904977 */ +#define HPF_Fs11025_Fc90_A0 1023687217 /* Floating point value 0.953383 */ +#define HPF_Fs11025_Fc90_A1 -2047374434 /* Floating point value -1.906766 */ +#define HPF_Fs11025_Fc90_A2 1023687217 /* Floating point value 0.953383 */ +#define HPF_Fs11025_Fc90_B1 -2069722397 /* Floating point value -1.927579 */ +#define HPF_Fs11025_Fc90_B2 998699604 /* Floating point value 0.930111 */ +#define HPF_Fs12000_Fc90_A0 1026704754 /* Floating point value 0.956193 */ +#define HPF_Fs12000_Fc90_A1 -2053409508 /* Floating point value -1.912387 */ +#define HPF_Fs12000_Fc90_A2 1026704754 /* Floating point value 0.956193 */ +#define HPF_Fs12000_Fc90_B1 -2076035996 /* Floating point value -1.933459 */ +#define HPF_Fs12000_Fc90_B2 1004595918 /* Floating point value 0.935603 */ +#define HPF_Fs16000_Fc90_A0 1035283225 /* Floating point value 0.964183 */ +#define HPF_Fs16000_Fc90_A1 -2070566451 /* Floating point value -1.928365 */ +#define HPF_Fs16000_Fc90_A2 1035283225 /* Floating point value 0.964183 */ +#define HPF_Fs16000_Fc90_B1 -2093889811 /* Floating point value -1.950087 */ +#define HPF_Fs16000_Fc90_B2 1021453326 /* Floating point value 0.951303 */ +#define HPF_Fs22050_Fc90_A0 1042398116 /* Floating point value 0.970809 */ +#define HPF_Fs22050_Fc90_A1 -2084796232 /* Floating point value -1.941618 */ +#define HPF_Fs22050_Fc90_A2 1042398116 /* Floating point value 0.970809 */ +#define HPF_Fs22050_Fc90_B1 -2108591057 /* Floating point value -1.963778 */ +#define HPF_Fs22050_Fc90_B2 1035541188 /* Floating point value 0.964423 */ +#define HPF_Fs24000_Fc90_A0 1043933302 /* Floating point value 0.972239 */ +#define HPF_Fs24000_Fc90_A1 -2087866604 /* Floating point value -1.944477 */ +#define HPF_Fs24000_Fc90_A2 1043933302 /* Floating point value 0.972239 */ +#define HPF_Fs24000_Fc90_B1 -2111750495 /* Floating point value -1.966721 */ +#define HPF_Fs24000_Fc90_B2 1038593601 /* Floating point value 0.967266 */ +#define HPF_Fs32000_Fc90_A0 1048285391 /* Floating point value 0.976292 */ +#define HPF_Fs32000_Fc90_A1 -2096570783 /* Floating point value -1.952584 */ +#define HPF_Fs32000_Fc90_A2 1048285391 /* Floating point value 0.976292 */ +#define HPF_Fs32000_Fc90_B1 -2120682737 /* Floating point value -1.975040 */ +#define HPF_Fs32000_Fc90_B2 1047271295 /* Floating point value 0.975347 */ +#define HPF_Fs44100_Fc90_A0 1051881330 /* Floating point value 0.979641 */ +#define HPF_Fs44100_Fc90_A1 -2103762660 /* Floating point value -1.959282 */ +#define HPF_Fs44100_Fc90_A2 1051881330 /* Floating point value 0.979641 */ +#define HPF_Fs44100_Fc90_B1 -2128035809 /* Floating point value -1.981888 */ +#define HPF_Fs44100_Fc90_B2 1054468533 /* Floating point value 0.982050 */ +#define HPF_Fs48000_Fc90_A0 1052655619 /* Floating point value 0.980362 */ +#define HPF_Fs48000_Fc90_A1 -2105311238 /* Floating point value -1.960724 */ +#define HPF_Fs48000_Fc90_A2 1052655619 /* Floating point value 0.980362 */ +#define HPF_Fs48000_Fc90_B1 -2129615871 /* Floating point value -1.983359 */ +#define HPF_Fs48000_Fc90_B2 1056021492 /* Floating point value 0.983497 */ + + +/************************************************************************************/ +/* */ +/* Band Pass Filter coefficients */ +/* */ +/************************************************************************************/ + + /* Coefficients for centre frequency 55Hz */ +#define BPF_Fs8000_Fc55_A0 9875247 /* Floating point value 0.009197 */ +#define BPF_Fs8000_Fc55_A1 0 /* Floating point value 0.000000 */ +#define BPF_Fs8000_Fc55_A2 -9875247 /* Floating point value -0.009197 */ +#define BPF_Fs8000_Fc55_B1 -2125519830 /* Floating point value -1.979545 */ +#define BPF_Fs8000_Fc55_B2 1053762629 /* Floating point value 0.981393 */ +#define BPF_Fs11025_Fc55_A0 7183952 /* Floating point value 0.006691 */ +#define BPF_Fs11025_Fc55_A1 0 /* Floating point value 0.000000 */ +#define BPF_Fs11025_Fc55_A2 -7183952 /* Floating point value -0.006691 */ +#define BPF_Fs11025_Fc55_B1 -2131901658 /* Floating point value -1.985488 */ +#define BPF_Fs11025_Fc55_B2 1059207548 /* Floating point value 0.986464 */ +#define BPF_Fs12000_Fc55_A0 6603871 /* Floating point value 0.006150 */ +#define BPF_Fs12000_Fc55_A1 0 /* Floating point value 0.000000 */ +#define BPF_Fs12000_Fc55_A2 -6603871 /* Floating point value -0.006150 */ +#define BPF_Fs12000_Fc55_B1 -2133238092 /* Floating point value -1.986733 */ +#define BPF_Fs12000_Fc55_B2 1060381143 /* Floating point value 0.987557 */ +#define BPF_Fs16000_Fc55_A0 4960591 /* Floating point value 0.004620 */ +#define BPF_Fs16000_Fc55_A1 0 /* Floating point value 0.000000 */ +#define BPF_Fs16000_Fc55_A2 -4960591 /* Floating point value -0.004620 */ +#define BPF_Fs16000_Fc55_B1 -2136949052 /* Floating point value -1.990189 */ +#define BPF_Fs16000_Fc55_B2 1063705760 /* Floating point value 0.990653 */ +#define BPF_Fs22050_Fc55_A0 3604131 /* Floating point value 0.003357 */ +#define BPF_Fs22050_Fc55_A1 0 /* Floating point value 0.000000 */ +#define BPF_Fs22050_Fc55_A2 -3604131 /* Floating point value -0.003357 */ +#define BPF_Fs22050_Fc55_B1 -2139929085 /* Floating point value -1.992964 */ +#define BPF_Fs22050_Fc55_B2 1066450095 /* Floating point value 0.993209 */ +#define BPF_Fs24000_Fc55_A0 3312207 /* Floating point value 0.003085 */ +#define BPF_Fs24000_Fc55_A1 0 /* Floating point value 0.000000 */ +#define BPF_Fs24000_Fc55_A2 -3312207 /* Floating point value -0.003085 */ +#define BPF_Fs24000_Fc55_B1 -2140560606 /* Floating point value -1.993552 */ +#define BPF_Fs24000_Fc55_B2 1067040703 /* Floating point value 0.993759 */ +#define BPF_Fs32000_Fc55_A0 2486091 /* Floating point value 0.002315 */ +#define BPF_Fs32000_Fc55_A1 0 /* Floating point value 0.000000 */ +#define BPF_Fs32000_Fc55_A2 -2486091 /* Floating point value -0.002315 */ +#define BPF_Fs32000_Fc55_B1 -2142328962 /* Floating point value -1.995199 */ +#define BPF_Fs32000_Fc55_B2 1068712067 /* Floating point value 0.995316 */ +#define BPF_Fs44100_Fc55_A0 1805125 /* Floating point value 0.001681 */ +#define BPF_Fs44100_Fc55_A1 0 /* Floating point value 0.000000 */ +#define BPF_Fs44100_Fc55_A2 -1805125 /* Floating point value -0.001681 */ +#define BPF_Fs44100_Fc55_B1 -2143765772 /* Floating point value -1.996537 */ +#define BPF_Fs44100_Fc55_B2 1070089770 /* Floating point value 0.996599 */ +#define BPF_Fs48000_Fc55_A0 1658687 /* Floating point value 0.001545 */ +#define BPF_Fs48000_Fc55_A1 0 /* Floating point value 0.000000 */ +#define BPF_Fs48000_Fc55_A2 -1658687 /* Floating point value -0.001545 */ +#define BPF_Fs48000_Fc55_B1 -2144072292 /* Floating point value -1.996823 */ +#define BPF_Fs48000_Fc55_B2 1070386036 /* Floating point value 0.996875 */ + + /* Coefficients for centre frequency 66Hz */ +#define BPF_Fs8000_Fc66_A0 13580189 /* Floating point value 0.012648 */ +#define BPF_Fs8000_Fc66_A1 0 /* Floating point value 0.000000 */ +#define BPF_Fs8000_Fc66_A2 -13580189 /* Floating point value -0.012648 */ +#define BPF_Fs8000_Fc66_B1 -2117161175 /* Floating point value -1.971760 */ +#define BPF_Fs8000_Fc66_B2 1046266945 /* Floating point value 0.974412 */ +#define BPF_Fs11025_Fc66_A0 9888559 /* Floating point value 0.009209 */ +#define BPF_Fs11025_Fc66_A1 0 /* Floating point value 0.000000 */ +#define BPF_Fs11025_Fc66_A2 -9888559 /* Floating point value -0.009209 */ +#define BPF_Fs11025_Fc66_B1 -2125972738 /* Floating point value -1.979966 */ +#define BPF_Fs11025_Fc66_B2 1053735698 /* Floating point value 0.981368 */ +#define BPF_Fs12000_Fc66_A0 9091954 /* Floating point value 0.008468 */ +#define BPF_Fs12000_Fc66_A1 0 /* Floating point value 0.000000 */ +#define BPF_Fs12000_Fc66_A2 -9091954 /* Floating point value -0.008468 */ +#define BPF_Fs12000_Fc66_B1 -2127818004 /* Floating point value -1.981685 */ +#define BPF_Fs12000_Fc66_B2 1055347356 /* Floating point value 0.982869 */ +#define BPF_Fs16000_Fc66_A0 6833525 /* Floating point value 0.006364 */ +#define BPF_Fs16000_Fc66_A1 0 /* Floating point value 0.000000 */ +#define BPF_Fs16000_Fc66_A2 -6833525 /* Floating point value -0.006364 */ +#define BPF_Fs16000_Fc66_B1 -2132941739 /* Floating point value -1.986457 */ +#define BPF_Fs16000_Fc66_B2 1059916517 /* Floating point value 0.987124 */ +#define BPF_Fs22050_Fc66_A0 4967309 /* Floating point value 0.004626 */ +#define BPF_Fs22050_Fc66_A1 0 /* Floating point value 0.000000 */ +#define BPF_Fs22050_Fc66_A2 -4967309 /* Floating point value -0.004626 */ +#define BPF_Fs22050_Fc66_B1 -2137056003 /* Floating point value -1.990288 */ +#define BPF_Fs22050_Fc66_B2 1063692170 /* Floating point value 0.990641 */ +#define BPF_Fs24000_Fc66_A0 4565445 /* Floating point value 0.004252 */ +#define BPF_Fs24000_Fc66_A1 0 /* Floating point value 0.000000 */ +#define BPF_Fs24000_Fc66_A2 -4565445 /* Floating point value -0.004252 */ +#define BPF_Fs24000_Fc66_B1 -2137927842 /* Floating point value -1.991100 */ +#define BPF_Fs24000_Fc66_B2 1064505202 /* Floating point value 0.991398 */ +#define BPF_Fs32000_Fc66_A0 3427761 /* Floating point value 0.003192 */ +#define BPF_Fs32000_Fc66_A1 0 /* Floating point value 0.000000 */ +#define BPF_Fs32000_Fc66_A2 -3427761 /* Floating point value -0.003192 */ +#define BPF_Fs32000_Fc66_B1 -2140369007 /* Floating point value -1.993374 */ +#define BPF_Fs32000_Fc66_B2 1066806920 /* Floating point value 0.993541 */ +#define BPF_Fs44100_Fc66_A0 2489466 /* Floating point value 0.002318 */ +#define BPF_Fs44100_Fc66_A1 0 /* Floating point value 0.000000 */ +#define BPF_Fs44100_Fc66_A2 -2489466 /* Floating point value -0.002318 */ +#define BPF_Fs44100_Fc66_B1 -2142352342 /* Floating point value -1.995221 */ +#define BPF_Fs44100_Fc66_B2 1068705240 /* Floating point value 0.995309 */ +#define BPF_Fs48000_Fc66_A0 2287632 /* Floating point value 0.002131 */ +#define BPF_Fs48000_Fc66_A1 0 /* Floating point value 0.000000 */ +#define BPF_Fs48000_Fc66_A2 -2287632 /* Floating point value -0.002131 */ +#define BPF_Fs48000_Fc66_B1 -2142775436 /* Floating point value -1.995615 */ +#define BPF_Fs48000_Fc66_B2 1069113581 /* Floating point value 0.995690 */ + + /* Coefficients for centre frequency 78Hz */ +#define BPF_Fs8000_Fc78_A0 19941180 /* Floating point value 0.018572 */ +#define BPF_Fs8000_Fc78_A1 0 /* Floating point value 0.000000 */ +#define BPF_Fs8000_Fc78_A2 -19941180 /* Floating point value -0.018572 */ +#define BPF_Fs8000_Fc78_B1 -2103186749 /* Floating point value -1.958745 */ +#define BPF_Fs8000_Fc78_B2 1033397648 /* Floating point value 0.962427 */ +#define BPF_Fs11025_Fc78_A0 14543934 /* Floating point value 0.013545 */ +#define BPF_Fs11025_Fc78_A1 0 /* Floating point value 0.000000 */ +#define BPF_Fs11025_Fc78_A2 -14543934 /* Floating point value -0.013545 */ +#define BPF_Fs11025_Fc78_B1 -2115966638 /* Floating point value -1.970647 */ +#define BPF_Fs11025_Fc78_B2 1044317135 /* Floating point value 0.972596 */ +#define BPF_Fs12000_Fc78_A0 13376999 /* Floating point value 0.012458 */ +#define BPF_Fs12000_Fc78_A1 0 /* Floating point value 0.000000 */ +#define BPF_Fs12000_Fc78_A2 -13376999 /* Floating point value -0.012458 */ +#define BPF_Fs12000_Fc78_B1 -2118651708 /* Floating point value -1.973148 */ +#define BPF_Fs12000_Fc78_B2 1046678029 /* Floating point value 0.974795 */ +#define BPF_Fs16000_Fc78_A0 10064222 /* Floating point value 0.009373 */ +#define BPF_Fs16000_Fc78_A1 0 /* Floating point value 0.000000 */ +#define BPF_Fs16000_Fc78_A2 -10064222 /* Floating point value -0.009373 */ +#define BPF_Fs16000_Fc78_B1 -2126124342 /* Floating point value -1.980108 */ +#define BPF_Fs16000_Fc78_B2 1053380304 /* Floating point value 0.981037 */ +#define BPF_Fs22050_Fc78_A0 7321780 /* Floating point value 0.006819 */ +#define BPF_Fs22050_Fc78_A1 0 /* Floating point value 0.000000 */ +#define BPF_Fs22050_Fc78_A2 -7321780 /* Floating point value -0.006819 */ +#define BPF_Fs22050_Fc78_B1 -2132143771 /* Floating point value -1.985714 */ +#define BPF_Fs22050_Fc78_B2 1058928700 /* Floating point value 0.986204 */ +#define BPF_Fs24000_Fc78_A0 6730640 /* Floating point value 0.006268 */ +#define BPF_Fs24000_Fc78_A1 0 /* Floating point value 0.000000 */ +#define BPF_Fs24000_Fc78_A2 -6730640 /* Floating point value -0.006268 */ +#define BPF_Fs24000_Fc78_B1 -2133421607 /* Floating point value -1.986904 */ +#define BPF_Fs24000_Fc78_B2 1060124669 /* Floating point value 0.987318 */ +#define BPF_Fs32000_Fc78_A0 5055965 /* Floating point value 0.004709 */ +#define BPF_Fs32000_Fc78_A1 0 /* Floating point value 0.000000 */ +#define BPF_Fs32000_Fc78_A2 -5055965 /* Floating point value -0.004709 */ +#define BPF_Fs32000_Fc78_B1 -2137003977 /* Floating point value -1.990240 */ +#define BPF_Fs32000_Fc78_B2 1063512802 /* Floating point value 0.990473 */ +#define BPF_Fs44100_Fc78_A0 3673516 /* Floating point value 0.003421 */ +#define BPF_Fs44100_Fc78_A1 0 /* Floating point value 0.000000 */ +#define BPF_Fs44100_Fc78_A2 -3673516 /* Floating point value -0.003421 */ +#define BPF_Fs44100_Fc78_B1 -2139919394 /* Floating point value -1.992955 */ +#define BPF_Fs44100_Fc78_B2 1066309718 /* Floating point value 0.993078 */ +#define BPF_Fs48000_Fc78_A0 3375990 /* Floating point value 0.003144 */ +#define BPF_Fs48000_Fc78_A1 0 /* Floating point value 0.000000 */ +#define BPF_Fs48000_Fc78_A2 -3375990 /* Floating point value -0.003144 */ +#define BPF_Fs48000_Fc78_B1 -2140541906 /* Floating point value -1.993535 */ +#define BPF_Fs48000_Fc78_B2 1066911660 /* Floating point value 0.993639 */ + + /* Coefficients for centre frequency 90Hz */ +#define BPF_Fs8000_Fc90_A0 24438548 /* Floating point value 0.022760 */ +#define BPF_Fs8000_Fc90_A1 0 /* Floating point value 0.000000 */ +#define BPF_Fs8000_Fc90_A2 -24438548 /* Floating point value -0.022760 */ +#define BPF_Fs8000_Fc90_B1 -2092801347 /* Floating point value -1.949073 */ +#define BPF_Fs8000_Fc90_B2 1024298757 /* Floating point value 0.953953 */ +#define BPF_Fs11025_Fc90_A0 17844385 /* Floating point value 0.016619 */ +#define BPF_Fs11025_Fc90_A1 0 /* Floating point value 0.000000 */ +#define BPF_Fs11025_Fc90_A2 -17844385 /* Floating point value -0.016619 */ +#define BPF_Fs11025_Fc90_B1 -2108604921 /* Floating point value -1.963791 */ +#define BPF_Fs11025_Fc90_B2 1037639797 /* Floating point value 0.966377 */ +#define BPF_Fs12000_Fc90_A0 16416707 /* Floating point value 0.015289 */ +#define BPF_Fs12000_Fc90_A1 0 /* Floating point value 0.000000 */ +#define BPF_Fs12000_Fc90_A2 -16416707 /* Floating point value -0.015289 */ +#define BPF_Fs12000_Fc90_B1 -2111922936 /* Floating point value -1.966882 */ +#define BPF_Fs12000_Fc90_B2 1040528216 /* Floating point value 0.969067 */ +#define BPF_Fs16000_Fc90_A0 12359883 /* Floating point value 0.011511 */ +#define BPF_Fs16000_Fc90_A1 0 /* Floating point value 0.000000 */ +#define BPF_Fs16000_Fc90_A2 -12359883 /* Floating point value -0.011511 */ +#define BPF_Fs16000_Fc90_B1 -2121152162 /* Floating point value -1.975477 */ +#define BPF_Fs16000_Fc90_B2 1048735817 /* Floating point value 0.976711 */ +#define BPF_Fs22050_Fc90_A0 8997173 /* Floating point value 0.008379 */ +#define BPF_Fs22050_Fc90_A1 0 /* Floating point value 0.000000 */ +#define BPF_Fs22050_Fc90_A2 -8997173 /* Floating point value -0.008379 */ +#define BPF_Fs22050_Fc90_B1 -2128580762 /* Floating point value -1.982395 */ +#define BPF_Fs22050_Fc90_B2 1055539113 /* Floating point value 0.983047 */ +#define BPF_Fs24000_Fc90_A0 8271818 /* Floating point value 0.007704 */ +#define BPF_Fs24000_Fc90_A1 0 /* Floating point value 0.000000 */ +#define BPF_Fs24000_Fc90_A2 -8271818 /* Floating point value -0.007704 */ +#define BPF_Fs24000_Fc90_B1 -2130157013 /* Floating point value -1.983863 */ +#define BPF_Fs24000_Fc90_B2 1057006621 /* Floating point value 0.984414 */ +#define BPF_Fs32000_Fc90_A0 6215918 /* Floating point value 0.005789 */ +#define BPF_Fs32000_Fc90_A1 0 /* Floating point value 0.000000 */ +#define BPF_Fs32000_Fc90_A2 -6215918 /* Floating point value -0.005789 */ +#define BPF_Fs32000_Fc90_B1 -2134574521 /* Floating point value -1.987977 */ +#define BPF_Fs32000_Fc90_B2 1061166033 /* Floating point value 0.988288 */ +#define BPF_Fs44100_Fc90_A0 4517651 /* Floating point value 0.004207 */ +#define BPF_Fs44100_Fc90_A1 0 /* Floating point value 0.000000 */ +#define BPF_Fs44100_Fc90_A2 -4517651 /* Floating point value -0.004207 */ +#define BPF_Fs44100_Fc90_B1 -2138167926 /* Floating point value -1.991324 */ +#define BPF_Fs44100_Fc90_B2 1064601898 /* Floating point value 0.991488 */ +#define BPF_Fs48000_Fc90_A0 4152024 /* Floating point value 0.003867 */ +#define BPF_Fs48000_Fc90_A1 0 /* Floating point value 0.000000 */ +#define BPF_Fs48000_Fc90_A2 -4152024 /* Floating point value -0.003867 */ +#define BPF_Fs48000_Fc90_B1 -2138935002 /* Floating point value -1.992038 */ +#define BPF_Fs48000_Fc90_B2 1065341620 /* Floating point value 0.992177 */ + + +/************************************************************************************/ +/* */ +/* Automatic Gain Control time constants and gain settings */ +/* */ +/************************************************************************************/ + +/* AGC Time constants */ +#define AGC_ATTACK_Fs8000 27571 /* Floating point value 0.841395 */ +#define AGC_ATTACK_Fs11025 28909 /* Floating point value 0.882223 */ +#define AGC_ATTACK_Fs12000 29205 /* Floating point value 0.891251 */ +#define AGC_ATTACK_Fs16000 30057 /* Floating point value 0.917276 */ +#define AGC_ATTACK_Fs22050 30778 /* Floating point value 0.939267 */ +#define AGC_ATTACK_Fs24000 30935 /* Floating point value 0.944061 */ +#define AGC_ATTACK_Fs32000 31383 /* Floating point value 0.957745 */ +#define AGC_ATTACK_Fs44100 31757 /* Floating point value 0.969158 */ +#define AGC_ATTACK_Fs48000 31838 /* Floating point value 0.971628 */ +#define DECAY_SHIFT 10 /* As a power of 2 */ +#define AGC_DECAY_Fs8000 44 /* Floating point value 0.000042 */ +#define AGC_DECAY_Fs11025 32 /* Floating point value 0.000030 */ +#define AGC_DECAY_Fs12000 29 /* Floating point value 0.000028 */ +#define AGC_DECAY_Fs16000 22 /* Floating point value 0.000021 */ +#define AGC_DECAY_Fs22050 16 /* Floating point value 0.000015 */ +#define AGC_DECAY_Fs24000 15 /* Floating point value 0.000014 */ +#define AGC_DECAY_Fs32000 11 /* Floating point value 0.000010 */ +#define AGC_DECAY_Fs44100 8 /* Floating point value 0.000008 */ +#define AGC_DECAY_Fs48000 7 /* Floating point value 0.000007 */ + +/* AGC Gain settings */ +#define AGC_GAIN_SCALE 31 /* As a power of 2 */ +#define AGC_GAIN_SHIFT 4 /* As a power of 2 */ +#define AGC_TARGETLEVEL 33170337 /* Floating point value -0.100000dB */ +#define AGC_HPFGAIN_0dB 110739704 /* Floating point value 0.412538 */ +#define AGC_GAIN_0dB 0 /* Floating point value 0.000000 */ +#define AGC_HPFGAIN_1dB 157006071 /* Floating point value 0.584893 */ +#define AGC_GAIN_1dB 32754079 /* Floating point value 0.122018 */ +#define AGC_HPFGAIN_2dB 208917788 /* Floating point value 0.778279 */ +#define AGC_GAIN_2dB 69504761 /* Floating point value 0.258925 */ +#define AGC_HPFGAIN_3dB 267163693 /* Floating point value 0.995262 */ +#define AGC_GAIN_3dB 110739704 /* Floating point value 0.412538 */ +#define AGC_HPFGAIN_4dB 332516674 /* Floating point value 1.238721 */ +#define AGC_GAIN_4dB 157006071 /* Floating point value 0.584893 */ +#define AGC_HPFGAIN_5dB 405843924 /* Floating point value 1.511886 */ +#define AGC_GAIN_5dB 208917788 /* Floating point value 0.778279 */ +#define AGC_HPFGAIN_6dB 488118451 /* Floating point value 1.818383 */ +#define AGC_GAIN_6dB 267163693 /* Floating point value 0.995262 */ +#define AGC_HPFGAIN_7dB 580431990 /* Floating point value 2.162278 */ +#define AGC_GAIN_7dB 332516674 /* Floating point value 1.238721 */ +#define AGC_HPFGAIN_8dB 684009483 /* Floating point value 2.548134 */ +#define AGC_GAIN_8dB 405843924 /* Floating point value 1.511886 */ +#define AGC_HPFGAIN_9dB 800225343 /* Floating point value 2.981072 */ +#define AGC_GAIN_9dB 488118451 /* Floating point value 1.818383 */ +#define AGC_HPFGAIN_10dB 930621681 /* Floating point value 3.466836 */ +#define AGC_GAIN_10dB 580431990 /* Floating point value 2.162278 */ +#define AGC_HPFGAIN_11dB 1076928780 /* Floating point value 4.011872 */ +#define AGC_GAIN_11dB 684009483 /* Floating point value 2.548134 */ +#define AGC_HPFGAIN_12dB 1241088045 /* Floating point value 4.623413 */ +#define AGC_GAIN_12dB 800225343 /* Floating point value 2.981072 */ +#define AGC_HPFGAIN_13dB 1425277769 /* Floating point value 5.309573 */ +#define AGC_GAIN_13dB 930621681 /* Floating point value 3.466836 */ +#define AGC_HPFGAIN_14dB 1631942039 /* Floating point value 6.079458 */ +#define AGC_GAIN_14dB 1076928780 /* Floating point value 4.011872 */ +#define AGC_HPFGAIN_15dB 1863823163 /* Floating point value 6.943282 */ +#define AGC_GAIN_15dB 1241088045 /* Floating point value 4.623413 */ + + +/************************************************************************************/ +/* */ +/* Volume control */ +/* */ +/************************************************************************************/ + +/* Volume control gain */ +#define VOLUME_MAX 0 /* In dBs */ +#define VOLUME_SHIFT 0 /* In dBs */ + +/* Volume control time constants */ +#define VOL_TC_SHIFT 21 /* As a power of 2 */ +#define VOL_TC_Fs8000 25889 /* Floating point value 0.024690 */ +#define VOL_TC_Fs11025 18850 /* Floating point value 0.017977 */ +#define VOL_TC_Fs12000 17331 /* Floating point value 0.016529 */ +#define VOL_TC_Fs16000 13026 /* Floating point value 0.012422 */ +#define VOL_TC_Fs22050 9468 /* Floating point value 0.009029 */ +#define VOL_TC_Fs24000 8702 /* Floating point value 0.008299 */ +#define VOL_TC_Fs32000 6533 /* Floating point value 0.006231 */ +#define VOL_TC_Fs44100 4745 /* Floating point value 0.004525 */ +#define VOL_TC_Fs48000 4360 /* Floating point value 0.004158 */ +#define MIX_TC_Fs8000 29365 /* Floating point value 0.896151 */ +#define MIX_TC_Fs11025 30230 /* Floating point value 0.922548 */ +#define MIX_TC_Fs12000 30422 /* Floating point value 0.928415 */ +#define MIX_TC_Fs16000 30978 /* Floating point value 0.945387 */ +#define MIX_TC_Fs22050 31451 /* Floating point value 0.959804 */ +#define MIX_TC_Fs24000 31554 /* Floating point value 0.962956 */ +#define MIX_TC_Fs32000 31850 /* Floating point value 0.971973 */ +#define MIX_TC_Fs44100 32097 /* Floating point value 0.979515 */ +#define MIX_TC_Fs48000 32150 /* Floating point value 0.981150 */ + + +#endif diff --git a/media/libeffects/lvm/lib/Bass/src/LVDBE_Control.c b/media/libeffects/lvm/lib/Bass/src/LVDBE_Control.c new file mode 100755 index 0000000..e66513f --- /dev/null +++ b/media/libeffects/lvm/lib/Bass/src/LVDBE_Control.c @@ -0,0 +1,377 @@ +/* + * 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: 1223 $ + $Date: 2010-07-15 14:27:01 +0200 (Thu, 15 Jul 2010) $ + +*****************************************************************************************/ + +/****************************************************************************************/ +/* */ +/* Includes */ +/* */ +/****************************************************************************************/ + +#include "LVDBE.h" +#include "LVDBE_Private.h" +#include "VectorArithmetic.h" +#include "LVDBE_Coeffs.h" +#include "LVDBE_Tables.h" + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVDBE_GetParameters */ +/* */ +/* DESCRIPTION: */ +/* Request the Dynamic Bass Enhancement parameters. The current parameter set is */ +/* returned via the parameter pointer. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance handle */ +/* pParams Pointer to an empty parameter structure */ +/* */ +/* RETURNS: */ +/* LVDBE_SUCCESS Always succeeds */ +/* */ +/* NOTES: */ +/* 1. This function may be interrupted by the LVDBE_Process function */ +/* */ +/****************************************************************************************/ + +LVDBE_ReturnStatus_en LVDBE_GetParameters(LVDBE_Handle_t hInstance, + LVDBE_Params_t *pParams) +{ + + LVDBE_Instance_t *pInstance =(LVDBE_Instance_t *)hInstance; + + *pParams = pInstance->Params; + + return(LVDBE_SUCCESS); +} + + +/************************************************************************************/ +/* */ +/* FUNCTION: LVDBE_GetCapabilities */ +/* */ +/* DESCRIPTION: Dynamic Bass Enhnacement capabilities. The current capabilities are */ +/* returned via the pointer. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance handle */ +/* pCapabilities Pointer to an empty capability structure */ +/* */ +/* RETURNS: */ +/* LVDBE_Success Always succeeds */ +/* */ +/* NOTES: */ +/* 1. This function may be interrupted by the LVDBE_Process function */ +/* */ +/************************************************************************************/ + +LVDBE_ReturnStatus_en LVDBE_GetCapabilities(LVDBE_Handle_t hInstance, + LVDBE_Capabilities_t *pCapabilities) +{ + + LVDBE_Instance_t *pInstance =(LVDBE_Instance_t *)hInstance; + + *pCapabilities = pInstance->Capabilities; + + return(LVDBE_SUCCESS); +} + + +/************************************************************************************/ +/* */ +/* FUNCTION: LVDBE_SetFilters */ +/* */ +/* DESCRIPTION: */ +/* Sets the filter coefficients and clears the data history */ +/* */ +/* PARAMETERS: */ +/* pInstance Pointer to the instance */ +/* pParams Initialisation parameters */ +/* */ +/************************************************************************************/ + +void LVDBE_SetFilters(LVDBE_Instance_t *pInstance, + LVDBE_Params_t *pParams) +{ + + /* + * Calculate the table offsets + */ + LVM_UINT16 Offset = (LVM_UINT16)((LVM_UINT16)pParams->SampleRate + (LVM_UINT16)(pParams->CentreFrequency * (1+LVDBE_FS_48000))); + + + /* + * Setup the high pass filter + */ + LoadConst_16(0, /* Clear the history, value 0 */ + (LVM_INT16 *)&pInstance->pData->HPFTaps, /* Destination */ + sizeof(pInstance->pData->HPFTaps)/sizeof(LVM_INT16)); /* Number of words */ + BQ_2I_D32F32Cll_TRC_WRA_01_Init(&pInstance->pCoef->HPFInstance, /* Initialise the filter */ + &pInstance->pData->HPFTaps, + (BQ_C32_Coefs_t *)&LVDBE_HPF_Table[Offset]); + + + /* + * Setup the band pass filter + */ + LoadConst_16(0, /* Clear the history, value 0 */ + (LVM_INT16 *)&pInstance->pData->BPFTaps, /* Destination */ + sizeof(pInstance->pData->BPFTaps)/sizeof(LVM_INT16)); /* Number of words */ + BP_1I_D32F32Cll_TRC_WRA_02_Init(&pInstance->pCoef->BPFInstance, /* Initialise the filter */ + &pInstance->pData->BPFTaps, + (BP_C32_Coefs_t *)&LVDBE_BPF_Table[Offset]); + +} + + + +/************************************************************************************/ +/* */ +/* FUNCTION: LVDBE_SetAGC */ +/* */ +/* DESCRIPTION: */ +/* Sets the AGC gain level and attack and decay times constants. */ +/* */ +/* PARAMETERS: */ +/* pInstance Pointer to the instance */ +/* pParams Initialisation parameters */ +/* */ +/************************************************************************************/ + +void LVDBE_SetAGC(LVDBE_Instance_t *pInstance, + LVDBE_Params_t *pParams) +{ + + /* + * Get the attack and decay time constants + */ + pInstance->pData->AGCInstance.AGC_Attack = LVDBE_AGC_ATTACK_Table[(LVM_UINT16)pParams->SampleRate]; /* Attack multiplier */ + pInstance->pData->AGCInstance.AGC_Decay = LVDBE_AGC_DECAY_Table[(LVM_UINT16)pParams->SampleRate]; /* Decay multipler */ + + + /* + * Get the boost gain + */ + if (pParams->HPFSelect == LVDBE_HPF_ON) + { + pInstance->pData->AGCInstance.AGC_MaxGain = LVDBE_AGC_HPFGAIN_Table[(LVM_UINT16)pParams->EffectLevel]; /* High pass filter on */ + } + else + { + pInstance->pData->AGCInstance.AGC_MaxGain = LVDBE_AGC_GAIN_Table[(LVM_UINT16)pParams->EffectLevel]; /* High pass filter off */ + } + pInstance->pData->AGCInstance.AGC_GainShift = AGC_GAIN_SHIFT; + pInstance->pData->AGCInstance.AGC_Target = AGC_TARGETLEVEL; + +} + + +/************************************************************************************/ +/* */ +/* FUNCTION: LVDBE_SetVolume */ +/* */ +/* DESCRIPTION: */ +/* Converts the input volume demand from dBs to linear. */ +/* */ +/* PARAMETERS: */ +/* pInstance Pointer to the instance */ +/* pParams Initialisation parameters */ +/* */ +/* NOTES: */ +/* 1. The volume should have the following settings: */ +/* */ +/* DBE Vol Control Volume setting */ +/* === =========== =================== */ +/* Off Off HeadroomdB */ +/* Off On VolumedB+HeadroomdB */ +/* On Off HeadroomdB */ +/* On On VolumedB+HeadroomdB */ +/* */ +/************************************************************************************/ + +void LVDBE_SetVolume(LVDBE_Instance_t *pInstance, + LVDBE_Params_t *pParams) +{ + + LVM_UINT16 dBShifts; /* 6dB shifts */ + LVM_UINT16 dBOffset; /* Table offset */ + LVM_INT16 Volume = 0; /* Required volume in dBs */ + + /* + * Apply the volume if enabled + */ + if (pParams->VolumeControl == LVDBE_VOLUME_ON) + { + /* + * Limit the gain to the maximum allowed + */ + if (pParams->VolumedB > VOLUME_MAX) + { + Volume = VOLUME_MAX; + } + else + { + Volume = pParams->VolumedB; + } + } + + + /* + * Calculate the required gain and shifts + */ + dBOffset = (LVM_UINT16)(6 + Volume % 6); /* Get the dBs 0-5 */ + dBShifts = (LVM_UINT16)(Volume / -6); /* Get the 6dB shifts */ + + + /* + * When DBE is enabled use AGC volume + */ + pInstance->pData->AGCInstance.Target = ((LVM_INT32)LVDBE_VolumeTable[dBOffset] << 16); + pInstance->pData->AGCInstance.Target = pInstance->pData->AGCInstance.Target >> dBShifts; + + pInstance->pData->AGCInstance.VolumeTC = LVDBE_VolumeTCTable[(LVM_UINT16)pParams->SampleRate]; /* Volume update time constant */ + pInstance->pData->AGCInstance.VolumeShift = VOLUME_SHIFT+1; + + /* + * When DBE is disabled use the bypass volume control + */ + if(dBShifts > 0) + { + LVC_Mixer_SetTarget(&pInstance->pData->BypassVolume.MixerStream[0],(((LVM_INT32)LVDBE_VolumeTable[dBOffset]) >> dBShifts)); + } + else + { + LVC_Mixer_SetTarget(&pInstance->pData->BypassVolume.MixerStream[0],(LVM_INT32)LVDBE_VolumeTable[dBOffset]); + } + + pInstance->pData->BypassVolume.MixerStream[0].CallbackSet = 1; + LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->pData->BypassVolume.MixerStream[0], + LVDBE_MIXER_TC, + (LVM_Fs_en)pInstance->Params.SampleRate, + 2); +} + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVDBE_Control */ +/* */ +/* DESCRIPTION: */ +/* Sets or changes the Bass Enhancement parameters. Changing the parameters while the */ +/* module is processing signals may have the following side effects: */ +/* */ +/* General parameters: */ +/* =================== */ +/* OperatingMode: Changing the mode of operation may cause a change in volume */ +/* level or cause pops and clicks. */ +/* */ +/* SampleRate: Changing the sample rate may cause pops and clicks. */ +/* */ +/* EffectLevel: Changing the effect level may cause pops and clicks */ +/* */ +/* CentreFrequency: Changing the centre frequency may cause pops and clicks */ +/* */ +/* HPFSelect: Selecting/de-selecting the high pass filter may cause pops and */ +/* clicks */ +/* */ +/* VolumedB Changing the volume setting will have no side effects */ +/* */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance handle */ +/* pParams Pointer to a parameter structure */ +/* */ +/* RETURNS: */ +/* LVDBE_SUCCESS Always succeeds */ +/* */ +/* NOTES: */ +/* 1. This function must not be interrupted by the LVDBE_Process function */ +/* */ +/****************************************************************************************/ + +LVDBE_ReturnStatus_en LVDBE_Control(LVDBE_Handle_t hInstance, + LVDBE_Params_t *pParams) +{ + + LVDBE_Instance_t *pInstance =(LVDBE_Instance_t *)hInstance; + + + /* + * Update the filters + */ + if ((pInstance->Params.SampleRate != pParams->SampleRate) || + (pInstance->Params.CentreFrequency != pParams->CentreFrequency)) + { + LVDBE_SetFilters(pInstance, /* Instance pointer */ + pParams); /* New parameters */ + } + + + /* + * Update the AGC is the effect level has changed + */ + if ((pInstance->Params.SampleRate != pParams->SampleRate) || + (pInstance->Params.EffectLevel != pParams->EffectLevel) || + (pInstance->Params.HPFSelect != pParams->HPFSelect)) + { + LVDBE_SetAGC(pInstance, /* Instance pointer */ + pParams); /* New parameters */ + } + + + /* + * Update the Volume if the volume demand has changed + */ + if ((pInstance->Params.VolumedB != pParams->VolumedB) || + (pInstance->Params.SampleRate != pParams->SampleRate) || + (pInstance->Params.HeadroomdB != pParams->HeadroomdB) || + (pInstance->Params.VolumeControl != pParams->VolumeControl)) + { + LVDBE_SetVolume(pInstance, /* Instance pointer */ + pParams); /* New parameters */ + } + + if (pInstance->Params.OperatingMode==LVDBE_ON && pParams->OperatingMode==LVDBE_OFF) + { + LVDBE_Params_t Params = *pParams; /* make local copy of params */ + Params.EffectLevel = 0; /* zero effect level before switching off module*/ + pInstance->bTransitionOnToOff = LVM_TRUE; /* Set the CallBack */ + LVDBE_SetAGC(pInstance, /* Instance pointer */ + &Params); /* New parameters */ + } + if (pInstance->Params.OperatingMode==LVDBE_OFF && pParams->OperatingMode==LVDBE_ON) + { + pInstance->bTransitionOnToOff = LVM_FALSE; /* Set the CallBack */ + LVDBE_SetAGC(pInstance, /* Instance pointer */ + pParams); /* New parameters */ + } + + /* + * Update the instance parameters + */ + pInstance->Params = *pParams; + + + return(LVDBE_SUCCESS); +} diff --git a/media/libeffects/lvm/lib/Bass/src/LVDBE_Init.c b/media/libeffects/lvm/lib/Bass/src/LVDBE_Init.c new file mode 100755 index 0000000..75869c7 --- /dev/null +++ b/media/libeffects/lvm/lib/Bass/src/LVDBE_Init.c @@ -0,0 +1,267 @@ +/* + * 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: 1081 $ + $Date: 2010-07-05 11:48:44 +0200 (Mon, 05 Jul 2010) $ + +*****************************************************************************************/ + +/****************************************************************************************/ +/* */ +/* Includes */ +/* */ +/****************************************************************************************/ + +#include "LVDBE.h" +#include "LVDBE_Private.h" + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVDBE_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) the memory */ +/* base address pointers are NULL on return. */ +/* */ +/* When the function is called for free (hInstance = Instance Handle) the memory */ +/* table returns the allocated memory and base addresses used during initialisation. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance Handle */ +/* pMemoryTable Pointer to an empty memory definition table */ +/* pCapabilities Pointer to the instance capabilities */ +/* */ +/* RETURNS: */ +/* LVDBE_SUCCESS Succeeded */ +/* */ +/* NOTES: */ +/* 1. This function may be interrupted by the LVDBE_Process function */ +/* */ +/****************************************************************************************/ + +LVDBE_ReturnStatus_en LVDBE_Memory(LVDBE_Handle_t hInstance, + LVDBE_MemTab_t *pMemoryTable, + LVDBE_Capabilities_t *pCapabilities) +{ + + LVM_UINT32 ScratchSize; + LVDBE_Instance_t *pInstance = (LVDBE_Instance_t *)hInstance; + + + /* + * Fill in the memory table + */ + if (hInstance == LVM_NULL) + { + /* + * Instance memory + */ + pMemoryTable->Region[LVDBE_MEMREGION_INSTANCE].Size = sizeof(LVDBE_Instance_t); + pMemoryTable->Region[LVDBE_MEMREGION_INSTANCE].Alignment = LVDBE_INSTANCE_ALIGN; + pMemoryTable->Region[LVDBE_MEMREGION_INSTANCE].Type = LVDBE_PERSISTENT; + pMemoryTable->Region[LVDBE_MEMREGION_INSTANCE].pBaseAddress = LVM_NULL; + + /* + * Data memory + */ + pMemoryTable->Region[LVDBE_MEMREGION_PERSISTENT_DATA].Size = sizeof(LVDBE_Data_t); + pMemoryTable->Region[LVDBE_MEMREGION_PERSISTENT_DATA].Alignment = LVDBE_PERSISTENT_DATA_ALIGN; + pMemoryTable->Region[LVDBE_MEMREGION_PERSISTENT_DATA].Type = LVDBE_PERSISTENT_DATA; + pMemoryTable->Region[LVDBE_MEMREGION_PERSISTENT_DATA].pBaseAddress = LVM_NULL; + + /* + * Coef memory + */ + pMemoryTable->Region[LVDBE_MEMREGION_PERSISTENT_COEF].Size = sizeof(LVDBE_Coef_t); + pMemoryTable->Region[LVDBE_MEMREGION_PERSISTENT_COEF].Alignment = LVDBE_PERSISTENT_COEF_ALIGN; + pMemoryTable->Region[LVDBE_MEMREGION_PERSISTENT_COEF].Type = LVDBE_PERSISTENT_COEF; + pMemoryTable->Region[LVDBE_MEMREGION_PERSISTENT_COEF].pBaseAddress = LVM_NULL; + + /* + * Scratch memory + */ + ScratchSize = (LVM_UINT32)(LVDBE_SCRATCHBUFFERS_INPLACE*sizeof(LVM_INT16)*pCapabilities->MaxBlockSize); + pMemoryTable->Region[LVDBE_MEMREGION_SCRATCH].Size = ScratchSize; + pMemoryTable->Region[LVDBE_MEMREGION_SCRATCH].Alignment = LVDBE_SCRATCH_ALIGN; + pMemoryTable->Region[LVDBE_MEMREGION_SCRATCH].Type = LVDBE_SCRATCH; + pMemoryTable->Region[LVDBE_MEMREGION_SCRATCH].pBaseAddress = LVM_NULL; + } + else + { + /* Read back memory allocation table */ + *pMemoryTable = pInstance->MemoryTable; + } + + return(LVDBE_SUCCESS); +} + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVDBE_Init */ +/* */ +/* DESCRIPTION: */ +/* Create and initialisation function for the Dynamic Bass Enhancement module */ +/* */ +/* This function can be used to create an algorithm instance by calling with */ +/* hInstance set to 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 */ +/* DBE_Memory before calling this function. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance handle */ +/* pMemoryTable Pointer to the memory definition table */ +/* pCapabilities Pointer to the instance capabilities */ +/* */ +/* RETURNS: */ +/* LVDBE_SUCCESS Initialisation succeeded */ +/* LVDBE_ALIGNMENTERROR Instance or scratch memory on incorrect alignment */ +/* LVDBE_NULLADDRESS Instance or scratch memory has a NULL pointer */ +/* */ +/* 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 LVDBE_Process function */ +/* */ +/****************************************************************************************/ + +LVDBE_ReturnStatus_en LVDBE_Init(LVDBE_Handle_t *phInstance, + LVDBE_MemTab_t *pMemoryTable, + LVDBE_Capabilities_t *pCapabilities) +{ + + LVDBE_Instance_t *pInstance; + LVMixer3_1St_st *pMixer_Instance; + LVM_INT16 i; + LVM_INT32 MixGain; + + + /* + * Set the instance handle if not already initialised + */ + if (*phInstance == LVM_NULL) + { + *phInstance = (LVDBE_Handle_t)pMemoryTable->Region[LVDBE_MEMREGION_INSTANCE].pBaseAddress; + } + pInstance =(LVDBE_Instance_t *)*phInstance; + + + /* + * Check the memory table for NULL pointers and incorrectly aligned data + */ + for (i=0; iRegion[i].Size!=0) + { + if (pMemoryTable->Region[i].pBaseAddress==LVM_NULL) + { + return(LVDBE_NULLADDRESS); + } + if (((LVM_UINT32)pMemoryTable->Region[i].pBaseAddress % pMemoryTable->Region[i].Alignment)!=0){ + return(LVDBE_ALIGNMENTERROR); + } + } + } + + + /* + * Save the memory table in the instance structure + */ + pInstance->Capabilities = *pCapabilities; + + + /* + * Save the memory table in the instance structure + */ + pInstance->MemoryTable = *pMemoryTable; + + + /* + * Set the default instance parameters + */ + pInstance->Params.CentreFrequency = LVDBE_CENTRE_55HZ; + pInstance->Params.EffectLevel = 0; + pInstance->Params.HeadroomdB = 0; + pInstance->Params.HPFSelect = LVDBE_HPF_OFF; + pInstance->Params.OperatingMode = LVDBE_OFF; + pInstance->Params.SampleRate = LVDBE_FS_8000; + pInstance->Params.VolumeControl = LVDBE_VOLUME_OFF; + pInstance->Params.VolumedB = 0; + + + /* + * Set pointer to data and coef memory + */ + pInstance->pData = pMemoryTable->Region[LVDBE_MEMREGION_PERSISTENT_DATA].pBaseAddress; + pInstance->pCoef = pMemoryTable->Region[LVDBE_MEMREGION_PERSISTENT_COEF].pBaseAddress; + + + /* + * Initialise the filters + */ + LVDBE_SetFilters(pInstance, /* Set the filter taps and coefficients */ + &pInstance->Params); + + + /* + * Initialise the AGC + */ + LVDBE_SetAGC(pInstance, /* Set the AGC gain */ + &pInstance->Params); + pInstance->pData->AGCInstance.AGC_Gain = pInstance->pData->AGCInstance.AGC_MaxGain; /* Default to the bass boost setting */ + + + /* + * Initialise the volume + */ + LVDBE_SetVolume(pInstance, /* Set the Volume */ + &pInstance->Params); + + pInstance->pData->AGCInstance.Volume = pInstance->pData->AGCInstance.Target; /* Initialise as the target */ + + pMixer_Instance = &pInstance->pData->BypassVolume; + MixGain = LVC_Mixer_GetTarget(&pMixer_Instance->MixerStream[0]); + LVC_Mixer_Init(&pMixer_Instance->MixerStream[0],MixGain,MixGain); + + /* Configure the mixer process path */ + pMixer_Instance->MixerStream[0].CallbackParam = 0; + pMixer_Instance->MixerStream[0].pCallbackHandle = LVM_NULL; + pMixer_Instance->MixerStream[0].pCallBack = LVM_NULL; + pMixer_Instance->MixerStream[0].CallbackSet = 0; + + /* + * Initialise the clicks minimisation variable + */ + pInstance->bTransitionOnToOff = LVM_FALSE; + + return(LVDBE_SUCCESS); +} + diff --git a/media/libeffects/lvm/lib/Bass/src/LVDBE_Private.h b/media/libeffects/lvm/lib/Bass/src/LVDBE_Private.h new file mode 100755 index 0000000..3e09cf4 --- /dev/null +++ b/media/libeffects/lvm/lib/Bass/src/LVDBE_Private.h @@ -0,0 +1,148 @@ +/* + * 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: 1081 $ + $Date: 2010-07-05 11:48:44 +0200 (Mon, 05 Jul 2010) $ + +*****************************************************************************************/ + +/****************************************************************************************/ +/* */ +/* Header file for the private layer interface of Dynamic Bass Enhancement module */ +/* */ +/* This files includes all definitions, types, structures and function */ +/* prototypes required by the execution layer. */ +/* */ +/****************************************************************************************/ + +#ifndef __LVDBE_PRIVATE_H__ +#define __LVDBE_PRIVATE_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/****************************************************************************************/ +/* */ +/* Includes */ +/* */ +/****************************************************************************************/ + +#include "LVDBE.h" /* Calling or Application layer definitions */ +#include "BIQUAD.h" +#include "LVC_Mixer.h" +#include "AGC.h" + + +/****************************************************************************************/ +/* */ +/* Defines */ +/* */ +/****************************************************************************************/ + +/* General */ +#define LVDBE_INVALID 0xFFFF /* Invalid init parameter */ + +/* Memory */ +#define LVDBE_MEMREGION_INSTANCE 0 /* Offset to the instance memory region */ +#define LVDBE_MEMREGION_PERSISTENT_DATA 1 /* Offset to persistent data memory region */ +#define LVDBE_MEMREGION_PERSISTENT_COEF 2 /* Offset to persistent coefficient region */ +#define LVDBE_MEMREGION_SCRATCH 3 /* Offset to data scratch memory region */ + +#define LVDBE_INSTANCE_ALIGN 4 /* 32-bit alignment for structures */ +#define LVDBE_PERSISTENT_DATA_ALIGN 4 /* 32-bit alignment for data */ +#define LVDBE_PERSISTENT_COEF_ALIGN 4 /* 32-bit alignment for coef */ +#define LVDBE_SCRATCH_ALIGN 4 /* 32-bit alignment for long data */ + +#define LVDBE_SCRATCHBUFFERS_INPLACE 4 /* Number of buffers required for inplace processing */ + +#define LVDBE_MIXER_TC 5 /* Mixer time */ + +/****************************************************************************************/ +/* */ +/* Structures */ +/* */ +/****************************************************************************************/ + +/* Data structure */ +typedef struct +{ + /* AGC parameters */ + AGC_MIX_VOL_2St1Mon_D32_t AGCInstance; /* AGC instance parameters */ + + /* Process variables */ + Biquad_2I_Order2_Taps_t HPFTaps; /* High pass filter taps */ + Biquad_1I_Order2_Taps_t BPFTaps; /* Band pass filter taps */ + LVMixer3_1St_st BypassVolume; /* Bypass volume scaler */ + +} LVDBE_Data_t; + +/* Coefs structure */ +typedef struct +{ + /* Process variables */ + Biquad_Instance_t HPFInstance; /* High pass filter instance */ + Biquad_Instance_t BPFInstance; /* Band pass filter instance */ + +} LVDBE_Coef_t; + +/* Instance structure */ +typedef struct +{ + /* Public parameters */ + LVDBE_MemTab_t MemoryTable; /* Instance memory allocation table */ + LVDBE_Params_t Params; /* Instance parameters */ + LVDBE_Capabilities_t Capabilities; /* Instance capabilities */ + + /* Data and coefficient pointers */ + LVDBE_Data_t *pData; /* Instance data */ + LVDBE_Coef_t *pCoef; /* Instance coefficients */ + + LVM_INT32 bTransitionOnToOff; + +} LVDBE_Instance_t; + + +/****************************************************************************************/ +/* */ +/* Function prototypes */ +/* */ +/****************************************************************************************/ + +void LVDBE_SetAGC(LVDBE_Instance_t *pInstance, + LVDBE_Params_t *pParams); + + +void LVDBE_SetVolume(LVDBE_Instance_t *pInstance, + LVDBE_Params_t *pParams); + + +void LVDBE_SetFilters(LVDBE_Instance_t *pInstance, + LVDBE_Params_t *pParams); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __LVDBE_PRIVATE_H__ */ + + diff --git a/media/libeffects/lvm/lib/Bass/src/LVDBE_Process.c b/media/libeffects/lvm/lib/Bass/src/LVDBE_Process.c new file mode 100755 index 0000000..35eec07 --- /dev/null +++ b/media/libeffects/lvm/lib/Bass/src/LVDBE_Process.c @@ -0,0 +1,205 @@ +/* + * 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: 1081 $ + $Date: 2010-07-05 11:48:44 +0200 (Mon, 05 Jul 2010) $ + +*****************************************************************************************/ + +/****************************************************************************************/ +/* */ +/* Includes */ +/* */ +/****************************************************************************************/ + +#include "LVDBE.h" +#include "LVDBE_Private.h" +#include "VectorArithmetic.h" +#include "AGC.h" +#include "LVDBE_Coeffs.h" /* Filter coefficients */ + + +/********************************************************************************************/ +/* */ +/* FUNCTION: LVDBE_Process */ +/* */ +/* DESCRIPTION: */ +/* Process function for the Bass Enhancement module. */ +/* */ +/* 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. */ +/* ___________ */ +/* ________ | | ________ */ +/* | | _____ |------------------------->| | | | */ +/* | 16-bit | | | | ________ | | | 32-bit | */ +/* -+-->| to |-->| HPF |--| | | _____ | AGC Mixer |-->| to |--| */ +/* | | 32-bit | |_____| | | Stereo | | | | | | 16-bit | | */ +/* | |________| |-->| to |-->| BPF |-->| | |________| 0 */ +/* | | Mono | |_____| |___________| \--> */ +/* | |________| */ +/* | _________ 0 */ +/* | | | | */ +/* |----------------------------------------------------| Volume |-----------------| */ +/* | Control | */ +/* |_________| */ +/* */ +/* 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: */ +/* LVDBE_SUCCESS Succeeded */ +/* LVDBE_TOOMANYSAMPLES NumSamples was larger than the maximum block size */ +/* */ +/* NOTES: */ +/* 1. The input and output data must be 32-bit format. The input is scaled by a shift */ +/* when converting from 16-bit format, this scaling allows for internal headroom in the */ +/* bass enhancement algorithm. */ +/* 2. For a 16-bit implementation the converstion to 32-bit is removed and replaced with */ +/* the headroom loss. This headroom loss is compensated in the volume control so the */ +/* overall end to end gain is odB. */ +/* */ +/********************************************************************************************/ + +LVDBE_ReturnStatus_en LVDBE_Process(LVDBE_Handle_t hInstance, + const LVM_INT16 *pInData, + LVM_INT16 *pOutData, + LVM_UINT16 NumSamples) +{ + + LVDBE_Instance_t *pInstance =(LVDBE_Instance_t *)hInstance; + LVM_INT32 *pScratch = (LVM_INT32 *)pInstance->MemoryTable.Region[LVDBE_MEMREGION_SCRATCH].pBaseAddress; + LVM_INT32 *pMono = (LVM_INT32 *)pOutData; + LVM_INT16 *pInput = (LVM_INT16 *)pInData; + + + /* + * Check the number of samples is not too large + */ + if (NumSamples > pInstance->Capabilities.MaxBlockSize) + { + return(LVDBE_TOOMANYSAMPLES); + } + + /* + * Check if the algorithm is enabled + */ + if ((pInstance->Params.OperatingMode != LVDBE_OFF) || + (pInstance->bTransitionOnToOff == LVM_TRUE)) + { + + /* + * Convert 16-bit samples to 32-bit and scale + * (For a 16-bit implementation apply headroom loss here) + */ + Int16LShiftToInt32_16x32(pInput, /* Source 16-bit data */ + pScratch, /* Destination 32-bit data */ + (LVM_INT16)(2*NumSamples), /* Left and right */ + LVDBE_SCALESHIFT); /* Shift scale */ + + + /* + * Apply the high pass filter if selected + */ + if (pInstance->Params.HPFSelect == LVDBE_HPF_ON) + { + BQ_2I_D32F32C30_TRC_WRA_01(&pInstance->pCoef->HPFInstance, /* Filter instance */ + (LVM_INT32 *)pScratch, /* Source */ + (LVM_INT32 *)pScratch, /* Destination */ + (LVM_INT16)NumSamples); /* Number of samples */ + } + + + /* + * Create the mono stream + */ + From2iToMono_32(pScratch, /* Stereo source */ + pMono, /* Mono destination */ + (LVM_INT16)NumSamples); /* Number of samples */ + + + /* + * Apply the band pass filter + */ + BP_1I_D32F32C30_TRC_WRA_02(&pInstance->pCoef->BPFInstance, /* Filter instance */ + (LVM_INT32 *)pMono, /* Source */ + (LVM_INT32 *)pMono, /* Destination */ + (LVM_INT16)NumSamples); /* Number of samples */ + + + /* + * Apply the AGC and mix + */ + AGC_MIX_VOL_2St1Mon_D32_WRA(&pInstance->pData->AGCInstance, /* Instance pointer */ + pScratch, /* Stereo source */ + pMono, /* Mono band pass source */ + pScratch, /* Stereo destination */ + NumSamples); /* Number of samples */ + + if(pInstance->bTransitionOnToOff == LVM_TRUE) + { + if ((pInstance->pData->AGCInstance.AGC_Gain == pInstance->pData->AGCInstance.AGC_Target)&& + (pInstance->pData->AGCInstance.AGC_Gain == 0)) + { + pInstance->bTransitionOnToOff = LVM_FALSE; + } + } + + + + /* + * Convert 32-bit samples to 16-bit and saturate + * (Not required for 16-bit implemenations) + */ + Int32RShiftToInt16_Sat_32x16(pScratch, /* Source 32-bit data */ + pOutData, /* Destination 16-bit data */ + (LVM_INT16)(2*NumSamples), /* Left and right */ + LVDBE_SCALESHIFT); /* Shift scale */ + + } + else + { + + /* + * The algorithm is disabled but volume management is required to compensate for + * headroom and volume (if enabled) + */ + LVC_MixSoft_1St_D16C31_SAT(&pInstance->pData->BypassVolume, + pInData, + pOutData, + (LVM_INT16)(2*NumSamples)); /* Left and right */ + + } + + return(LVDBE_SUCCESS); +} + + + + + + + + + + diff --git a/media/libeffects/lvm/lib/Bass/src/LVDBE_Tables.c b/media/libeffects/lvm/lib/Bass/src/LVDBE_Tables.c new file mode 100755 index 0000000..da8ca5a --- /dev/null +++ b/media/libeffects/lvm/lib/Bass/src/LVDBE_Tables.c @@ -0,0 +1,463 @@ +/* + * 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: 1009 $ + $Date: 2010-06-28 14:14:15 +0200 (Mon, 28 Jun 2010) $ + +*************************************************************************************/ + + +/************************************************************************************/ +/* */ +/* Includes */ +/* */ +/************************************************************************************/ + +#include "LVDBE.h" +#include "LVDBE_Coeffs.h" /* Filter coefficients */ +#include "BIQUAD.h" + + +/************************************************************************************/ +/* */ +/* Coefficients constant table */ +/* */ +/************************************************************************************/ + +/* + * High Pass Filter Coefficient table + */ +const BQ_C32_Coefs_t LVDBE_HPF_Table[] = { + /* Coefficients for 55Hz centre frequency */ + {HPF_Fs8000_Fc55_A2, /* 8kS/s coefficients */ + HPF_Fs8000_Fc55_A1, + HPF_Fs8000_Fc55_A0, + -HPF_Fs8000_Fc55_B2, + -HPF_Fs8000_Fc55_B1}, + {HPF_Fs11025_Fc55_A2, /* 11kS/s coefficients */ + HPF_Fs11025_Fc55_A1, + HPF_Fs11025_Fc55_A0, + -HPF_Fs11025_Fc55_B2, + -HPF_Fs11025_Fc55_B1}, + {HPF_Fs12000_Fc55_A2, /* 12kS/s coefficients */ + HPF_Fs12000_Fc55_A1, + HPF_Fs12000_Fc55_A0, + -HPF_Fs12000_Fc55_B2, + -HPF_Fs12000_Fc55_B1}, + {HPF_Fs16000_Fc55_A2, /* 16kS/s coefficients */ + HPF_Fs16000_Fc55_A1, + HPF_Fs16000_Fc55_A0, + -HPF_Fs16000_Fc55_B2, + -HPF_Fs16000_Fc55_B1}, + {HPF_Fs22050_Fc55_A2, /* 22kS/s coefficients */ + HPF_Fs22050_Fc55_A1, + HPF_Fs22050_Fc55_A0, + -HPF_Fs22050_Fc55_B2, + -HPF_Fs22050_Fc55_B1}, + {HPF_Fs24000_Fc55_A2, /* 24kS/s coefficients */ + HPF_Fs24000_Fc55_A1, + HPF_Fs24000_Fc55_A0, + -HPF_Fs24000_Fc55_B2, + -HPF_Fs24000_Fc55_B1}, + {HPF_Fs32000_Fc55_A2, /* 32kS/s coefficients */ + HPF_Fs32000_Fc55_A1, + HPF_Fs32000_Fc55_A0, + -HPF_Fs32000_Fc55_B2, + -HPF_Fs32000_Fc55_B1}, + {HPF_Fs44100_Fc55_A2, /* 44kS/s coefficients */ + HPF_Fs44100_Fc55_A1, + HPF_Fs44100_Fc55_A0, + -HPF_Fs44100_Fc55_B2, + -HPF_Fs44100_Fc55_B1}, + {HPF_Fs48000_Fc55_A2, /* 48kS/s coefficients */ + HPF_Fs48000_Fc55_A1, + HPF_Fs48000_Fc55_A0, + -HPF_Fs48000_Fc55_B2, + -HPF_Fs48000_Fc55_B1}, + + /* Coefficients for 66Hz centre frequency */ + {HPF_Fs8000_Fc66_A2, /* 8kS/s coefficients */ + HPF_Fs8000_Fc66_A1, + HPF_Fs8000_Fc66_A0, + -HPF_Fs8000_Fc66_B2, + -HPF_Fs8000_Fc66_B1}, + {HPF_Fs11025_Fc66_A2, /* 11kS/s coefficients */ + HPF_Fs11025_Fc66_A1, + HPF_Fs11025_Fc66_A0, + -HPF_Fs11025_Fc66_B2, + -HPF_Fs11025_Fc66_B1}, + {HPF_Fs12000_Fc66_A2, /* 12kS/s coefficients */ + HPF_Fs12000_Fc66_A1, + HPF_Fs12000_Fc66_A0, + -HPF_Fs12000_Fc66_B2, + -HPF_Fs12000_Fc66_B1}, + {HPF_Fs16000_Fc66_A2, /* 16kS/s coefficients */ + HPF_Fs16000_Fc66_A1, + HPF_Fs16000_Fc66_A0, + -HPF_Fs16000_Fc66_B2, + -HPF_Fs16000_Fc66_B1}, + {HPF_Fs22050_Fc66_A2, /* 22kS/s coefficients */ + HPF_Fs22050_Fc66_A1, + HPF_Fs22050_Fc66_A0, + -HPF_Fs22050_Fc66_B2, + -HPF_Fs22050_Fc66_B1}, + {HPF_Fs24000_Fc66_A2, /* 24kS/s coefficients */ + HPF_Fs24000_Fc66_A1, + HPF_Fs24000_Fc66_A0, + -HPF_Fs24000_Fc66_B2, + -HPF_Fs24000_Fc66_B1}, + {HPF_Fs32000_Fc66_A2, /* 32kS/s coefficients */ + HPF_Fs32000_Fc66_A1, + HPF_Fs32000_Fc66_A0, + -HPF_Fs32000_Fc66_B2, + -HPF_Fs32000_Fc66_B1}, + {HPF_Fs44100_Fc66_A2, /* 44kS/s coefficients */ + HPF_Fs44100_Fc66_A1, + HPF_Fs44100_Fc66_A0, + -HPF_Fs44100_Fc66_B2, + -HPF_Fs44100_Fc66_B1}, + {HPF_Fs48000_Fc66_A2, /* 48kS/s coefficients */ + HPF_Fs48000_Fc66_A1, + HPF_Fs48000_Fc66_A0, + -HPF_Fs48000_Fc66_B2, + -HPF_Fs48000_Fc66_B1}, + + /* Coefficients for 78Hz centre frequency */ + {HPF_Fs8000_Fc78_A2, /* 8kS/s coefficients */ + HPF_Fs8000_Fc78_A1, + HPF_Fs8000_Fc78_A0, + -HPF_Fs8000_Fc78_B2, + -HPF_Fs8000_Fc78_B1}, + {HPF_Fs11025_Fc78_A2, /* 11kS/s coefficients */ + HPF_Fs11025_Fc78_A1, + HPF_Fs11025_Fc78_A0, + -HPF_Fs11025_Fc78_B2, + -HPF_Fs11025_Fc78_B1}, + {HPF_Fs12000_Fc78_A2, /* 12kS/s coefficients */ + HPF_Fs12000_Fc78_A1, + HPF_Fs12000_Fc78_A0, + -HPF_Fs12000_Fc78_B2, + -HPF_Fs12000_Fc78_B1}, + {HPF_Fs16000_Fc78_A2, /* 16kS/s coefficients */ + HPF_Fs16000_Fc78_A1, + HPF_Fs16000_Fc78_A0, + -HPF_Fs16000_Fc78_B2, + -HPF_Fs16000_Fc78_B1}, + {HPF_Fs22050_Fc78_A2, /* 22kS/s coefficients */ + HPF_Fs22050_Fc78_A1, + HPF_Fs22050_Fc78_A0, + -HPF_Fs22050_Fc78_B2, + -HPF_Fs22050_Fc78_B1}, + {HPF_Fs24000_Fc78_A2, /* 24kS/s coefficients */ + HPF_Fs24000_Fc78_A1, + HPF_Fs24000_Fc78_A0, + -HPF_Fs24000_Fc78_B2, + -HPF_Fs24000_Fc78_B1}, + {HPF_Fs32000_Fc78_A2, /* 32kS/s coefficients */ + HPF_Fs32000_Fc78_A1, + HPF_Fs32000_Fc78_A0, + -HPF_Fs32000_Fc78_B2, + -HPF_Fs32000_Fc78_B1}, + {HPF_Fs44100_Fc78_A2, /* 44kS/s coefficients */ + HPF_Fs44100_Fc78_A1, + HPF_Fs44100_Fc78_A0, + -HPF_Fs44100_Fc78_B2, + -HPF_Fs44100_Fc78_B1}, + {HPF_Fs48000_Fc78_A2, /* 48kS/s coefficients */ + HPF_Fs48000_Fc78_A1, + HPF_Fs48000_Fc78_A0, + -HPF_Fs48000_Fc78_B2, + -HPF_Fs48000_Fc78_B1}, + + /* Coefficients for 90Hz centre frequency */ + {HPF_Fs8000_Fc90_A2, /* 8kS/s coefficients */ + HPF_Fs8000_Fc90_A1, + HPF_Fs8000_Fc90_A0, + -HPF_Fs8000_Fc90_B2, + -HPF_Fs8000_Fc90_B1}, + {HPF_Fs11025_Fc90_A2, /* 11kS/s coefficients */ + HPF_Fs11025_Fc90_A1, + HPF_Fs11025_Fc90_A0, + -HPF_Fs11025_Fc90_B2, + -HPF_Fs11025_Fc90_B1}, + {HPF_Fs12000_Fc90_A2, /* 12kS/s coefficients */ + HPF_Fs12000_Fc90_A1, + HPF_Fs12000_Fc90_A0, + -HPF_Fs12000_Fc90_B2, + -HPF_Fs12000_Fc90_B1}, + {HPF_Fs16000_Fc90_A2, /* 16kS/s coefficients */ + HPF_Fs16000_Fc90_A1, + HPF_Fs16000_Fc90_A0, + -HPF_Fs16000_Fc90_B2, + -HPF_Fs16000_Fc90_B1}, + {HPF_Fs22050_Fc90_A2, /* 22kS/s coefficients */ + HPF_Fs22050_Fc90_A1, + HPF_Fs22050_Fc90_A0, + -HPF_Fs22050_Fc90_B2, + -HPF_Fs22050_Fc90_B1}, + {HPF_Fs24000_Fc90_A2, /* 24kS/s coefficients */ + HPF_Fs24000_Fc90_A1, + HPF_Fs24000_Fc90_A0, + -HPF_Fs24000_Fc90_B2, + -HPF_Fs24000_Fc90_B1}, + {HPF_Fs32000_Fc90_A2, /* 32kS/s coefficients */ + HPF_Fs32000_Fc90_A1, + HPF_Fs32000_Fc90_A0, + -HPF_Fs32000_Fc90_B2, + -HPF_Fs32000_Fc90_B1}, + {HPF_Fs44100_Fc90_A2, /* 44kS/s coefficients */ + HPF_Fs44100_Fc90_A1, + HPF_Fs44100_Fc90_A0, + -HPF_Fs44100_Fc90_B2, + -HPF_Fs44100_Fc90_B1}, + {HPF_Fs48000_Fc90_A2, /* 48kS/s coefficients */ + HPF_Fs48000_Fc90_A1, + HPF_Fs48000_Fc90_A0, + -HPF_Fs48000_Fc90_B2, + -HPF_Fs48000_Fc90_B1}}; + +/* + * Band Pass Filter coefficient table + */ +const BP_C32_Coefs_t LVDBE_BPF_Table[] = { + /* Coefficients for 55Hz centre frequency */ + {BPF_Fs8000_Fc55_A0, /* 8kS/s coefficients */ + -BPF_Fs8000_Fc55_B2, + -BPF_Fs8000_Fc55_B1}, + {BPF_Fs11025_Fc55_A0, /* 11kS/s coefficients */ + -BPF_Fs11025_Fc55_B2, + -BPF_Fs11025_Fc55_B1}, + {BPF_Fs12000_Fc55_A0, /* 12kS/s coefficients */ + -BPF_Fs12000_Fc55_B2, + -BPF_Fs12000_Fc55_B1}, + {BPF_Fs16000_Fc55_A0, /* 16kS/s coefficients */ + -BPF_Fs16000_Fc55_B2, + -BPF_Fs16000_Fc55_B1}, + {BPF_Fs22050_Fc55_A0, /* 22kS/s coefficients */ + -BPF_Fs22050_Fc55_B2, + -BPF_Fs22050_Fc55_B1}, + {BPF_Fs24000_Fc55_A0, /* 24kS/s coefficients */ + -BPF_Fs24000_Fc55_B2, + -BPF_Fs24000_Fc55_B1}, + {BPF_Fs32000_Fc55_A0, /* 32kS/s coefficients */ + -BPF_Fs32000_Fc55_B2, + -BPF_Fs32000_Fc55_B1}, + {BPF_Fs44100_Fc55_A0, /* 44kS/s coefficients */ + -BPF_Fs44100_Fc55_B2, + -BPF_Fs44100_Fc55_B1}, + {BPF_Fs48000_Fc55_A0, /* 48kS/s coefficients */ + -BPF_Fs48000_Fc55_B2, + -BPF_Fs48000_Fc55_B1}, + + /* Coefficients for 66Hz centre frequency */ + {BPF_Fs8000_Fc66_A0, /* 8kS/s coefficients */ + -BPF_Fs8000_Fc66_B2, + -BPF_Fs8000_Fc66_B1}, + {BPF_Fs11025_Fc66_A0, /* 11kS/s coefficients */ + -BPF_Fs11025_Fc66_B2, + -BPF_Fs11025_Fc66_B1}, + {BPF_Fs12000_Fc66_A0, /* 12kS/s coefficients */ + -BPF_Fs12000_Fc66_B2, + -BPF_Fs12000_Fc66_B1}, + {BPF_Fs16000_Fc66_A0, /* 16kS/s coefficients */ + -BPF_Fs16000_Fc66_B2, + -BPF_Fs16000_Fc66_B1}, + {BPF_Fs22050_Fc66_A0, /* 22kS/s coefficients */ + -BPF_Fs22050_Fc66_B2, + -BPF_Fs22050_Fc66_B1}, + {BPF_Fs24000_Fc66_A0, /* 24kS/s coefficients */ + -BPF_Fs24000_Fc66_B2, + -BPF_Fs24000_Fc66_B1}, + {BPF_Fs32000_Fc66_A0, /* 32kS/s coefficients */ + -BPF_Fs32000_Fc66_B2, + -BPF_Fs32000_Fc66_B1}, + {BPF_Fs44100_Fc66_A0, /* 44kS/s coefficients */ + -BPF_Fs44100_Fc66_B2, + -BPF_Fs44100_Fc66_B1}, + {BPF_Fs48000_Fc66_A0, /* 48kS/s coefficients */ + -BPF_Fs48000_Fc66_B2, + -BPF_Fs48000_Fc66_B1}, + + /* Coefficients for 78Hz centre frequency */ + {BPF_Fs8000_Fc78_A0, /* 8kS/s coefficients */ + -BPF_Fs8000_Fc78_B2, + -BPF_Fs8000_Fc78_B1}, + {BPF_Fs11025_Fc78_A0, /* 11kS/s coefficients */ + -BPF_Fs11025_Fc78_B2, + -BPF_Fs11025_Fc78_B1}, + {BPF_Fs12000_Fc78_A0, /* 12kS/s coefficients */ + -BPF_Fs12000_Fc78_B2, + -BPF_Fs12000_Fc78_B1}, + {BPF_Fs16000_Fc78_A0, /* 16kS/s coefficients */ + -BPF_Fs16000_Fc78_B2, + -BPF_Fs16000_Fc78_B1}, + {BPF_Fs22050_Fc78_A0, /* 22kS/s coefficients */ + -BPF_Fs22050_Fc78_B2, + -BPF_Fs22050_Fc78_B1}, + {BPF_Fs24000_Fc78_A0, /* 24kS/s coefficients */ + -BPF_Fs24000_Fc78_B2, + -BPF_Fs24000_Fc78_B1}, + {BPF_Fs32000_Fc78_A0, /* 32kS/s coefficients */ + -BPF_Fs32000_Fc78_B2, + -BPF_Fs32000_Fc78_B1}, + {BPF_Fs44100_Fc78_A0, /* 44kS/s coefficients */ + -BPF_Fs44100_Fc78_B2, + -BPF_Fs44100_Fc78_B1}, + {BPF_Fs48000_Fc78_A0, /* 48kS/s coefficients */ + -BPF_Fs48000_Fc78_B2, + -BPF_Fs48000_Fc78_B1}, + + /* Coefficients for 90Hz centre frequency */ + {BPF_Fs8000_Fc90_A0, /* 8kS/s coefficients */ + -BPF_Fs8000_Fc90_B2, + -BPF_Fs8000_Fc90_B1}, + {BPF_Fs11025_Fc90_A0, /* 11kS/s coefficients */ + -BPF_Fs11025_Fc90_B2, + -BPF_Fs11025_Fc90_B1}, + {BPF_Fs12000_Fc90_A0, /* 12kS/s coefficients */ + -BPF_Fs12000_Fc90_B2, + -BPF_Fs12000_Fc90_B1}, + {BPF_Fs16000_Fc90_A0, /* 16kS/s coefficients */ + -BPF_Fs16000_Fc90_B2, + -BPF_Fs16000_Fc90_B1}, + {BPF_Fs22050_Fc90_A0, /* 22kS/s coefficients */ + -BPF_Fs22050_Fc90_B2, + -BPF_Fs22050_Fc90_B1}, + {BPF_Fs24000_Fc90_A0, /* 24kS/s coefficients */ + -BPF_Fs24000_Fc90_B2, + -BPF_Fs24000_Fc90_B1}, + {BPF_Fs32000_Fc90_A0, /* 32kS/s coefficients */ + -BPF_Fs32000_Fc90_B2, + -BPF_Fs32000_Fc90_B1}, + {BPF_Fs44100_Fc90_A0, /* 44kS/s coefficients */ + -BPF_Fs44100_Fc90_B2, + -BPF_Fs44100_Fc90_B1}, + {BPF_Fs48000_Fc90_A0, /* 48kS/s coefficients */ + -BPF_Fs48000_Fc90_B2, + -BPF_Fs48000_Fc90_B1}}; + + +/************************************************************************************/ +/* */ +/* AGC constant tables */ +/* */ +/************************************************************************************/ + +/* Attack time (signal too large) */ +const LVM_INT16 LVDBE_AGC_ATTACK_Table[] = { + AGC_ATTACK_Fs8000, + AGC_ATTACK_Fs11025, + AGC_ATTACK_Fs12000, + AGC_ATTACK_Fs16000, + AGC_ATTACK_Fs22050, + AGC_ATTACK_Fs24000, + AGC_ATTACK_Fs32000, + AGC_ATTACK_Fs44100, + AGC_ATTACK_Fs48000}; + +/* Decay time (signal too small) */ +const LVM_INT16 LVDBE_AGC_DECAY_Table[] = { + AGC_DECAY_Fs8000, + AGC_DECAY_Fs11025, + AGC_DECAY_Fs12000, + AGC_DECAY_Fs16000, + AGC_DECAY_Fs22050, + AGC_DECAY_Fs24000, + AGC_DECAY_Fs32000, + AGC_DECAY_Fs44100, + AGC_DECAY_Fs48000}; + +/* Gain for use without the high pass filter */ +const LVM_INT32 LVDBE_AGC_GAIN_Table[] = { + AGC_GAIN_0dB, + AGC_GAIN_1dB, + AGC_GAIN_2dB, + AGC_GAIN_3dB, + AGC_GAIN_4dB, + AGC_GAIN_5dB, + AGC_GAIN_6dB, + AGC_GAIN_7dB, + AGC_GAIN_8dB, + AGC_GAIN_9dB, + AGC_GAIN_10dB, + AGC_GAIN_11dB, + AGC_GAIN_12dB, + AGC_GAIN_13dB, + AGC_GAIN_14dB, + AGC_GAIN_15dB}; + +/* Gain for use with the high pass filter */ +const LVM_INT32 LVDBE_AGC_HPFGAIN_Table[] = { + AGC_HPFGAIN_0dB, + AGC_HPFGAIN_1dB, + AGC_HPFGAIN_2dB, + AGC_HPFGAIN_3dB, + AGC_HPFGAIN_4dB, + AGC_HPFGAIN_5dB, + AGC_HPFGAIN_6dB, + AGC_HPFGAIN_7dB, + AGC_HPFGAIN_8dB, + AGC_HPFGAIN_9dB, + AGC_HPFGAIN_10dB, + AGC_HPFGAIN_11dB, + AGC_HPFGAIN_12dB, + AGC_HPFGAIN_13dB, + AGC_HPFGAIN_14dB, + AGC_HPFGAIN_15dB}; + + +/************************************************************************************/ +/* */ +/* Volume control gain and time constant tables */ +/* */ +/************************************************************************************/ + +/* dB to linear conversion table */ +const LVM_INT16 LVDBE_VolumeTable[] = { + 0x4000, /* -6dB */ + 0x47FB, /* -5dB */ + 0x50C3, /* -4dB */ + 0x5A9E, /* -3dB */ + 0x65AD, /* -2dB */ + 0x7215, /* -1dB */ + 0x7FFF}; /* 0dB */ + +const LVM_INT16 LVDBE_VolumeTCTable[] = { + VOL_TC_Fs8000, + VOL_TC_Fs11025, + VOL_TC_Fs12000, + VOL_TC_Fs16000, + VOL_TC_Fs22050, + VOL_TC_Fs24000, + VOL_TC_Fs32000, + VOL_TC_Fs44100, + VOL_TC_Fs48000}; + +const LVM_INT16 LVDBE_MixerTCTable[] = { + MIX_TC_Fs8000, + MIX_TC_Fs11025, + MIX_TC_Fs12000, + MIX_TC_Fs16000, + MIX_TC_Fs22050, + MIX_TC_Fs24000, + MIX_TC_Fs32000, + MIX_TC_Fs44100, + MIX_TC_Fs48000}; + + diff --git a/media/libeffects/lvm/lib/Bass/src/LVDBE_Tables.h b/media/libeffects/lvm/lib/Bass/src/LVDBE_Tables.h new file mode 100755 index 0000000..4cb6d21 --- /dev/null +++ b/media/libeffects/lvm/lib/Bass/src/LVDBE_Tables.h @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************************ + + $Author: beq07716 $ + $Revision: 1009 $ + $Date: 2010-06-28 14:14:15 +0200 (Mon, 28 Jun 2010) $ + +*************************************************************************************/ + + +/************************************************************************************/ +/* */ +/* Includes */ +/* */ +/************************************************************************************/ +#ifndef __LVBDE_TABLES_H__ +#define __LVBDE_TABLES_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "BIQUAD.h" +#include "LVM_Types.h" + +/************************************************************************************/ +/* */ +/* Coefficients constant table */ +/* */ +/************************************************************************************/ + +/* + * High Pass Filter Coefficient table + */ +extern const BQ_C32_Coefs_t LVDBE_HPF_Table[]; + +/* + * Band Pass Filter coefficient table + */ +extern const BP_C32_Coefs_t LVDBE_BPF_Table[]; + +/************************************************************************************/ +/* */ +/* AGC constant tables */ +/* */ +/************************************************************************************/ + +/* Attack time (signal too large) */ +extern const LVM_INT16 LVDBE_AGC_ATTACK_Table[]; + +/* Decay time (signal too small) */ +extern const LVM_INT16 LVDBE_AGC_DECAY_Table[]; + +/* Gain for use without the high pass filter */ +extern const LVM_INT32 LVDBE_AGC_GAIN_Table[]; + +/* Gain for use with the high pass filter */ +extern const LVM_INT32 LVDBE_AGC_HPFGAIN_Table[]; + +/************************************************************************************/ +/* */ +/* Volume control gain and time constant tables */ +/* */ +/************************************************************************************/ + +/* dB to linear conversion table */ +extern const LVM_INT16 LVDBE_VolumeTable[]; + +extern const LVM_INT16 LVDBE_VolumeTCTable[]; + +extern const LVM_INT16 LVDBE_MixerTCTable[]; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __LVBDE_TABLES_H__ */ diff --git a/media/libeffects/lvm/lib/Bundle/lib/LVM.h b/media/libeffects/lvm/lib/Bundle/lib/LVM.h new file mode 100755 index 0000000..d472182 --- /dev/null +++ b/media/libeffects/lvm/lib/Bundle/lib/LVM.h @@ -0,0 +1,637 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/***************************************************************************************** + + $Author: beq07716 $ + $Revision: 1002 $ + $Date: 2010-06-28 13:40:09 +0200 (Mon, 28 Jun 2010) $ + +*****************************************************************************************/ + +/****************************************************************************************/ +/* */ +/* Header file for the application layer interface of Concert Sound, Bass Enhancement, */ +/* Equalizer, Power Spectrum Analyzer, Trebble Enhancement and volume management */ +/* bundle. */ +/* */ +/* This files includes all definitions, types, structures and function */ +/* prototypes required by the calling layer. All other types, structures and */ +/* functions are private. */ +/* */ +/****************************************************************************************/ +/* */ +/* Note: 1 */ +/* ======= */ +/* The algorithm can execute either with separate input and output buffers or with */ +/* a common buffer, i.e. the data is processed in-place. */ +/* */ +/****************************************************************************************/ +/* */ +/* Note: 2 */ +/* ======= */ +/* Three data formats are support Stereo,Mono-In-Stereo and Mono. The data is */ +/* interleaved as follows: */ +/* */ +/* Byte Offset Stereo Input Mono-In-Stereo Input Mono Input */ +/* =========== ============ ==================== ============== */ +/* 0 Left Sample #1 Mono Sample #1 Mono Sample #1 */ +/* 2 Right Sample #1 Mono Sample #1 Mono Sample #2 */ +/* 4 Left Sample #2 Mono Sample #2 Mono Sample #3 */ +/* 6 Right Sample #2 Mono Sample #2 Mono Sample #4 */ +/* . . . . */ +/* . . . . */ +/* */ +/****************************************************************************************/ + +#ifndef __LVM_H__ +#define __LVM_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/****************************************************************************************/ +/* */ +/* Includes */ +/* */ +/****************************************************************************************/ + +#include "LVM_Types.h" + + +/****************************************************************************************/ +/* */ +/* Definitions */ +/* */ +/****************************************************************************************/ + +/* Memory table*/ +#define LVM_NR_MEMORY_REGIONS 4 /* Number of memory regions */ + +/* Concert Sound effect level presets */ +#define LVM_CS_EFFECT_NONE 0 /* 0% effect, minimum value */ +#define LVM_CS_EFFECT_LOW 16384 /* 50% effect */ +#define LVM_CS_EFFECT_MED 24576 /* 75% effect */ +#define LVM_CS_EFFECT_HIGH 32767 /* 100% effect, maximum value */ + +/* Treble enhancement */ +#define LVM_TE_LOW_MIPS 32767 + +/* Bass enhancement effect level presets */ +#define LVM_BE_0DB 0 /* 0dB boost, no effect */ +#define LVM_BE_3DB 3 /* +3dB boost */ +#define LVM_BE_6DB 6 /* +6dB boost */ +#define LVM_BE_9DB 9 /* +9dB boost */ +#define LVM_BE_12DB 12 /* +12dB boost */ +#define LVM_BE_15DB 15 /* +15dB boost */ + +/* N-Band Equalizer */ +#define LVM_EQ_NBANDS 5 /* Number of bands for equalizer */ + +/* Headroom management */ +#define LVM_HEADROOM_MAX_NBANDS 5 + +/****************************************************************************************/ +/* */ +/* Types */ +/* */ +/****************************************************************************************/ + +/* Instance handle */ +typedef void *LVM_Handle_t; + + +/* Status return values */ +typedef enum +{ + LVM_SUCCESS = 0, /* Successful return from a routine */ + LVM_ALIGNMENTERROR = 1, /* Memory alignment error */ + LVM_NULLADDRESS = 2, /* NULL allocation address */ + LVM_OUTOFRANGE = 3, /* Out of range control parameter */ + LVM_INVALIDNUMSAMPLES = 4, /* Invalid number of samples */ + LVM_WRONGAUDIOTIME = 5, /* Wrong time value for audio time*/ + LVM_ALGORITHMDISABLED = 6, /* Algorithm is disabled*/ + LVM_ALGORITHMPSA = 7, /* Algorithm PSA returns an error */ + LVM_RETURNSTATUS_DUMMY = LVM_MAXENUM +} LVM_ReturnStatus_en; + + +/* Buffer Management mode */ +typedef enum +{ + LVM_MANAGED_BUFFERS = 0, + LVM_UNMANAGED_BUFFERS = 1, + LVM_BUFFERS_DUMMY = LVM_MAXENUM +} LVM_BufferMode_en; + +/* Output device type */ +typedef enum +{ + LVM_HEADPHONES = 0, + LVM_EX_HEADPHONES = 1, + LVM_SPEAKERTYPE_MAX = LVM_MAXENUM +} LVM_OutputDeviceType_en; + +/* Virtualizer mode selection*/ +typedef enum +{ + LVM_CONCERTSOUND = 0, + LVM_VIRTUALIZERTYPE_DUMMY = LVM_MAXENUM +} LVM_VirtualizerType_en; + +/* N-Band Equaliser operating mode */ +typedef enum +{ + LVM_EQNB_OFF = 0, + LVM_EQNB_ON = 1, + LVM_EQNB_DUMMY = LVM_MAXENUM +} LVM_EQNB_Mode_en; + +/* Bass Enhancement operating mode */ +typedef enum +{ + LVM_BE_OFF = 0, + LVM_BE_ON = 1, + LVM_BE_DUMMY = LVM_MAXENUM +} LVM_BE_Mode_en; + +/* Bass Enhancement centre frequency selection control */ +typedef enum +{ + LVM_BE_CENTRE_55Hz = 0, + LVM_BE_CENTRE_66Hz = 1, + LVM_BE_CENTRE_78Hz = 2, + LVM_BE_CENTRE_90Hz = 3, + LVM_BE_CENTRE_DUMMY = LVM_MAXENUM +} LVM_BE_CentreFreq_en; + +/* Bass Enhancement HPF selection control */ +typedef enum +{ + LVM_BE_HPF_OFF = 0, + LVM_BE_HPF_ON = 1, + LVM_BE_HPF_DUMMY = LVM_MAXENUM +} LVM_BE_FilterSelect_en; + +/* Volume Control operating mode */ +typedef enum +{ + LVM_VC_OFF = 0, + LVM_VC_ON = 1, + LVM_VC_DUMMY = LVM_MAXENUM +} LVM_VC_Mode_en; + +/* Treble Enhancement operating mode */ +typedef enum +{ + LVM_TE_OFF = 0, + LVM_TE_ON = 1, + LVM_TE_DUMMY = LVM_MAXENUM +} LVM_TE_Mode_en; + +/* Headroom management operating mode */ +typedef enum +{ + LVM_HEADROOM_OFF = 0, + LVM_HEADROOM_ON = 1, + LVM_Headroom_DUMMY = LVM_MAXENUM +} LVM_Headroom_Mode_en; + +typedef enum +{ + LVM_PSA_SPEED_SLOW, /* Peak decaying at slow speed */ + LVM_PSA_SPEED_MEDIUM, /* Peak decaying at medium speed */ + LVM_PSA_SPEED_FAST, /* Peak decaying at fast speed */ + LVM_PSA_SPEED_DUMMY = LVM_MAXENUM +} LVM_PSA_DecaySpeed_en; + +typedef enum +{ + LVM_PSA_OFF = 0, + LVM_PSA_ON = 1, + LVM_PSA_DUMMY = LVM_MAXENUM +} LVM_PSA_Mode_en; + +/* Version information */ +typedef struct +{ + LVM_CHAR *pVersionNumber; /* Pointer to the version number in the format X.YY.ZZ */ + LVM_CHAR *pPlatform; /* Pointer to the library platform type */ +} LVM_VersionInfo_st; + + +/****************************************************************************************/ +/* */ +/* Structures */ +/* */ +/****************************************************************************************/ + +/* Memory table containing the region definitions */ +typedef struct +{ + LVM_MemoryRegion_st Region[LVM_NR_MEMORY_REGIONS]; /* One definition for each region */ +} LVM_MemTab_t; + +/* N-Band equaliser band definition */ +typedef struct +{ + LVM_INT16 Gain; /* Band gain in dB */ + LVM_UINT16 Frequency; /* Band centre frequency in Hz */ + LVM_UINT16 QFactor; /* Band quality factor (x100) */ +} LVM_EQNB_BandDef_t; + + +/* Headroom band definition */ +typedef struct +{ + LVM_UINT16 Limit_Low; /* Low frequency limit of the band in Hertz */ + LVM_UINT16 Limit_High; /* High frequency limit of the band in Hertz */ + LVM_INT16 Headroom_Offset; /* Headroom = biggest band gain - Headroom_Offset */ +} LVM_HeadroomBandDef_t; + + +/* Control Parameter structure */ +typedef struct +{ + /* General parameters */ + LVM_Mode_en OperatingMode; /* Bundle operating mode On/Bypass */ + LVM_Fs_en SampleRate; /* Sample rate */ + LVM_Format_en SourceFormat; /* Input data format */ + LVM_OutputDeviceType_en SpeakerType; /* Output device type */ + + /* Concert Sound Virtualizer parameters*/ + LVM_Mode_en VirtualizerOperatingMode; /* Virtualizer operating mode On/Off */ + LVM_VirtualizerType_en VirtualizerType; /* Virtualizer type: ConcertSound */ + LVM_UINT16 VirtualizerReverbLevel; /* Virtualizer reverb level in % */ + LVM_INT16 CS_EffectLevel; /* Concert Sound effect level */ + + /* N-Band Equaliser parameters */ + LVM_EQNB_Mode_en EQNB_OperatingMode; /* N-Band Equaliser operating mode */ + LVM_UINT16 EQNB_NBands; /* Number of bands */ + LVM_EQNB_BandDef_t *pEQNB_BandDefinition; /* Pointer to equaliser definitions */ + + /* Bass Enhancement parameters */ + LVM_BE_Mode_en BE_OperatingMode; /* Bass Enhancement operating mode */ + LVM_INT16 BE_EffectLevel; /* Bass Enhancement effect level */ + LVM_BE_CentreFreq_en BE_CentreFreq; /* Bass Enhancement centre frequency */ + LVM_BE_FilterSelect_en BE_HPF; /* Bass Enhancement high pass filter selector */ + + /* Volume Control parameters */ + LVM_INT16 VC_EffectLevel; /* Volume Control setting in dBs */ + LVM_INT16 VC_Balance; /* Left Right Balance control in dB (-96 to 96 dB), -ve values reduce + Right channel while +ve value reduces Left channel*/ + + /* Treble Enhancement parameters */ + LVM_TE_Mode_en TE_OperatingMode; /* Treble Enhancement On/Off */ + LVM_INT16 TE_EffectLevel; /* Treble Enhancement gain dBs */ + + /* Spectrum Analyzer parameters Control */ + LVM_PSA_Mode_en PSA_Enable; + LVM_PSA_DecaySpeed_en PSA_PeakDecayRate; /* Peak value decay rate*/ + +} LVM_ControlParams_t; + + +/* Instance Parameter structure */ +typedef struct +{ + /* General */ + LVM_BufferMode_en BufferMode; /* Buffer management mode */ + LVM_UINT16 MaxBlockSize; /* Maximum processing block size */ + + /* N-Band Equaliser */ + LVM_UINT16 EQNB_NumBands; /* Maximum number of equaliser bands */ + + /* PSA */ + LVM_PSA_Mode_en PSA_Included; /* Controls the instance memory allocation for PSA: ON/OFF */ +} LVM_InstParams_t; + +/* Headroom management parameter structure */ +typedef struct +{ + LVM_Headroom_Mode_en Headroom_OperatingMode; /* Headroom Control On/Off */ + LVM_HeadroomBandDef_t *pHeadroomDefinition; /* Pointer to headroom bands definition */ + LVM_UINT16 NHeadroomBands; /* Number of headroom bands */ + +} LVM_HeadroomParams_t; + +/****************************************************************************************/ +/* */ +/* Function Prototypes */ +/* */ +/****************************************************************************************/ + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVM_GetVersionInfo */ +/* */ +/* DESCRIPTION: */ +/* This function is used to retrieve information about the library's version. */ +/* */ +/* PARAMETERS: */ +/* pVersion Pointer to an empty version info structure */ +/* */ +/* RETURNS: */ +/* LVM_SUCCESS Succeeded */ +/* LVM_NULLADDRESS when pVersion is NULL */ +/* */ +/* NOTES: */ +/* 1. This function may be interrupted by the LVM_Process function */ +/* */ +/****************************************************************************************/ +LVM_ReturnStatus_en LVM_GetVersionInfo(LVM_VersionInfo_st *pVersion); + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVM_GetMemoryTable */ +/* */ +/* DESCRIPTION: */ +/* This function is used for memory allocation and free. It can be called in */ +/* two ways: */ +/* */ +/* hInstance = NULL Returns the memory requirements */ +/* hInstance = Instance handle Returns the memory requirements and */ +/* allocated base addresses for the instance */ +/* */ +/* When this function is called for memory allocation (hInstance=NULL) the memory */ +/* base address pointers are NULL on return. */ +/* */ +/* When the function is called for free (hInstance = Instance Handle) the memory */ +/* table returns the allocated memory and base addresses used during initialisation. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance Handle */ +/* pMemoryTable Pointer to an empty memory definition table */ +/* pInstParams Pointer to the instance parameters */ +/* */ +/* RETURNS: */ +/* LVM_SUCCESS Succeeded */ +/* LVM_NULLADDRESS When one of pMemoryTable or pInstParams is NULL */ +/* LVM_OUTOFRANGE When any of the Instance parameters are out of range */ +/* */ +/* NOTES: */ +/* 1. This function may be interrupted by the LVM_Process function */ +/* */ +/****************************************************************************************/ +LVM_ReturnStatus_en LVM_GetMemoryTable(LVM_Handle_t hInstance, + LVM_MemTab_t *pMemoryTable, + LVM_InstParams_t *pInstParams); + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVM_GetInstanceHandle */ +/* */ +/* DESCRIPTION: */ +/* This function is used to create a bundle instance. It returns the created instance */ +/* handle through phInstance. All parameters are set to their default, inactive state. */ +/* */ +/* PARAMETERS: */ +/* phInstance pointer to the instance handle */ +/* pMemoryTable Pointer to the memory definition table */ +/* pInstParams Pointer to the instance parameters */ +/* */ +/* RETURNS: */ +/* LVM_SUCCESS Initialisation succeeded */ +/* LVM_NULLADDRESS One or more memory has a NULL pointer */ +/* LVM_OUTOFRANGE When any of the Instance parameters are out of range */ +/* */ +/* NOTES: */ +/* 1. This function must not be interrupted by the LVM_Process function */ +/* */ +/****************************************************************************************/ +LVM_ReturnStatus_en LVM_GetInstanceHandle(LVM_Handle_t *phInstance, + LVM_MemTab_t *pMemoryTable, + LVM_InstParams_t *pInstParams); + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVM_ClearAudioBuffers */ +/* */ +/* DESCRIPTION: */ +/* This function is used to clear the internal audio buffers of the bundle. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance handle */ +/* */ +/* RETURNS: */ +/* LVM_SUCCESS Initialisation succeeded */ +/* LVM_NULLADDRESS Instance memory has a NULL pointer */ +/* */ +/* NOTES: */ +/* 1. This function must not be interrupted by the LVM_Process function */ +/* */ +/****************************************************************************************/ +LVM_ReturnStatus_en LVM_ClearAudioBuffers(LVM_Handle_t hInstance); + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVM_GetControlParameters */ +/* */ +/* DESCRIPTION: */ +/* Request the LifeVibes module parameters. The current parameter set is returned */ +/* via the parameter pointer. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance handle */ +/* pParams Pointer to an empty parameter structure */ +/* */ +/* RETURNS: */ +/* LVM_SUCCESS Succeeded */ +/* LVM_NULLADDRESS when any of hInstance or pParams is NULL */ +/* */ +/* NOTES: */ +/* 1. This function may be interrupted by the LVM_Process function */ +/* */ +/****************************************************************************************/ +LVM_ReturnStatus_en LVM_GetControlParameters(LVM_Handle_t hInstance, + LVM_ControlParams_t *pParams); + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVM_SetControlParameters */ +/* */ +/* DESCRIPTION: */ +/* Sets or changes the LifeVibes module parameters. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance handle */ +/* pParams Pointer to a parameter structure */ +/* */ +/* RETURNS: */ +/* LVM_SUCCESS Succeeded */ +/* LVM_NULLADDRESS When hInstance, pParams or any control pointers are NULL */ +/* LVM_OUTOFRANGE When any of the control parameters are out of range */ +/* */ +/* NOTES: */ +/* 1. This function may be interrupted by the LVM_Process function */ +/* */ +/****************************************************************************************/ +LVM_ReturnStatus_en LVM_SetControlParameters(LVM_Handle_t hInstance, + LVM_ControlParams_t *pParams); + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVM_Process */ +/* */ +/* DESCRIPTION: */ +/* Process function for the LifeVibes module. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance handle */ +/* pInData Pointer to the input data */ +/* pOutData Pointer to the output data */ +/* NumSamples Number of samples in the input buffer */ +/* AudioTime Audio Time of the current input data in milli-seconds */ +/* */ +/* RETURNS: */ +/* LVM_SUCCESS Succeeded */ +/* LVM_INVALIDNUMSAMPLES When the NumSamples is not a valied multiple in unmanaged */ +/* buffer mode */ +/* LVM_ALIGNMENTERROR When either the input our output buffers are not 32-bit */ +/* aligned in unmanaged mode */ +/* LVM_NULLADDRESS When one of hInstance, pInData or pOutData is NULL */ +/* */ +/* NOTES: */ +/* 1. The input and output buffers must be 32-bit aligned */ +/* 2. Number of samples is defined as follows: */ +/* MONO the number of samples in the block */ +/* MONOINSTEREO the number of sample pairs in the block */ +/* STEREO the number of sample pairs in the block */ +/* */ +/****************************************************************************************/ +LVM_ReturnStatus_en LVM_Process(LVM_Handle_t hInstance, + const LVM_INT16 *pInData, + LVM_INT16 *pOutData, + LVM_UINT16 NumSamples, + LVM_UINT32 AudioTime); + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVM_SetHeadroomParams */ +/* */ +/* DESCRIPTION: */ +/* This function is used to set the automatic headroom management parameters. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance Handle */ +/* pHeadroomParams Pointer to headroom parameter structure */ +/* */ +/* RETURNS: */ +/* LVM_NULLADDRESS When hInstance or pHeadroomParams is NULL */ +/* LVM_SUCCESS Succeeded */ +/* */ +/* NOTES: */ +/* 1. This function may be interrupted by the LVM_Process function */ +/* */ +/****************************************************************************************/ +LVM_ReturnStatus_en LVM_SetHeadroomParams( LVM_Handle_t hInstance, + LVM_HeadroomParams_t *pHeadroomParams); + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVM_GetHeadroomParams */ +/* */ +/* DESCRIPTION: */ +/* This function is used to get the automatic headroom management parameters. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance Handle */ +/* pHeadroomParams Pointer to headroom parameter structure (output) */ +/* */ +/* RETURNS: */ +/* LVM_SUCCESS Succeeded */ +/* LVM_NULLADDRESS When hInstance or pHeadroomParams are NULL */ +/* */ +/* NOTES: */ +/* 1. This function may be interrupted by the LVM_Process function */ +/* */ +/****************************************************************************************/ +LVM_ReturnStatus_en LVM_GetHeadroomParams( LVM_Handle_t hInstance, + LVM_HeadroomParams_t *pHeadroomParams); + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVM_GetSpectrum */ +/* */ +/* DESCRIPTION: */ +/* This function is used to retrieve Spectral information at a given Audio time */ +/* for display usage */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance Handle */ +/* pCurrentPeaks Pointer to location where currents peaks are to be saved */ +/* pPastPeaks Pointer to location where past peaks are to be saved */ +/* pCentreFreqs Pointer to location where centre frequency of each band is */ +/* to be saved */ +/* AudioTime Audio time at which the spectral information is needed */ +/* */ +/* RETURNS: */ +/* LVM_SUCCESS Succeeded */ +/* LVM_NULLADDRESS If any of input addresses are NULL */ +/* LVM_WRONGAUDIOTIME Failure due to audio time error */ +/* */ +/* NOTES: */ +/* 1. This function may be interrupted by the LVM_Process function */ +/* */ +/****************************************************************************************/ +LVM_ReturnStatus_en LVM_GetSpectrum( LVM_Handle_t hInstance, + LVM_UINT8 *pCurrentPeaks, + LVM_UINT8 *pPastPeaks, + LVM_INT32 AudioTime); + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVM_SetVolumeNoSmoothing */ +/* */ +/* DESCRIPTION: */ +/* This function is used to set output volume without any smoothing */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance Handle */ +/* pParams Control Parameters, only volume value is used here */ +/* */ +/* RETURNS: */ +/* LVM_SUCCESS Succeeded */ +/* LVM_NULLADDRESS If any of input addresses are NULL */ +/* LVM_OUTOFRANGE When any of the control parameters are out of range */ +/* */ +/* NOTES: */ +/* 1. This function may be interrupted by the LVM_Process function */ +/* */ +/****************************************************************************************/ +LVM_ReturnStatus_en LVM_SetVolumeNoSmoothing( LVM_Handle_t hInstance, + LVM_ControlParams_t *pParams); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __LVM_H__ */ + diff --git a/media/libeffects/lvm/lib/Bundle/src/LVM_API_Specials.c b/media/libeffects/lvm/lib/Bundle/src/LVM_API_Specials.c new file mode 100755 index 0000000..2f6fa4c --- /dev/null +++ b/media/libeffects/lvm/lib/Bundle/src/LVM_API_Specials.c @@ -0,0 +1,158 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/**************************************************************************************** + + $Author: beq07716 $ + $Revision: 1002 $ + $Date: 2010-06-28 13:40:09 +0200 (Mon, 28 Jun 2010) $ + +*****************************************************************************************/ + + +/****************************************************************************************/ +/* */ +/* Includes */ +/* */ +/****************************************************************************************/ + +#include "LVM_Private.h" +#include "LVM_Tables.h" + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVM_GetSpectrum */ +/* */ +/* DESCRIPTION: */ +/* This function is used to retrieve Spectral information at a given Audio time */ +/* for display usage */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance Handle */ +/* pCurrentPeaks Pointer to location where currents peaks are to be saved */ +/* pPastPeaks Pointer to location where past peaks are to be saved */ +/* AudioTime Audio time at which the spectral information is needed */ +/* */ +/* RETURNS: */ +/* LVM_SUCCESS Succeeded */ +/* LVM_NULLADDRESS If any of input addresses are NULL */ +/* LVM_WRONGAUDIOTIME Failure due to audio time error */ +/* */ +/* NOTES: */ +/* 1. This function may be interrupted by the LVM_Process function */ +/* */ +/****************************************************************************************/ +LVM_ReturnStatus_en LVM_GetSpectrum( + LVM_Handle_t hInstance, + LVM_UINT8 *pCurrentPeaks, + LVM_UINT8 *pPastPeaks, + LVM_INT32 AudioTime + ) +{ + LVM_Instance_t *pInstance = (LVM_Instance_t *)hInstance; + + pLVPSA_Handle_t *hPSAInstance; + LVPSA_RETURN LVPSA_Status; + + + if(pInstance == LVM_NULL) + { + return LVM_NULLADDRESS; + } + + /*If PSA is not included at the time of instance creation, return without any processing*/ + if(pInstance->InstParams.PSA_Included!=LVM_PSA_ON) + { + return LVM_SUCCESS; + } + + hPSAInstance = pInstance->hPSAInstance; + + if((pCurrentPeaks == LVM_NULL) || + (pPastPeaks == LVM_NULL)) + { + return LVM_NULLADDRESS; + } + + + /* + * Update new parameters if necessary + */ + if (pInstance->ControlPending == LVM_TRUE) + { + LVM_ApplyNewSettings(hInstance); + } + + /* If PSA module is disabled, do nothing */ + if(pInstance->Params.PSA_Enable==LVM_PSA_OFF) + { + return LVM_ALGORITHMDISABLED; + } + + LVPSA_Status = LVPSA_GetSpectrum(hPSAInstance, + (LVPSA_Time) (AudioTime), + (LVM_UINT8*) pCurrentPeaks, + (LVM_UINT8*) pPastPeaks ); + + if(LVPSA_Status != LVPSA_OK) + { + if(LVPSA_Status == LVPSA_ERROR_WRONGTIME) + { + return (LVM_ReturnStatus_en) LVM_WRONGAUDIOTIME; + } + else + { + return (LVM_ReturnStatus_en) LVM_NULLADDRESS; + } + } + + return(LVM_SUCCESS); +} + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVM_SetVolumeNoSmoothing */ +/* */ +/* DESCRIPTION: */ +/* This function is used to set output volume without any smoothing */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance Handle */ +/* pParams Control Parameters, only volume value is used here */ +/* */ +/* RETURNS: */ +/* LVM_SUCCESS Succeeded */ +/* LVM_NULLADDRESS If any of input addresses are NULL */ +/* LVM_OUTOFRANGE When any of the control parameters are out of range */ +/* */ +/* NOTES: */ +/* 1. This function may be interrupted by the LVM_Process function */ +/* */ +/****************************************************************************************/ +LVM_ReturnStatus_en LVM_SetVolumeNoSmoothing( LVM_Handle_t hInstance, + LVM_ControlParams_t *pParams) +{ + LVM_Instance_t *pInstance =(LVM_Instance_t *)hInstance; + LVM_ReturnStatus_en Error; + + /*Apply new controls*/ + Error = LVM_SetControlParameters(hInstance,pParams); + pInstance->NoSmoothVolume = LVM_TRUE; + return Error; +} + diff --git a/media/libeffects/lvm/lib/Bundle/src/LVM_Buffers.c b/media/libeffects/lvm/lib/Bundle/src/LVM_Buffers.c new file mode 100755 index 0000000..41785a3 --- /dev/null +++ b/media/libeffects/lvm/lib/Bundle/src/LVM_Buffers.c @@ -0,0 +1,878 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +/**************************************************************************************** + + $Author: nxp007753 $ + $Revision: 1082 $ + $Date: 2010-07-05 12:44:39 +0200 (Mon, 05 Jul 2010) $ + +*****************************************************************************************/ + +/****************************************************************************************/ +/* */ +/* Includes */ +/* */ +/****************************************************************************************/ + +#include "LVM_Private.h" +#include "VectorArithmetic.h" + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVM_BufferManagedIn */ +/* */ +/* DESCRIPTION: */ +/* Full buffer management allowing the user to provide input and output buffers on */ +/* any alignment and with any number of samples. The alignment is corrected within */ +/* the buffer management and the samples are grouped in to blocks of the correct size */ +/* before processing. */ +/* */ +/* PARAMETERS: */ +/* hInstance - Instance handle */ +/* pInData - Pointer to the input data stream */ +/* *pToProcess - Pointer to pointer to the start of data processing */ +/* *pProcessed - Pointer to pointer to the destination of the processed data */ +/* pNumSamples - Pointer to the number of samples to process */ +/* */ +/* RETURNS: */ +/* None */ +/* */ +/* NOTES: */ +/* */ +/****************************************************************************************/ + +void LVM_BufferManagedIn(LVM_Handle_t hInstance, + const LVM_INT16 *pInData, + LVM_INT16 **pToProcess, + LVM_INT16 **pProcessed, + LVM_UINT16 *pNumSamples) +{ + + LVM_INT16 SampleCount; /* Number of samples to be processed this call */ + LVM_INT16 NumSamples; /* Number of samples in scratch buffer */ + LVM_INT16 *pStart; + LVM_Instance_t *pInstance = (LVM_Instance_t *)hInstance; + LVM_Buffer_t *pBuffer; + LVM_INT16 *pDest; + LVM_INT16 NumChannels =2; + + + /* + * Set the processing address pointers + */ + pBuffer = pInstance->pBufferManagement; + pDest = pBuffer->pScratch; + *pToProcess = pBuffer->pScratch; + *pProcessed = pBuffer->pScratch; + + /* + * Check if it is the first call of a block + */ + if (pInstance->SamplesToProcess == 0) + { + /* + * First call for a new block of samples + */ + pInstance->SamplesToProcess = (LVM_INT16)(*pNumSamples + pBuffer->InDelaySamples); + pInstance->pInputSamples = (LVM_INT16 *)pInData; + pBuffer->BufferState = LVM_FIRSTCALL; + } + pStart = pInstance->pInputSamples; /* Pointer to the input samples */ + pBuffer->SamplesToOutput = 0; /* Samples to output is same as number read for inplace processing */ + + + /* + * Calculate the number of samples to process this call and update the buffer state + */ + if (pInstance->SamplesToProcess > pInstance->InternalBlockSize) + { + /* + * Process the maximum bock size of samples. + */ + SampleCount = pInstance->InternalBlockSize; + NumSamples = pInstance->InternalBlockSize; + } + else + { + /* + * Last call for the block, so calculate how many frames and samples to process + */ + LVM_INT16 NumFrames; + + NumSamples = pInstance->SamplesToProcess; + NumFrames = (LVM_INT16)(NumSamples >> MIN_INTERNAL_BLOCKSHIFT); + SampleCount = (LVM_INT16)(NumFrames << MIN_INTERNAL_BLOCKSHIFT); + + /* + * Update the buffer state + */ + if (pBuffer->BufferState == LVM_FIRSTCALL) + { + pBuffer->BufferState = LVM_FIRSTLASTCALL; + } + else + { + pBuffer->BufferState = LVM_LASTCALL; + } + } + *pNumSamples = (LVM_UINT16)SampleCount; /* Set the number of samples to process this call */ + + + /* + * Copy samples from the delay buffer as required + */ + if (((pBuffer->BufferState == LVM_FIRSTCALL) || + (pBuffer->BufferState == LVM_FIRSTLASTCALL)) && + (pBuffer->InDelaySamples != 0)) + { + Copy_16(&pBuffer->InDelayBuffer[0], /* Source */ + pDest, /* Destination */ + (LVM_INT16)(NumChannels*pBuffer->InDelaySamples)); /* Number of delay samples, left and right */ + NumSamples = (LVM_INT16)(NumSamples - pBuffer->InDelaySamples); /* Update sample count */ + pDest += NumChannels * pBuffer->InDelaySamples; /* Update the destination pointer */ + } + + + /* + * Copy the rest of the samples for this call from the input buffer + */ + if (NumSamples > 0) + { + Copy_16(pStart, /* Source */ + pDest, /* Destination */ + (LVM_INT16)(NumChannels*NumSamples)); /* Number of input samples */ + pStart += NumChannels * NumSamples; /* Update the input pointer */ + + /* + * Update the input data pointer and samples to output + */ + pBuffer->SamplesToOutput = (LVM_INT16)(pBuffer->SamplesToOutput + NumSamples); /* Update samples to output */ + } + + + /* + * Update the sample count and input pointer + */ + pInstance->SamplesToProcess = (LVM_INT16)(pInstance->SamplesToProcess - SampleCount); /* Update the count of samples */ + pInstance->pInputSamples = pStart; /* Update input sample pointer */ + + + /* + * Save samples to the delay buffer if any left unprocessed + */ + if ((pBuffer->BufferState == LVM_FIRSTLASTCALL) || + (pBuffer->BufferState == LVM_LASTCALL)) + { + NumSamples = pInstance->SamplesToProcess; + pStart = pBuffer->pScratch; /* Start of the buffer */ + pStart += NumChannels*SampleCount; /* Offset by the number of processed samples */ + if (NumSamples != 0) + { + Copy_16(pStart, /* Source */ + &pBuffer->InDelayBuffer[0], /* Destination */ + (LVM_INT16)(NumChannels*NumSamples)); /* Number of input samples */ + } + + + /* + * Update the delay sample count + */ + pBuffer->InDelaySamples = NumSamples; /* Number of delay sample pairs */ + pInstance->SamplesToProcess = 0; /* All Samples used */ + } +} + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVM_BufferUnmanagedIn */ +/* */ +/* DESCRIPTION: */ +/* This mode is selected by the user code and disables the buffer management with the */ +/* exception of the maximum block size processing. The user must ensure that the */ +/* input and output buffers are 32-bit aligned and also that the number of samples to */ +/* process is a correct multiple of samples. */ +/* */ +/* PARAMETERS: */ +/* hInstance - Instance handle */ +/* *pToProcess - Pointer to the start of data processing */ +/* *pProcessed - Pointer to the destination of the processed data */ +/* pNumSamples - Pointer to the number of samples to process */ +/* */ +/* RETURNS: */ +/* None */ +/* */ +/* NOTES: */ +/* */ +/****************************************************************************************/ + +void LVM_BufferUnmanagedIn(LVM_Handle_t hInstance, + LVM_INT16 **pToProcess, + LVM_INT16 **pProcessed, + LVM_UINT16 *pNumSamples) +{ + + LVM_Instance_t *pInstance = (LVM_Instance_t *)hInstance; + + + /* + * Check if this is the first call of a block + */ + if (pInstance->SamplesToProcess == 0) + { + pInstance->SamplesToProcess = (LVM_INT16)*pNumSamples; /* Get the number of samples on first call */ + pInstance->pInputSamples = *pToProcess; /* Get the I/O pointers */ + pInstance->pOutputSamples = *pProcessed; + + + /* + * Set te block size to process + */ + if (pInstance->SamplesToProcess > pInstance->InternalBlockSize) + { + *pNumSamples = (LVM_UINT16)pInstance->InternalBlockSize; + } + else + { + *pNumSamples = (LVM_UINT16)pInstance->SamplesToProcess; + } + } + + /* + * Set the process pointers + */ + *pToProcess = pInstance->pInputSamples; + *pProcessed = pInstance->pOutputSamples; +} + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVM_BufferOptimisedIn */ +/* */ +/* DESCRIPTION: */ +/* Optimised buffer management for the case where the data is outplace processing, */ +/* the output data is 32-bit aligned and there are sufficient samples to allow some */ +/* processing directly in the output buffer. This saves one data copy per sample */ +/* compared with the unoptimsed version. */ +/* */ +/* PARAMETERS: */ +/* hInstance - Instance handle */ +/* pInData - Pointer to the input data stream */ +/* *pToProcess - Pointer to the start of data processing */ +/* *pProcessed - Pointer to the destination of the processed data */ +/* pNumSamples - Pointer to the number of samples to process */ +/* */ +/* RETURNS: */ +/* None */ +/* */ +/* NOTES: */ +/* */ +/****************************************************************************************/ + +void LVM_BufferOptimisedIn(LVM_Handle_t hInstance, + const LVM_INT16 *pInData, + LVM_INT16 **pToProcess, + LVM_INT16 **pProcessed, + LVM_UINT16 *pNumSamples) +{ + + LVM_Instance_t *pInstance = (LVM_Instance_t *)hInstance; + LVM_Buffer_t *pBuffer = pInstance->pBufferManagement; + LVM_INT16 *pDest; + LVM_INT16 SampleCount; + LVM_INT16 NumSamples; + LVM_INT16 NumFrames; + + /* + * Check if it is the first call for this block + */ + if (pInstance->SamplesToProcess == 0) + { + /* + * First call for a new block of samples + */ + pBuffer->BufferState = LVM_FIRSTCALL; + pInstance->pInputSamples = (LVM_INT16 *)pInData; + pInstance->SamplesToProcess = (LVM_INT16)*pNumSamples; + pBuffer->SamplesToOutput = (LVM_INT16)*pNumSamples; + pDest = *pProcessed; /* The start of the output buffer */ + + + /* + * Copy the already processed samples to the output buffer + */ + if (pBuffer->OutDelaySamples != 0) + { + Copy_16(&pBuffer->OutDelayBuffer[0], /* Source */ + pDest, /* Detsination */ + (LVM_INT16)(2*pBuffer->OutDelaySamples)); /* Number of delay samples */ + pDest += 2 * pBuffer->OutDelaySamples; /* Update the output pointer */ + pBuffer->SamplesToOutput = (LVM_INT16)(pBuffer->SamplesToOutput - pBuffer->OutDelaySamples); /* Update the numbr of samples to output */ + } + *pToProcess = pDest; /* Set the address to start processing */ + *pProcessed = pDest; /* Process in the output buffer, now inplace */ + + /* + * Copy the input delay buffer (unprocessed) samples to the output buffer + */ + if (pBuffer->InDelaySamples != 0) + { + Copy_16(&pBuffer->InDelayBuffer[0], /* Source */ + pDest, /* Destination */ + (LVM_INT16)(2*pBuffer->InDelaySamples)); /* Number of delay samples */ + pDest += 2 * pBuffer->InDelaySamples; /* Update the output pointer */ + } + + + /* + * Calculate how many input samples to process and copy + */ + NumSamples = (LVM_INT16)(*pNumSamples - pBuffer->OutDelaySamples); /* Number that will fit in the output buffer */ + if (NumSamples >= pInstance->InternalBlockSize) + { + NumSamples = pInstance->InternalBlockSize; + } + NumFrames = (LVM_INT16)(NumSamples >> MIN_INTERNAL_BLOCKSHIFT); + SampleCount = (LVM_INT16)(NumFrames << MIN_INTERNAL_BLOCKSHIFT); + *pNumSamples = (LVM_UINT16)SampleCount; /* The number of samples to process */ + pBuffer->SamplesToOutput = (LVM_INT16)(pBuffer->SamplesToOutput - SampleCount); /* Update the number of samples to output */ + SampleCount = (LVM_INT16)(SampleCount - pBuffer->InDelaySamples); /* The number of samples to copy from the input */ + + + /* + * Copy samples from the input buffer and update counts and pointers + */ + Copy_16(pInstance->pInputSamples, /* Source */ + pDest, /* Destination */ + (LVM_INT16)(2*SampleCount)); /* Number of input samples */ + pInstance->pInputSamples += 2 * SampleCount; /* Update the input pointer */ + pInstance->pOutputSamples = pDest + (2 * SampleCount); /* Update the output pointer */ + pInstance->SamplesToProcess = (LVM_INT16)(pInstance->SamplesToProcess - SampleCount); /* Samples left in the input buffer */ + } + else + { + /* + * Second or subsequent call in optimised mode + */ + if (pBuffer->SamplesToOutput >= MIN_INTERNAL_BLOCKSIZE) + { + /* + * More samples can be processed directly in the output buffer + */ + *pToProcess = pInstance->pOutputSamples; /* Set the address to start processing */ + *pProcessed = pInstance->pOutputSamples; /* Process in the output buffer, now inplace */ + NumSamples = pBuffer->SamplesToOutput; /* Number that will fit in the output buffer */ + if (NumSamples >= pInstance->InternalBlockSize) + { + NumSamples = pInstance->InternalBlockSize; + } + NumFrames = (LVM_INT16)(NumSamples >> MIN_INTERNAL_BLOCKSHIFT); + SampleCount = (LVM_INT16)(NumFrames << MIN_INTERNAL_BLOCKSHIFT); + *pNumSamples = (LVM_UINT16)SampleCount; /* The number of samples to process */ + + + /* + * Copy samples from the input buffer and update counts and pointers + */ + Copy_16(pInstance->pInputSamples, /* Source */ + pInstance->pOutputSamples, /* Destination */ + (LVM_INT16)(2*SampleCount)); /* Number of input samples */ + pInstance->pInputSamples += 2 * SampleCount; /* Update the input pointer */ + pInstance->pOutputSamples += 2 * SampleCount; /* Update the output pointer */ + pInstance->SamplesToProcess = (LVM_INT16)(pInstance->SamplesToProcess - SampleCount); /* Samples left in the input buffer */ + pBuffer->SamplesToOutput = (LVM_INT16)(pBuffer->SamplesToOutput - SampleCount); /* Number that will fit in the output buffer */ + } + else + { + /* + * The remaining samples can not be processed in the output buffer + */ + pBuffer->BufferState = LVM_LASTCALL; /* Indicate this is the last bock to process */ + *pToProcess = pBuffer->pScratch; /* Set the address to start processing */ + *pProcessed = pBuffer->pScratch; /* Process in the output buffer, now inplace */ + NumSamples = pInstance->SamplesToProcess; /* Number left to be processed */ + NumFrames = (LVM_INT16)(NumSamples >> MIN_INTERNAL_BLOCKSHIFT); + SampleCount = (LVM_INT16)(NumFrames << MIN_INTERNAL_BLOCKSHIFT); + *pNumSamples = (LVM_UINT16)SampleCount; /* The number of samples to process */ + + + /* + * Copy samples from the input buffer and update counts and pointers + */ + Copy_16(pInstance->pInputSamples, /* Source */ + pBuffer->pScratch, /* Destination */ + (LVM_INT16)(2*SampleCount)); /* Number of input samples */ + pInstance->pInputSamples += 2 * SampleCount; /* Update the input pointer */ + pInstance->SamplesToProcess = (LVM_INT16)(pInstance->SamplesToProcess - SampleCount); /* Samples left in the input buffer */ + } + } +} + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVM_BufferIn */ +/* */ +/* DESCRIPTION: */ +/* This function manages the data input, it has the following features: */ +/* - Accepts data in 16-bit aligned memory */ +/* - Copies the data to 32-bit aligned memory */ +/* - Converts Mono inputs to Mono-in-Stereo */ +/* - Accepts any number of samples as input, except 0 */ +/* - Breaks the input sample stream in to blocks of the configured frame size or */ +/* multiples of the frame size */ +/* - Limits the processing block size to the maximum block size. */ +/* - Works with inplace or outplace processing automatically */ +/* */ +/* To manage the data the function has a number of operating states: */ +/* LVM_FIRSTCALL - The first call for this block of input samples */ +/* LVM_MAXBLOCKCALL - The current block is the maximum size. Only used for the */ +/* second and subsequent blocks. */ +/* LVM_LASTCALL - The last call for this block of input samples */ +/* LVM_FIRSTLASTCALL - This is the first and last call for this block of input*/ +/* samples, this occurs when the number of samples to */ +/* process is less than the maximum block size. */ +/* */ +/* The function uses an internal delay buffer the size of the minimum frame, this is */ +/* used to temporarily hold samples when the number of samples to process is not a */ +/* multiple of the frame size. */ +/* */ +/* To ensure correct operation with inplace buffering the number of samples to output*/ +/* per call is calculated in this function and is set to the number of samples read */ +/* from the input buffer. */ +/* */ +/* The total number of samples to process is stored when the function is called for */ +/* the first time. The value is overwritten by the size of the block to be processed */ +/* in each call so the size of the processing blocks can be controlled. The number of */ +/* samples actually processed for each block of input samples is always a multiple of*/ +/* the frame size so for any particular block of input samples the actual number of */ +/* processed samples may not match the number of input samples, sometime it will be */ +/* sometimes less. The average is the same and the difference is never more than the */ +/* frame size. */ +/* */ +/* PARAMETERS: */ +/* hInstance - Instance handle */ +/* pInData - Pointer to the input data stream */ +/* *pToProcess - Pointer to the start of data processing */ +/* *pProcessed - Pointer to the destination of the processed data */ +/* pNumSamples - Pointer to the number of samples to process */ +/* */ +/* RETURNS: */ +/* None */ +/* */ +/* NOTES: */ +/* */ +/****************************************************************************************/ + +void LVM_BufferIn(LVM_Handle_t hInstance, + const LVM_INT16 *pInData, + LVM_INT16 **pToProcess, + LVM_INT16 **pProcessed, + LVM_UINT16 *pNumSamples) +{ + + LVM_Instance_t *pInstance = (LVM_Instance_t *)hInstance; + + + /* + * Check which mode, managed or unmanaged + */ + if (pInstance->InstParams.BufferMode == LVM_MANAGED_BUFFERS) + { + LVM_BufferManagedIn(hInstance, + pInData, + pToProcess, + pProcessed, + pNumSamples); + } + else + { + LVM_BufferUnmanagedIn(hInstance, + pToProcess, + pProcessed, + pNumSamples); + } +} + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVM_BufferManagedOut */ +/* */ +/* DESCRIPTION: */ +/* Full buffer management output. This works in conjunction with the managed input */ +/* routine and ensures the correct number of samples are always output to the output */ +/* buffer. */ +/* */ +/* PARAMETERS: */ +/* hInstance - Instance handle */ +/* pOutData - Pointer to the output data stream */ +/* pNumSamples - Pointer to the number of samples to process */ +/* */ +/* RETURNS: */ +/* None */ +/* */ +/* NOTES: */ +/* */ +/****************************************************************************************/ + +void LVM_BufferManagedOut(LVM_Handle_t hInstance, + LVM_INT16 *pOutData, + LVM_UINT16 *pNumSamples) +{ + + LVM_Instance_t *pInstance = (LVM_Instance_t *)hInstance; + LVM_Buffer_t *pBuffer = pInstance->pBufferManagement; + LVM_INT16 SampleCount = (LVM_INT16)*pNumSamples; + LVM_INT16 NumSamples; + LVM_INT16 *pStart; + LVM_INT16 *pDest; + + + /* + * Set the pointers + */ + NumSamples = pBuffer->SamplesToOutput; + pStart = pBuffer->pScratch; + + + /* + * check if it is the first call of a block + */ + if ((pBuffer->BufferState == LVM_FIRSTCALL) || + (pBuffer->BufferState == LVM_FIRSTLASTCALL)) + { + /* First call for a new block */ + pInstance->pOutputSamples = pOutData; /* Initialise the destination */ + } + pDest = pInstance->pOutputSamples; /* Set the output address */ + + + /* + * If the number of samples is non-zero then there are still samples to send to + * the output buffer + */ + if ((NumSamples != 0) && + (pBuffer->OutDelaySamples != 0)) + { + /* + * Copy the delayed output buffer samples to the output + */ + if (pBuffer->OutDelaySamples <= NumSamples) + { + /* + * Copy all output delay samples to the output + */ + Copy_16(&pBuffer->OutDelayBuffer[0], /* Source */ + pDest, /* Detsination */ + (LVM_INT16)(2*pBuffer->OutDelaySamples)); /* Number of delay samples */ + + /* + * Update the pointer and sample counts + */ + pDest += 2*pBuffer->OutDelaySamples; /* Output sample pointer */ + NumSamples = (LVM_INT16)(NumSamples - pBuffer->OutDelaySamples); /* Samples left to send */ + pBuffer->OutDelaySamples = 0; /* No samples left in the buffer */ + + } + else + { + /* + * Copy only some of the ouput delay samples to the output + */ + Copy_16(&pBuffer->OutDelayBuffer[0], /* Source */ + pDest, /* Detsination */ + (LVM_INT16)(2*NumSamples)); /* Number of delay samples */ + + /* + * Update the pointer and sample counts + */ + pDest += 2*NumSamples; /* Output sample pointer */ + pBuffer->OutDelaySamples = (LVM_INT16)(pBuffer->OutDelaySamples - NumSamples); /* No samples left in the buffer */ + + + /* + * Realign the delay buffer data to avoid using circular buffer management + */ + Copy_16(&pBuffer->OutDelayBuffer[2*NumSamples], /* Source */ + &pBuffer->OutDelayBuffer[0], /* Destination */ + (LVM_INT16)(2*pBuffer->OutDelaySamples)); /* Number of samples to move */ + NumSamples = 0; /* Samples left to send */ + } + } + + + /* + * Copy the processed results to the output + */ + if ((NumSamples != 0) && + (SampleCount != 0)) + { + if (SampleCount <= NumSamples) + { + /* + * Copy all processed samples to the output + */ + Copy_16(pStart, /* Source */ + pDest, /* Detsination */ + (LVM_INT16)(2*SampleCount)); /* Number of processed samples */ + + /* + * Update the pointer and sample counts + */ + pDest += 2 * SampleCount; /* Output sample pointer */ + NumSamples = (LVM_INT16)(NumSamples - SampleCount); /* Samples left to send */ + SampleCount = 0; /* No samples left in the buffer */ + } + else + { + /* + * Copy only some processed samples to the output + */ + Copy_16(pStart, /* Source */ + pDest, /* Destination */ + (LVM_INT16)(2*NumSamples)); /* Number of processed samples */ + + + /* + * Update the pointers and sample counts + */ + pStart += 2 * NumSamples; /* Processed sample pointer */ + pDest += 2 * NumSamples; /* Output sample pointer */ + SampleCount = (LVM_INT16)(SampleCount - NumSamples); /* Processed samples left */ + NumSamples = 0; /* Clear the sample count */ + } + } + + + /* + * Copy the remaining processed data to the output delay buffer + */ + if (SampleCount != 0) + { + Copy_16(pStart, /* Source */ + &pBuffer->OutDelayBuffer[2*pBuffer->OutDelaySamples], /* Destination */ + (LVM_INT16)(2*SampleCount)); /* Number of processed samples */ + pBuffer->OutDelaySamples = (LVM_INT16)(pBuffer->OutDelaySamples + SampleCount); /* Update the buffer count */ + } + + + /* + * pointers, counts and set default buffer processing + */ + pBuffer->SamplesToOutput = NumSamples; /* Samples left to send */ + pInstance->pOutputSamples = pDest; /* Output sample pointer */ + pBuffer->BufferState = LVM_MAXBLOCKCALL; /* Set for the default call block size */ + *pNumSamples = (LVM_UINT16)pInstance->SamplesToProcess; /* This will terminate the loop when all samples processed */ +} + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVM_BufferUnmanagedOut */ +/* */ +/* DESCRIPTION: */ +/* This works in conjunction with the unmanaged input routine and updates the number */ +/* of samples left to be processed and adjusts the buffer pointers. */ +/* */ +/* PARAMETERS: */ +/* hInstance - Instance handle */ +/* pNumSamples - Pointer to the number of samples to process */ +/* */ +/* RETURNS: */ +/* None */ +/* */ +/* NOTES: */ +/* */ +/****************************************************************************************/ + +void LVM_BufferUnmanagedOut(LVM_Handle_t hInstance, + LVM_UINT16 *pNumSamples) +{ + + LVM_Instance_t *pInstance = (LVM_Instance_t *)hInstance; + LVM_INT16 NumChannels =2; + + + /* + * Update sample counts + */ + pInstance->pInputSamples += (LVM_INT16)(*pNumSamples * NumChannels); /* Update the I/O pointers */ + pInstance->pOutputSamples += (LVM_INT16)(*pNumSamples * 2); + pInstance->SamplesToProcess = (LVM_INT16)(pInstance->SamplesToProcess - *pNumSamples); /* Update the sample count */ + + /* + * Set te block size to process + */ + if (pInstance->SamplesToProcess > pInstance->InternalBlockSize) + { + *pNumSamples = (LVM_UINT16)pInstance->InternalBlockSize; + } + else + { + *pNumSamples = (LVM_UINT16)pInstance->SamplesToProcess; + } +} + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVM_BufferOptimisedOut */ +/* */ +/* DESCRIPTION: */ +/* This works in conjunction with the optimised input routine and copies the last few */ +/* processed and unprocessed samples to their respective buffers. */ +/* */ +/* PARAMETERS: */ +/* hInstance - Instance handle */ +/* pNumSamples - Pointer to the number of samples to process */ +/* */ +/* RETURNS: */ +/* None */ +/* */ +/* NOTES: */ +/* */ +/****************************************************************************************/ + +void LVM_BufferOptimisedOut(LVM_Handle_t hInstance, + LVM_UINT16 *pNumSamples) +{ + + LVM_Instance_t *pInstance = (LVM_Instance_t *)hInstance; + LVM_Buffer_t *pBuffer = pInstance->pBufferManagement; + + /* + * Check if it is the last block to process + */ + if (pBuffer->BufferState == LVM_LASTCALL) + { + LVM_INT16 *pSrc = pBuffer->pScratch; + + /* + * Copy the unprocessed samples to the input delay buffer + */ + if (pInstance->SamplesToProcess != 0) + { + Copy_16(pInstance->pInputSamples, /* Source */ + &pBuffer->InDelayBuffer[0], /* Destination */ + (LVM_INT16)(2*pInstance->SamplesToProcess)); /* Number of input samples */ + pBuffer->InDelaySamples = pInstance->SamplesToProcess; + pInstance->SamplesToProcess = 0; + } + else + { + pBuffer->InDelaySamples = 0; + } + + + /* + * Fill the last empty spaces in the output buffer + */ + if (pBuffer->SamplesToOutput != 0) + { + Copy_16(pSrc, /* Source */ + pInstance->pOutputSamples, /* Destination */ + (LVM_INT16)(2*pBuffer->SamplesToOutput)); /* Number of input samples */ + *pNumSamples = (LVM_UINT16)(*pNumSamples - pBuffer->SamplesToOutput); + pSrc += 2 * pBuffer->SamplesToOutput; /* Update scratch pointer */ + pBuffer->SamplesToOutput = 0; /* No more samples in this block */ + } + + + /* + * Save any remaining processed samples in the output delay buffer + */ + if (*pNumSamples != 0) + { + Copy_16(pSrc, /* Source */ + &pBuffer->OutDelayBuffer[0], /* Destination */ + (LVM_INT16)(2**pNumSamples)); /* Number of input samples */ + + pBuffer->OutDelaySamples = (LVM_INT16)*pNumSamples; + + *pNumSamples = 0; /* No more samples in this block */ + } + else + { + pBuffer->OutDelaySamples = 0; + } + } +} + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVM_BufferOut */ +/* */ +/* DESCRIPTION: */ +/* This function manages the data output, it has the following features: */ +/* - Output data to 16-bit aligned memory */ +/* - Reads data from 32-bit aligned memory */ +/* - Reads data only in blocks of frame size or multiples of frame size */ +/* - Writes the same number of samples as the LVM_BufferIn function reads */ +/* - Works with inplace or outplace processing automatically */ +/* */ +/* To manage the data the function has a number of operating states: */ +/* LVM_FIRSTCALL - The first call for this block of input samples */ +/* LVM_FIRSTLASTCALL - This is the first and last call for this block of input*/ +/* samples, this occurs when the number of samples to */ +/* process is less than the maximum block size. */ +/* */ +/* The function uses an internal delay buffer the size of the minimum frame, this is */ +/* used to temporarily hold samples when the number of samples to write is not a */ +/* multiple of the frame size. */ +/* */ +/* To ensure correct operation with inplace buffering the number of samples to output*/ +/* per call is always the same as the number of samples read from the input buffer. */ +/* */ +/* PARAMETERS: */ +/* hInstance - Instance handle */ +/* pOutData - Pointer to the output data stream */ +/* pNumSamples - Pointer to the number of samples to process */ +/* */ +/* RETURNS: */ +/* None */ +/* */ +/* NOTES: */ +/* */ +/****************************************************************************************/ + +void LVM_BufferOut(LVM_Handle_t hInstance, + LVM_INT16 *pOutData, + LVM_UINT16 *pNumSamples) +{ + + LVM_Instance_t *pInstance = (LVM_Instance_t *)hInstance; + + + /* + * Check which mode, managed or unmanaged + */ + if (pInstance->InstParams.BufferMode == LVM_MANAGED_BUFFERS) + { + LVM_BufferManagedOut(hInstance, + pOutData, + pNumSamples); + } + else + { + LVM_BufferUnmanagedOut(hInstance, + pNumSamples); + } +} + diff --git a/media/libeffects/lvm/lib/Bundle/src/LVM_Coeffs.h b/media/libeffects/lvm/lib/Bundle/src/LVM_Coeffs.h new file mode 100755 index 0000000..f578db9 --- /dev/null +++ b/media/libeffects/lvm/lib/Bundle/src/LVM_Coeffs.h @@ -0,0 +1,573 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __LVM_COEFFS_H__ +#define __LVM_COEFFS_H__ + + +/************************************************************************************/ +/* */ +/* High Pass Shelving Filter coefficients */ +/* */ +/************************************************************************************/ + +#define TrebleBoostCorner 8000 +#define TrebleBoostMinRate 4 +#define TrebleBoostSteps 15 + + +/* Coefficients for sample rate 22050Hz */ + /* Gain = 1.000000 dB */ +#define HPF_Fs22050_Gain1_A0 5383 /* Floating point value 0.164291 */ +#define HPF_Fs22050_Gain1_A1 16859 /* Floating point value 0.514492 */ +#define HPF_Fs22050_Gain1_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs22050_Gain1_B1 12125 /* Floating point value 0.370033 */ +#define HPF_Fs22050_Gain1_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs22050_Gain1_Shift 1 /* Shift value */ + /* Gain = 2.000000 dB */ +#define HPF_Fs22050_Gain2_A0 4683 /* Floating point value 0.142925 */ +#define HPF_Fs22050_Gain2_A1 17559 /* Floating point value 0.535858 */ +#define HPF_Fs22050_Gain2_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs22050_Gain2_B1 12125 /* Floating point value 0.370033 */ +#define HPF_Fs22050_Gain2_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs22050_Gain2_Shift 1 /* Shift value */ + /* Gain = 3.000000 dB */ +#define HPF_Fs22050_Gain3_A0 3898 /* Floating point value 0.118953 */ +#define HPF_Fs22050_Gain3_A1 18345 /* Floating point value 0.559830 */ +#define HPF_Fs22050_Gain3_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs22050_Gain3_B1 12125 /* Floating point value 0.370033 */ +#define HPF_Fs22050_Gain3_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs22050_Gain3_Shift 1 /* Shift value */ + /* Gain = 4.000000 dB */ +#define HPF_Fs22050_Gain4_A0 3016 /* Floating point value 0.092055 */ +#define HPF_Fs22050_Gain4_A1 19226 /* Floating point value 0.586728 */ +#define HPF_Fs22050_Gain4_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs22050_Gain4_B1 12125 /* Floating point value 0.370033 */ +#define HPF_Fs22050_Gain4_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs22050_Gain4_Shift 1 /* Shift value */ + /* Gain = 5.000000 dB */ +#define HPF_Fs22050_Gain5_A0 2028 /* Floating point value 0.061876 */ +#define HPF_Fs22050_Gain5_A1 20215 /* Floating point value 0.616907 */ +#define HPF_Fs22050_Gain5_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs22050_Gain5_B1 12125 /* Floating point value 0.370033 */ +#define HPF_Fs22050_Gain5_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs22050_Gain5_Shift 1 /* Shift value */ + /* Gain = 6.000000 dB */ +#define HPF_Fs22050_Gain6_A0 918 /* Floating point value 0.028013 */ +#define HPF_Fs22050_Gain6_A1 21324 /* Floating point value 0.650770 */ +#define HPF_Fs22050_Gain6_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs22050_Gain6_B1 12125 /* Floating point value 0.370033 */ +#define HPF_Fs22050_Gain6_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs22050_Gain6_Shift 1 /* Shift value */ + /* Gain = 7.000000 dB */ +#define HPF_Fs22050_Gain7_A0 -164 /* Floating point value -0.005002 */ +#define HPF_Fs22050_Gain7_A1 11311 /* Floating point value 0.345199 */ +#define HPF_Fs22050_Gain7_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs22050_Gain7_B1 12125 /* Floating point value 0.370033 */ +#define HPF_Fs22050_Gain7_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs22050_Gain7_Shift 2 /* Shift value */ + /* Gain = 8.000000 dB */ +#define HPF_Fs22050_Gain8_A0 -864 /* Floating point value -0.026368 */ +#define HPF_Fs22050_Gain8_A1 12012 /* Floating point value 0.366565 */ +#define HPF_Fs22050_Gain8_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs22050_Gain8_B1 12125 /* Floating point value 0.370033 */ +#define HPF_Fs22050_Gain8_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs22050_Gain8_Shift 2 /* Shift value */ + /* Gain = 9.000000 dB */ +#define HPF_Fs22050_Gain9_A0 -1650 /* Floating point value -0.050340 */ +#define HPF_Fs22050_Gain9_A1 12797 /* Floating point value 0.390537 */ +#define HPF_Fs22050_Gain9_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs22050_Gain9_B1 12125 /* Floating point value 0.370033 */ +#define HPF_Fs22050_Gain9_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs22050_Gain9_Shift 2 /* Shift value */ + /* Gain = 10.000000 dB */ +#define HPF_Fs22050_Gain10_A0 -2531 /* Floating point value -0.077238 */ +#define HPF_Fs22050_Gain10_A1 13679 /* Floating point value 0.417435 */ +#define HPF_Fs22050_Gain10_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs22050_Gain10_B1 12125 /* Floating point value 0.370033 */ +#define HPF_Fs22050_Gain10_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs22050_Gain10_Shift 2 /* Shift value */ + /* Gain = 11.000000 dB */ +#define HPF_Fs22050_Gain11_A0 -3520 /* Floating point value -0.107417 */ +#define HPF_Fs22050_Gain11_A1 14667 /* Floating point value 0.447615 */ +#define HPF_Fs22050_Gain11_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs22050_Gain11_B1 12125 /* Floating point value 0.370033 */ +#define HPF_Fs22050_Gain11_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs22050_Gain11_Shift 2 /* Shift value */ + /* Gain = 12.000000 dB */ +#define HPF_Fs22050_Gain12_A0 -4629 /* Floating point value -0.141279 */ +#define HPF_Fs22050_Gain12_A1 15777 /* Floating point value 0.481477 */ +#define HPF_Fs22050_Gain12_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs22050_Gain12_B1 12125 /* Floating point value 0.370033 */ +#define HPF_Fs22050_Gain12_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs22050_Gain12_Shift 2 /* Shift value */ + /* Gain = 13.000000 dB */ +#define HPF_Fs22050_Gain13_A0 -2944 /* Floating point value -0.089849 */ +#define HPF_Fs22050_Gain13_A1 8531 /* Floating point value 0.260352 */ +#define HPF_Fs22050_Gain13_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs22050_Gain13_B1 12125 /* Floating point value 0.370033 */ +#define HPF_Fs22050_Gain13_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs22050_Gain13_Shift 3 /* Shift value */ + /* Gain = 14.000000 dB */ +#define HPF_Fs22050_Gain14_A0 -3644 /* Floating point value -0.111215 */ +#define HPF_Fs22050_Gain14_A1 9231 /* Floating point value 0.281718 */ +#define HPF_Fs22050_Gain14_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs22050_Gain14_B1 12125 /* Floating point value 0.370033 */ +#define HPF_Fs22050_Gain14_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs22050_Gain14_Shift 3 /* Shift value */ + /* Gain = 15.000000 dB */ +#define HPF_Fs22050_Gain15_A0 -4430 /* Floating point value -0.135187 */ +#define HPF_Fs22050_Gain15_A1 10017 /* Floating point value 0.305690 */ +#define HPF_Fs22050_Gain15_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs22050_Gain15_B1 12125 /* Floating point value 0.370033 */ +#define HPF_Fs22050_Gain15_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs22050_Gain15_Shift 3 /* Shift value */ + + +/* Coefficients for sample rate 24000Hz */ + /* Gain = 1.000000 dB */ +#define HPF_Fs24000_Gain1_A0 3625 /* Floating point value 0.110628 */ +#define HPF_Fs24000_Gain1_A1 16960 /* Floating point value 0.517578 */ +#define HPF_Fs24000_Gain1_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs24000_Gain1_B1 8780 /* Floating point value 0.267949 */ +#define HPF_Fs24000_Gain1_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs24000_Gain1_Shift 1 /* Shift value */ + /* Gain = 2.000000 dB */ +#define HPF_Fs24000_Gain2_A0 2811 /* Floating point value 0.085800 */ +#define HPF_Fs24000_Gain2_A1 17774 /* Floating point value 0.542406 */ +#define HPF_Fs24000_Gain2_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs24000_Gain2_B1 8780 /* Floating point value 0.267949 */ +#define HPF_Fs24000_Gain2_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs24000_Gain2_Shift 1 /* Shift value */ + /* Gain = 3.000000 dB */ +#define HPF_Fs24000_Gain3_A0 1899 /* Floating point value 0.057943 */ +#define HPF_Fs24000_Gain3_A1 18686 /* Floating point value 0.570263 */ +#define HPF_Fs24000_Gain3_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs24000_Gain3_B1 8780 /* Floating point value 0.267949 */ +#define HPF_Fs24000_Gain3_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs24000_Gain3_Shift 1 /* Shift value */ + /* Gain = 4.000000 dB */ +#define HPF_Fs24000_Gain4_A0 874 /* Floating point value 0.026687 */ +#define HPF_Fs24000_Gain4_A1 19711 /* Floating point value 0.601519 */ +#define HPF_Fs24000_Gain4_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs24000_Gain4_B1 8780 /* Floating point value 0.267949 */ +#define HPF_Fs24000_Gain4_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs24000_Gain4_Shift 1 /* Shift value */ + /* Gain = 5.000000 dB */ +#define HPF_Fs24000_Gain5_A0 -275 /* Floating point value -0.008383 */ +#define HPF_Fs24000_Gain5_A1 20860 /* Floating point value 0.636589 */ +#define HPF_Fs24000_Gain5_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs24000_Gain5_B1 8780 /* Floating point value 0.267949 */ +#define HPF_Fs24000_Gain5_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs24000_Gain5_Shift 1 /* Shift value */ + /* Gain = 6.000000 dB */ +#define HPF_Fs24000_Gain6_A0 -1564 /* Floating point value -0.047733 */ +#define HPF_Fs24000_Gain6_A1 22149 /* Floating point value 0.675938 */ +#define HPF_Fs24000_Gain6_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs24000_Gain6_B1 8780 /* Floating point value 0.267949 */ +#define HPF_Fs24000_Gain6_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs24000_Gain6_Shift 1 /* Shift value */ + /* Gain = 7.000000 dB */ +#define HPF_Fs24000_Gain7_A0 -1509 /* Floating point value -0.046051 */ +#define HPF_Fs24000_Gain7_A1 11826 /* Floating point value 0.360899 */ +#define HPF_Fs24000_Gain7_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs24000_Gain7_B1 8780 /* Floating point value 0.267949 */ +#define HPF_Fs24000_Gain7_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs24000_Gain7_Shift 2 /* Shift value */ + /* Gain = 8.000000 dB */ +#define HPF_Fs24000_Gain8_A0 -2323 /* Floating point value -0.070878 */ +#define HPF_Fs24000_Gain8_A1 12640 /* Floating point value 0.385727 */ +#define HPF_Fs24000_Gain8_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs24000_Gain8_B1 8780 /* Floating point value 0.267949 */ +#define HPF_Fs24000_Gain8_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs24000_Gain8_Shift 2 /* Shift value */ + /* Gain = 9.000000 dB */ +#define HPF_Fs24000_Gain9_A0 -3235 /* Floating point value -0.098736 */ +#define HPF_Fs24000_Gain9_A1 13552 /* Floating point value 0.413584 */ +#define HPF_Fs24000_Gain9_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs24000_Gain9_B1 8780 /* Floating point value 0.267949 */ +#define HPF_Fs24000_Gain9_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs24000_Gain9_Shift 2 /* Shift value */ + /* Gain = 10.000000 dB */ +#define HPF_Fs24000_Gain10_A0 -4260 /* Floating point value -0.129992 */ +#define HPF_Fs24000_Gain10_A1 14577 /* Floating point value 0.444841 */ +#define HPF_Fs24000_Gain10_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs24000_Gain10_B1 8780 /* Floating point value 0.267949 */ +#define HPF_Fs24000_Gain10_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs24000_Gain10_Shift 2 /* Shift value */ + /* Gain = 11.000000 dB */ +#define HPF_Fs24000_Gain11_A0 -5409 /* Floating point value -0.165062 */ +#define HPF_Fs24000_Gain11_A1 15726 /* Floating point value 0.479911 */ +#define HPF_Fs24000_Gain11_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs24000_Gain11_B1 8780 /* Floating point value 0.267949 */ +#define HPF_Fs24000_Gain11_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs24000_Gain11_Shift 2 /* Shift value */ + /* Gain = 12.000000 dB */ +#define HPF_Fs24000_Gain12_A0 -6698 /* Floating point value -0.204411 */ +#define HPF_Fs24000_Gain12_A1 17015 /* Floating point value 0.519260 */ +#define HPF_Fs24000_Gain12_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs24000_Gain12_B1 8780 /* Floating point value 0.267949 */ +#define HPF_Fs24000_Gain12_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs24000_Gain12_Shift 2 /* Shift value */ + /* Gain = 13.000000 dB */ +#define HPF_Fs24000_Gain13_A0 -4082 /* Floating point value -0.124576 */ +#define HPF_Fs24000_Gain13_A1 9253 /* Floating point value 0.282374 */ +#define HPF_Fs24000_Gain13_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs24000_Gain13_B1 8780 /* Floating point value 0.267949 */ +#define HPF_Fs24000_Gain13_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs24000_Gain13_Shift 3 /* Shift value */ + /* Gain = 14.000000 dB */ +#define HPF_Fs24000_Gain14_A0 -4896 /* Floating point value -0.149404 */ +#define HPF_Fs24000_Gain14_A1 10066 /* Floating point value 0.307202 */ +#define HPF_Fs24000_Gain14_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs24000_Gain14_B1 8780 /* Floating point value 0.267949 */ +#define HPF_Fs24000_Gain14_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs24000_Gain14_Shift 3 /* Shift value */ + /* Gain = 15.000000 dB */ +#define HPF_Fs24000_Gain15_A0 -5808 /* Floating point value -0.177261 */ +#define HPF_Fs24000_Gain15_A1 10979 /* Floating point value 0.335059 */ +#define HPF_Fs24000_Gain15_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs24000_Gain15_B1 8780 /* Floating point value 0.267949 */ +#define HPF_Fs24000_Gain15_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs24000_Gain15_Shift 3 /* Shift value */ + + +/* Coefficients for sample rate 32000Hz */ + /* Gain = 1.000000 dB */ +#define HPF_Fs32000_Gain1_A0 17225 /* Floating point value 0.525677 */ +#define HPF_Fs32000_Gain1_A1 -990 /* Floating point value -0.030227 */ +#define HPF_Fs32000_Gain1_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs32000_Gain1_B1 0 /* Floating point value -0.000000 */ +#define HPF_Fs32000_Gain1_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs32000_Gain1_Shift 1 /* Shift value */ + /* Gain = 2.000000 dB */ +#define HPF_Fs32000_Gain2_A0 18337 /* Floating point value 0.559593 */ +#define HPF_Fs32000_Gain2_A1 -2102 /* Floating point value -0.064142 */ +#define HPF_Fs32000_Gain2_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs32000_Gain2_B1 0 /* Floating point value -0.000000 */ +#define HPF_Fs32000_Gain2_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs32000_Gain2_Shift 1 /* Shift value */ + /* Gain = 3.000000 dB */ +#define HPF_Fs32000_Gain3_A0 19584 /* Floating point value 0.597646 */ +#define HPF_Fs32000_Gain3_A1 -3349 /* Floating point value -0.102196 */ +#define HPF_Fs32000_Gain3_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs32000_Gain3_B1 0 /* Floating point value -0.000000 */ +#define HPF_Fs32000_Gain3_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs32000_Gain3_Shift 1 /* Shift value */ + /* Gain = 4.000000 dB */ +#define HPF_Fs32000_Gain4_A0 20983 /* Floating point value 0.640343 */ +#define HPF_Fs32000_Gain4_A1 -4748 /* Floating point value -0.144893 */ +#define HPF_Fs32000_Gain4_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs32000_Gain4_B1 0 /* Floating point value -0.000000 */ +#define HPF_Fs32000_Gain4_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs32000_Gain4_Shift 1 /* Shift value */ + /* Gain = 5.000000 dB */ +#define HPF_Fs32000_Gain5_A0 22553 /* Floating point value 0.688250 */ +#define HPF_Fs32000_Gain5_A1 -6318 /* Floating point value -0.192799 */ +#define HPF_Fs32000_Gain5_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs32000_Gain5_B1 0 /* Floating point value -0.000000 */ +#define HPF_Fs32000_Gain5_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs32000_Gain5_Shift 1 /* Shift value */ + /* Gain = 6.000000 dB */ +#define HPF_Fs32000_Gain6_A0 24314 /* Floating point value 0.742002 */ +#define HPF_Fs32000_Gain6_A1 -8079 /* Floating point value -0.246551 */ +#define HPF_Fs32000_Gain6_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs32000_Gain6_B1 0 /* Floating point value -0.000000 */ +#define HPF_Fs32000_Gain6_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs32000_Gain6_Shift 1 /* Shift value */ + /* Gain = 7.000000 dB */ +#define HPF_Fs32000_Gain7_A0 13176 /* Floating point value 0.402109 */ +#define HPF_Fs32000_Gain7_A1 -5040 /* Floating point value -0.153795 */ +#define HPF_Fs32000_Gain7_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs32000_Gain7_B1 0 /* Floating point value -0.000000 */ +#define HPF_Fs32000_Gain7_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs32000_Gain7_Shift 2 /* Shift value */ + /* Gain = 8.000000 dB */ +#define HPF_Fs32000_Gain8_A0 14288 /* Floating point value 0.436024 */ +#define HPF_Fs32000_Gain8_A1 -6151 /* Floating point value -0.187711 */ +#define HPF_Fs32000_Gain8_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs32000_Gain8_B1 0 /* Floating point value -0.000000 */ +#define HPF_Fs32000_Gain8_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs32000_Gain8_Shift 2 /* Shift value */ + /* Gain = 9.000000 dB */ +#define HPF_Fs32000_Gain9_A0 15535 /* Floating point value 0.474078 */ +#define HPF_Fs32000_Gain9_A1 -7398 /* Floating point value -0.225764 */ +#define HPF_Fs32000_Gain9_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs32000_Gain9_B1 0 /* Floating point value -0.000000 */ +#define HPF_Fs32000_Gain9_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs32000_Gain9_Shift 2 /* Shift value */ + /* Gain = 10.000000 dB */ +#define HPF_Fs32000_Gain10_A0 16934 /* Floating point value 0.516774 */ +#define HPF_Fs32000_Gain10_A1 -8797 /* Floating point value -0.268461 */ +#define HPF_Fs32000_Gain10_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs32000_Gain10_B1 0 /* Floating point value -0.000000 */ +#define HPF_Fs32000_Gain10_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs32000_Gain10_Shift 2 /* Shift value */ + /* Gain = 11.000000 dB */ +#define HPF_Fs32000_Gain11_A0 18503 /* Floating point value 0.564681 */ +#define HPF_Fs32000_Gain11_A1 -10367 /* Floating point value -0.316368 */ +#define HPF_Fs32000_Gain11_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs32000_Gain11_B1 0 /* Floating point value -0.000000 */ +#define HPF_Fs32000_Gain11_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs32000_Gain11_Shift 2 /* Shift value */ + /* Gain = 12.000000 dB */ +#define HPF_Fs32000_Gain12_A0 20265 /* Floating point value 0.618433 */ +#define HPF_Fs32000_Gain12_A1 -12128 /* Floating point value -0.370120 */ +#define HPF_Fs32000_Gain12_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs32000_Gain12_B1 0 /* Floating point value -0.000000 */ +#define HPF_Fs32000_Gain12_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs32000_Gain12_Shift 2 /* Shift value */ + /* Gain = 13.000000 dB */ +#define HPF_Fs32000_Gain13_A0 11147 /* Floating point value 0.340178 */ +#define HPF_Fs32000_Gain13_A1 -7069 /* Floating point value -0.215726 */ +#define HPF_Fs32000_Gain13_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs32000_Gain13_B1 0 /* Floating point value -0.000000 */ +#define HPF_Fs32000_Gain13_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs32000_Gain13_Shift 3 /* Shift value */ + /* Gain = 14.000000 dB */ +#define HPF_Fs32000_Gain14_A0 12258 /* Floating point value 0.374093 */ +#define HPF_Fs32000_Gain14_A1 -8180 /* Floating point value -0.249642 */ +#define HPF_Fs32000_Gain14_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs32000_Gain14_B1 0 /* Floating point value -0.000000 */ +#define HPF_Fs32000_Gain14_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs32000_Gain14_Shift 3 /* Shift value */ + /* Gain = 15.000000 dB */ +#define HPF_Fs32000_Gain15_A0 13505 /* Floating point value 0.412147 */ +#define HPF_Fs32000_Gain15_A1 -9427 /* Floating point value -0.287695 */ +#define HPF_Fs32000_Gain15_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs32000_Gain15_B1 0 /* Floating point value -0.000000 */ +#define HPF_Fs32000_Gain15_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs32000_Gain15_Shift 3 /* Shift value */ + + +/* Coefficients for sample rate 44100Hz */ + /* Gain = 1.000000 dB */ +#define HPF_Fs44100_Gain1_A0 17442 /* Floating point value 0.532294 */ +#define HPF_Fs44100_Gain1_A1 -4761 /* Floating point value -0.145294 */ +#define HPF_Fs44100_Gain1_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs44100_Gain1_B1 -7173 /* Floating point value -0.218894 */ +#define HPF_Fs44100_Gain1_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs44100_Gain1_Shift 1 /* Shift value */ + /* Gain = 2.000000 dB */ +#define HPF_Fs44100_Gain2_A0 18797 /* Floating point value 0.573633 */ +#define HPF_Fs44100_Gain2_A1 -6116 /* Floating point value -0.186634 */ +#define HPF_Fs44100_Gain2_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs44100_Gain2_B1 -7173 /* Floating point value -0.218894 */ +#define HPF_Fs44100_Gain2_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs44100_Gain2_Shift 1 /* Shift value */ + /* Gain = 3.000000 dB */ +#define HPF_Fs44100_Gain3_A0 20317 /* Floating point value 0.620016 */ +#define HPF_Fs44100_Gain3_A1 -7635 /* Floating point value -0.233017 */ +#define HPF_Fs44100_Gain3_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs44100_Gain3_B1 -7173 /* Floating point value -0.218894 */ +#define HPF_Fs44100_Gain3_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs44100_Gain3_Shift 1 /* Shift value */ + /* Gain = 4.000000 dB */ +#define HPF_Fs44100_Gain4_A0 22022 /* Floating point value 0.672059 */ +#define HPF_Fs44100_Gain4_A1 -9341 /* Floating point value -0.285060 */ +#define HPF_Fs44100_Gain4_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs44100_Gain4_B1 -7173 /* Floating point value -0.218894 */ +#define HPF_Fs44100_Gain4_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs44100_Gain4_Shift 1 /* Shift value */ + /* Gain = 5.000000 dB */ +#define HPF_Fs44100_Gain5_A0 23935 /* Floating point value 0.730452 */ +#define HPF_Fs44100_Gain5_A1 -11254 /* Floating point value -0.343453 */ +#define HPF_Fs44100_Gain5_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs44100_Gain5_B1 -7173 /* Floating point value -0.218894 */ +#define HPF_Fs44100_Gain5_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs44100_Gain5_Shift 1 /* Shift value */ + /* Gain = 6.000000 dB */ +#define HPF_Fs44100_Gain6_A0 26082 /* Floating point value 0.795970 */ +#define HPF_Fs44100_Gain6_A1 -13401 /* Floating point value -0.408971 */ +#define HPF_Fs44100_Gain6_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs44100_Gain6_B1 -7173 /* Floating point value -0.218894 */ +#define HPF_Fs44100_Gain6_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs44100_Gain6_Shift 1 /* Shift value */ + /* Gain = 7.000000 dB */ +#define HPF_Fs44100_Gain7_A0 14279 /* Floating point value 0.435774 */ +#define HPF_Fs44100_Gain7_A1 -7924 /* Floating point value -0.241815 */ +#define HPF_Fs44100_Gain7_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs44100_Gain7_B1 -7173 /* Floating point value -0.218894 */ +#define HPF_Fs44100_Gain7_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs44100_Gain7_Shift 2 /* Shift value */ + /* Gain = 8.000000 dB */ +#define HPF_Fs44100_Gain8_A0 15634 /* Floating point value 0.477113 */ +#define HPF_Fs44100_Gain8_A1 -9278 /* Floating point value -0.283154 */ +#define HPF_Fs44100_Gain8_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs44100_Gain8_B1 -7173 /* Floating point value -0.218894 */ +#define HPF_Fs44100_Gain8_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs44100_Gain8_Shift 2 /* Shift value */ + /* Gain = 9.000000 dB */ +#define HPF_Fs44100_Gain9_A0 17154 /* Floating point value 0.523496 */ +#define HPF_Fs44100_Gain9_A1 -10798 /* Floating point value -0.329537 */ +#define HPF_Fs44100_Gain9_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs44100_Gain9_B1 -7173 /* Floating point value -0.218894 */ +#define HPF_Fs44100_Gain9_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs44100_Gain9_Shift 2 /* Shift value */ + /* Gain = 10.000000 dB */ +#define HPF_Fs44100_Gain10_A0 18859 /* Floating point value 0.575539 */ +#define HPF_Fs44100_Gain10_A1 -12504 /* Floating point value -0.381580 */ +#define HPF_Fs44100_Gain10_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs44100_Gain10_B1 -7173 /* Floating point value -0.218894 */ +#define HPF_Fs44100_Gain10_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs44100_Gain10_Shift 2 /* Shift value */ + /* Gain = 11.000000 dB */ +#define HPF_Fs44100_Gain11_A0 20773 /* Floating point value 0.633932 */ +#define HPF_Fs44100_Gain11_A1 -14417 /* Floating point value -0.439973 */ +#define HPF_Fs44100_Gain11_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs44100_Gain11_B1 -7173 /* Floating point value -0.218894 */ +#define HPF_Fs44100_Gain11_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs44100_Gain11_Shift 2 /* Shift value */ + /* Gain = 12.000000 dB */ +#define HPF_Fs44100_Gain12_A0 22920 /* Floating point value 0.699450 */ +#define HPF_Fs44100_Gain12_A1 -16564 /* Floating point value -0.505491 */ +#define HPF_Fs44100_Gain12_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs44100_Gain12_B1 -7173 /* Floating point value -0.218894 */ +#define HPF_Fs44100_Gain12_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs44100_Gain12_Shift 2 /* Shift value */ + /* Gain = 13.000000 dB */ +#define HPF_Fs44100_Gain13_A0 12694 /* Floating point value 0.387399 */ +#define HPF_Fs44100_Gain13_A1 -9509 /* Floating point value -0.290189 */ +#define HPF_Fs44100_Gain13_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs44100_Gain13_B1 -7173 /* Floating point value -0.218894 */ +#define HPF_Fs44100_Gain13_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs44100_Gain13_Shift 3 /* Shift value */ + /* Gain = 14.000000 dB */ +#define HPF_Fs44100_Gain14_A0 14049 /* Floating point value 0.428738 */ +#define HPF_Fs44100_Gain14_A1 -10864 /* Floating point value -0.331528 */ +#define HPF_Fs44100_Gain14_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs44100_Gain14_B1 -7173 /* Floating point value -0.218894 */ +#define HPF_Fs44100_Gain14_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs44100_Gain14_Shift 3 /* Shift value */ + /* Gain = 15.000000 dB */ +#define HPF_Fs44100_Gain15_A0 15569 /* Floating point value 0.475121 */ +#define HPF_Fs44100_Gain15_A1 -12383 /* Floating point value -0.377912 */ +#define HPF_Fs44100_Gain15_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs44100_Gain15_B1 -7173 /* Floating point value -0.218894 */ +#define HPF_Fs44100_Gain15_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs44100_Gain15_Shift 3 /* Shift value */ + + +/* Coefficients for sample rate 48000Hz */ + /* Gain = 1.000000 dB */ +#define HPF_Fs48000_Gain1_A0 17491 /* Floating point value 0.533777 */ +#define HPF_Fs48000_Gain1_A1 -5606 /* Floating point value -0.171082 */ +#define HPF_Fs48000_Gain1_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs48000_Gain1_B1 -8780 /* Floating point value -0.267949 */ +#define HPF_Fs48000_Gain1_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs48000_Gain1_Shift 1 /* Shift value */ + /* Gain = 2.000000 dB */ +#define HPF_Fs48000_Gain2_A0 18900 /* Floating point value 0.576779 */ +#define HPF_Fs48000_Gain2_A1 -7015 /* Floating point value -0.214085 */ +#define HPF_Fs48000_Gain2_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs48000_Gain2_B1 -8780 /* Floating point value -0.267949 */ +#define HPF_Fs48000_Gain2_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs48000_Gain2_Shift 1 /* Shift value */ + /* Gain = 3.000000 dB */ +#define HPF_Fs48000_Gain3_A0 20481 /* Floating point value 0.625029 */ +#define HPF_Fs48000_Gain3_A1 -8596 /* Floating point value -0.262335 */ +#define HPF_Fs48000_Gain3_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs48000_Gain3_B1 -8780 /* Floating point value -0.267949 */ +#define HPF_Fs48000_Gain3_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs48000_Gain3_Shift 1 /* Shift value */ + /* Gain = 4.000000 dB */ +#define HPF_Fs48000_Gain4_A0 22255 /* Floating point value 0.679167 */ +#define HPF_Fs48000_Gain4_A1 -10370 /* Floating point value -0.316472 */ +#define HPF_Fs48000_Gain4_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs48000_Gain4_B1 -8780 /* Floating point value -0.267949 */ +#define HPF_Fs48000_Gain4_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs48000_Gain4_Shift 1 /* Shift value */ + /* Gain = 5.000000 dB */ +#define HPF_Fs48000_Gain5_A0 24245 /* Floating point value 0.739910 */ +#define HPF_Fs48000_Gain5_A1 -12361 /* Floating point value -0.377215 */ +#define HPF_Fs48000_Gain5_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs48000_Gain5_B1 -8780 /* Floating point value -0.267949 */ +#define HPF_Fs48000_Gain5_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs48000_Gain5_Shift 1 /* Shift value */ + /* Gain = 6.000000 dB */ +#define HPF_Fs48000_Gain6_A0 26479 /* Floating point value 0.808065 */ +#define HPF_Fs48000_Gain6_A1 -14594 /* Floating point value -0.445370 */ +#define HPF_Fs48000_Gain6_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs48000_Gain6_B1 -8780 /* Floating point value -0.267949 */ +#define HPF_Fs48000_Gain6_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs48000_Gain6_Shift 1 /* Shift value */ + /* Gain = 7.000000 dB */ +#define HPF_Fs48000_Gain7_A0 14527 /* Floating point value 0.443318 */ +#define HPF_Fs48000_Gain7_A1 -8570 /* Floating point value -0.261540 */ +#define HPF_Fs48000_Gain7_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs48000_Gain7_B1 -8780 /* Floating point value -0.267949 */ +#define HPF_Fs48000_Gain7_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs48000_Gain7_Shift 2 /* Shift value */ + /* Gain = 8.000000 dB */ +#define HPF_Fs48000_Gain8_A0 15936 /* Floating point value 0.486321 */ +#define HPF_Fs48000_Gain8_A1 -9979 /* Floating point value -0.304543 */ +#define HPF_Fs48000_Gain8_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs48000_Gain8_B1 -8780 /* Floating point value -0.267949 */ +#define HPF_Fs48000_Gain8_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs48000_Gain8_Shift 2 /* Shift value */ + /* Gain = 9.000000 dB */ +#define HPF_Fs48000_Gain9_A0 17517 /* Floating point value 0.534571 */ +#define HPF_Fs48000_Gain9_A1 -11560 /* Floating point value -0.352793 */ +#define HPF_Fs48000_Gain9_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs48000_Gain9_B1 -8780 /* Floating point value -0.267949 */ +#define HPF_Fs48000_Gain9_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs48000_Gain9_Shift 2 /* Shift value */ + /* Gain = 10.000000 dB */ +#define HPF_Fs48000_Gain10_A0 19291 /* Floating point value 0.588708 */ +#define HPF_Fs48000_Gain10_A1 -13334 /* Floating point value -0.406930 */ +#define HPF_Fs48000_Gain10_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs48000_Gain10_B1 -8780 /* Floating point value -0.267949 */ +#define HPF_Fs48000_Gain10_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs48000_Gain10_Shift 2 /* Shift value */ + /* Gain = 11.000000 dB */ +#define HPF_Fs48000_Gain11_A0 21281 /* Floating point value 0.649452 */ +#define HPF_Fs48000_Gain11_A1 -15325 /* Floating point value -0.467674 */ +#define HPF_Fs48000_Gain11_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs48000_Gain11_B1 -8780 /* Floating point value -0.267949 */ +#define HPF_Fs48000_Gain11_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs48000_Gain11_Shift 2 /* Shift value */ + /* Gain = 12.000000 dB */ +#define HPF_Fs48000_Gain12_A0 23515 /* Floating point value 0.717607 */ +#define HPF_Fs48000_Gain12_A1 -17558 /* Floating point value -0.535829 */ +#define HPF_Fs48000_Gain12_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs48000_Gain12_B1 -8780 /* Floating point value -0.267949 */ +#define HPF_Fs48000_Gain12_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs48000_Gain12_Shift 2 /* Shift value */ + /* Gain = 13.000000 dB */ +#define HPF_Fs48000_Gain13_A0 13041 /* Floating point value 0.397982 */ +#define HPF_Fs48000_Gain13_A1 -10056 /* Floating point value -0.306877 */ +#define HPF_Fs48000_Gain13_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs48000_Gain13_B1 -8780 /* Floating point value -0.267949 */ +#define HPF_Fs48000_Gain13_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs48000_Gain13_Shift 3 /* Shift value */ + /* Gain = 14.000000 dB */ +#define HPF_Fs48000_Gain14_A0 14450 /* Floating point value 0.440984 */ +#define HPF_Fs48000_Gain14_A1 -11465 /* Floating point value -0.349880 */ +#define HPF_Fs48000_Gain14_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs48000_Gain14_B1 -8780 /* Floating point value -0.267949 */ +#define HPF_Fs48000_Gain14_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs48000_Gain14_Shift 3 /* Shift value */ + /* Gain = 15.000000 dB */ +#define HPF_Fs48000_Gain15_A0 16031 /* Floating point value 0.489234 */ +#define HPF_Fs48000_Gain15_A1 -13046 /* Floating point value -0.398130 */ +#define HPF_Fs48000_Gain15_A2 0 /* Floating point value 0.000000 */ +#define HPF_Fs48000_Gain15_B1 -8780 /* Floating point value -0.267949 */ +#define HPF_Fs48000_Gain15_B2 0 /* Floating point value 0.000000 */ +#define HPF_Fs48000_Gain15_Shift 3 /* Shift value */ + + +#endif diff --git a/media/libeffects/lvm/lib/Bundle/src/LVM_Control.c b/media/libeffects/lvm/lib/Bundle/src/LVM_Control.c new file mode 100755 index 0000000..4667feb --- /dev/null +++ b/media/libeffects/lvm/lib/Bundle/src/LVM_Control.c @@ -0,0 +1,1032 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/**************************************************************************************** + + $Author: nxp007753 $ + $Revision: 1255 $ + $Date: 2010-07-16 17:07:29 +0200 (Fri, 16 Jul 2010) $ + +*****************************************************************************************/ + + +/****************************************************************************************/ +/* */ +/* Includes */ +/* */ +/****************************************************************************************/ + +#include "VectorArithmetic.h" +#include "ScalarArithmetic.h" +#include "LVM_Coeffs.h" +#include "LVM_Tables.h" +#include "LVM_Private.h" + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVM_SetControlParameters */ +/* */ +/* DESCRIPTION: */ +/* Sets or changes the LifeVibes module parameters. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance handle */ +/* pParams Pointer to a parameter structure */ +/* */ +/* RETURNS: */ +/* LVM_SUCCESS Succeeded */ +/* LVM_NULLADDRESS When hInstance, pParams or any control pointers are NULL */ +/* LVM_OUTOFRANGE When any of the control parameters are out of range */ +/* */ +/* NOTES: */ +/* 1. This function may be interrupted by the LVM_Process function */ +/* */ +/****************************************************************************************/ + +LVM_ReturnStatus_en LVM_SetControlParameters(LVM_Handle_t hInstance, + LVM_ControlParams_t *pParams) +{ + LVM_Instance_t *pInstance =(LVM_Instance_t *)hInstance; + + + if ((pParams == LVM_NULL) || (hInstance == LVM_NULL)) + { + return (LVM_NULLADDRESS); + } + + pInstance->NewParams = *pParams; + + if( + /* General parameters */ + ((pParams->OperatingMode != LVM_MODE_OFF) && (pParams->OperatingMode != LVM_MODE_ON)) || + ((pParams->SampleRate != LVM_FS_8000) && (pParams->SampleRate != LVM_FS_11025) && (pParams->SampleRate != LVM_FS_12000) && + (pParams->SampleRate != LVM_FS_16000) && (pParams->SampleRate != LVM_FS_22050) && (pParams->SampleRate != LVM_FS_24000) && + (pParams->SampleRate != LVM_FS_32000) && (pParams->SampleRate != LVM_FS_44100) && (pParams->SampleRate != LVM_FS_48000)) || + ((pParams->SourceFormat != LVM_STEREO) && (pParams->SourceFormat != LVM_MONOINSTEREO) && (pParams->SourceFormat != LVM_MONO)) || + (pParams->SpeakerType > LVM_EX_HEADPHONES)) + { + return (LVM_OUTOFRANGE); + } + + /* + * Cinema Sound parameters + */ + if((pParams->VirtualizerOperatingMode != LVM_MODE_OFF) && (pParams->VirtualizerOperatingMode != LVM_MODE_ON)) + { + return (LVM_OUTOFRANGE); + } + + if(pParams->VirtualizerType != LVM_CONCERTSOUND) + { + return (LVM_OUTOFRANGE); + } + + if(pParams->VirtualizerReverbLevel > LVM_VIRTUALIZER_MAX_REVERB_LEVEL) + { + return (LVM_OUTOFRANGE); + } + + if(pParams->CS_EffectLevel < LVM_CS_MIN_EFFECT_LEVEL) + { + return (LVM_OUTOFRANGE); + } + + /* + * N-Band Equalizer + */ + if(pParams->EQNB_NBands > pInstance->InstParams.EQNB_NumBands) + { + return (LVM_OUTOFRANGE); + } + + /* Definition pointer */ + if ((pParams->pEQNB_BandDefinition == LVM_NULL) && + (pParams->EQNB_NBands != 0)) + { + return (LVM_NULLADDRESS); + } + + /* + * Copy the filter definitions for the Equaliser + */ + { + LVM_INT16 i; + + if (pParams->EQNB_NBands != 0) + { + for (i=0; iEQNB_NBands; i++) + { + pInstance->pEQNB_BandDefs[i] = pParams->pEQNB_BandDefinition[i]; + } + pInstance->NewParams.pEQNB_BandDefinition = pInstance->pEQNB_BandDefs; + } + } + if( /* N-Band Equaliser parameters */ + ((pParams->EQNB_OperatingMode != LVM_EQNB_OFF) && (pParams->EQNB_OperatingMode != LVM_EQNB_ON)) || + (pParams->EQNB_NBands > pInstance->InstParams.EQNB_NumBands)) + { + return (LVM_OUTOFRANGE); + } + /* Band parameters*/ + { + LVM_INT16 i; + for(i = 0; i < pParams->EQNB_NBands; i++) + { + if(((pParams->pEQNB_BandDefinition[i].Frequency < LVM_EQNB_MIN_BAND_FREQ) || + (pParams->pEQNB_BandDefinition[i].Frequency > LVM_EQNB_MAX_BAND_FREQ)) || + ((pParams->pEQNB_BandDefinition[i].Gain < LVM_EQNB_MIN_BAND_GAIN) || + (pParams->pEQNB_BandDefinition[i].Gain > LVM_EQNB_MAX_BAND_GAIN)) || + ((pParams->pEQNB_BandDefinition[i].QFactor < LVM_EQNB_MIN_QFACTOR) || + (pParams->pEQNB_BandDefinition[i].QFactor > LVM_EQNB_MAX_QFACTOR))) + { + return (LVM_OUTOFRANGE); + } + } + } + + /* + * Bass Enhancement parameters + */ + if(((pParams->BE_OperatingMode != LVM_BE_OFF) && (pParams->BE_OperatingMode != LVM_BE_ON)) || + ((pParams->BE_EffectLevel < LVM_BE_MIN_EFFECTLEVEL ) || (pParams->BE_EffectLevel > LVM_BE_MAX_EFFECTLEVEL ))|| + ((pParams->BE_CentreFreq != LVM_BE_CENTRE_55Hz) && (pParams->BE_CentreFreq != LVM_BE_CENTRE_66Hz) && + (pParams->BE_CentreFreq != LVM_BE_CENTRE_78Hz) && (pParams->BE_CentreFreq != LVM_BE_CENTRE_90Hz)) || + ((pParams->BE_HPF != LVM_BE_HPF_OFF) && (pParams->BE_HPF != LVM_BE_HPF_ON))) + { + return (LVM_OUTOFRANGE); + } + + /* + * Volume Control parameters + */ + if((pParams->VC_EffectLevel < LVM_VC_MIN_EFFECTLEVEL ) || (pParams->VC_EffectLevel > LVM_VC_MAX_EFFECTLEVEL )) + { + return (LVM_OUTOFRANGE); + } + if((pParams->VC_Balance < LVM_VC_BALANCE_MIN ) || (pParams->VC_Balance > LVM_VC_BALANCE_MAX )) + { + return (LVM_OUTOFRANGE); + } + + /* + * PSA parameters + */ + if( (pParams->PSA_PeakDecayRate > LVPSA_SPEED_HIGH) || + (pParams->PSA_Enable > LVM_PSA_ON)) + { + return (LVM_OUTOFRANGE); + } + + + /* + * Set the flag to indicate there are new parameters to use + * + * Protect the copy of the new parameters from interrupts to avoid possible problems + * with loss control parameters. This problem can occur if this control function is called more + * than once before a call to the process function. If the process function interrupts + * the copy to NewParams then one frame may have mixed parameters, some old and some new. + */ + pInstance->ControlPending = LVM_TRUE; + pInstance->NoSmoothVolume = LVM_FALSE; + + return(LVM_SUCCESS); +} + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVM_GetControlParameters */ +/* */ +/* DESCRIPTION: */ +/* Request the LifeVibes module parameters. The current parameter set is returned */ +/* via the parameter pointer. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance handle */ +/* pParams Pointer to an empty parameter structure */ +/* */ +/* RETURNS: */ +/* LVM_SUCCESS Succeeded */ +/* LVM_NULLADDRESS when any of hInstance or pParams is NULL */ +/* */ +/* NOTES: */ +/* 1. This function may be interrupted by the LVM_Process function */ +/* */ +/****************************************************************************************/ + +LVM_ReturnStatus_en LVM_GetControlParameters(LVM_Handle_t hInstance, + LVM_ControlParams_t *pParams) +{ + LVM_Instance_t *pInstance =(LVM_Instance_t *)hInstance; + + + /* + * Check pointer + */ + if ((pParams == LVM_NULL) || (hInstance == LVM_NULL)) + { + return (LVM_NULLADDRESS); + } + *pParams = pInstance->NewParams; + + /* + * Copy the filter definitions for the Equaliser + */ + { + LVM_INT16 i; + + if (pInstance->NewParams.EQNB_NBands != 0) + for (i=0; iNewParams.EQNB_NBands; i++) + { + pInstance->pEQNB_UserDefs[i] = pInstance->pEQNB_BandDefs[i]; + } + pParams->pEQNB_BandDefinition = pInstance->pEQNB_UserDefs; + } + + return(LVM_SUCCESS); +} + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVM_SetTrebleBoost */ +/* */ +/* DESCRIPTION: */ +/* Enable the treble boost when the settings are appropriate, i.e. non-zero gain */ +/* and the sample rate is high enough for the effect to be heard. */ +/* */ +/* PARAMETERS: */ +/* pInstance Pointer to the instance structure */ +/* pParams Pointer to the parameters to use */ +/* */ +/****************************************************************************************/ +void LVM_SetTrebleBoost(LVM_Instance_t *pInstance, + LVM_ControlParams_t *pParams) +{ + extern FO_C16_LShx_Coefs_t LVM_TrebleBoostCoefs[]; + LVM_INT16 Offset; + LVM_INT16 EffectLevel = 0; + + /* + * Load the coefficients + */ + if ((pParams->TE_OperatingMode == LVM_TE_ON) && + (pParams->SampleRate >= TrebleBoostMinRate) && + (pParams->OperatingMode == LVM_MODE_ON) && + (pParams->TE_EffectLevel > 0)) + { + if((pParams->TE_EffectLevel == LVM_TE_LOW_MIPS) && + ((pParams->SpeakerType == LVM_HEADPHONES)|| + (pParams->SpeakerType == LVM_EX_HEADPHONES))) + { + pInstance->TE_Active = LVM_FALSE; + } + else + { + EffectLevel = pParams->TE_EffectLevel; + pInstance->TE_Active = LVM_TRUE; + } + + if(pInstance->TE_Active == LVM_TRUE) + { + /* + * Load the coefficients and enabled the treble boost + */ + Offset = (LVM_INT16)(EffectLevel - 1 + TrebleBoostSteps * (pParams->SampleRate - TrebleBoostMinRate)); + FO_2I_D16F32Css_LShx_TRC_WRA_01_Init(&pInstance->pTE_State->TrebleBoost_State, + &pInstance->pTE_Taps->TrebleBoost_Taps, + &LVM_TrebleBoostCoefs[Offset]); + + /* + * Clear the taps + */ + LoadConst_16((LVM_INT16)0, /* Value */ + (LVM_INT16 *)&pInstance->pTE_Taps->TrebleBoost_Taps, /* Destination */ + (LVM_UINT16)(sizeof(pInstance->pTE_Taps->TrebleBoost_Taps)/sizeof(LVM_INT16))); /* Number of words */ + } + } + else + { + /* + * Disable the treble boost + */ + pInstance->TE_Active = LVM_FALSE; + } + + return; +} + + +/************************************************************************************/ +/* */ +/* FUNCTION: LVM_SetVolume */ +/* */ +/* DESCRIPTION: */ +/* Converts the input volume demand from dBs to linear. */ +/* */ +/* PARAMETERS: */ +/* pInstance Pointer to the instance */ +/* pParams Initialisation parameters */ +/* */ +/************************************************************************************/ +void LVM_SetVolume(LVM_Instance_t *pInstance, + LVM_ControlParams_t *pParams) +{ + + LVM_UINT16 dBShifts; /* 6dB shifts */ + LVM_UINT16 dBOffset; /* Table offset */ + LVM_INT16 Volume = 0; /* Required volume in dBs */ + + /* + * Limit the gain to the maximum allowed + */ + if (pParams->VC_EffectLevel > 0) + { + Volume = 0; + } + else + { + Volume = pParams->VC_EffectLevel; + } + + /* Compensate this volume in PSA plot */ + if(Volume > -60) /* Limit volume loss to PSA Limits*/ + pInstance->PSA_GainOffset=(LVM_INT16)(-Volume);/* Loss is compensated by Gain*/ + else + pInstance->PSA_GainOffset=(LVM_INT16)60;/* Loss is compensated by Gain*/ + + pInstance->VC_AVLFixedVolume = 0; + + /* + * Set volume control and AVL volumes according to headroom and volume user setting + */ + if(pParams->OperatingMode == LVM_MODE_ON) + { + /* Default Situation with no AVL and no RS */ + if(pParams->EQNB_OperatingMode == LVM_EQNB_ON) + { + if(Volume > -pInstance->Headroom) + Volume = (LVM_INT16)-pInstance->Headroom; + } + } + + /* + * Activate volume control if necessary + */ + pInstance->VC_Active = LVM_TRUE; + if (Volume != 0) + { + pInstance->VC_VolumedB = Volume; + } + else + { + pInstance->VC_VolumedB = 0; + } + + /* + * Calculate the required gain and shifts + */ + dBOffset = (LVM_UINT16)((-Volume) % 6); /* Get the dBs 0-5 */ + dBShifts = (LVM_UINT16)(Volume / -6); /* Get the 6dB shifts */ + + + /* + * Set the parameters + */ + if(dBShifts == 0) + { + LVC_Mixer_SetTarget(&pInstance->VC_Volume.MixerStream[0], + (LVM_INT32)LVM_VolumeTable[dBOffset]); + } + else + { + LVC_Mixer_SetTarget(&pInstance->VC_Volume.MixerStream[0], + (((LVM_INT32)LVM_VolumeTable[dBOffset])>>dBShifts)); + } + pInstance->VC_Volume.MixerStream[0].CallbackSet = 1; + if(pInstance->NoSmoothVolume == LVM_TRUE) + { + LVC_Mixer_SetTimeConstant(&pInstance->VC_Volume.MixerStream[0],0,pInstance->Params.SampleRate,2); + } + else + { + LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->VC_Volume.MixerStream[0],LVM_VC_MIXER_TIME,pInstance->Params.SampleRate,2); + } +} + + +/************************************************************************************/ +/* */ +/* FUNCTION: LVM_SetHeadroom */ +/* */ +/* DESCRIPTION: */ +/* Find suitable headroom based on EQ settings. */ +/* */ +/* PARAMETERS: */ +/* pInstance Pointer to the instance */ +/* pParams Initialisation parameters */ +/* */ +/* RETURNS: */ +/* void Nothing */ +/* */ +/* NOTES: */ +/* */ +/************************************************************************************/ +void LVM_SetHeadroom(LVM_Instance_t *pInstance, + LVM_ControlParams_t *pParams) +{ + LVM_INT16 ii, jj; + LVM_INT16 Headroom = 0; + LVM_INT16 MaxGain = 0; + + + if ((pParams->EQNB_OperatingMode == LVEQNB_ON) && (pInstance->HeadroomParams.Headroom_OperatingMode == LVM_HEADROOM_ON)) + { + /* Find typical headroom value */ + for(jj = 0; jj < pInstance->HeadroomParams.NHeadroomBands; jj++) + { + MaxGain = 0; + for( ii = 0; ii < pParams->EQNB_NBands; ii++) + { + if((pParams->pEQNB_BandDefinition[ii].Frequency >= pInstance->HeadroomParams.pHeadroomDefinition[jj].Limit_Low) && + (pParams->pEQNB_BandDefinition[ii].Frequency <= pInstance->HeadroomParams.pHeadroomDefinition[jj].Limit_High)) + { + if(pParams->pEQNB_BandDefinition[ii].Gain > MaxGain) + { + MaxGain = pParams->pEQNB_BandDefinition[ii].Gain; + } + } + } + + if((MaxGain - pInstance->HeadroomParams.pHeadroomDefinition[jj].Headroom_Offset) > Headroom){ + Headroom = (LVM_INT16)(MaxGain - pInstance->HeadroomParams.pHeadroomDefinition[jj].Headroom_Offset); + } + } + + /* Saturate */ + if(Headroom < 0) + Headroom = 0; + } + pInstance->Headroom = (LVM_UINT16)Headroom ; + +} + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVM_ApplyNewSettings */ +/* */ +/* DESCRIPTION: */ +/* Applies changes to parametres. This function makes no assumptions about what */ +/* each module needs for initialisation and hence passes all parameters to all the */ +/* the modules in turn. */ +/* */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance handle */ +/* */ +/* RETURNS: */ +/* LVM_Success Succeeded */ +/* */ +/****************************************************************************************/ + +LVM_ReturnStatus_en LVM_ApplyNewSettings(LVM_Handle_t hInstance) +{ + LVM_Instance_t *pInstance =(LVM_Instance_t *)hInstance; + LVM_ControlParams_t LocalParams; + LVM_INT16 Count = 5; + + + /* + * Copy the new parameters but make sure they didn't change while copying + */ + do + { + pInstance->ControlPending = LVM_FALSE; + LocalParams = pInstance->NewParams; + pInstance->HeadroomParams = pInstance->NewHeadroomParams; + Count--; + } while ((pInstance->ControlPending != LVM_FALSE) && + (Count > 0)); + + /* Clear all internal data if format change*/ + if(LocalParams.SourceFormat != pInstance->Params.SourceFormat) + { + LVM_ClearAudioBuffers(pInstance); + pInstance->ControlPending = LVM_FALSE; + } + + /* + * Update the treble boost if required + */ + if ((pInstance->Params.SampleRate != LocalParams.SampleRate) || + (pInstance->Params.TE_EffectLevel != LocalParams.TE_EffectLevel) || + (pInstance->Params.TE_OperatingMode != LocalParams.TE_OperatingMode) || + (pInstance->Params.OperatingMode != LocalParams.OperatingMode) || + (pInstance->Params.SpeakerType != LocalParams.SpeakerType)) + { + LVM_SetTrebleBoost(pInstance, + &LocalParams); + } + + /* + * Update the headroom if required + */ + LVM_SetHeadroom(pInstance, /* Instance pointer */ + &LocalParams); /* New parameters */ + + /* + * Update the volume if required + */ + { + LVM_SetVolume(pInstance, /* Instance pointer */ + &LocalParams); /* New parameters */ + } + /* Apply balance changes*/ + if(pInstance->Params.VC_Balance != LocalParams.VC_Balance) + { + /* Configure Mixer module for gradual changes to volume*/ + if(LocalParams.VC_Balance < 0) + { + LVM_INT32 Target; + /* Drop in right channel volume*/ + Target = LVM_MAXINT_16; + LVC_Mixer_SetTarget(&pInstance->VC_BalanceMix.MixerStream[0],Target); + LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->VC_BalanceMix.MixerStream[0],LVM_VC_MIXER_TIME,LocalParams.SampleRate,1); + + Target = dB_to_Lin32((LVM_INT16)(LocalParams.VC_Balance<<4)); + LVC_Mixer_SetTarget(&pInstance->VC_BalanceMix.MixerStream[1],Target); + LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->VC_BalanceMix.MixerStream[1],LVM_VC_MIXER_TIME,LocalParams.SampleRate,1); + } + else if(LocalParams.VC_Balance >0) + { + LVM_INT32 Target; + /* Drop in left channel volume*/ + Target = dB_to_Lin32((LVM_INT16)((-LocalParams.VC_Balance)<<4)); + LVC_Mixer_SetTarget(&pInstance->VC_BalanceMix.MixerStream[0],Target); + LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->VC_BalanceMix.MixerStream[0],LVM_VC_MIXER_TIME,LocalParams.SampleRate,1); + + Target = LVM_MAXINT_16; + LVC_Mixer_SetTarget(&pInstance->VC_BalanceMix.MixerStream[1],Target); + LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->VC_BalanceMix.MixerStream[1],LVM_VC_MIXER_TIME,LocalParams.SampleRate,1); + } + else + { + LVM_INT32 Target; + /* No drop*/ + Target = LVM_MAXINT_16; + LVC_Mixer_SetTarget(&pInstance->VC_BalanceMix.MixerStream[0],Target); + LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->VC_BalanceMix.MixerStream[0],LVM_VC_MIXER_TIME,LocalParams.SampleRate,1); + + LVC_Mixer_SetTarget(&pInstance->VC_BalanceMix.MixerStream[1],Target); + LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->VC_BalanceMix.MixerStream[1],LVM_VC_MIXER_TIME,LocalParams.SampleRate,1); + } + } + /* + * Update the bass enhancement + */ + { + LVDBE_ReturnStatus_en DBE_Status; + LVDBE_Params_t DBE_Params; + LVDBE_Handle_t *hDBEInstance = pInstance->hDBEInstance; + + + /* + * Set the new parameters + */ + if(LocalParams.OperatingMode == LVM_MODE_OFF) + { + DBE_Params.OperatingMode = LVDBE_OFF; + } + else + { + DBE_Params.OperatingMode = (LVDBE_Mode_en)LocalParams.BE_OperatingMode; + } + DBE_Params.SampleRate = (LVDBE_Fs_en)LocalParams.SampleRate; + DBE_Params.EffectLevel = LocalParams.BE_EffectLevel; + DBE_Params.CentreFrequency = (LVDBE_CentreFreq_en)LocalParams.BE_CentreFreq; + DBE_Params.HPFSelect = (LVDBE_FilterSelect_en)LocalParams.BE_HPF; + DBE_Params.HeadroomdB = 0; + DBE_Params.VolumeControl = LVDBE_VOLUME_OFF; + DBE_Params.VolumedB = 0; + + /* + * Make the changes + */ + DBE_Status = LVDBE_Control(hDBEInstance, + &DBE_Params); + + + /* + * Quit if the changes were not accepted + */ + if (DBE_Status != LVDBE_SUCCESS) + { + return((LVM_ReturnStatus_en)DBE_Status); + } + + + /* + * Set the control flag + */ + pInstance->DBE_Active = LVM_TRUE; + } + + /* + * Update the N-Band Equaliser + */ + { + LVEQNB_ReturnStatus_en EQNB_Status; + LVEQNB_Params_t EQNB_Params; + LVEQNB_Handle_t *hEQNBInstance = pInstance->hEQNBInstance; + + + /* + * Set the new parameters + */ + + if(LocalParams.OperatingMode == LVM_MODE_OFF) + { + EQNB_Params.OperatingMode = LVEQNB_BYPASS; + } + else + { + EQNB_Params.OperatingMode = (LVEQNB_Mode_en)LocalParams.EQNB_OperatingMode; + } + + EQNB_Params.SampleRate = (LVEQNB_Fs_en)LocalParams.SampleRate; + EQNB_Params.NBands = LocalParams.EQNB_NBands; + EQNB_Params.pBandDefinition = (LVEQNB_BandDef_t *)LocalParams.pEQNB_BandDefinition; + if (LocalParams.SourceFormat == LVM_STEREO) /* Mono format not supported */ + { + EQNB_Params.SourceFormat = LVEQNB_STEREO; + } + else + { + EQNB_Params.SourceFormat = LVEQNB_MONOINSTEREO; /* Force to Mono-in-Stereo mode */ + } + + + /* + * Set the control flag + */ + if ((LocalParams.OperatingMode == LVM_MODE_ON) && + (LocalParams.EQNB_OperatingMode == LVM_EQNB_ON)) + { + pInstance->EQNB_Active = LVM_TRUE; + } + else + { + EQNB_Params.OperatingMode = LVEQNB_BYPASS; + } + + /* + * Make the changes + */ + EQNB_Status = LVEQNB_Control(hEQNBInstance, + &EQNB_Params); + + + /* + * Quit if the changes were not accepted + */ + if (EQNB_Status != LVEQNB_SUCCESS) + { + return((LVM_ReturnStatus_en)EQNB_Status); + } + + } + + + /* + * Update concert sound + */ + { + LVCS_ReturnStatus_en CS_Status; + LVCS_Params_t CS_Params; + LVCS_Handle_t *hCSInstance = pInstance->hCSInstance; + LVM_Mode_en CompressorMode=LVM_MODE_ON; + + /* + * Set the new parameters + */ + if(LocalParams.VirtualizerOperatingMode == LVM_MODE_ON) + { + CS_Params.OperatingMode = LVCS_ON; + } + else + { + CS_Params.OperatingMode = LVCS_OFF; + } + + if((LocalParams.TE_OperatingMode == LVM_TE_ON) && (LocalParams.TE_EffectLevel == LVM_TE_LOW_MIPS)) + { + CS_Params.SpeakerType = LVCS_EX_HEADPHONES; + } + else + { + CS_Params.SpeakerType = LVCS_HEADPHONES; + } + + if (LocalParams.SourceFormat == LVM_STEREO) /* Mono format not supported */ + { + CS_Params.SourceFormat = LVCS_STEREO; + } + else + { + CS_Params.SourceFormat = LVCS_MONOINSTEREO; /* Force to Mono-in-Stereo mode */ + } + CS_Params.SampleRate = LocalParams.SampleRate; + CS_Params.ReverbLevel = LocalParams.VirtualizerReverbLevel; + CS_Params.EffectLevel = LocalParams.CS_EffectLevel; + + + /* + * Set the control flag + */ + if ((LocalParams.OperatingMode == LVM_MODE_ON) && + (LocalParams.VirtualizerOperatingMode != LVCS_OFF)) + { + pInstance->CS_Active = LVM_TRUE; + } + else + { + CS_Params.OperatingMode = LVCS_OFF; + } + + CS_Params.CompressorMode=CompressorMode; + + /* + * Make the changes + */ + CS_Status = LVCS_Control(hCSInstance, + &CS_Params); + + + /* + * Quit if the changes were not accepted + */ + if (CS_Status != LVCS_SUCCESS) + { + return((LVM_ReturnStatus_en)CS_Status); + } + + } + + /* + * Update the Power Spectrum Analyser + */ + { + LVPSA_RETURN PSA_Status; + LVPSA_ControlParams_t PSA_Params; + pLVPSA_Handle_t *hPSAInstance = pInstance->hPSAInstance; + + + /* + * Set the new parameters + */ + PSA_Params.Fs = LocalParams.SampleRate; + PSA_Params.LevelDetectionSpeed = (LVPSA_LevelDetectSpeed_en)LocalParams.PSA_PeakDecayRate; + + /* + * Make the changes + */ + if(pInstance->InstParams.PSA_Included==LVM_PSA_ON) + { + PSA_Status = LVPSA_Control(hPSAInstance, + &PSA_Params); + + if (PSA_Status != LVPSA_OK) + { + return((LVM_ReturnStatus_en)PSA_Status); + } + + /* + * Apply new settings + */ + PSA_Status = LVPSA_ApplyNewSettings ((LVPSA_InstancePr_t*)hPSAInstance); + if(PSA_Status != LVPSA_OK) + { + return((LVM_ReturnStatus_en)PSA_Status); + } + } + } + + /* + * Update the parameters and clear the flag + */ + pInstance->Params = LocalParams; + + + return(LVM_SUCCESS); +} + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVM_SetHeadroomParams */ +/* */ +/* DESCRIPTION: */ +/* This function is used to set the automatiuc headroom management parameters. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance Handle */ +/* pHeadroomParams Pointer to headroom parameter structure */ +/* */ +/* RETURNS: */ +/* LVM_Success Succeeded */ +/* */ +/* NOTES: */ +/* 1. This function may be interrupted by the LVM_Process function */ +/* */ +/****************************************************************************************/ + +LVM_ReturnStatus_en LVM_SetHeadroomParams(LVM_Handle_t hInstance, + LVM_HeadroomParams_t *pHeadroomParams) +{ + LVM_Instance_t *pInstance =(LVM_Instance_t *)hInstance; + LVM_UINT16 ii, NBands; + + /* Check for NULL pointers */ + if ((hInstance == LVM_NULL) || (pHeadroomParams == LVM_NULL)) + { + return (LVM_NULLADDRESS); + } + if ((pHeadroomParams->NHeadroomBands != 0) && (pHeadroomParams->pHeadroomDefinition == LVM_NULL)) + { + return (LVM_NULLADDRESS); + } + + /* Consider only the LVM_HEADROOM_MAX_NBANDS first bands*/ + if (pHeadroomParams->NHeadroomBands > LVM_HEADROOM_MAX_NBANDS) + { + NBands = LVM_HEADROOM_MAX_NBANDS; + } + else + { + NBands = pHeadroomParams->NHeadroomBands; + } + pInstance->NewHeadroomParams.NHeadroomBands = NBands; + + /* Copy settings in memory */ + for(ii = 0; ii < NBands; ii++) + { + pInstance->pHeadroom_BandDefs[ii] = pHeadroomParams->pHeadroomDefinition[ii]; + } + + pInstance->NewHeadroomParams.pHeadroomDefinition = pInstance->pHeadroom_BandDefs; + pInstance->NewHeadroomParams.Headroom_OperatingMode = pHeadroomParams->Headroom_OperatingMode; + pInstance->ControlPending = LVM_TRUE; + + return(LVM_SUCCESS); +} + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVM_GetHeadroomParams */ +/* */ +/* DESCRIPTION: */ +/* This function is used to get the automatic headroom management parameters. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance Handle */ +/* pHeadroomParams Pointer to headroom parameter structure (output) */ +/* */ +/* RETURNS: */ +/* LVM_SUCCESS Succeeded */ +/* LVM_NULLADDRESS When hInstance or pHeadroomParams are NULL */ +/* */ +/* NOTES: */ +/* 1. This function may be interrupted by the LVM_Process function */ +/* */ +/****************************************************************************************/ + +LVM_ReturnStatus_en LVM_GetHeadroomParams(LVM_Handle_t hInstance, + LVM_HeadroomParams_t *pHeadroomParams) +{ + LVM_Instance_t *pInstance =(LVM_Instance_t *)hInstance; + LVM_UINT16 ii; + + /* Check for NULL pointers */ + if ((hInstance == LVM_NULL) || (pHeadroomParams == LVM_NULL)) + { + return (LVM_NULLADDRESS); + } + + pHeadroomParams->NHeadroomBands = pInstance->NewHeadroomParams.NHeadroomBands; + + + /* Copy settings in memory */ + for(ii = 0; ii < pInstance->NewHeadroomParams.NHeadroomBands; ii++) + { + pInstance->pHeadroom_UserDefs[ii] = pInstance->pHeadroom_BandDefs[ii]; + } + + + pHeadroomParams->pHeadroomDefinition = pInstance->pHeadroom_UserDefs; + pHeadroomParams->Headroom_OperatingMode = pInstance->NewHeadroomParams.Headroom_OperatingMode; + return(LVM_SUCCESS); +} + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVM_AlgoCallBack */ +/* */ +/* DESCRIPTION: */ +/* This is the callback function of the algorithm. */ +/* */ +/* PARAMETERS: */ +/* pBundleHandle Pointer to the Instance Handle */ +/* pData Pointer to the data */ +/* callbackId ID of the callback */ +/* */ +/* NOTES: */ +/* 1. This function may be interrupted by the LVM_Process function */ +/* */ +/****************************************************************************************/ +LVM_INT32 LVM_AlgoCallBack( void *pBundleHandle, + void *pData, + LVM_INT16 callbackId) +{ + LVM_Instance_t *pInstance =(LVM_Instance_t *)pBundleHandle; + + (void) pData; + + switch(callbackId & 0xFF00){ + case ALGORITHM_CS_ID: + switch(callbackId & 0x00FF) + { + case LVCS_EVENT_ALGOFF: + pInstance->CS_Active = LVM_FALSE; + break; + default: + break; + } + break; + case ALGORITHM_EQNB_ID: + switch(callbackId & 0x00FF) + { + case LVEQNB_EVENT_ALGOFF: + pInstance->EQNB_Active = LVM_FALSE; + break; + default: + break; + } + break; + default: + break; + } + + return 0; +} + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVM_VCCallBack */ +/* */ +/* DESCRIPTION: */ +/* This is the callback function of the Volume control. */ +/* */ +/* PARAMETERS: */ +/* pBundleHandle Pointer to the Instance Handle */ +/* pGeneralPurpose Pointer to the data */ +/* CallBackParam ID of the callback */ +/* */ +/* NOTES: */ +/* 1. This function may be interrupted by the LVM_Process function */ +/* */ +/****************************************************************************************/ +LVM_INT32 LVM_VCCallBack(void* pBundleHandle, + void* pGeneralPurpose, + short CallBackParam) +{ + LVM_Instance_t *pInstance =(LVM_Instance_t *)pBundleHandle; + LVM_INT32 Target; + + (void) pGeneralPurpose; + (void) CallBackParam; + + /* When volume mixer has reached 0 dB target then stop it to avoid + unnecessary processing. */ + Target = LVC_Mixer_GetTarget(&pInstance->VC_Volume.MixerStream[0]); + + if(Target == 0x7FFF) + { + pInstance->VC_Active = LVM_FALSE; + } + return 1; +} diff --git a/media/libeffects/lvm/lib/Bundle/src/LVM_Init.c b/media/libeffects/lvm/lib/Bundle/src/LVM_Init.c new file mode 100755 index 0000000..7ac5685 --- /dev/null +++ b/media/libeffects/lvm/lib/Bundle/src/LVM_Init.c @@ -0,0 +1,1003 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************************ + + $Author: nxp007753 $ + $Revision: 1255 $ + $Date: 2010-07-16 17:07:29 +0200 (Fri, 16 Jul 2010) $ + +*************************************************************************************/ + +/************************************************************************************/ +/* */ +/* Includes */ +/* */ +/************************************************************************************/ + +#include "LVM_Private.h" +#include "LVM_Tables.h" +#include "VectorArithmetic.h" +#include "InstAlloc.h" + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVM_GetMemoryTable */ +/* */ +/* DESCRIPTION: */ +/* This function is used for memory allocation and free. It can be called in */ +/* two ways: */ +/* */ +/* hInstance = NULL Returns the memory requirements */ +/* hInstance = Instance handle Returns the memory requirements and */ +/* allocated base addresses for the instance */ +/* */ +/* When this function is called for memory allocation (hInstance=NULL) the memory */ +/* base address pointers are NULL on return. */ +/* */ +/* When the function is called for free (hInstance = Instance Handle) the memory */ +/* table returns the allocated memory and base addresses used during initialisation. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance Handle */ +/* pMemoryTable Pointer to an empty memory definition table */ +/* pCapabilities Pointer to the default capabilities */ +/* */ +/* RETURNS: */ +/* LVM_SUCCESS Succeeded */ +/* LVM_NULLADDRESS When one of pMemoryTable or pInstParams is NULL */ +/* LVM_OUTOFRANGE When any of the Instance parameters are out of range */ +/* */ +/* NOTES: */ +/* 1. This function may be interrupted by the LVM_Process function */ +/* 2. The scratch memory is the largest required by any of the sub-modules plus any */ +/* additional scratch requirements of the bundle */ +/* */ +/****************************************************************************************/ + +LVM_ReturnStatus_en LVM_GetMemoryTable(LVM_Handle_t hInstance, + LVM_MemTab_t *pMemoryTable, + LVM_InstParams_t *pInstParams) +{ + + LVM_Instance_t *pInstance = (LVM_Instance_t *)hInstance; + LVM_UINT32 AlgScratchSize; + LVM_UINT32 BundleScratchSize; + LVM_UINT16 InternalBlockSize; + INST_ALLOC AllocMem[LVM_NR_MEMORY_REGIONS]; + LVM_INT16 i; + + + /* + * Check parameters + */ + if(pMemoryTable == LVM_NULL) + { + return LVM_NULLADDRESS; + } + + + /* + * Return memory table if the instance has already been created + */ + if (hInstance != LVM_NULL) + { + /* Read back memory allocation table */ + *pMemoryTable = pInstance->MemoryTable; + return(LVM_SUCCESS); + } + + if(pInstParams == LVM_NULL) + { + return LVM_NULLADDRESS; + } + + /* + * Power Spectrum Analyser + */ + if(pInstParams->PSA_Included > LVM_PSA_ON) + { + return (LVM_OUTOFRANGE); + } + + /* + * Check the instance parameters + */ + if( (pInstParams->BufferMode != LVM_MANAGED_BUFFERS) && (pInstParams->BufferMode != LVM_UNMANAGED_BUFFERS) ) + { + return (LVM_OUTOFRANGE); + } + + /* N-Band Equalizer */ + if( pInstParams->EQNB_NumBands > 32 ) + { + return (LVM_OUTOFRANGE); + } + + if(pInstParams->BufferMode == LVM_MANAGED_BUFFERS) + { + if( (pInstParams->MaxBlockSize < LVM_MIN_MAXBLOCKSIZE ) || (pInstParams->MaxBlockSize > LVM_MANAGED_MAX_MAXBLOCKSIZE ) ) + { + return (LVM_OUTOFRANGE); + } + } + else + { + if( (pInstParams->MaxBlockSize < LVM_MIN_MAXBLOCKSIZE ) || (pInstParams->MaxBlockSize > LVM_UNMANAGED_MAX_MAXBLOCKSIZE) ) + { + return (LVM_OUTOFRANGE); + } + } + + /* + * Initialise the AllocMem structures + */ + for (i=0; iMaxBlockSize) & MIN_INTERNAL_BLOCKMASK); /* Force to a multiple of MIN_INTERNAL_BLOCKSIZE */ + + if (InternalBlockSize < MIN_INTERNAL_BLOCKSIZE) + { + InternalBlockSize = MIN_INTERNAL_BLOCKSIZE; + } + + /* Maximum Internal Black Size should not be more than MAX_INTERNAL_BLOCKSIZE*/ + if(InternalBlockSize > MAX_INTERNAL_BLOCKSIZE) + { + InternalBlockSize = MAX_INTERNAL_BLOCKSIZE; + } + + /* + * Bundle requirements + */ + InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_SLOW_DATA], + sizeof(LVM_Instance_t)); + + + /* + * Set the algorithm and bundle scratch requirements + */ + AlgScratchSize = 0; + if (pInstParams->BufferMode == LVM_MANAGED_BUFFERS) + { + BundleScratchSize = 6 * (MIN_INTERNAL_BLOCKSIZE + InternalBlockSize) * sizeof(LVM_INT16); + InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_TEMPORARY_FAST], /* Scratch buffer */ + BundleScratchSize); + InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_SLOW_DATA], + sizeof(LVM_Buffer_t)); + } + + /* + * Treble Enhancement requirements + */ + InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA], + sizeof(LVM_TE_Data_t)); + InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_COEF], + sizeof(LVM_TE_Coefs_t)); + + /* + * N-Band Equalizer requirements + */ + InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA], /* Local storage */ + (pInstParams->EQNB_NumBands * sizeof(LVM_EQNB_BandDef_t))); + InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA], /* User storage */ + (pInstParams->EQNB_NumBands * sizeof(LVM_EQNB_BandDef_t))); + + /* + * Concert Sound requirements + */ + { + LVCS_MemTab_t CS_MemTab; + LVCS_Capabilities_t CS_Capabilities; + + /* + * Set the capabilities + */ + CS_Capabilities.MaxBlockSize = InternalBlockSize; + + /* + * Get the memory requirements + */ + LVCS_Memory(LVM_NULL, + &CS_MemTab, + &CS_Capabilities); + + /* + * Update the memory allocation structures + */ + InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA], + CS_MemTab.Region[LVM_MEMREGION_PERSISTENT_FAST_DATA].Size); + InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_COEF], + CS_MemTab.Region[LVM_MEMREGION_PERSISTENT_FAST_COEF].Size); + if (CS_MemTab.Region[LVM_MEMREGION_TEMPORARY_FAST].Size > AlgScratchSize) AlgScratchSize = CS_MemTab.Region[LVM_MEMREGION_TEMPORARY_FAST].Size; + + } + + + /* + * Dynamic Bass Enhancement requirements + */ + { + LVDBE_MemTab_t DBE_MemTab; + LVDBE_Capabilities_t DBE_Capabilities; + + /* + * Set the capabilities + */ + DBE_Capabilities.SampleRate = LVDBE_CAP_FS_8000 | LVDBE_CAP_FS_11025 | LVDBE_CAP_FS_12000 | LVDBE_CAP_FS_16000 | LVDBE_CAP_FS_22050 | LVDBE_CAP_FS_24000 | LVDBE_CAP_FS_32000 | LVDBE_CAP_FS_44100 | LVDBE_CAP_FS_48000; + DBE_Capabilities.CentreFrequency = LVDBE_CAP_CENTRE_55Hz | LVDBE_CAP_CENTRE_55Hz | LVDBE_CAP_CENTRE_66Hz | LVDBE_CAP_CENTRE_78Hz | LVDBE_CAP_CENTRE_90Hz; + DBE_Capabilities.MaxBlockSize = InternalBlockSize; + + /* + * Get the memory requirements + */ + LVDBE_Memory(LVM_NULL, + &DBE_MemTab, + + &DBE_Capabilities); + /* + * Update the bundle table + */ + InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA], + DBE_MemTab.Region[LVM_MEMREGION_PERSISTENT_FAST_DATA].Size); + InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_COEF], + DBE_MemTab.Region[LVM_MEMREGION_PERSISTENT_FAST_COEF].Size); + if (DBE_MemTab.Region[LVM_MEMREGION_TEMPORARY_FAST].Size > AlgScratchSize) AlgScratchSize = DBE_MemTab.Region[LVM_MEMREGION_TEMPORARY_FAST].Size; + + } + + + /* + * N-Band equaliser requirements + */ + { + LVEQNB_MemTab_t EQNB_MemTab; /* For N-Band Equaliser */ + LVEQNB_Capabilities_t EQNB_Capabilities; + + /* + * Set the capabilities + */ + EQNB_Capabilities.SampleRate = LVEQNB_CAP_FS_8000 | LVEQNB_CAP_FS_11025 | LVEQNB_CAP_FS_12000 | LVEQNB_CAP_FS_16000 | LVEQNB_CAP_FS_22050 | LVEQNB_CAP_FS_24000 | LVEQNB_CAP_FS_32000 | LVEQNB_CAP_FS_44100 | LVEQNB_CAP_FS_48000; + EQNB_Capabilities.SourceFormat = LVEQNB_CAP_STEREO | LVEQNB_CAP_MONOINSTEREO; + EQNB_Capabilities.MaxBlockSize = InternalBlockSize; + EQNB_Capabilities.MaxBands = pInstParams->EQNB_NumBands; + + /* + * Get the memory requirements + */ + LVEQNB_Memory(LVM_NULL, + &EQNB_MemTab, + &EQNB_Capabilities); + + /* + * Update the bundle table + */ + InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA], + EQNB_MemTab.Region[LVM_MEMREGION_PERSISTENT_FAST_DATA].Size); + InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_COEF], + EQNB_MemTab.Region[LVM_MEMREGION_PERSISTENT_FAST_COEF].Size); + if (EQNB_MemTab.Region[LVM_MEMREGION_TEMPORARY_FAST].Size > AlgScratchSize) AlgScratchSize = EQNB_MemTab.Region[LVM_MEMREGION_TEMPORARY_FAST].Size; + + } + + /* + * Headroom management memory allocation + */ + InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA], + (LVM_HEADROOM_MAX_NBANDS * sizeof(LVM_HeadroomBandDef_t))); + InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA], + (LVM_HEADROOM_MAX_NBANDS * sizeof(LVM_HeadroomBandDef_t))); + + + /* + * Spectrum Analyzer memory requirements + */ + { + pLVPSA_Handle_t hPSAInst = LVM_NULL; + LVPSA_MemTab_t PSA_MemTab; + LVPSA_InitParams_t PSA_InitParams; + LVPSA_FilterParam_t FiltersParams[9]; + LVPSA_RETURN PSA_Status; + + if(pInstParams->PSA_Included == LVM_PSA_ON) + { + PSA_InitParams.SpectralDataBufferDuration = (LVM_UINT16) 500; + PSA_InitParams.MaxInputBlockSize = (LVM_UINT16) 1000; + PSA_InitParams.nBands = (LVM_UINT16) 9; + + PSA_InitParams.pFiltersParams = &FiltersParams[0]; + for(i = 0; i < PSA_InitParams.nBands; i++) + { + FiltersParams[i].CenterFrequency = (LVM_UINT16) 1000; + FiltersParams[i].QFactor = (LVM_UINT16) 25; + FiltersParams[i].PostGain = (LVM_INT16) 0; + } + + /* + * Get the memory requirements + */ + PSA_Status = LVPSA_Memory (hPSAInst, + &PSA_MemTab, + &PSA_InitParams); + + if (PSA_Status != LVPSA_OK) + { + return((LVM_ReturnStatus_en) LVM_ALGORITHMPSA); + } + + /* + * Update the bundle table + */ + /* Slow Data */ + InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_SLOW_DATA], + PSA_MemTab.Region[LVM_PERSISTENT_SLOW_DATA].Size); + + /* Fast Data */ + InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA], + PSA_MemTab.Region[LVM_PERSISTENT_FAST_DATA].Size); + + /* Fast Coef */ + InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_COEF], + PSA_MemTab.Region[LVM_PERSISTENT_FAST_COEF].Size); + + /* Fast Temporary */ + InstAlloc_AddMember(&AllocMem[LVM_TEMPORARY_FAST], + MAX_INTERNAL_BLOCKSIZE * sizeof(LVM_INT16)); + + if (PSA_MemTab.Region[LVM_TEMPORARY_FAST].Size > AlgScratchSize) + { + AlgScratchSize = PSA_MemTab.Region[LVM_TEMPORARY_FAST].Size; + } + } + } + + /* + * Return the memory table + */ + pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_SLOW_DATA].Size = InstAlloc_GetTotal(&AllocMem[LVM_MEMREGION_PERSISTENT_SLOW_DATA]); + pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_SLOW_DATA].Type = LVM_PERSISTENT_SLOW_DATA; + pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_SLOW_DATA].pBaseAddress = LVM_NULL; + + pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_FAST_DATA].Size = InstAlloc_GetTotal(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA]); + pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_FAST_DATA].Type = LVM_PERSISTENT_FAST_DATA; + pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_FAST_DATA].pBaseAddress = LVM_NULL; + if (pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_FAST_DATA].Size < 4) + { + pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_FAST_DATA].Size = 0; + } + + pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_FAST_COEF].Size = InstAlloc_GetTotal(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_COEF]); + pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_FAST_COEF].Type = LVM_PERSISTENT_FAST_COEF; + pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_FAST_COEF].pBaseAddress = LVM_NULL; + if (pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_FAST_COEF].Size < 4) + { + pMemoryTable->Region[LVM_MEMREGION_PERSISTENT_FAST_COEF].Size = 0; + } + + InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_TEMPORARY_FAST], + AlgScratchSize); + pMemoryTable->Region[LVM_MEMREGION_TEMPORARY_FAST].Size = InstAlloc_GetTotal(&AllocMem[LVM_MEMREGION_TEMPORARY_FAST]); + pMemoryTable->Region[LVM_MEMREGION_TEMPORARY_FAST].Type = LVM_TEMPORARY_FAST; + pMemoryTable->Region[LVM_MEMREGION_TEMPORARY_FAST].pBaseAddress = LVM_NULL; + if (pMemoryTable->Region[LVM_MEMREGION_TEMPORARY_FAST].Size < 4) + { + pMemoryTable->Region[LVM_MEMREGION_TEMPORARY_FAST].Size = 0; + } + + return(LVM_SUCCESS); + +} + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVM_GetInstanceHandle */ +/* */ +/* DESCRIPTION: */ +/* This function is used to create a bundle instance. It returns the created instance */ +/* handle through phInstance. All parameters are set to their default, inactive state. */ +/* */ +/* PARAMETERS: */ +/* phInstance pointer to the instance handle */ +/* pMemoryTable Pointer to the memory definition table */ +/* pInstParams Pointer to the initialisation capabilities */ +/* */ +/* RETURNS: */ +/* LVM_SUCCESS Initialisation succeeded */ +/* LVM_OUTOFRANGE When any of the Instance parameters are out of range */ +/* LVM_NULLADDRESS When one of phInstance, pMemoryTable or pInstParams are NULL*/ +/* */ +/* NOTES: */ +/* 1. This function must not be interrupted by the LVM_Process function */ +/* */ +/****************************************************************************************/ + +LVM_ReturnStatus_en LVM_GetInstanceHandle(LVM_Handle_t *phInstance, + LVM_MemTab_t *pMemoryTable, + LVM_InstParams_t *pInstParams) +{ + + LVM_ReturnStatus_en Status = LVM_SUCCESS; + LVM_Instance_t *pInstance; + INST_ALLOC AllocMem[LVM_NR_MEMORY_REGIONS]; + LVM_INT16 i; + LVM_UINT16 InternalBlockSize; + LVM_INT32 BundleScratchSize; + + + /* + * Check valid points have been given + */ + if ((phInstance == LVM_NULL) || (pMemoryTable == LVM_NULL) || (pInstParams == LVM_NULL)) + { + return (LVM_NULLADDRESS); + } + + /* + * Check the memory table for NULL pointers + */ + for (i=0; iRegion[i].Size != 0) && + (pMemoryTable->Region[i].pBaseAddress==LVM_NULL)) + { + return(LVM_NULLADDRESS); + } + } + + /* + * Check the instance parameters + */ + if( (pInstParams->BufferMode != LVM_MANAGED_BUFFERS) && (pInstParams->BufferMode != LVM_UNMANAGED_BUFFERS) ) + { + return (LVM_OUTOFRANGE); + } + + if( pInstParams->EQNB_NumBands > 32 ) + { + return (LVM_OUTOFRANGE); + } + + if(pInstParams->BufferMode == LVM_MANAGED_BUFFERS) + { + if( (pInstParams->MaxBlockSize < LVM_MIN_MAXBLOCKSIZE ) || (pInstParams->MaxBlockSize > LVM_MANAGED_MAX_MAXBLOCKSIZE ) ) + { + return (LVM_OUTOFRANGE); + } + } + else + { + if( (pInstParams->MaxBlockSize < LVM_MIN_MAXBLOCKSIZE ) || (pInstParams->MaxBlockSize > LVM_UNMANAGED_MAX_MAXBLOCKSIZE) ) + { + return (LVM_OUTOFRANGE); + } + } + + if(pInstParams->PSA_Included > LVM_PSA_ON) + { + return (LVM_OUTOFRANGE); + } + + /* + * Initialise the AllocMem structures + */ + for (i=0; iRegion[i].pBaseAddress); + } + + + /* + * Set the instance handle + */ + *phInstance = (LVM_Handle_t)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_SLOW_DATA], + sizeof(LVM_Instance_t)); + pInstance =(LVM_Instance_t *)*phInstance; + + + /* + * Save the memory table, parameters and capabilities + */ + pInstance->MemoryTable = *pMemoryTable; + pInstance->InstParams = *pInstParams; + + + /* + * Set the bundle scratch memory and initialse the buffer management + */ + InternalBlockSize = (LVM_UINT16)((pInstParams->MaxBlockSize) & MIN_INTERNAL_BLOCKMASK); /* Force to a multiple of MIN_INTERNAL_BLOCKSIZE */ + if (InternalBlockSize < MIN_INTERNAL_BLOCKSIZE) + { + InternalBlockSize = MIN_INTERNAL_BLOCKSIZE; + } + + /* Maximum Internal Black Size should not be more than MAX_INTERNAL_BLOCKSIZE*/ + if(InternalBlockSize > MAX_INTERNAL_BLOCKSIZE) + { + InternalBlockSize = MAX_INTERNAL_BLOCKSIZE; + } + pInstance->InternalBlockSize = (LVM_INT16)InternalBlockSize; + + + /* + * Common settings for managed and unmanaged buffers + */ + pInstance->SamplesToProcess = 0; /* No samples left to process */ + if (pInstParams->BufferMode == LVM_MANAGED_BUFFERS) + { + /* + * Managed buffers required + */ + pInstance->pBufferManagement = InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_SLOW_DATA], + sizeof(LVM_Buffer_t)); + BundleScratchSize = (LVM_INT32)(6 * (MIN_INTERNAL_BLOCKSIZE + InternalBlockSize) * sizeof(LVM_INT16)); + pInstance->pBufferManagement->pScratch = InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_TEMPORARY_FAST], /* Scratch 1 buffer */ + (LVM_UINT32)BundleScratchSize); + + LoadConst_16(0, /* Clear the input delay buffer */ + (LVM_INT16 *)&pInstance->pBufferManagement->InDelayBuffer, + (LVM_INT16)(2 * MIN_INTERNAL_BLOCKSIZE)); + pInstance->pBufferManagement->InDelaySamples = MIN_INTERNAL_BLOCKSIZE; /* Set the number of delay samples */ + pInstance->pBufferManagement->OutDelaySamples = 0; /* No samples in the output buffer */ + pInstance->pBufferManagement->BufferState = LVM_FIRSTCALL; /* Set the state ready for the first call */ + } + + + /* + * Set default parameters + */ + pInstance->Params.OperatingMode = LVM_MODE_OFF; + pInstance->Params.SampleRate = LVM_FS_8000; + pInstance->Params.SourceFormat = LVM_MONO; + pInstance->Params.SpeakerType = LVM_HEADPHONES; + pInstance->Params.VC_EffectLevel = 0; + pInstance->Params.VC_Balance = 0; + + /* + * Set callback + */ + pInstance->CallBack = LVM_AlgoCallBack; + + + /* + * DC removal filter + */ + DC_2I_D16_TRC_WRA_01_Init(&pInstance->DC_RemovalInstance); + + + /* + * Treble Enhancement + */ + pInstance->pTE_Taps = (LVM_TE_Data_t *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA], + sizeof(LVM_TE_Data_t)); + + pInstance->pTE_State = (LVM_TE_Coefs_t *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_COEF], + sizeof(LVM_TE_Coefs_t)); + pInstance->Params.TE_OperatingMode = LVM_TE_OFF; + pInstance->Params.TE_EffectLevel = 0; + pInstance->TE_Active = LVM_FALSE; + + + /* + * Set the volume control and initialise Current to Target + */ + pInstance->VC_Volume.MixerStream[0].CallbackParam = 0; + pInstance->VC_Volume.MixerStream[0].CallbackSet = 0; + pInstance->VC_Volume.MixerStream[0].pCallbackHandle = pInstance; + pInstance->VC_Volume.MixerStream[0].pCallBack = LVM_VCCallBack; + + /* In managed buffering, start with low signal level as delay in buffer management causes a click*/ + if (pInstParams->BufferMode == LVM_MANAGED_BUFFERS) + { + LVC_Mixer_Init(&pInstance->VC_Volume.MixerStream[0],0,0); + } + else + { + LVC_Mixer_Init(&pInstance->VC_Volume.MixerStream[0],LVM_MAXINT_16,LVM_MAXINT_16); + } + + LVC_Mixer_SetTimeConstant(&pInstance->VC_Volume.MixerStream[0],0,LVM_FS_8000,2); + + pInstance->VC_VolumedB = 0; + pInstance->VC_AVLFixedVolume = 0; + pInstance->VC_Active = LVM_FALSE; + + pInstance->VC_BalanceMix.MixerStream[0].CallbackParam = 0; + pInstance->VC_BalanceMix.MixerStream[0].CallbackSet = 0; + pInstance->VC_BalanceMix.MixerStream[0].pCallbackHandle = pInstance; + pInstance->VC_BalanceMix.MixerStream[0].pCallBack = LVM_VCCallBack; + LVC_Mixer_Init(&pInstance->VC_BalanceMix.MixerStream[0],LVM_MAXINT_16,LVM_MAXINT_16); + LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->VC_BalanceMix.MixerStream[0],LVM_VC_MIXER_TIME,LVM_FS_8000,2); + + pInstance->VC_BalanceMix.MixerStream[1].CallbackParam = 0; + pInstance->VC_BalanceMix.MixerStream[1].CallbackSet = 0; + pInstance->VC_BalanceMix.MixerStream[1].pCallbackHandle = pInstance; + pInstance->VC_BalanceMix.MixerStream[1].pCallBack = LVM_VCCallBack; + LVC_Mixer_Init(&pInstance->VC_BalanceMix.MixerStream[1],LVM_MAXINT_16,LVM_MAXINT_16); + LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->VC_BalanceMix.MixerStream[1],LVM_VC_MIXER_TIME,LVM_FS_8000,2); + /* + * Set the default EQNB pre-gain and pointer to the band definitions + */ + pInstance->pEQNB_BandDefs = InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA], + (pInstParams->EQNB_NumBands * sizeof(LVM_EQNB_BandDef_t))); + pInstance->pEQNB_UserDefs = InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA], + (pInstParams->EQNB_NumBands * sizeof(LVM_EQNB_BandDef_t))); + + + /* + * Initialise the Concert Sound module + */ + { + LVCS_Handle_t hCSInstance; /* Instance handle */ + LVCS_MemTab_t CS_MemTab; /* Memory table */ + LVCS_Capabilities_t CS_Capabilities; /* Initial capabilities */ + LVCS_ReturnStatus_en LVCS_Status; /* Function call status */ + + /* + * Set default parameters + */ + pInstance->Params.VirtualizerReverbLevel = 100; + pInstance->Params.VirtualizerType = LVM_CONCERTSOUND; + pInstance->Params.VirtualizerOperatingMode = LVM_MODE_OFF; + pInstance->CS_Active = LVM_FALSE; + + /* + * Set the initialisation capabilities + */ + CS_Capabilities.MaxBlockSize = (LVM_UINT16)InternalBlockSize; + CS_Capabilities.CallBack = pInstance->CallBack; + CS_Capabilities.pBundleInstance = (void*)pInstance; + + + /* + * Get the memory requirements and then set the address pointers, forcing alignment + */ + LVCS_Status = LVCS_Memory(LVM_NULL, /* Get the memory requirements */ + &CS_MemTab, + &CS_Capabilities); + CS_MemTab.Region[LVCS_MEMREGION_PERSISTENT_SLOW_DATA].pBaseAddress = &pInstance->CS_Instance; + CS_MemTab.Region[LVCS_MEMREGION_PERSISTENT_FAST_DATA].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA], + CS_MemTab.Region[LVCS_MEMREGION_PERSISTENT_FAST_DATA].Size); + CS_MemTab.Region[LVCS_MEMREGION_PERSISTENT_FAST_COEF].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_COEF], + CS_MemTab.Region[LVCS_MEMREGION_PERSISTENT_FAST_COEF].Size); + CS_MemTab.Region[LVCS_MEMREGION_TEMPORARY_FAST].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_TEMPORARY_FAST], + 0); + + /* + * Initialise the Concert Sound instance and save the instance handle + */ + hCSInstance = LVM_NULL; /* Set to NULL to return handle */ + LVCS_Status = LVCS_Init(&hCSInstance, /* Initiailse */ + &CS_MemTab, + &CS_Capabilities); + if (LVCS_Status != LVCS_SUCCESS) return((LVM_ReturnStatus_en)LVCS_Status); + pInstance->hCSInstance = hCSInstance; /* Save the instance handle */ + + } + + /* + * Initialise the Bass Enhancement module + */ + { + LVDBE_Handle_t hDBEInstance; /* Instance handle */ + LVDBE_MemTab_t DBE_MemTab; /* Memory table */ + LVDBE_Capabilities_t DBE_Capabilities; /* Initial capabilities */ + LVDBE_ReturnStatus_en LVDBE_Status; /* Function call status */ + + + /* + * Set the initialisation parameters + */ + pInstance->Params.BE_OperatingMode = LVM_BE_OFF; + pInstance->Params.BE_CentreFreq = LVM_BE_CENTRE_55Hz; + pInstance->Params.BE_EffectLevel = 0; + pInstance->Params.BE_HPF = LVM_BE_HPF_OFF; + + pInstance->DBE_Active = LVM_FALSE; + + + + /* + * Set the initialisation capabilities + */ + DBE_Capabilities.SampleRate = LVDBE_CAP_FS_8000 | LVDBE_CAP_FS_11025 | LVDBE_CAP_FS_12000 | LVDBE_CAP_FS_16000 | LVDBE_CAP_FS_22050 | LVDBE_CAP_FS_24000 | LVDBE_CAP_FS_32000 | LVDBE_CAP_FS_44100 | LVDBE_CAP_FS_48000; + DBE_Capabilities.CentreFrequency = LVDBE_CAP_CENTRE_55Hz | LVDBE_CAP_CENTRE_55Hz | LVDBE_CAP_CENTRE_66Hz | LVDBE_CAP_CENTRE_78Hz | LVDBE_CAP_CENTRE_90Hz; + DBE_Capabilities.MaxBlockSize = (LVM_UINT16)InternalBlockSize; + + + /* + * Get the memory requirements and then set the address pointers + */ + LVDBE_Status = LVDBE_Memory(LVM_NULL, /* Get the memory requirements */ + &DBE_MemTab, + &DBE_Capabilities); + DBE_MemTab.Region[LVDBE_MEMREGION_INSTANCE].pBaseAddress = &pInstance->DBE_Instance; + DBE_MemTab.Region[LVDBE_MEMREGION_PERSISTENT_DATA].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA], + DBE_MemTab.Region[LVDBE_MEMREGION_PERSISTENT_DATA].Size); + DBE_MemTab.Region[LVDBE_MEMREGION_PERSISTENT_COEF].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_COEF], + DBE_MemTab.Region[LVDBE_MEMREGION_PERSISTENT_COEF].Size); + DBE_MemTab.Region[LVDBE_MEMREGION_SCRATCH].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_TEMPORARY_FAST], + 0); + + + /* + * Initialise the Dynamic Bass Enhancement instance and save the instance handle + */ + hDBEInstance = LVM_NULL; /* Set to NULL to return handle */ + LVDBE_Status = LVDBE_Init(&hDBEInstance, /* Initiailse */ + &DBE_MemTab, + &DBE_Capabilities); + if (LVDBE_Status != LVDBE_SUCCESS) return((LVM_ReturnStatus_en)LVDBE_Status); + pInstance->hDBEInstance = hDBEInstance; /* Save the instance handle */ + } + + + /* + * Initialise the N-Band Equaliser module + */ + { + LVEQNB_Handle_t hEQNBInstance; /* Instance handle */ + LVEQNB_MemTab_t EQNB_MemTab; /* Memory table */ + LVEQNB_Capabilities_t EQNB_Capabilities; /* Initial capabilities */ + LVEQNB_ReturnStatus_en LVEQNB_Status; /* Function call status */ + + + /* + * Set the initialisation parameters + */ + pInstance->Params.EQNB_OperatingMode = LVM_EQNB_OFF; + pInstance->Params.EQNB_NBands = 0; + pInstance->Params.pEQNB_BandDefinition = LVM_NULL; + pInstance->EQNB_Active = LVM_FALSE; + + + /* + * Set the initialisation capabilities + */ + EQNB_Capabilities.SampleRate = LVEQNB_CAP_FS_8000 | LVEQNB_CAP_FS_11025 | LVEQNB_CAP_FS_12000 | LVEQNB_CAP_FS_16000 | LVEQNB_CAP_FS_22050 | LVEQNB_CAP_FS_24000 | LVEQNB_CAP_FS_32000 | LVEQNB_CAP_FS_44100 | LVEQNB_CAP_FS_48000; + EQNB_Capabilities.MaxBlockSize = (LVM_UINT16)InternalBlockSize; + EQNB_Capabilities.MaxBands = pInstParams->EQNB_NumBands; + EQNB_Capabilities.SourceFormat = LVEQNB_CAP_STEREO | LVEQNB_CAP_MONOINSTEREO; + EQNB_Capabilities.CallBack = pInstance->CallBack; + EQNB_Capabilities.pBundleInstance = (void*)pInstance; + + + /* + * Get the memory requirements and then set the address pointers, forcing alignment + */ + LVEQNB_Status = LVEQNB_Memory(LVM_NULL, /* Get the memory requirements */ + &EQNB_MemTab, + &EQNB_Capabilities); + EQNB_MemTab.Region[LVEQNB_MEMREGION_INSTANCE].pBaseAddress = &pInstance->EQNB_Instance; + EQNB_MemTab.Region[LVEQNB_MEMREGION_PERSISTENT_DATA].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA], + EQNB_MemTab.Region[LVEQNB_MEMREGION_PERSISTENT_DATA].Size); + EQNB_MemTab.Region[LVEQNB_MEMREGION_PERSISTENT_COEF].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_COEF], + EQNB_MemTab.Region[LVEQNB_MEMREGION_PERSISTENT_COEF].Size); + EQNB_MemTab.Region[LVEQNB_MEMREGION_SCRATCH].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_TEMPORARY_FAST], + 0); + + + /* + * Initialise the Dynamic Bass Enhancement instance and save the instance handle + */ + hEQNBInstance = LVM_NULL; /* Set to NULL to return handle */ + LVEQNB_Status = LVEQNB_Init(&hEQNBInstance, /* Initiailse */ + &EQNB_MemTab, + &EQNB_Capabilities); + if (LVEQNB_Status != LVEQNB_SUCCESS) return((LVM_ReturnStatus_en)LVEQNB_Status); + pInstance->hEQNBInstance = hEQNBInstance; /* Save the instance handle */ + } + + /* + * Headroom management memory allocation + */ + { + pInstance->pHeadroom_BandDefs = InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA], + (LVM_HEADROOM_MAX_NBANDS * sizeof(LVM_HeadroomBandDef_t))); + pInstance->pHeadroom_UserDefs = InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA], + (LVM_HEADROOM_MAX_NBANDS * sizeof(LVM_HeadroomBandDef_t))); + + /* Headroom management parameters initialisation */ + pInstance->NewHeadroomParams.NHeadroomBands = 2; + pInstance->NewHeadroomParams.pHeadroomDefinition = pInstance->pHeadroom_BandDefs; + pInstance->NewHeadroomParams.pHeadroomDefinition[0].Limit_Low = 20; + pInstance->NewHeadroomParams.pHeadroomDefinition[0].Limit_High = 4999; + pInstance->NewHeadroomParams.pHeadroomDefinition[0].Headroom_Offset = 3; + pInstance->NewHeadroomParams.pHeadroomDefinition[1].Limit_Low = 5000; + pInstance->NewHeadroomParams.pHeadroomDefinition[1].Limit_High = 24000; + pInstance->NewHeadroomParams.pHeadroomDefinition[1].Headroom_Offset = 4; + pInstance->NewHeadroomParams.Headroom_OperatingMode = LVM_HEADROOM_ON; + + pInstance->Headroom =0; + } + + + /* + * Initialise the PSA module + */ + { + pLVPSA_Handle_t hPSAInstance = LVM_NULL; /* Instance handle */ + LVPSA_MemTab_t PSA_MemTab; + LVPSA_RETURN PSA_Status; /* Function call status */ + LVPSA_FilterParam_t FiltersParams[9]; + + if(pInstParams->PSA_Included==LVM_PSA_ON) + { + pInstance->PSA_InitParams.SpectralDataBufferDuration = (LVM_UINT16) 500; + pInstance->PSA_InitParams.MaxInputBlockSize = (LVM_UINT16) 2048; + pInstance->PSA_InitParams.nBands = (LVM_UINT16) 9; + pInstance->PSA_InitParams.pFiltersParams = &FiltersParams[0]; + for(i = 0; i < pInstance->PSA_InitParams.nBands; i++) + { + FiltersParams[i].CenterFrequency = (LVM_UINT16) 1000; + FiltersParams[i].QFactor = (LVM_UINT16) 100; + FiltersParams[i].PostGain = (LVM_INT16) 0; + } + + /*Get the memory requirements and then set the address pointers*/ + PSA_Status = LVPSA_Memory (hPSAInstance, + &PSA_MemTab, + &pInstance->PSA_InitParams); + + if (PSA_Status != LVPSA_OK) + { + return((LVM_ReturnStatus_en) LVM_ALGORITHMPSA); + } + + /* Slow Data */ + PSA_MemTab.Region[LVM_PERSISTENT_SLOW_DATA].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_SLOW_DATA], + PSA_MemTab.Region[LVM_PERSISTENT_SLOW_DATA].Size); + + + /* Fast Data */ + PSA_MemTab.Region[LVM_PERSISTENT_FAST_DATA].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_DATA], + PSA_MemTab.Region[LVM_PERSISTENT_FAST_DATA].Size); + + + /* Fast Coef */ + PSA_MemTab.Region[LVM_PERSISTENT_FAST_COEF].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_PERSISTENT_FAST_COEF], + PSA_MemTab.Region[LVM_PERSISTENT_FAST_COEF].Size); + + /* Fast Temporary */ + pInstance->pPSAInput = InstAlloc_AddMember(&AllocMem[LVM_TEMPORARY_FAST], + (LVM_UINT32) MAX_INTERNAL_BLOCKSIZE * sizeof(LVM_INT16)); + + PSA_MemTab.Region[LVM_TEMPORARY_FAST].pBaseAddress = (void *)InstAlloc_AddMember(&AllocMem[LVM_MEMREGION_TEMPORARY_FAST],0); + + + /*Initialise PSA instance and save the instance handle*/ + pInstance->PSA_ControlParams.Fs = LVM_FS_48000; + pInstance->PSA_ControlParams.LevelDetectionSpeed = LVPSA_SPEED_MEDIUM; + PSA_Status = LVPSA_Init (&hPSAInstance, + &pInstance->PSA_InitParams, + &pInstance->PSA_ControlParams, + &PSA_MemTab); + + if (PSA_Status != LVPSA_OK) + { + return((LVM_ReturnStatus_en) LVM_ALGORITHMPSA); + } + + pInstance->hPSAInstance = hPSAInstance; /* Save the instance handle */ + pInstance->PSA_GainOffset = 0; + } + else + { + pInstance->hPSAInstance = LVM_NULL; + } + + /* + * Set the initialisation parameters. + */ + pInstance->Params.PSA_PeakDecayRate = LVM_PSA_SPEED_MEDIUM; + pInstance->Params.PSA_Enable = LVM_PSA_OFF; + } + + /* + * Copy the initial parameters to the new parameters for correct readback of + * the settings. + */ + pInstance->NewParams = pInstance->Params; + + + /* + * Create configuration number + */ + pInstance->ConfigurationNumber = 0x00000000; + pInstance->ConfigurationNumber += LVM_CS_MASK; + pInstance->ConfigurationNumber += LVM_EQNB_MASK; + pInstance->ConfigurationNumber += LVM_DBE_MASK; + pInstance->ConfigurationNumber += LVM_VC_MASK; + pInstance->ConfigurationNumber += LVM_PSA_MASK; + + if(((pInstance->ConfigurationNumber & LVM_CS_MASK)!=0) || + ((pInstance->ConfigurationNumber & LVM_DBE_MASK)!=0) || + ((pInstance->ConfigurationNumber & LVM_EQNB_MASK)!=0)|| + ((pInstance->ConfigurationNumber & LVM_TE_MASK)!=0) || + ((pInstance->ConfigurationNumber & LVM_VC_MASK)!=0)) + { + pInstance->BlickSizeMultiple = 4; + } + else + { + pInstance->BlickSizeMultiple = 1; + } + + return(Status); +} + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVM_ClearAudioBuffers */ +/* */ +/* DESCRIPTION: */ +/* This function is used to clear the internal audio buffers of the bundle. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance handle */ +/* */ +/* RETURNS: */ +/* LVM_SUCCESS Initialisation succeeded */ +/* LVM_NULLADDRESS Instance or scratch memory has a NULL pointer */ +/* */ +/* NOTES: */ +/* 1. This function must not be interrupted by the LVM_Process function */ +/* */ +/****************************************************************************************/ + +LVM_ReturnStatus_en LVM_ClearAudioBuffers(LVM_Handle_t hInstance) +{ + LVM_MemTab_t MemTab; /* Memory table */ + LVM_InstParams_t InstParams; /* Instance parameters */ + LVM_ControlParams_t Params; /* Control Parameters */ + LVM_Instance_t *pInstance = (LVM_Instance_t *)hInstance; /* Pointer to Instance */ + + + if(hInstance == LVM_NULL){ + return LVM_NULLADDRESS; + } + + /* Save the control parameters */ /* coverity[unchecked_value] */ /* Do not check return value internal function calls */ + LVM_GetControlParameters(hInstance, &Params); + + /* Retrieve allocated buffers in memtab */ + LVM_GetMemoryTable(hInstance, &MemTab, LVM_NULL); + + /* Save the instance parameters */ + InstParams = pInstance->InstParams; + + /* Call LVM_GetInstanceHandle to re-initialise the bundle */ + LVM_GetInstanceHandle( &hInstance, + &MemTab, + &InstParams); + + /* Restore control parameters */ /* coverity[unchecked_value] */ /* Do not check return value internal function calls */ + LVM_SetControlParameters(hInstance, &Params); + + /* DC removal filter */ + DC_2I_D16_TRC_WRA_01_Init(&pInstance->DC_RemovalInstance); + + + return LVM_SUCCESS; +} + + + diff --git a/media/libeffects/lvm/lib/Bundle/src/LVM_Private.h b/media/libeffects/lvm/lib/Bundle/src/LVM_Private.h new file mode 100755 index 0000000..f70e473 --- /dev/null +++ b/media/libeffects/lvm/lib/Bundle/src/LVM_Private.h @@ -0,0 +1,292 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************************** + + $Author: nxp007753 $ + $Revision: 1082 $ + $Date: 2010-07-05 12:44:39 +0200 (Mon, 05 Jul 2010) $ + +***********************************************************************************/ + +/************************************************************************************/ +/* */ +/* Header file for the private layer interface of concert sound bundle */ +/* */ +/* This files includes all definitions, types, structures and function */ +/* prototypes required by the execution layer. */ +/* */ +/************************************************************************************/ + +#ifndef __LVM_PRIVATE_H__ +#define __LVM_PRIVATE_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/************************************************************************************/ +/* */ +/* Includes */ +/* */ +/************************************************************************************/ + +#include "LVM.h" /* LifeVibes */ +#include "LVM_Common.h" /* LifeVibes common */ +#include "BIQUAD.h" /* Biquad library */ +#include "LVC_Mixer.h" /* Mixer library */ +#include "LVCS_Private.h" /* Concert Sound */ +#include "LVDBE_Private.h" /* Dynamic Bass Enhancement */ +#include "LVEQNB_Private.h" /* N-Band equaliser */ +#include "LVPSA_Private.h" /* Parametric Spectrum Analyzer */ + + +/************************************************************************************/ +/* */ +/* Defines */ +/* */ +/************************************************************************************/ + +/* General */ +#define LVM_INVALID 0xFFFF /* Invalid init parameter */ + +/* Memory */ +#define LVM_INSTANCE_ALIGN 4 /* 32-bit for structures */ +#define LVM_FIRSTCALL 0 /* First call to the buffer */ +#define LVM_MAXBLOCKCALL 1 /* Maximum block size calls to the buffer */ +#define LVM_LASTCALL 2 /* Last call to the buffer */ +#define LVM_FIRSTLASTCALL 3 /* Single call for small number of samples */ + +/* Block Size */ +#define LVM_MIN_MAXBLOCKSIZE 16 /* Minimum MaxBlockSize Limit*/ +#define LVM_MANAGED_MAX_MAXBLOCKSIZE 8191 /* Maximum MaxBlockSzie Limit for Managed Buffer Mode*/ +#define LVM_UNMANAGED_MAX_MAXBLOCKSIZE 4096 /* Maximum MaxBlockSzie Limit for Unmanaged Buffer Mode */ + +#define MAX_INTERNAL_BLOCKSIZE 8128 /* Maximum multiple of 64 below 8191*/ + +#define MIN_INTERNAL_BLOCKSIZE 16 /* Minimum internal block size */ +#define MIN_INTERNAL_BLOCKSHIFT 4 /* Minimum internal block size as a power of 2 */ +#define MIN_INTERNAL_BLOCKMASK 0xFFF0 /* Minimum internal block size mask */ + +#define LVM_PSA_DYNAMICRANGE 60 /* Spectral Dynamic range: used for offseting output*/ +#define LVM_PSA_BARHEIGHT 127 /* Spectral Bar Height*/ + +#define LVM_TE_MIN_EFFECTLEVEL 0 /*TE Minimum EffectLevel*/ +#define LVM_TE_MAX_EFFECTLEVEL 15 /*TE Maximum Effect level*/ + +#define LVM_VC_MIN_EFFECTLEVEL -96 /*VC Minimum EffectLevel*/ +#define LVM_VC_MAX_EFFECTLEVEL 0 /*VC Maximum Effect level*/ + +#define LVM_BE_MIN_EFFECTLEVEL 0 /*BE Minimum EffectLevel*/ +#define LVM_BE_MAX_EFFECTLEVEL 15 /*BE Maximum Effect level*/ + +#define LVM_EQNB_MIN_BAND_FREQ 20 /*EQNB Minimum Band Frequency*/ +#define LVM_EQNB_MAX_BAND_FREQ 24000 /*EQNB Maximum Band Frequency*/ +#define LVM_EQNB_MIN_BAND_GAIN -15 /*EQNB Minimum Band Frequency*/ +#define LVM_EQNB_MAX_BAND_GAIN 15 /*EQNB Maximum Band Frequency*/ +#define LVM_EQNB_MIN_QFACTOR 25 /*EQNB Minimum Q Factor*/ +#define LVM_EQNB_MAX_QFACTOR 1200 /*EQNB Maximum Q Factor*/ +#define LVM_EQNB_MIN_LPF_FREQ 1000 /*EQNB Minimum Low Pass Corner frequency*/ +#define LVM_EQNB_MIN_HPF_FREQ 20 /*EQNB Minimum High Pass Corner frequency*/ +#define LVM_EQNB_MAX_HPF_FREQ 1000 /*EQNB Maximum High Pass Corner frequency*/ + +#define LVM_CS_MIN_EFFECT_LEVEL 0 /*CS Minimum Effect Level*/ +#define LVM_CS_MAX_REVERB_LEVEL 100 /*CS Maximum Reverb Level*/ +#define LVM_VIRTUALIZER_MAX_REVERB_LEVEL 100 /*Vitrualizer Maximum Reverb Level*/ + +#define LVM_VC_MIXER_TIME 100 /*VC mixer time*/ +#define LVM_VC_BALANCE_MAX 96 /*VC balance max value*/ +#define LVM_VC_BALANCE_MIN -96 /*VC balance min value*/ + +/* Algorithm masks */ +#define LVM_CS_MASK 1 +#define LVM_EQNB_MASK 2 +#define LVM_DBE_MASK 4 +#define LVM_VC_MASK 16 +#define LVM_TE_MASK 32 +#define LVM_PSA_MASK 2048 + + +/************************************************************************************/ +/* */ +/* Structures */ +/* */ +/************************************************************************************/ + +/* Memory region definition */ +typedef struct +{ + LVM_UINT32 Size; /* Region size in bytes */ + LVM_UINT16 Alignment; /* Byte alignment */ + LVM_MemoryTypes_en Type; /* Region type */ + void *pBaseAddress; /* Pointer to the region base address */ +} LVM_IntMemoryRegion_t; + + +/* Memory table containing the region definitions */ +typedef struct +{ + LVM_IntMemoryRegion_t Region[LVM_NR_MEMORY_REGIONS]; /* One definition for each region */ +} LVM_IntMemTab_t; + + +/* Buffer Management */ +typedef struct +{ + LVM_INT16 *pScratch; /* Bundle scratch buffer */ + + LVM_INT16 BufferState; /* Buffer status */ + LVM_INT16 InDelayBuffer[6*MIN_INTERNAL_BLOCKSIZE]; /* Input buffer delay line, left and right */ + LVM_INT16 InDelaySamples; /* Number of samples in the input delay buffer */ + + LVM_INT16 OutDelayBuffer[2*MIN_INTERNAL_BLOCKSIZE]; /* Output buffer delay line */ + LVM_INT16 OutDelaySamples; /* Number of samples in the output delay buffer, left and right */ + LVM_INT16 SamplesToOutput; /* Samples to write to the output */ +} LVM_Buffer_t; + + +/* Filter taps */ +typedef struct +{ + Biquad_2I_Order1_Taps_t TrebleBoost_Taps; /* Treble boost Taps */ +} LVM_TE_Data_t; + + +/* Coefficients */ +typedef struct +{ + Biquad_Instance_t TrebleBoost_State; /* State for the treble boost filter */ +} LVM_TE_Coefs_t; + + +typedef struct +{ + /* Public parameters */ + LVM_MemTab_t MemoryTable; /* Instance memory allocation table */ + LVM_ControlParams_t Params; /* Control parameters */ + LVM_InstParams_t InstParams; /* Instance parameters */ + + /* Private parameters */ + LVM_UINT16 ControlPending; /* Control flag to indicate update pending */ + LVM_ControlParams_t NewParams; /* New control parameters pending update */ + + /* Buffer control */ + LVM_INT16 InternalBlockSize; /* Maximum internal block size */ + LVM_Buffer_t *pBufferManagement; /* Buffer management variables */ + LVM_INT16 SamplesToProcess; /* Input samples left to process */ + LVM_INT16 *pInputSamples; /* External input sample pointer */ + LVM_INT16 *pOutputSamples; /* External output sample pointer */ + + /* Configuration number */ + LVM_INT32 ConfigurationNumber; + LVM_INT32 BlickSizeMultiple; + + /* DC removal */ + Biquad_Instance_t DC_RemovalInstance; /* DC removal filter instance */ + + /* Concert Sound */ + LVCS_Handle_t hCSInstance; /* Concert Sound instance handle */ + LVCS_Instance_t CS_Instance; /* Concert Sound instance */ + LVM_INT16 CS_Active; /* Control flag */ + + /* Equalizer */ + LVEQNB_Handle_t hEQNBInstance; /* N-Band Equaliser instance handle */ + LVEQNB_Instance_t EQNB_Instance; /* N-Band Equaliser instance */ + LVM_EQNB_BandDef_t *pEQNB_BandDefs; /* Local storage for new definitions */ + LVM_EQNB_BandDef_t *pEQNB_UserDefs; /* Local storage for the user's definitions */ + LVM_INT16 EQNB_Active; /* Control flag */ + + /* Dynamic Bass Enhancement */ + LVDBE_Handle_t hDBEInstance; /* Dynamic Bass Enhancement instance handle */ + LVDBE_Instance_t DBE_Instance; /* Dynamic Bass Enhancement instance */ + LVM_INT16 DBE_Active; /* Control flag */ + + /* Volume Control */ + LVMixer3_1St_st VC_Volume; /* Volume scaler */ + LVMixer3_2St_st VC_BalanceMix; /* VC balance mixer */ + LVM_INT16 VC_VolumedB; /* Gain in dB */ + LVM_INT16 VC_Active; /* Control flag */ + LVM_INT16 VC_AVLFixedVolume; /* AVL fixed volume */ + + /* Treble Enhancement */ + LVM_TE_Data_t *pTE_Taps; /* Treble boost Taps */ + LVM_TE_Coefs_t *pTE_State; /* State for the treble boost filter */ + LVM_INT16 TE_Active; /* Control flag */ + + /* Headroom */ + LVM_HeadroomParams_t NewHeadroomParams; /* New headroom parameters pending update */ + LVM_HeadroomParams_t HeadroomParams; /* Headroom parameters */ + LVM_HeadroomBandDef_t *pHeadroom_BandDefs; /* Local storage for new definitions */ + LVM_HeadroomBandDef_t *pHeadroom_UserDefs; /* Local storage for the user's definitions */ + LVM_UINT16 Headroom; /* Value of the current headroom */ + + /* Spectrum Analyzer */ + pLVPSA_Handle_t hPSAInstance; /* Spectrum Analyzer instance handle */ + LVPSA_InstancePr_t PSA_Instance; /* Spectrum Analyzer instance */ + LVPSA_InitParams_t PSA_InitParams; /* Spectrum Analyzer initialization parameters */ + LVPSA_ControlParams_t PSA_ControlParams; /* Spectrum Analyzer control parameters */ + LVM_INT16 PSA_GainOffset; /* Tone control flag */ + LVM_Callback CallBack; + LVM_INT16 *pPSAInput; /* PSA input pointer */ + + LVM_INT16 NoSmoothVolume; /* Enable or disable smooth volume changes*/ + +} LVM_Instance_t; + + +/************************************************************************************/ +/* */ +/* Function Prototypes */ +/* */ +/************************************************************************************/ + +LVM_ReturnStatus_en LVM_ApplyNewSettings(LVM_Handle_t hInstance); + +void LVM_SetTrebleBoost( LVM_Instance_t *pInstance, + LVM_ControlParams_t *pParams); + +void LVM_SetVolume( LVM_Instance_t *pInstance, + LVM_ControlParams_t *pParams); + +LVM_INT32 LVM_VCCallBack(void* pBundleHandle, + void* pGeneralPurpose, + short CallBackParam); + +void LVM_SetHeadroom( LVM_Instance_t *pInstance, + LVM_ControlParams_t *pParams); + +void LVM_BufferIn( LVM_Handle_t hInstance, + const LVM_INT16 *pInData, + LVM_INT16 **pToProcess, + LVM_INT16 **pProcessed, + LVM_UINT16 *pNumSamples); + +void LVM_BufferOut( LVM_Handle_t hInstance, + LVM_INT16 *pOutData, + LVM_UINT16 *pNumSamples); + +LVM_INT32 LVM_AlgoCallBack( void *pBundleHandle, + void *pData, + LVM_INT16 callbackId); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __LVM_PRIVATE_H__ */ + diff --git a/media/libeffects/lvm/lib/Bundle/src/LVM_Process.c b/media/libeffects/lvm/lib/Bundle/src/LVM_Process.c new file mode 100755 index 0000000..bad9450 --- /dev/null +++ b/media/libeffects/lvm/lib/Bundle/src/LVM_Process.c @@ -0,0 +1,283 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/**************************************************************************************** + + $Author: beq07716 $ + $Revision: 1002 $ + $Date: 2010-06-28 13:40:09 +0200 (Mon, 28 Jun 2010) $ + +*****************************************************************************************/ + + +/****************************************************************************************/ +/* */ +/* Includes */ +/* */ +/****************************************************************************************/ + +#include "LVM_Private.h" +#include "VectorArithmetic.h" +#include "LVM_Coeffs.h" + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVM_Process */ +/* */ +/* DESCRIPTION: */ +/* Process function for the LifeVibes module. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance handle */ +/* pInData Pointer to the input data */ +/* pOutData Pointer to the output data */ +/* NumSamples Number of samples in the input buffer */ +/* AudioTime Audio Time of the current input buffer in ms */ +/* */ +/* RETURNS: */ +/* LVM_SUCCESS Succeeded */ +/* LVM_INVALIDNUMSAMPLES When the NumSamples is not a valied multiple in unmanaged */ +/* buffer mode */ +/* LVM_ALIGNMENTERROR When either the input our output buffers are not 32-bit */ +/* aligned in unmanaged mode */ +/* LVM_NULLADDRESS When one of hInstance, pInData or pOutData is NULL */ +/* */ +/* NOTES: */ +/* */ +/****************************************************************************************/ + +LVM_ReturnStatus_en LVM_Process(LVM_Handle_t hInstance, + const LVM_INT16 *pInData, + LVM_INT16 *pOutData, + LVM_UINT16 NumSamples, + LVM_UINT32 AudioTime) +{ + + LVM_Instance_t *pInstance = (LVM_Instance_t *)hInstance; + LVM_UINT16 SampleCount = NumSamples; + LVM_INT16 *pInput = (LVM_INT16 *)pInData; + LVM_INT16 *pToProcess = (LVM_INT16 *)pInData; + LVM_INT16 *pProcessed = pOutData; + LVM_ReturnStatus_en Status; + + /* + * Check if the number of samples is zero + */ + if (NumSamples == 0) + { + return(LVM_SUCCESS); + } + + + /* + * Check valid points have been given + */ + if ((hInstance == LVM_NULL) || (pInData == LVM_NULL) || (pOutData == LVM_NULL)) + { + return (LVM_NULLADDRESS); + } + + /* + * For unmanaged mode only + */ + if(pInstance->InstParams.BufferMode == LVM_UNMANAGED_BUFFERS) + { + /* + * Check if the number of samples is a good multiple (unmanaged mode only) + */ + if((NumSamples % pInstance->BlickSizeMultiple) != 0) + { + return(LVM_INVALIDNUMSAMPLES); + } + + /* + * Check the buffer alignment + */ + if((((LVM_UINT32)pInData % 4) != 0) || (((LVM_UINT32)pOutData % 4) != 0)) + { + return(LVM_ALIGNMENTERROR); + } + } + + + /* + * Update new parameters if necessary + */ + if (pInstance->ControlPending == LVM_TRUE) + { + Status = LVM_ApplyNewSettings(hInstance); + + if(Status != LVM_SUCCESS) + { + return Status; + } + } + + + /* + * Convert from Mono if necessary + */ + if (pInstance->Params.SourceFormat == LVM_MONO) + { + MonoTo2I_16(pInData, /* Source */ + pOutData, /* Destination */ + (LVM_INT16)NumSamples); /* Number of input samples */ + pInput = pOutData; + pToProcess = pOutData; + } + + + /* + * Process the data with managed buffers + */ + while (SampleCount != 0) + { + /* + * Manage the input buffer and frame processing + */ + LVM_BufferIn(hInstance, + pInput, + &pToProcess, + &pProcessed, + &SampleCount); + + /* + * Only process data when SampleCount is none zero, a zero count can occur when + * the BufferIn routine is working in managed mode. + */ + if (SampleCount != 0) + { + + /* + * Apply ConcertSound if required + */ + if (pInstance->CS_Active == LVM_TRUE) + { + (void)LVCS_Process(pInstance->hCSInstance, /* Concert Sound instance handle */ + pToProcess, + pProcessed, + SampleCount); + pToProcess = pProcessed; + } + + /* + * Apply volume if required + */ + if (pInstance->VC_Active!=0) + { + LVC_MixSoft_1St_D16C31_SAT(&pInstance->VC_Volume, + pToProcess, + pProcessed, + (LVM_INT16)(2*SampleCount)); /* Left and right*/ + pToProcess = pProcessed; + } + + /* + * Call N-Band equaliser if enabled + */ + if (pInstance->EQNB_Active == LVM_TRUE) + { + LVEQNB_Process(pInstance->hEQNBInstance, /* N-Band equaliser instance handle */ + pToProcess, + pProcessed, + SampleCount); + pToProcess = pProcessed; + } + + /* + * Call bass enhancement if enabled + */ + if (pInstance->DBE_Active == LVM_TRUE) + { + LVDBE_Process(pInstance->hDBEInstance, /* Dynamic Bass Enhancement instance handle */ + pToProcess, + pProcessed, + SampleCount); + pToProcess = pProcessed; + } + + /* + * Bypass mode or everything off, so copy the input to the output + */ + if (pToProcess != pProcessed) + { + Copy_16(pToProcess, /* Source */ + pProcessed, /* Destination */ + (LVM_INT16)(2*SampleCount)); /* Left and right */ + } + + /* + * Apply treble boost if required + */ + if (pInstance->TE_Active == LVM_TRUE) + { + /* + * Apply the filter + */ + FO_2I_D16F32C15_LShx_TRC_WRA_01(&pInstance->pTE_State->TrebleBoost_State, + pProcessed, + pProcessed, + (LVM_INT16)SampleCount); + + } + + /* + * Volume balance + */ + LVC_MixSoft_1St_2i_D16C31_SAT(&pInstance->VC_BalanceMix, + pProcessed, + pProcessed, + SampleCount); + + /* + * Perform Parametric Spectum Analysis + */ + if ((pInstance->Params.PSA_Enable == LVM_PSA_ON)&&(pInstance->InstParams.PSA_Included==LVM_PSA_ON)) + { + From2iToMono_16(pProcessed, + pInstance->pPSAInput, + (LVM_INT16) (SampleCount)); + + LVPSA_Process(pInstance->hPSAInstance, + pInstance->pPSAInput, + (LVM_UINT16) (SampleCount), + AudioTime); + } + + + /* + * DC removal + */ + DC_2I_D16_TRC_WRA_01(&pInstance->DC_RemovalInstance, + pProcessed, + pProcessed, + (LVM_INT16)SampleCount); + + + } + + /* + * Manage the output buffer + */ + LVM_BufferOut(hInstance, + pOutData, + &SampleCount); + + } + + return(LVM_SUCCESS); +} diff --git a/media/libeffects/lvm/lib/Bundle/src/LVM_Tables.c b/media/libeffects/lvm/lib/Bundle/src/LVM_Tables.c new file mode 100755 index 0000000..cb33541 --- /dev/null +++ b/media/libeffects/lvm/lib/Bundle/src/LVM_Tables.c @@ -0,0 +1,397 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************************ + + $Author: beq07716 $ + $Revision: 1002 $ + $Date: 2010-06-28 13:40:09 +0200 (Mon, 28 Jun 2010) $ + +*************************************************************************************/ + +/************************************************************************************/ +/* */ +/* Includes */ +/* */ +/************************************************************************************/ + +#include "LVM_Tables.h" +#include "LVM_Coeffs.h" + +/************************************************************************************/ +/* */ +/* Treble Boost Filter Coefficients */ +/* */ +/************************************************************************************/ + +FO_C16_LShx_Coefs_t LVM_TrebleBoostCoefs[] = { + + /* 22kHz sampling rate */ + {HPF_Fs22050_Gain1_A1, /* Gain setting 1 */ + HPF_Fs22050_Gain1_A0, + -HPF_Fs22050_Gain1_B1, + HPF_Fs22050_Gain1_Shift}, + {HPF_Fs22050_Gain2_A1, /* Gain setting 2 */ + HPF_Fs22050_Gain2_A0, + -HPF_Fs22050_Gain2_B1, + HPF_Fs22050_Gain2_Shift}, + {HPF_Fs22050_Gain3_A1, /* Gain setting 3 */ + HPF_Fs22050_Gain3_A0, + -HPF_Fs22050_Gain3_B1, + HPF_Fs22050_Gain3_Shift}, + {HPF_Fs22050_Gain4_A1, /* Gain setting 4 */ + HPF_Fs22050_Gain4_A0, + -HPF_Fs22050_Gain4_B1, + HPF_Fs22050_Gain4_Shift}, + {HPF_Fs22050_Gain5_A1, /* Gain setting 5 */ + HPF_Fs22050_Gain5_A0, + -HPF_Fs22050_Gain5_B1, + HPF_Fs22050_Gain5_Shift}, + {HPF_Fs22050_Gain6_A1, /* Gain setting 6 */ + HPF_Fs22050_Gain6_A0, + -HPF_Fs22050_Gain6_B1, + HPF_Fs22050_Gain6_Shift}, + {HPF_Fs22050_Gain7_A1, /* Gain setting 7 */ + HPF_Fs22050_Gain7_A0, + -HPF_Fs22050_Gain7_B1, + HPF_Fs22050_Gain7_Shift}, + {HPF_Fs22050_Gain8_A1, /* Gain setting 8 */ + HPF_Fs22050_Gain8_A0, + -HPF_Fs22050_Gain8_B1, + HPF_Fs22050_Gain8_Shift}, + {HPF_Fs22050_Gain9_A1, /* Gain setting 9 */ + HPF_Fs22050_Gain9_A0, + -HPF_Fs22050_Gain9_B1, + HPF_Fs22050_Gain9_Shift}, + {HPF_Fs22050_Gain10_A1, /* Gain setting 10 */ + HPF_Fs22050_Gain10_A0, + -HPF_Fs22050_Gain10_B1, + HPF_Fs22050_Gain10_Shift}, + {HPF_Fs22050_Gain11_A1, /* Gain setting 11 */ + HPF_Fs22050_Gain11_A0, + -HPF_Fs22050_Gain11_B1, + HPF_Fs22050_Gain11_Shift}, + {HPF_Fs22050_Gain12_A1, /* Gain setting 12 */ + HPF_Fs22050_Gain12_A0, + -HPF_Fs22050_Gain12_B1, + HPF_Fs22050_Gain12_Shift}, + {HPF_Fs22050_Gain13_A1, /* Gain setting 13 */ + HPF_Fs22050_Gain13_A0, + -HPF_Fs22050_Gain13_B1, + HPF_Fs22050_Gain13_Shift}, + {HPF_Fs22050_Gain14_A1, /* Gain setting 14 */ + HPF_Fs22050_Gain14_A0, + -HPF_Fs22050_Gain14_B1, + HPF_Fs22050_Gain14_Shift}, + {HPF_Fs22050_Gain15_A1, /* Gain setting 15 */ + HPF_Fs22050_Gain15_A0, + -HPF_Fs22050_Gain15_B1, + HPF_Fs22050_Gain15_Shift}, + + /* 24kHz sampling rate */ + {HPF_Fs24000_Gain1_A1, /* Gain setting 1 */ + HPF_Fs24000_Gain1_A0, + -HPF_Fs24000_Gain1_B1, + HPF_Fs24000_Gain1_Shift}, + {HPF_Fs24000_Gain2_A1, /* Gain setting 2 */ + HPF_Fs24000_Gain2_A0, + -HPF_Fs24000_Gain2_B1, + HPF_Fs24000_Gain2_Shift}, + {HPF_Fs24000_Gain3_A1, /* Gain setting 3 */ + HPF_Fs24000_Gain3_A0, + -HPF_Fs24000_Gain3_B1, + HPF_Fs24000_Gain3_Shift}, + {HPF_Fs24000_Gain4_A1, /* Gain setting 4 */ + HPF_Fs24000_Gain4_A0, + -HPF_Fs24000_Gain4_B1, + HPF_Fs24000_Gain4_Shift}, + {HPF_Fs24000_Gain5_A1, /* Gain setting 5 */ + HPF_Fs24000_Gain5_A0, + -HPF_Fs24000_Gain5_B1, + HPF_Fs24000_Gain5_Shift}, + {HPF_Fs24000_Gain6_A1, /* Gain setting 6 */ + HPF_Fs24000_Gain6_A0, + -HPF_Fs24000_Gain6_B1, + HPF_Fs24000_Gain6_Shift}, + {HPF_Fs24000_Gain7_A1, /* Gain setting 7 */ + HPF_Fs24000_Gain7_A0, + -HPF_Fs24000_Gain7_B1, + HPF_Fs24000_Gain7_Shift}, + {HPF_Fs24000_Gain8_A1, /* Gain setting 8 */ + HPF_Fs24000_Gain8_A0, + -HPF_Fs24000_Gain8_B1, + HPF_Fs24000_Gain8_Shift}, + {HPF_Fs24000_Gain9_A1, /* Gain setting 9 */ + HPF_Fs24000_Gain9_A0, + -HPF_Fs24000_Gain9_B1, + HPF_Fs24000_Gain9_Shift}, + {HPF_Fs24000_Gain10_A1, /* Gain setting 10 */ + HPF_Fs24000_Gain10_A0, + -HPF_Fs24000_Gain10_B1, + HPF_Fs24000_Gain10_Shift}, + {HPF_Fs24000_Gain11_A1, /* Gain setting 11 */ + HPF_Fs24000_Gain11_A0, + -HPF_Fs24000_Gain11_B1, + HPF_Fs24000_Gain11_Shift}, + {HPF_Fs24000_Gain12_A1, /* Gain setting 12 */ + HPF_Fs24000_Gain12_A0, + -HPF_Fs24000_Gain12_B1, + HPF_Fs24000_Gain12_Shift}, + {HPF_Fs24000_Gain13_A1, /* Gain setting 13 */ + HPF_Fs24000_Gain13_A0, + -HPF_Fs24000_Gain13_B1, + HPF_Fs24000_Gain13_Shift}, + {HPF_Fs24000_Gain14_A1, /* Gain setting 14 */ + HPF_Fs24000_Gain14_A0, + -HPF_Fs24000_Gain14_B1, + HPF_Fs24000_Gain14_Shift}, + {HPF_Fs24000_Gain15_A1, /* Gain setting 15 */ + HPF_Fs24000_Gain15_A0, + -HPF_Fs24000_Gain15_B1, + HPF_Fs24000_Gain15_Shift}, + + /* 32kHz sampling rate */ + {HPF_Fs32000_Gain1_A1, /* Gain setting 1 */ + HPF_Fs32000_Gain1_A0, + -HPF_Fs32000_Gain1_B1, + HPF_Fs32000_Gain1_Shift}, + {HPF_Fs32000_Gain2_A1, /* Gain setting 2 */ + HPF_Fs32000_Gain2_A0, + -HPF_Fs32000_Gain2_B1, + HPF_Fs32000_Gain2_Shift}, + {HPF_Fs32000_Gain3_A1, /* Gain setting 3 */ + HPF_Fs32000_Gain3_A0, + -HPF_Fs32000_Gain3_B1, + HPF_Fs32000_Gain3_Shift}, + {HPF_Fs32000_Gain4_A1, /* Gain setting 4 */ + HPF_Fs32000_Gain4_A0, + -HPF_Fs32000_Gain4_B1, + HPF_Fs32000_Gain4_Shift}, + {HPF_Fs32000_Gain5_A1, /* Gain setting 5 */ + HPF_Fs32000_Gain5_A0, + -HPF_Fs32000_Gain5_B1, + HPF_Fs32000_Gain5_Shift}, + {HPF_Fs32000_Gain6_A1, /* Gain setting 6 */ + HPF_Fs32000_Gain6_A0, + -HPF_Fs32000_Gain6_B1, + HPF_Fs32000_Gain6_Shift}, + {HPF_Fs32000_Gain7_A1, /* Gain setting 7 */ + HPF_Fs32000_Gain7_A0, + -HPF_Fs32000_Gain7_B1, + HPF_Fs32000_Gain7_Shift}, + {HPF_Fs32000_Gain8_A1, /* Gain setting 8 */ + HPF_Fs32000_Gain8_A0, + -HPF_Fs32000_Gain8_B1, + HPF_Fs32000_Gain8_Shift}, + {HPF_Fs32000_Gain9_A1, /* Gain setting 9 */ + HPF_Fs32000_Gain9_A0, + -HPF_Fs32000_Gain9_B1, + HPF_Fs32000_Gain9_Shift}, + {HPF_Fs32000_Gain10_A1, /* Gain setting 10 */ + HPF_Fs32000_Gain10_A0, + -HPF_Fs32000_Gain10_B1, + HPF_Fs32000_Gain10_Shift}, + {HPF_Fs32000_Gain11_A1, /* Gain setting 11 */ + HPF_Fs32000_Gain11_A0, + -HPF_Fs32000_Gain11_B1, + HPF_Fs32000_Gain11_Shift}, + {HPF_Fs32000_Gain12_A1, /* Gain setting 12 */ + HPF_Fs32000_Gain12_A0, + -HPF_Fs32000_Gain12_B1, + HPF_Fs32000_Gain12_Shift}, + {HPF_Fs32000_Gain13_A1, /* Gain setting 13 */ + HPF_Fs32000_Gain13_A0, + -HPF_Fs32000_Gain13_B1, + HPF_Fs32000_Gain13_Shift}, + {HPF_Fs32000_Gain14_A1, /* Gain setting 14 */ + HPF_Fs32000_Gain14_A0, + -HPF_Fs32000_Gain14_B1, + HPF_Fs32000_Gain14_Shift}, + {HPF_Fs32000_Gain15_A1, /* Gain setting 15 */ + HPF_Fs32000_Gain15_A0, + -HPF_Fs32000_Gain15_B1, + HPF_Fs32000_Gain15_Shift}, + + /* 44kHz sampling rate */ + {HPF_Fs44100_Gain1_A1, /* Gain setting 1 */ + HPF_Fs44100_Gain1_A0, + -HPF_Fs44100_Gain1_B1, + HPF_Fs44100_Gain1_Shift}, + {HPF_Fs44100_Gain2_A1, /* Gain setting 2 */ + HPF_Fs44100_Gain2_A0, + -HPF_Fs44100_Gain2_B1, + HPF_Fs44100_Gain2_Shift}, + {HPF_Fs44100_Gain3_A1, /* Gain setting 3 */ + HPF_Fs44100_Gain3_A0, + -HPF_Fs44100_Gain3_B1, + HPF_Fs44100_Gain3_Shift}, + {HPF_Fs44100_Gain4_A1, /* Gain setting 4 */ + HPF_Fs44100_Gain4_A0, + -HPF_Fs44100_Gain4_B1, + HPF_Fs44100_Gain4_Shift}, + {HPF_Fs44100_Gain5_A1, /* Gain setting 5 */ + HPF_Fs44100_Gain5_A0, + -HPF_Fs44100_Gain5_B1, + HPF_Fs44100_Gain5_Shift}, + {HPF_Fs44100_Gain6_A1, /* Gain setting 6 */ + HPF_Fs44100_Gain6_A0, + -HPF_Fs44100_Gain6_B1, + HPF_Fs44100_Gain6_Shift}, + {HPF_Fs44100_Gain7_A1, /* Gain setting 7 */ + HPF_Fs44100_Gain7_A0, + -HPF_Fs44100_Gain7_B1, + HPF_Fs44100_Gain7_Shift}, + {HPF_Fs44100_Gain8_A1, /* Gain setting 8 */ + HPF_Fs44100_Gain8_A0, + -HPF_Fs44100_Gain8_B1, + HPF_Fs44100_Gain8_Shift}, + {HPF_Fs44100_Gain9_A1, /* Gain setting 9 */ + HPF_Fs44100_Gain9_A0, + -HPF_Fs44100_Gain9_B1, + HPF_Fs44100_Gain9_Shift}, + {HPF_Fs44100_Gain10_A1, /* Gain setting 10 */ + HPF_Fs44100_Gain10_A0, + -HPF_Fs44100_Gain10_B1, + HPF_Fs44100_Gain10_Shift}, + {HPF_Fs44100_Gain11_A1, /* Gain setting 11 */ + HPF_Fs44100_Gain11_A0, + -HPF_Fs44100_Gain11_B1, + HPF_Fs44100_Gain11_Shift}, + {HPF_Fs44100_Gain12_A1, /* Gain setting 12 */ + HPF_Fs44100_Gain12_A0, + -HPF_Fs44100_Gain12_B1, + HPF_Fs44100_Gain12_Shift}, + {HPF_Fs44100_Gain13_A1, /* Gain setting 13 */ + HPF_Fs44100_Gain13_A0, + -HPF_Fs44100_Gain13_B1, + HPF_Fs44100_Gain13_Shift}, + {HPF_Fs44100_Gain14_A1, /* Gain setting 14 */ + HPF_Fs44100_Gain14_A0, + -HPF_Fs44100_Gain14_B1, + HPF_Fs44100_Gain14_Shift}, + {HPF_Fs44100_Gain15_A1, /* Gain setting 15 */ + HPF_Fs44100_Gain15_A0, + -HPF_Fs44100_Gain15_B1, + HPF_Fs44100_Gain15_Shift}, + + /* 48kHz sampling rate */ + {HPF_Fs48000_Gain1_A1, /* Gain setting 1 */ + HPF_Fs48000_Gain1_A0, + -HPF_Fs48000_Gain1_B1, + HPF_Fs48000_Gain1_Shift}, + {HPF_Fs48000_Gain2_A1, /* Gain setting 2 */ + HPF_Fs48000_Gain2_A0, + -HPF_Fs48000_Gain2_B1, + HPF_Fs48000_Gain2_Shift}, + {HPF_Fs48000_Gain3_A1, /* Gain setting 3 */ + HPF_Fs48000_Gain3_A0, + -HPF_Fs48000_Gain3_B1, + HPF_Fs48000_Gain3_Shift}, + {HPF_Fs48000_Gain4_A1, /* Gain setting 4 */ + HPF_Fs48000_Gain4_A0, + -HPF_Fs48000_Gain4_B1, + HPF_Fs48000_Gain4_Shift}, + {HPF_Fs48000_Gain5_A1, /* Gain setting 5 */ + HPF_Fs48000_Gain5_A0, + -HPF_Fs48000_Gain5_B1, + HPF_Fs48000_Gain5_Shift}, + {HPF_Fs48000_Gain6_A1, /* Gain setting 6 */ + HPF_Fs48000_Gain6_A0, + -HPF_Fs48000_Gain6_B1, + HPF_Fs48000_Gain6_Shift}, + {HPF_Fs48000_Gain7_A1, /* Gain setting 7 */ + HPF_Fs48000_Gain7_A0, + -HPF_Fs48000_Gain7_B1, + HPF_Fs48000_Gain7_Shift}, + {HPF_Fs48000_Gain8_A1, /* Gain setting 8 */ + HPF_Fs48000_Gain8_A0, + -HPF_Fs48000_Gain8_B1, + HPF_Fs48000_Gain8_Shift}, + {HPF_Fs48000_Gain9_A1, /* Gain setting 9 */ + HPF_Fs48000_Gain9_A0, + -HPF_Fs48000_Gain9_B1, + HPF_Fs48000_Gain9_Shift}, + {HPF_Fs48000_Gain10_A1, /* Gain setting 10 */ + HPF_Fs48000_Gain10_A0, + -HPF_Fs48000_Gain10_B1, + HPF_Fs48000_Gain10_Shift}, + {HPF_Fs48000_Gain11_A1, /* Gain setting 11 */ + HPF_Fs48000_Gain11_A0, + -HPF_Fs48000_Gain11_B1, + HPF_Fs48000_Gain11_Shift}, + {HPF_Fs48000_Gain12_A1, /* Gain setting 12 */ + HPF_Fs48000_Gain12_A0, + -HPF_Fs48000_Gain12_B1, + HPF_Fs48000_Gain12_Shift}, + {HPF_Fs48000_Gain13_A1, /* Gain setting 13 */ + HPF_Fs48000_Gain13_A0, + -HPF_Fs48000_Gain13_B1, + HPF_Fs48000_Gain13_Shift}, + {HPF_Fs48000_Gain14_A1, /* Gain setting 14 */ + HPF_Fs48000_Gain14_A0, + -HPF_Fs48000_Gain14_B1, + HPF_Fs48000_Gain14_Shift}, + {HPF_Fs48000_Gain15_A1, /* Gain setting 15 */ + HPF_Fs48000_Gain15_A0, + -HPF_Fs48000_Gain15_B1, + HPF_Fs48000_Gain15_Shift}}; + + +/************************************************************************************/ +/* */ +/* Volume control gain and time constant tables */ +/* */ +/************************************************************************************/ + +/* dB to linear conversion table */ +const LVM_INT16 LVM_VolumeTable[] = { + 0x7FFF, /* 0dB */ + 0x7215, /* -1dB */ + 0x65AD, /* -2dB */ + 0x5A9E, /* -3dB */ + 0x50C3, /* -4dB */ + 0x47FB, /* -5dB */ + 0x4000}; /* -6dB */ + +/************************************************************************************/ +/* */ +/* Volume mixer time constants (100ms) */ +/* */ +/************************************************************************************/ + +#define LVM_MIX_TC_Fs8000 32580 /* Floating point value 0.994262695 */ +#define LVM_MIX_TC_Fs11025 32632 /* Floating point value 0.995849609 */ +#define LVM_MIX_TC_Fs12000 32643 /* Floating point value 0.996185303 */ +#define LVM_MIX_TC_Fs16000 32674 /* Floating point value 0.997131348 */ +#define LVM_MIX_TC_Fs22050 32700 /* Floating point value 0.997924805 */ +#define LVM_MIX_TC_Fs24000 32705 /* Floating point value 0.998077393 */ +#define LVM_MIX_TC_Fs32000 32721 /* Floating point value 0.998565674 */ +#define LVM_MIX_TC_Fs44100 32734 /* Floating point value 0.998962402 */ +#define LVM_MIX_TC_Fs48000 32737 /* Floating point value 0.999053955 */ + + +const LVM_INT16 LVM_MixerTCTable[] = { + LVM_MIX_TC_Fs8000, + LVM_MIX_TC_Fs11025, + LVM_MIX_TC_Fs12000, + LVM_MIX_TC_Fs16000, + LVM_MIX_TC_Fs22050, + LVM_MIX_TC_Fs24000, + LVM_MIX_TC_Fs32000, + LVM_MIX_TC_Fs44100, + LVM_MIX_TC_Fs48000}; + diff --git a/media/libeffects/lvm/lib/Bundle/src/LVM_Tables.h b/media/libeffects/lvm/lib/Bundle/src/LVM_Tables.h new file mode 100755 index 0000000..574f641 --- /dev/null +++ b/media/libeffects/lvm/lib/Bundle/src/LVM_Tables.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************************ + + $Author: beq07716 $ + $Revision: 1002 $ + $Date: 2010-06-28 13:40:09 +0200 (Mon, 28 Jun 2010) $ + +*************************************************************************************/ + +#ifndef __LVM_TABLES_H__ +#define __LVM_TABLES_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/************************************************************************************/ +/* */ +/* Includes */ +/* */ +/************************************************************************************/ + +#include "BIQUAD.h" +#include "LVM_Types.h" + +/************************************************************************************/ +/* */ +/* Treble Boost Filter Coefficients */ +/* */ +/************************************************************************************/ + +extern FO_C16_LShx_Coefs_t LVM_TrebleBoostCoefs[]; + + +/************************************************************************************/ +/* */ +/* Volume control gain and time constant tables */ +/* */ +/************************************************************************************/ + +extern const LVM_INT16 LVM_VolumeTable[]; +extern const LVM_INT16 LVM_MixerTCTable[]; + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __LVM_TABLES_H__ */ + + diff --git a/media/libeffects/lvm/lib/Common/lib/AGC.h b/media/libeffects/lvm/lib/Common/lib/AGC.h new file mode 100755 index 0000000..980a8e3 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/lib/AGC.h @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************************** + + $Author: beq07716 $ + $Revision: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +#ifndef __AGC_H__ +#define __AGC_H__ + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/**********************************************************************************/ +/* */ +/* Includes */ +/* */ +/**********************************************************************************/ + +#include "LVM_Types.h" + + +/**********************************************************************************/ +/* */ +/* Types */ +/* */ +/**********************************************************************************/ + +typedef struct +{ + LVM_INT32 AGC_Gain; /* The current AGC gain */ + LVM_INT32 AGC_MaxGain; /* The maximum AGC gain */ + LVM_INT32 Volume; /* The current volume setting */ + LVM_INT32 Target; /* The target volume setting */ + LVM_INT32 AGC_Target; /* AGC target level */ + LVM_INT16 AGC_Attack; /* AGC attack scaler */ + LVM_INT16 AGC_Decay; /* AGC decay scaler */ + LVM_INT16 AGC_GainShift; /* The gain shift */ + LVM_INT16 VolumeShift; /* Volume shift scaling */ + LVM_INT16 VolumeTC; /* Volume update time constant */ + +} AGC_MIX_VOL_2St1Mon_D32_t; + + +/**********************************************************************************/ +/* */ +/* Function Prototypes */ +/* */ +/**********************************************************************************/ + +void AGC_MIX_VOL_2St1Mon_D32_WRA(AGC_MIX_VOL_2St1Mon_D32_t *pInstance, /* Instance pointer */ + const LVM_INT32 *pStSrc, /* Stereo source */ + const LVM_INT32 *pMonoSrc, /* Mono source */ + LVM_INT32 *pDst, /* Stereo destination */ + LVM_UINT16 n); /* Number of samples */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* __AGC_H__ */ + + + + + + + + + + diff --git a/media/libeffects/lvm/lib/Common/lib/BIQUAD.h b/media/libeffects/lvm/lib/Common/lib/BIQUAD.h new file mode 100755 index 0000000..08e5a6f --- /dev/null +++ b/media/libeffects/lvm/lib/Common/lib/BIQUAD.h @@ -0,0 +1,341 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************************** + + $Author: beq07716 $ + $Revision: 722 $ + $Date: 2010-06-10 15:12:34 +0200 (Thu, 10 Jun 2010) $ + +***********************************************************************************/ + +#ifndef _BIQUAD_H_ +#define _BIQUAD_H_ + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "LVM_Types.h" +/********************************************************************************** + INSTANCE MEMORY TYPE DEFINITION +***********************************************************************************/ + +typedef struct +{ + LVM_INT32 Storage[6]; + +} Biquad_Instance_t; + + +/********************************************************************************** + COEFFICIENT TYPE DEFINITIONS +***********************************************************************************/ + +/*** Biquad coefficients **********************************************************/ +typedef struct +{ + LVM_INT16 A2; /* a2 */ + LVM_INT16 A1; /* a1 */ + LVM_INT16 A0; /* a0 */ + LVM_INT16 B2; /* -b2! */ + LVM_INT16 B1; /* -b1! */ +} BQ_C16_Coefs_t; + +typedef struct +{ + LVM_INT32 A2; /* a2 */ + LVM_INT32 A1; /* a1 */ + LVM_INT32 A0; /* a0 */ + LVM_INT32 B2; /* -b2! */ + LVM_INT32 B1; /* -b1! */ +} BQ_C32_Coefs_t; + +/*** First order coefficients *****************************************************/ +typedef struct +{ + LVM_INT16 A1; /* a1 */ + LVM_INT16 A0; /* a0 */ + LVM_INT16 B1; /* -b1! */ +} FO_C16_Coefs_t; + +typedef struct +{ + LVM_INT32 A1; /* a1 */ + LVM_INT32 A0; /* a0 */ + LVM_INT32 B1; /* -b1! */ +} FO_C32_Coefs_t; + +/*** First order coefficients with Shift*****************************************************/ +typedef struct +{ + LVM_INT16 A1; /* a1 */ + LVM_INT16 A0; /* a0 */ + LVM_INT16 B1; /* -b1! */ + LVM_INT16 Shift; /* Shift */ +} FO_C16_LShx_Coefs_t; + +/*** Band pass coefficients *******************************************************/ +typedef struct +{ + LVM_INT16 A0; /* a0 */ + LVM_INT16 B2; /* -b2! */ + LVM_INT16 B1; /* -b1! */ +} BP_C16_Coefs_t; + +typedef struct +{ + LVM_INT32 A0; /* a0 */ + LVM_INT32 B2; /* -b2! */ + LVM_INT32 B1; /* -b1! */ +} BP_C32_Coefs_t; + +/*** Peaking coefficients *********************************************************/ +typedef struct +{ + LVM_INT16 A0; /* a0 */ + LVM_INT16 B2; /* -b2! */ + LVM_INT16 B1; /* -b1! */ + LVM_INT16 G; /* Gain */ +} PK_C16_Coefs_t; + +typedef struct +{ + LVM_INT32 A0; /* a0 */ + LVM_INT32 B2; /* -b2! */ + LVM_INT32 B1; /* -b1! */ + LVM_INT16 G; /* Gain */ +} PK_C32_Coefs_t; + + +/********************************************************************************** + TAPS TYPE DEFINITIONS +***********************************************************************************/ + +/*** Types used for first order and shelving filter *******************************/ + +typedef struct +{ + LVM_INT32 Storage[ (1*2) ]; /* One channel, two taps of size LVM_INT32 */ +} Biquad_1I_Order1_Taps_t; + +typedef struct +{ + LVM_INT32 Storage[ (2*2) ]; /* Two channels, two taps of size LVM_INT32 */ +} Biquad_2I_Order1_Taps_t; + + +/*** Types used for biquad, band pass and peaking filter **************************/ + +typedef struct +{ + LVM_INT32 Storage[ (1*4) ]; /* One channel, four taps of size LVM_INT32 */ +} Biquad_1I_Order2_Taps_t; + +typedef struct +{ + LVM_INT32 Storage[ (2*4) ]; /* Two channels, four taps of size LVM_INT32 */ +} Biquad_2I_Order2_Taps_t; + +/* The names of the functions are changed to satisfy QAC rules: Name should be Unique withing 16 characters*/ +#define BQ_2I_D32F32Cll_TRC_WRA_01_Init Init_BQ_2I_D32F32Cll_TRC_WRA_01 +#define BP_1I_D32F32C30_TRC_WRA_02 TWO_BP_1I_D32F32C30_TRC_WRA_02 + +/********************************************************************************** + FUNCTION PROTOTYPES: BIQUAD FILTERS +***********************************************************************************/ + +/*** 16 bit data path *************************************************************/ + +void BQ_2I_D16F32Css_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance, + Biquad_2I_Order2_Taps_t *pTaps, + BQ_C16_Coefs_t *pCoef); + +void BQ_2I_D16F32C15_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples); + +void BQ_2I_D16F32C14_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples); + +void BQ_2I_D16F32C13_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples); + +void BQ_2I_D16F16Css_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance, + Biquad_2I_Order2_Taps_t *pTaps, + BQ_C16_Coefs_t *pCoef); + +void BQ_2I_D16F16C15_TRC_WRA_01( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples); + +void BQ_2I_D16F16C14_TRC_WRA_01( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples); + +void BQ_1I_D16F16Css_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance, + Biquad_1I_Order2_Taps_t *pTaps, + BQ_C16_Coefs_t *pCoef); + +void BQ_1I_D16F16C15_TRC_WRA_01( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples); + +void BQ_1I_D16F32Css_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance, + Biquad_1I_Order2_Taps_t *pTaps, + BQ_C16_Coefs_t *pCoef); + +void BQ_1I_D16F32C14_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples); + +/*** 32 bit data path *************************************************************/ + +void BQ_2I_D32F32Cll_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance, + Biquad_2I_Order2_Taps_t *pTaps, + BQ_C32_Coefs_t *pCoef); + +void BQ_2I_D32F32C30_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT32 *pDataIn, + LVM_INT32 *pDataOut, + LVM_INT16 NrSamples); + +/********************************************************************************** + FUNCTION PROTOTYPES: FIRST ORDER FILTERS +***********************************************************************************/ + +/*** 16 bit data path *************************************************************/ + +void FO_1I_D16F16Css_TRC_WRA_01_Init( Biquad_Instance_t *pInstance, + Biquad_1I_Order1_Taps_t *pTaps, + FO_C16_Coefs_t *pCoef); + +void FO_1I_D16F16C15_TRC_WRA_01( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples); + +void FO_2I_D16F32Css_LShx_TRC_WRA_01_Init(Biquad_Instance_t *pInstance, + Biquad_2I_Order1_Taps_t *pTaps, + FO_C16_LShx_Coefs_t *pCoef); + +void FO_2I_D16F32C15_LShx_TRC_WRA_01(Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples); + +/*** 32 bit data path *************************************************************/ + +void FO_1I_D32F32Cll_TRC_WRA_01_Init( Biquad_Instance_t *pInstance, + Biquad_1I_Order1_Taps_t *pTaps, + FO_C32_Coefs_t *pCoef); + +void FO_1I_D32F32C31_TRC_WRA_01( Biquad_Instance_t *pInstance, + LVM_INT32 *pDataIn, + LVM_INT32 *pDataOut, + LVM_INT16 NrSamples); + +/********************************************************************************** + FUNCTION PROTOTYPES: BAND PASS FILTERS +***********************************************************************************/ + +/*** 16 bit data path *************************************************************/ + +void BP_1I_D16F16Css_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance, + Biquad_1I_Order2_Taps_t *pTaps, + BP_C16_Coefs_t *pCoef); + +void BP_1I_D16F16C14_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples); + +void BP_1I_D16F32Cll_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance, + Biquad_1I_Order2_Taps_t *pTaps, + BP_C32_Coefs_t *pCoef); + +void BP_1I_D16F32C30_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples); + + +/*** 32 bit data path *************************************************************/ + +void BP_1I_D32F32Cll_TRC_WRA_02_Init ( Biquad_Instance_t *pInstance, + Biquad_1I_Order2_Taps_t *pTaps, + BP_C32_Coefs_t *pCoef); + +void BP_1I_D32F32C30_TRC_WRA_02( Biquad_Instance_t *pInstance, + LVM_INT32 *pDataIn, + LVM_INT32 *pDataOut, + LVM_INT16 NrSamples); + + +/*** 32 bit data path STEREO ******************************************************/ + +void PK_2I_D32F32CllGss_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance, + Biquad_2I_Order2_Taps_t *pTaps, + PK_C32_Coefs_t *pCoef); + +void PK_2I_D32F32C30G11_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT32 *pDataIn, + LVM_INT32 *pDataOut, + LVM_INT16 NrSamples); + +void PK_2I_D32F32CssGss_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance, + Biquad_2I_Order2_Taps_t *pTaps, + PK_C16_Coefs_t *pCoef); + +void PK_2I_D32F32C14G11_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT32 *pDataIn, + LVM_INT32 *pDataOut, + LVM_INT16 NrSamples); + + +/********************************************************************************** + FUNCTION PROTOTYPES: DC REMOVAL FILTERS +***********************************************************************************/ + +/*** 16 bit data path STEREO ******************************************************/ + +void DC_2I_D16_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance); + +void DC_2I_D16_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/**********************************************************************************/ + +#endif /** _BIQUAD_H_ **/ + diff --git a/media/libeffects/lvm/lib/Common/lib/CompLim.h b/media/libeffects/lvm/lib/Common/lib/CompLim.h new file mode 100755 index 0000000..df9b583 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/lib/CompLim.h @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************************** + + $Author: nxp27078 $ + $Revision: 672 $ + $Date: 2010-06-08 19:39:38 +0200 (Tue, 08 Jun 2010) $ + +***********************************************************************************/ + +#ifndef _COMP_LIM_H +#define _COMP_LIM_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/************************************************************************************/ +/* */ +/* Includes */ +/* */ +/************************************************************************************/ + +#include "LVM_Types.h" + + +/************************************************************************************/ +/* */ +/* Structures */ +/* */ +/************************************************************************************/ + +typedef struct /* Compressor state */ +{ + /* Normaliser */ + LVM_INT16 Norm_Attack; /* Attack time constant of the Normaliser integrator */ + LVM_INT16 Norm_Decay; /* Decay time constant of the Normaliser integrator */ + LVM_INT32 NormInt; /* Normaliser integrator current value */ + LVM_INT16 Shift; /* Shift gain */ + LVM_INT16 Threshold; /* Target threshold */ + + /* Compressor */ + LVM_INT16 Comp_Atten; /* Attenuation applied before soft knee compressor */ + LVM_INT16 Comp_Attack_S; /* Attack time constant of the slow integrator */ + LVM_INT16 Comp_Decay_S; /* Decay time constant of slow the integrator */ + LVM_INT16 Comp_Attack_F; /* Attack time constant of fast the integrator */ + LVM_INT16 Comp_Decay_F; /* Decay time constant of fast the integrator */ + LVM_INT16 SoftClipGain; /* Soft clip gain control */ + LVM_INT32 CompIntSlow; /* Compressor slow integrator current value */ + LVM_INT32 CompIntFast; /* Compressor fast integrator current value */ + + +} CompLim_Instance_t; + + +/************************************************************************************/ +/* */ +/* Function Prototypes */ +/* */ +/************************************************************************************/ + +void NonLinComp_D16(LVM_INT16 Gain, + LVM_INT16 *pSterBfIn, + LVM_INT16 *pSterBfOut, + LVM_INT32 BlockLength); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* #ifndef _COMP_LIM_H */ + + + diff --git a/media/libeffects/lvm/lib/Common/lib/Filter.h b/media/libeffects/lvm/lib/Common/lib/Filter.h new file mode 100755 index 0000000..93ccbcb --- /dev/null +++ b/media/libeffects/lvm/lib/Common/lib/Filter.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 771 $*/ +/* $Date: 2010-06-14 10:41:36 +0200 (Mon, 14 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#ifndef _FILTER_H_ +#define _FILTER_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/********************************************************************************** + INCLUDES +***********************************************************************************/ +#include "LVM_Types.h" +#include "BIQUAD.h" + + +/********************************************************************************** + DEFINES +***********************************************************************************/ +#define FILTER_LOSS 32730 /* -0.01dB loss to avoid wrapping due to band ripple */ + +/********************************************************************************** + FUNCTION PROTOTYPES +***********************************************************************************/ + +LVM_INT32 LVM_Polynomial(LVM_UINT16 N, + LVM_INT32 *pCoefficients, + LVM_INT32 X); + +LVM_INT32 LVM_Power10( LVM_INT32 X); + +LVM_INT32 LVM_FO_LPF( LVM_INT32 w, + FO_C32_Coefs_t *pCoeffs); + +LVM_INT32 LVM_FO_HPF( LVM_INT32 w, + FO_C32_Coefs_t *pCoeffs); + +LVM_INT32 LVM_GetOmega(LVM_UINT16 Fc, + LVM_Fs_en SampleRate); + +/**********************************************************************************/ +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /** _FILTER_H_ **/ + diff --git a/media/libeffects/lvm/lib/Common/lib/InstAlloc.h b/media/libeffects/lvm/lib/Common/lib/InstAlloc.h new file mode 100755 index 0000000..31409bf --- /dev/null +++ b/media/libeffects/lvm/lib/Common/lib/InstAlloc.h @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ +#ifndef __INSTALLOC_H__ +#define __INSTALLOC_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "LVM_Types.h" +/*######################################################################################*/ +/* Type declarations */ +/*######################################################################################*/ +typedef struct +{ + LVM_UINT32 TotalSize; /* Accumulative total memory size */ + LVM_UINT32 pNextMember; /* Pointer to the next instance member to be allocated */ +} INST_ALLOC; + + +/*######################################################################################*/ +/* Function prototypes */ +/*######################################################################################*/ + +/**************************************************************************************** + * Name : InstAlloc_Init() + * Input : pms - Pointer to the INST_ALLOC instance + StartAddr - Base address of the instance memory + * Returns : Error code + * Description : Initializes the instance distribution and memory size calculation function + * Remarks : + ****************************************************************************************/ + +void InstAlloc_Init( INST_ALLOC *pms, void *StartAddr ); + + +/**************************************************************************************** + * Name : InstAlloc_AddMember() + * Input : pms - Pointer to the INST_ALLOC instance + Size - The size in bytes of the new added member + * Returns : A pointer to the new added member + * Description : Allocates space for a new member in the instance memory and returns + a pointer to this new member. The start address of all members will + be 32 bit alligned. + * Remarks : + ****************************************************************************************/ + +void* InstAlloc_AddMember( INST_ALLOC *pms, LVM_UINT32 Size ); + +/**************************************************************************************** + * Name : InstAlloc_GetTotal() + * Input : pms - Pointer to the INST_ALLOC instance + * Returns : The instance memory size + * Description : This functions returns the calculated instance memory size + * Remarks : + ****************************************************************************************/ + +LVM_UINT32 InstAlloc_GetTotal( INST_ALLOC *pms); + +void* InstAlloc_AddMemberAllRet( INST_ALLOC *pms, + LVM_UINT32 Size[], + void **ptr); + +void* InstAlloc_AddMemberAll( INST_ALLOC *pms, + LVM_UINT32 Size[], + LVM_MemoryTable_st *pMemoryTable); + +void InstAlloc_InitAll( INST_ALLOC *pms, + LVM_MemoryTable_st *pMemoryTable); + +void InstAlloc_InitAll_NULL( INST_ALLOC *pms); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __JBS_INSTALLOC_H__ */ diff --git a/media/libeffects/lvm/lib/Common/lib/LVM_Common.h b/media/libeffects/lvm/lib/Common/lib/LVM_Common.h new file mode 100755 index 0000000..f0f893d --- /dev/null +++ b/media/libeffects/lvm/lib/Common/lib/LVM_Common.h @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/***************************************************************************************** + + $Author: nxp27078 $ + $Revision: 672 $ + $Date: 2010-06-08 19:39:38 +0200 (Tue, 08 Jun 2010) $ + +*****************************************************************************************/ + +/****************************************************************************************/ +/* */ +/* Header file for the common definitions used within the bundle and its algorithms. */ +/* */ +/* This files includes all definitions, types, structures and function prototypes. */ +/* */ +/****************************************************************************************/ + + +#ifndef __LVM_COMMON_H__ +#define __LVM_COMMON_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/****************************************************************************************/ +/* */ +/* Includes */ +/* */ +/****************************************************************************************/ +#include "LVM_Types.h" + + +/****************************************************************************************/ +/* */ +/* Definitions */ +/* */ +/****************************************************************************************/ +/* Algorithm identification */ +#define ALGORITHM_NONE_ID 0x0000 +#define ALGORITHM_CS_ID 0x0100 +#define ALGORITHM_EQNB_ID 0x0200 +#define ALGORITHM_DBE_ID 0x0300 +#define ALGORITHM_VC_ID 0x0500 +#define ALGORITHM_TE_ID 0x0600 + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __LVM_COMMON_H__ */ + diff --git a/media/libeffects/lvm/lib/Common/lib/LVM_Macros.h b/media/libeffects/lvm/lib/Common/lib/LVM_Macros.h new file mode 100755 index 0000000..8bd363d --- /dev/null +++ b/media/libeffects/lvm/lib/Common/lib/LVM_Macros.h @@ -0,0 +1,130 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************************** + + $Author: beq07716 $ + $Revision: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +#ifndef _LVM_MACROS_H_ +#define _LVM_MACROS_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/********************************************************************************** + MUL32x32INTO32(A,B,C,ShiftR) + C = (A * B) >> ShiftR + + A, B and C are all 32 bit SIGNED numbers and ShiftR can vary from 0 to 64 + + The user has to take care that C does not overflow. The result in case + of overflow is undefined. + +***********************************************************************************/ +#ifndef MUL32x32INTO32 +#define MUL32x32INTO32(A,B,C,ShiftR) \ + {LVM_INT32 MUL32x32INTO32_temp,MUL32x32INTO32_temp2,MUL32x32INTO32_mask,MUL32x32INTO32_HH,MUL32x32INTO32_HL,MUL32x32INTO32_LH,MUL32x32INTO32_LL;\ + LVM_INT32 shiftValue;\ + shiftValue = (ShiftR);\ + MUL32x32INTO32_mask=0x0000FFFF;\ + MUL32x32INTO32_HH= ((LVM_INT32)((LVM_INT16)((A)>>16))*((LVM_INT16)((B)>>16)) );\ + MUL32x32INTO32_HL= ((LVM_INT32)((B)&MUL32x32INTO32_mask)*((LVM_INT16)((A)>>16))) ;\ + MUL32x32INTO32_LH= ((LVM_INT32)((A)&MUL32x32INTO32_mask)*((LVM_INT16)((B)>>16)));\ + MUL32x32INTO32_LL= (LVM_INT32)((A)&MUL32x32INTO32_mask)*(LVM_INT32)((B)&MUL32x32INTO32_mask);\ + MUL32x32INTO32_temp= (LVM_INT32)(MUL32x32INTO32_HL&MUL32x32INTO32_mask)+(LVM_INT32)(MUL32x32INTO32_LH&MUL32x32INTO32_mask)+(LVM_INT32)((MUL32x32INTO32_LL>>16)&MUL32x32INTO32_mask);\ + MUL32x32INTO32_HH= MUL32x32INTO32_HH+(LVM_INT32)(MUL32x32INTO32_HL>>16)+(LVM_INT32)(MUL32x32INTO32_LH>>16)+(LVM_INT32)(MUL32x32INTO32_temp>>16);\ + MUL32x32INTO32_LL=MUL32x32INTO32_LL+(LVM_INT32)(MUL32x32INTO32_HL<<16)+(LVM_INT32)(MUL32x32INTO32_LH<<16);\ + if(shiftValue<32)\ + {\ + MUL32x32INTO32_HH=MUL32x32INTO32_HH<<(32-shiftValue);\ + MUL32x32INTO32_mask=((LVM_INT32)1<<(32-shiftValue))-1;\ + MUL32x32INTO32_LL=(MUL32x32INTO32_LL>>shiftValue)&MUL32x32INTO32_mask;\ + MUL32x32INTO32_temp2=MUL32x32INTO32_HH|MUL32x32INTO32_LL;\ + }\ + else\ + {\ + MUL32x32INTO32_temp2=(LVM_INT32)MUL32x32INTO32_HH>>(shiftValue-32);\ + }\ + (C) = MUL32x32INTO32_temp2;\ + } +#endif + +/********************************************************************************** + MUL32x16INTO32(A,B,C,ShiftR) + C = (A * B) >> ShiftR + + A and C are 32 bit SIGNED numbers. B is a 16 bit SIGNED number. + ShiftR can vary from 0 to 48 + + The user has to take care that C does not overflow. The result in case + of overflow is undefined. + +***********************************************************************************/ +#ifndef MUL32x16INTO32 +#define MUL32x16INTO32(A,B,C,ShiftR) \ + {LVM_INT32 MUL32x16INTO32_mask,MUL32x16INTO32_HH,MUL32x16INTO32_LL;\ + LVM_INT32 shiftValue;\ + shiftValue = (ShiftR);\ + MUL32x16INTO32_mask=0x0000FFFF;\ + MUL32x16INTO32_HH= ((LVM_INT32)(B)*((LVM_INT16)((A)>>16)));\ + MUL32x16INTO32_LL= ((LVM_INT32)((A)&MUL32x16INTO32_mask)*(B));\ + if(shiftValue<16)\ + {\ + MUL32x16INTO32_HH=(LVM_INT32)((LVM_UINT32)MUL32x16INTO32_HH<<(16-shiftValue));\ + (C)=MUL32x16INTO32_HH+(LVM_INT32)(MUL32x16INTO32_LL>>shiftValue);\ + }\ + else if(shiftValue<32) {\ + MUL32x16INTO32_HH=(LVM_INT32)(MUL32x16INTO32_HH>>(shiftValue-16));\ + (C)=MUL32x16INTO32_HH+(LVM_INT32)(MUL32x16INTO32_LL>>shiftValue);\ + }\ + else {\ + (C)=MUL32x16INTO32_HH>>(shiftValue-16);}\ + } +#endif + +/********************************************************************************** + ADD2_SAT_32x32(A,B,C) + C = SAT(A + B) + + A,B and C are 32 bit SIGNED numbers. +***********************************************************************************/ +#ifndef ADD2_SAT_32x32 +#define ADD2_SAT_32x32(A,B,C) \ + {(C)=(A)+(B);\ + if ((((C) ^ (A)) & ((C) ^ (B))) >> 31)\ + {\ + if((A)<0)\ + (C)=0x80000000l;\ + else\ + (C)=0x7FFFFFFFl;\ + }\ + } +#endif + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _LVM_MACROS_H_ */ + +/*** End of file ******************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/lib/LVM_Timer.h b/media/libeffects/lvm/lib/Common/lib/LVM_Timer.h new file mode 100755 index 0000000..22a16d6 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/lib/LVM_Timer.h @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __LVM_TIMER_H__ +#define __LVM_TIMER_H__ +/************************************************************************/ +/* */ +/* Project:: My Project */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ +#include "LVM_Types.h" + +/****************************************************************************************/ +/* */ +/* Header file for the LVM_Timer library */ +/* */ +/* Functionality: */ +/* The timer will count down a number of ms, based on the number of samples it */ +/* sees and the curent sampling rate. When the timer expires, a registered */ +/* callback function will be called. */ +/* The maximal number of sampless that can be called by the timer is 2^32, which */ +/* corresponds to 24.8 hours at a sampling rate of 48 kHz */ +/* The timer currently does not suport changes in sampling rate while timing. */ +/****************************************************************************************/ + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/****************************************************************************************/ +/* TYPE DEFINITIONS */ +/****************************************************************************************/ + +typedef struct +{ + LVM_INT32 Storage[6]; + +} LVM_Timer_Instance_t; + +typedef struct +{ + LVM_INT32 SamplingRate; + LVM_INT16 TimeInMs; + LVM_INT32 CallBackParam; + void *pCallBackParams; + void *pCallbackInstance; + void (*pCallBack)(void*,void*,LVM_INT32); + +} LVM_Timer_Params_t; + +/****************************************************************************************/ +/* FUNCTION PROTOTYPES */ +/****************************************************************************************/ + +void LVM_Timer_Init ( LVM_Timer_Instance_t *pInstance, + LVM_Timer_Params_t *pParams ); + + +void LVM_Timer ( LVM_Timer_Instance_t *pInstance, + LVM_INT16 BlockSize ); + + +/****************************************************************************************/ +/* END OF HEADER */ +/****************************************************************************************/ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __LVM_TIMER_H__ */ diff --git a/media/libeffects/lvm/lib/Common/lib/LVM_Types.h b/media/libeffects/lvm/lib/Common/lib/LVM_Types.h new file mode 100755 index 0000000..e4649ba --- /dev/null +++ b/media/libeffects/lvm/lib/Common/lib/LVM_Types.h @@ -0,0 +1,195 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/**************************************************************************************** + + $Author: beq07716 $ + $Revision: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +*****************************************************************************************/ + +/****************************************************************************************/ +/* */ +/* Header file defining the standard LifeVibes types for use in the application layer */ +/* interface of all LifeVibes modules */ +/* */ +/****************************************************************************************/ + +#ifndef LVM_TYPES_H +#define LVM_TYPES_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/****************************************************************************************/ +/* */ +/* definitions */ +/* */ +/****************************************************************************************/ + +#define LVM_NULL 0 /* NULL pointer */ + +#define LVM_TRUE 1 /* Booleans */ +#define LVM_FALSE 0 + +#define LVM_MAXINT_8 127 /* Maximum positive integer size */ +#define LVM_MAXINT_16 32767 +#define LVM_MAXINT_32 2147483647 +#define LVM_MAXENUM 2147483647 + +#define LVM_MODULEID_MASK 0xFF00 /* Mask to extract the calling module ID from callbackId */ +#define LVM_EVENTID_MASK 0x00FF /* Mask to extract the callback event from callbackId */ + +/* Memory table*/ +#define LVM_MEMREGION_PERSISTENT_SLOW_DATA 0 /* Offset to the instance memory region */ +#define LVM_MEMREGION_PERSISTENT_FAST_DATA 1 /* Offset to the persistent data memory region */ +#define LVM_MEMREGION_PERSISTENT_FAST_COEF 2 /* Offset to the persistent coefficient memory region */ +#define LVM_MEMREGION_TEMPORARY_FAST 3 /* Offset to temporary memory region */ + +#define LVM_NR_MEMORY_REGIONS 4 /* Number of memory regions */ + +/* Memory partition type */ +#define LVM_MEM_PARTITION0 0 /* 1st memory partition */ +#define LVM_MEM_PARTITION1 1 /* 2nd memory partition */ +#define LVM_MEM_PARTITION2 2 /* 3rd memory partition */ +#define LVM_MEM_PARTITION3 3 /* 4th memory partition */ + +/* Use type */ +#define LVM_MEM_PERSISTENT 0 /* Persistent memory type */ +#define LVM_MEM_SCRATCH 4 /* Scratch memory type */ + +/* Access type */ +#define LVM_MEM_INTERNAL 0 /* Internal (fast) access memory */ +#define LVM_MEM_EXTERNAL 8 /* External (slow) access memory */ + +/* Platform specific */ +#define LVM_PERSISTENT LVM_MEM_PARTITION0+LVM_MEM_PERSISTENT+LVM_MEM_INTERNAL +#define LVM_PERSISTENT_DATA LVM_MEM_PARTITION1+LVM_MEM_PERSISTENT+LVM_MEM_INTERNAL +#define LVM_PERSISTENT_COEF LVM_MEM_PARTITION2+LVM_MEM_PERSISTENT+LVM_MEM_INTERNAL +#define LVM_SCRATCH LVM_MEM_PARTITION3+LVM_MEM_SCRATCH+LVM_MEM_INTERNAL + +/****************************************************************************************/ +/* */ +/* Basic types */ +/* */ +/****************************************************************************************/ + +typedef char LVM_CHAR; /* ASCII character */ + +typedef char LVM_INT8; /* Signed 8-bit word */ +typedef unsigned char LVM_UINT8; /* Unsigned 8-bit word */ + +typedef short LVM_INT16; /* Signed 16-bit word */ +typedef unsigned short LVM_UINT16; /* Unsigned 16-bit word */ + +typedef long LVM_INT32; /* Signed 32-bit word */ +typedef unsigned long LVM_UINT32; /* Unsigned 32-bit word */ + + +/****************************************************************************************/ +/* */ +/* Standard Enumerated types */ +/* */ +/****************************************************************************************/ + +/* Operating mode */ +typedef enum +{ + LVM_MODE_OFF = 0, + LVM_MODE_ON = 1, + LVM_MODE_DUMMY = LVM_MAXENUM +} LVM_Mode_en; + + +/* Format */ +typedef enum +{ + LVM_STEREO = 0, + LVM_MONOINSTEREO = 1, + LVM_MONO = 2, + LVM_SOURCE_DUMMY = LVM_MAXENUM +} LVM_Format_en; + + +/* LVM sampling rates */ +typedef enum +{ + LVM_FS_8000 = 0, + LVM_FS_11025 = 1, + LVM_FS_12000 = 2, + LVM_FS_16000 = 3, + LVM_FS_22050 = 4, + LVM_FS_24000 = 5, + LVM_FS_32000 = 6, + LVM_FS_44100 = 7, + LVM_FS_48000 = 8, + LVM_FS_INVALID = LVM_MAXENUM-1, + LVM_FS_DUMMY = LVM_MAXENUM +} LVM_Fs_en; + + +/* Memory Types */ +typedef enum +{ + LVM_PERSISTENT_SLOW_DATA = LVM_MEMREGION_PERSISTENT_SLOW_DATA, + LVM_PERSISTENT_FAST_DATA = LVM_MEMREGION_PERSISTENT_FAST_DATA, + LVM_PERSISTENT_FAST_COEF = LVM_MEMREGION_PERSISTENT_FAST_COEF, + LVM_TEMPORARY_FAST = LVM_MEMREGION_TEMPORARY_FAST, + LVM_MEMORYTYPE_DUMMY = LVM_MAXENUM +} LVM_MemoryTypes_en; + + +/* Memory region definition */ +typedef struct +{ + LVM_UINT32 Size; /* Region size in bytes */ + LVM_MemoryTypes_en Type; /* Region type */ + void *pBaseAddress; /* Pointer to the region base address */ +} LVM_MemoryRegion_st; + + +/* Memory table containing the region definitions */ +typedef struct +{ + LVM_MemoryRegion_st Region[LVM_NR_MEMORY_REGIONS]; /* One definition for each region */ +} LVM_MemoryTable_st; + + +/****************************************************************************************/ +/* */ +/* Standard Function Prototypes */ +/* */ +/****************************************************************************************/ +typedef LVM_INT32 (*LVM_Callback)(void *pCallbackData, /* Pointer to the callback data structure */ + void *pGeneralPurpose, /* General purpose pointer (e.g. to a data structure needed in the callback) */ + LVM_INT16 GeneralPurpose ); /* General purpose variable (e.g. to be used as callback ID) */ + + +/****************************************************************************************/ +/* */ +/* End of file */ +/* */ +/****************************************************************************************/ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* LVM_TYPES_H */ diff --git a/media/libeffects/lvm/lib/Common/lib/Mixer.h b/media/libeffects/lvm/lib/Common/lib/Mixer.h new file mode 100755 index 0000000..d741980 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/lib/Mixer.h @@ -0,0 +1,135 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************************** + + $Author: beq07716 $ + $Revision: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +#ifndef __MIXER_H__ +#define __MIXER_H__ + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +#include "LVM_Types.h" + +/********************************************************************************** + INSTANCE MEMORY TYPE DEFINITION +***********************************************************************************/ + +typedef struct +{ + LVM_INT32 Alpha; /* Time constant. Set by calling application. Can be changed at any time */ + LVM_INT32 Target; /* Target value. Set by calling application. Can be changed at any time */ + LVM_INT32 Current; /* Current value. Set by the mixer function. */ + LVM_INT16 CallbackSet; /* Boolean. Should be set by calling application each time the target value is updated */ + LVM_INT16 CallbackParam; /* Parameter that will be used in the calback function */ + void *pCallbackHandle; /* Pointer to the instance of the callback function */ + void *pGeneralPurpose; /* Pointer for general purpose usage */ + LVM_Callback pCallBack; /* Pointer to the callback function */ +} Mix_1St_Cll_t; + +typedef struct +{ + LVM_INT32 Alpha1; + LVM_INT32 Target1; + LVM_INT32 Current1; + LVM_INT16 CallbackSet1; + LVM_INT16 CallbackParam1; + void *pCallbackHandle1; + void *pGeneralPurpose1; + LVM_Callback pCallBack1; + + LVM_INT32 Alpha2; /* Warning the address of this location is passed as a pointer to Mix_1St_Cll_t in some functions */ + LVM_INT32 Target2; + LVM_INT32 Current2; + LVM_INT16 CallbackSet2; + LVM_INT16 CallbackParam2; + void *pCallbackHandle2; + void *pGeneralPurpose2; + LVM_Callback pCallBack2; + +} Mix_2St_Cll_t; + + +/*** General functions ************************************************************/ + +LVM_UINT32 LVM_Mixer_TimeConstant(LVM_UINT32 tc, + LVM_UINT16 Fs, + LVM_UINT16 NumChannels); + + +void MixSoft_1St_D32C31_WRA( Mix_1St_Cll_t *pInstance, + const LVM_INT32 *src, + LVM_INT32 *dst, + LVM_INT16 n); + +void MixSoft_2St_D32C31_SAT( Mix_2St_Cll_t *pInstance, + const LVM_INT32 *src1, + const LVM_INT32 *src2, + LVM_INT32 *dst, + LVM_INT16 n); + +void MixInSoft_D32C31_SAT( Mix_1St_Cll_t *pInstance, + const LVM_INT32 *src, + LVM_INT32 *dst, + LVM_INT16 n); + +/********************************************************************************** + FUNCTION PROTOTYPES (LOW LEVEL SUBFUNCTIONS) +***********************************************************************************/ + +void Core_MixSoft_1St_D32C31_WRA( Mix_1St_Cll_t *pInstance, + const LVM_INT32 *src, + LVM_INT32 *dst, + LVM_INT16 n); + +void Core_MixHard_2St_D32C31_SAT( Mix_2St_Cll_t *pInstance, + const LVM_INT32 *src1, + const LVM_INT32 *src2, + LVM_INT32 *dst, + LVM_INT16 n); + +void Core_MixInSoft_D32C31_SAT( Mix_1St_Cll_t *pInstance, + const LVM_INT32 *src, + LVM_INT32 *dst, + LVM_INT16 n); +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/**********************************************************************************/ + +#endif /* __MIXER_H__ */ + + + + + + + + + + diff --git a/media/libeffects/lvm/lib/Common/lib/ScalarArithmetic.h b/media/libeffects/lvm/lib/Common/lib/ScalarArithmetic.h new file mode 100755 index 0000000..c66e201 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/lib/ScalarArithmetic.h @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#ifndef __SCALARARITHMETIC_H__ +#define __SCALARARITHMETIC_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/*######################################################################################*/ +/* Include files */ +/*######################################################################################*/ + +#include "LVM_Types.h" + +/*######################################################################################*/ +/* Extern function prototypes */ +/*######################################################################################*/ + +/* Absolute value including the corner case for the extreme negative value */ +LVM_INT32 Abs_32(LVM_INT32 input); + +/**************************************************************************************** + * Name : dB_to_Lin32() + * Input : Signed 16-bit integer + * MSB (16) = sign bit + * (15->05) = integer part + * (04->01) = decimal part + * Output : Signed 32-bit integer + * MSB (32) = sign bit + * (31->16) = integer part + * (15->01) = decimal part + * Returns : Lin value format 1.16.15 + ****************************************************************************************/ + +LVM_INT32 dB_to_Lin32(LVM_INT16 db_fix); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __SCALARARITHMETIC_H__ */ + + diff --git a/media/libeffects/lvm/lib/Common/lib/VectorArithmetic.h b/media/libeffects/lvm/lib/Common/lib/VectorArithmetic.h new file mode 100755 index 0000000..290a996 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/lib/VectorArithmetic.h @@ -0,0 +1,189 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************************** + + $Author: beq07716 $ + $Revision: 853 $ + $Date: 2010-06-16 15:10:28 +0200 (Wed, 16 Jun 2010) $ + +***********************************************************************************/ + +#ifndef _VECTOR_ARITHMETIC_H_ +#define _VECTOR_ARITHMETIC_H_ + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "LVM_Types.h" + +/********************************************************************************** + VARIOUS FUNCTIONS +***********************************************************************************/ + +void LoadConst_16( const LVM_INT16 val, + LVM_INT16 *dst, + LVM_INT16 n ); + +void LoadConst_32( const LVM_INT32 val, + LVM_INT32 *dst, + LVM_INT16 n ); + +void Copy_16( const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n ); + +/********************************************************************************* + * note: In Mult3s_16x16() saturation of result is not taken care when * + * overflow occurs. * + * For example when *src = 0x8000, val = *0x8000 * + * The function gives the output as 0x8000 instead of 0x7fff * + * This is the only case which will give wrong result. * + * For more information refer to Vector_Arithmetic.doc in /doc folder * + *********************************************************************************/ +void Mult3s_16x16( const LVM_INT16 *src, + const LVM_INT16 val, + LVM_INT16 *dst, + LVM_INT16 n); + +/********************************************************************************* + * note: In Mult3s_32x16() saturation of result is not taken care when * + * overflow occurs. * + * For example when *src = 0x8000000, val = *0x8000 * + * The function gives the output as 0x8000000 instead of 0x7fffffff * + * This is the only extreme condition which is giving unexpected result * + * For more information refer to Vector_Arithmetic.doc in /doc folder * + *********************************************************************************/ +void Mult3s_32x16( const LVM_INT32 *src, + const LVM_INT16 val, + LVM_INT32 *dst, + LVM_INT16 n); + +void DelayMix_16x16( const LVM_INT16 *src, + LVM_INT16 *delay, + LVM_INT16 size, + LVM_INT16 *dst, + LVM_INT16 *pOffset, + LVM_INT16 n); + +void DelayWrite_32( const LVM_INT32 *src, /* Source 1, to be delayed */ + LVM_INT32 *delay, /* Delay buffer */ + LVM_UINT16 size, /* Delay size */ + LVM_UINT16 *pOffset, /* Delay offset */ + LVM_INT16 n); + +void Add2_Sat_16x16( const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n ); + +void Add2_Sat_32x32( const LVM_INT32 *src, + LVM_INT32 *dst, + LVM_INT16 n ); + +void Mac3s_Sat_16x16( const LVM_INT16 *src, + const LVM_INT16 val, + LVM_INT16 *dst, + LVM_INT16 n); + +void Mac3s_Sat_32x16( const LVM_INT32 *src, + const LVM_INT16 val, + LVM_INT32 *dst, + LVM_INT16 n); + +void DelayAllPass_Sat_32x16To32( LVM_INT32 *delay, /* Delay buffer */ + LVM_UINT16 size, /* Delay size */ + LVM_INT16 coeff, /* All pass filter coefficient */ + LVM_UINT16 DelayOffset, /* Simple delay offset */ + LVM_UINT16 *pAllPassOffset, /* All pass filter delay offset */ + LVM_INT32 *dst, /* Source/destination */ + LVM_INT16 n); + +/********************************************************************************** + SHIFT FUNCTIONS +***********************************************************************************/ + +void Shift_Sat_v16xv16 ( const LVM_INT16 val, + const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n); + +void Shift_Sat_v32xv32 ( const LVM_INT16 val, + const LVM_INT32 *src, + LVM_INT32 *dst, + LVM_INT16 n); + +/********************************************************************************** + AUDIO FORMAT CONVERSION FUNCTIONS +***********************************************************************************/ + +void MonoTo2I_16( const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n); + +void MonoTo2I_32( const LVM_INT32 *src, + LVM_INT32 *dst, + LVM_INT16 n); + +void From2iToMono_32( const LVM_INT32 *src, + LVM_INT32 *dst, + LVM_INT16 n); + +void MSTo2i_Sat_16x16( const LVM_INT16 *srcM, + const LVM_INT16 *srcS, + LVM_INT16 *dst, + LVM_INT16 n ); + +void From2iToMS_16x16( const LVM_INT16 *src, + LVM_INT16 *dstM, + LVM_INT16 *dstS, + LVM_INT16 n ); + +void From2iToMono_16( const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n); + +void JoinTo2i_32x32( const LVM_INT32 *srcL, + const LVM_INT32 *srcR, + LVM_INT32 *dst, + LVM_INT16 n ); + +/********************************************************************************** + DATA TYPE CONVERSION FUNCTIONS +***********************************************************************************/ + +void Int16LShiftToInt32_16x32(const LVM_INT16 *src, + LVM_INT32 *dst, + LVM_INT16 n, + LVM_INT16 shift ); + +void Int32RShiftToInt16_Sat_32x16(const LVM_INT32 *src, + LVM_INT16 *dst, + LVM_INT16 n, + LVM_INT16 shift ); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/**********************************************************************************/ + +#endif /* _VECTOR_ARITHMETIC_H_ */ + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/AGC_MIX_VOL_2St1Mon_D32_WRA.c b/media/libeffects/lvm/lib/Common/src/AGC_MIX_VOL_2St1Mon_D32_WRA.c new file mode 100755 index 0000000..40e0dbf --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/AGC_MIX_VOL_2St1Mon_D32_WRA.c @@ -0,0 +1,204 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/**************************************************************************************** + + $Author: beq07716 $ + $Revision: 1070 $ + $Date: 2010-07-02 11:22:18 +0200 (Fri, 02 Jul 2010) $ + +*****************************************************************************************/ + +/****************************************************************************************/ +/* */ +/* Includes */ +/* */ +/****************************************************************************************/ + +#include "AGC.h" +#include "ScalarArithmetic.h" + + +/****************************************************************************************/ +/* */ +/* Defines */ +/* */ +/****************************************************************************************/ + +#define VOL_TC_SHIFT 21 /* As a power of 2 */ +#define DECAY_SHIFT 10 /* As a power of 2 */ + + +/****************************************************************************************/ +/* */ +/* FUNCTION: AGC_MIX_VOL_2St1Mon_D32_WRA */ +/* */ +/* DESCRIPTION: */ +/* Apply AGC and mix signals */ +/* */ +/* */ +/* StSrc ------------------| */ +/* | */ +/* ______ _|_ ________ */ +/* | | | | | | */ +/* MonoSrc -->| AGC |---->| + |----->| Volume |------------------------------+---> */ +/* | Gain | |___| | Gain | | */ +/* |______| |________| | */ +/* /|\ __________ ________ | */ +/* | | | | | | */ +/* |-------------------------------| AGC Gain |<--| Peak |<--| */ +/* | Update | | Detect | */ +/* |__________| |________| */ +/* */ +/* */ +/* PARAMETERS: */ +/* pInstance Instance pointer */ +/* pStereoIn Stereo source */ +/* pMonoIn Mono band pass source */ +/* pStereoOut Stereo destination */ +/* */ +/* RETURNS: */ +/* Void */ +/* */ +/* NOTES: */ +/* */ +/****************************************************************************************/ + +void AGC_MIX_VOL_2St1Mon_D32_WRA(AGC_MIX_VOL_2St1Mon_D32_t *pInstance, /* Instance pointer */ + const LVM_INT32 *pStSrc, /* Stereo source */ + const LVM_INT32 *pMonoSrc, /* Mono source */ + LVM_INT32 *pDst, /* Stereo destination */ + LVM_UINT16 NumSamples) /* Number of samples */ +{ + + /* + * General variables + */ + LVM_UINT16 i; /* Sample index */ + LVM_INT32 Left; /* Left sample */ + LVM_INT32 Right; /* Right sample */ + LVM_INT32 Mono; /* Mono sample */ + LVM_INT32 AbsPeak; /* Absolute peak signal */ + LVM_INT32 HighWord; /* High word in intermediate calculations */ + LVM_INT32 LowWord; /* Low word in intermediate calculations */ + LVM_INT16 AGC_Mult; /* Short AGC gain */ + LVM_INT16 Vol_Mult; /* Short volume */ + + + /* + * Instance control variables + */ + LVM_INT32 AGC_Gain = pInstance->AGC_Gain; /* Get the current AGC gain */ + LVM_INT32 AGC_MaxGain = pInstance->AGC_MaxGain; /* Get maximum AGC gain */ + LVM_INT16 AGC_GainShift = pInstance->AGC_GainShift; /* Get the AGC shift */ + LVM_INT16 AGC_Attack = pInstance->AGC_Attack; /* Attack scaler */ + LVM_INT16 AGC_Decay = pInstance->AGC_Decay; /* Decay scaler */ + LVM_INT32 AGC_Target = pInstance->AGC_Target; /* Get the target level */ + LVM_INT32 Vol_Current = pInstance->Volume; /* Actual volume setting */ + LVM_INT32 Vol_Target = pInstance->Target; /* Target volume setting */ + LVM_INT16 Vol_Shift = pInstance->VolumeShift; /* Volume shift scaling */ + LVM_INT16 Vol_TC = pInstance->VolumeTC; /* Time constant */ + + + /* + * Process on a sample by sample basis + */ + for (i=0;i> 16); /* Get the short AGC gain */ + Vol_Mult = (LVM_INT16)(Vol_Current >> 16); /* Get the short volume gain */ + + + /* + * Get the input samples + */ + Left = *pStSrc++; /* Get the left sample */ + Right = *pStSrc++; /* Get the right sample */ + Mono = *pMonoSrc++; /* Get the mono sample */ + + + /* + * Apply the AGC gain to the mono input and mix with the stereo signal + */ + HighWord = (AGC_Mult * (Mono >> 16)); /* signed long (Mono) by unsigned short (AGC_Mult) multiply */ + LowWord = (AGC_Mult * (Mono & 0xffff)); + Mono = (HighWord + (LowWord >> 16)) << (AGC_GainShift); + Left += Mono; /* Mix in the mono signal */ + Right += Mono; + + + /* + * Apply the volume and write to the output stream + */ + HighWord = (Vol_Mult * (Left >> 16)); /* signed long (Left) by unsigned short (Vol_Mult) multiply */ + LowWord = (Vol_Mult * (Left & 0xffff)); + Left = (HighWord + (LowWord >> 16)) << (Vol_Shift); + HighWord = (Vol_Mult * (Right >> 16)); /* signed long (Right) by unsigned short (Vol_Mult) multiply */ + LowWord = (Vol_Mult * (Right & 0xffff)); + Right = (HighWord + (LowWord >> 16)) << (Vol_Shift); + *pDst++ = Left; /* Save the results */ + *pDst++ = Right; + + + /* + * Update the AGC gain + */ + AbsPeak = (Abs_32(Left)>Abs_32(Right)) ? Abs_32(Left) : Abs_32(Right); /* Get the absolute peak */ + if (AbsPeak > AGC_Target) + { + /* + * The signal is too large so decrease the gain + */ + HighWord = (AGC_Attack * (AGC_Gain >> 16)); /* signed long (AGC_Gain) by unsigned short (AGC_Attack) multiply */ + LowWord = (AGC_Attack * (AGC_Gain & 0xffff)); + AGC_Gain = (HighWord + (LowWord >> 16)) << 1; + } + else + { + /* + * The signal is too small so increase the gain + */ + if (AGC_Gain > AGC_MaxGain) + { + AGC_Gain -= (AGC_Decay << DECAY_SHIFT); + } + else + { + AGC_Gain += (AGC_Decay << DECAY_SHIFT); + } + } + + /* + * Update the gain + */ + Vol_Current += Vol_TC * ((Vol_Target - Vol_Current) >> VOL_TC_SHIFT); + } + + + /* + * Update the parameters + */ + pInstance->Volume = Vol_Current; /* Actual volume setting */ + pInstance->AGC_Gain = AGC_Gain; + + return; +} + diff --git a/media/libeffects/lvm/lib/Common/src/Abs_32.c b/media/libeffects/lvm/lib/Common/src/Abs_32.c new file mode 100755 index 0000000..635315d --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/Abs_32.c @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/*######################################################################################*/ +/* Include files */ +/*######################################################################################*/ + +#include "ScalarArithmetic.h" + +/**************************************************************************************** + * Name : Abs_32() + * Input : Signed 32-bit integer + * Output : + * Returns : Absolute value + * Description : Absolute value with maximum negative value corner case + * Remarks : + ****************************************************************************************/ + +LVM_INT32 Abs_32(LVM_INT32 input) +{ + if(input < 0) + { + if (input == (LVM_INT32)(0x80000000U)) + { + /* The corner case, so set to the maximum positive value */ + input=(LVM_INT32) 0x7fffffff; + } + else + { + /* Negative input, so invert */ + input = (LVM_INT32)(-input); + } + } + return input; +} + diff --git a/media/libeffects/lvm/lib/Common/src/Add2_Sat_16x16.c b/media/libeffects/lvm/lib/Common/src/Add2_Sat_16x16.c new file mode 100755 index 0000000..18026c5 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/Add2_Sat_16x16.c @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************************** + + $Author: beq07716 $ + $Revision: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION ADD2_SAT_16X16 +***********************************************************************************/ + +void Add2_Sat_16x16( const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n ) +{ + LVM_INT32 Temp; + LVM_INT16 ii; + for (ii = n; ii != 0; ii--) + { + Temp = ((LVM_INT32) *src) + ((LVM_INT32) *dst); + src++; + + if (Temp > 0x00007FFF) + { + *dst = 0x7FFF; + } + else if (Temp < -0x00008000) + { + *dst = - 0x8000; + } + else + { + *dst = (LVM_INT16)Temp; + } + dst++; + } + return; +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/Add2_Sat_32x32.c b/media/libeffects/lvm/lib/Common/src/Add2_Sat_32x32.c new file mode 100755 index 0000000..96fc7e6 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/Add2_Sat_32x32.c @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + + +/********************************************************************************** + FUNCTION ADD2_SAT_32X32 +***********************************************************************************/ + +void Add2_Sat_32x32( const LVM_INT32 *src, + LVM_INT32 *dst, + LVM_INT16 n ) +{ + LVM_INT32 a,b,c; + LVM_INT16 ii; + for (ii = n; ii != 0; ii--) + { + a=*src; + src++; + + b=*dst; + c=a+b; + if ((((c ^ a) & (c ^ b)) >> 31)!=0) /* overflow / underflow */ + { + if(a<0) + { + c=0x80000000l; + } + else + { + c=0x7FFFFFFFl; + } + } + + *dst = c; + dst++; + } + return; +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/BP_1I_D16F16C14_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/BP_1I_D16F16C14_TRC_WRA_01.c new file mode 100755 index 0000000..76d8e42 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BP_1I_D16F16C14_TRC_WRA_01.c @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "BP_1I_D16F16Css_TRC_WRA_01_Private.h" +#include "LVM_Macros.h" + + +/************************************************************************** + ASSUMPTIONS: + COEFS- + pBiquadState->coefs[0] is A0, + pBiquadState->coefs[1] is -B2, + pBiquadState->coefs[2] is -B1, these are in Q14 format + + DELAYS- + pBiquadState->pDelays[0] is x(n-1)L in Q0 format + pBiquadState->pDelays[1] is x(n-2)L in Q0 format + pBiquadState->pDelays[2] is y(n-1)L in Q0 format + pBiquadState->pDelays[3] is y(n-2)L in Q0 format +***************************************************************************/ + +void BP_1I_D16F16C14_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples) + + + { + LVM_INT32 ynL; + LVM_INT16 ii; + PFilter_State pBiquadState = (PFilter_State) pInstance; + + for (ii = NrSamples; ii != 0; ii--) + { + + + /************************************************************************** + PROCESSING OF THE LEFT CHANNEL + ***************************************************************************/ + // ynL= (A0 (Q14) * (x(n)L (Q0) - x(n-2)L (Q0) ) ) in Q14 + ynL=(LVM_INT32)pBiquadState->coefs[0]* ((*pDataIn)-pBiquadState->pDelays[1]); + + // ynL+= ((-B2 (Q14) * y(n-2)L (Q0) ) ) in Q14 + ynL+=(LVM_INT32)pBiquadState->coefs[1]*pBiquadState->pDelays[3]; + + // ynL+= ((-B1 (Q30) * y(n-1)L (Q0) ) ) in Q14 + ynL+=(LVM_INT32)pBiquadState->coefs[2]*pBiquadState->pDelays[2]; + + ynL=(LVM_INT16)(ynL>>14); // ynL in Q0 + /************************************************************************** + UPDATING THE DELAYS + ***************************************************************************/ + pBiquadState->pDelays[3]=pBiquadState->pDelays[2]; // y(n-2)L=y(n-1)L + pBiquadState->pDelays[1]=pBiquadState->pDelays[0]; // x(n-2)L=x(n-1)L + pBiquadState->pDelays[2]=ynL; // Update y(n-1)L in Q0 + pBiquadState->pDelays[0]=(*pDataIn++); // Update x(n-1)L in Q0 + + /************************************************************************** + WRITING THE OUTPUT + ***************************************************************************/ + *pDataOut++=(LVM_INT16)ynL; // Write Left output in Q0 + + } + + } + diff --git a/media/libeffects/lvm/lib/Common/src/BP_1I_D16F16Css_TRC_WRA_01_Init.c b/media/libeffects/lvm/lib/Common/src/BP_1I_D16F16Css_TRC_WRA_01_Init.c new file mode 100755 index 0000000..9338eb2 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BP_1I_D16F16Css_TRC_WRA_01_Init.c @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/*-------------------------------------------------------------------------*/ +#include "BIQUAD.h" +#include "BP_1I_D16F16Css_TRC_WRA_01_Private.h" + + +/*-------------------------------------------------------------------------*/ +/* FUNCTION: */ +/* BP_1I_D16F16Css_TRC_WRA_01_Init */ +/* */ +/* DESCRIPTION: */ +/* These functions initializes a BIQUAD filter defined as a cascade of */ +/* biquadratic Filter Sections. */ +/* */ +/* PARAMETERS: */ +/* pInstance - output, returns the pointer to the State Variable */ +/* This state pointer must be passed to any subsequent */ +/* call to "Biquad" functions. */ +/* pTaps - input, pointer to the taps memory */ +/* pCoef - input, pointer to the coefficient structure */ +/* N - M coefficient factor of QM.N */ +/* RETURNS: */ +/* void return code */ +/*-------------------------------------------------------------------------*/ +void BP_1I_D16F16Css_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance, + Biquad_1I_Order2_Taps_t *pTaps, + BP_C16_Coefs_t *pCoef) +{ + PFilter_State pBiquadState = (PFilter_State) pInstance; + pBiquadState->pDelays =(LVM_INT32 *) pTaps; + + pBiquadState->coefs[0]=pCoef->A0; + pBiquadState->coefs[1]=pCoef->B2; + pBiquadState->coefs[2]=pCoef->B1; + } +/*-------------------------------------------------------------------------*/ +/* End Of File: BP_1I_D16F16Css_TRC_WRA_01_Init.c */ + diff --git a/media/libeffects/lvm/lib/Common/src/BP_1I_D16F16Css_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/BP_1I_D16F16Css_TRC_WRA_01_Private.h new file mode 100755 index 0000000..2a0d7d5 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BP_1I_D16F16Css_TRC_WRA_01_Private.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef _BP_1I_D16F16CSS_TRC_WRA_01_PRIVATE_H_ +#define _BP_1I_D16F16CSS_TRC_WRA_01_PRIVATE_H_ +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/* The internal state variables are implemented in a (for the user) hidden structure */ +/* In this (private) file, the internal structure is declared fro private use. */ +typedef struct _Filter_State_ +{ + LVM_INT32 * pDelays; /* pointer to the delayed samples (data of 32 bits) */ + LVM_INT32 coefs[3]; /* pointer to the filter coefficients */ +}Filter_State; + +typedef Filter_State * PFilter_State ; + +#endif /*_BP_1I_D16F16CSS_TRC_WRA_01_PRIVATE_H_*/ diff --git a/media/libeffects/lvm/lib/Common/src/BP_1I_D16F32C30_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/BP_1I_D16F32C30_TRC_WRA_01.c new file mode 100755 index 0000000..f52d3db --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BP_1I_D16F32C30_TRC_WRA_01.c @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "BP_1I_D16F32Cll_TRC_WRA_01_Private.h" +#include "LVM_Macros.h" + + +/************************************************************************** + ASSUMPTIONS: + COEFS- + pBiquadState->coefs[0] is A0, + pBiquadState->coefs[1] is -B2, + pBiquadState->coefs[2] is -B1, these are in Q30 format + + DELAYS- + pBiquadState->pDelays[0] is x(n-1)L in Q0 format + pBiquadState->pDelays[1] is x(n-2)L in Q0 format + pBiquadState->pDelays[2] is y(n-1)L in Q16 format + pBiquadState->pDelays[3] is y(n-2)L in Q16 format +***************************************************************************/ + +void BP_1I_D16F32C30_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples) + + + { + LVM_INT32 ynL,templ; + LVM_INT16 ii; + PFilter_State pBiquadState = (PFilter_State) pInstance; + + for (ii = NrSamples; ii != 0; ii--) + { + + + /************************************************************************** + PROCESSING OF THE LEFT CHANNEL + ***************************************************************************/ + // ynL= (A0 (Q30) * (x(n)L (Q0) - x(n-2)L (Q0) ) >>14) in Q16 + templ= (LVM_INT32) *pDataIn-pBiquadState->pDelays[1]; + MUL32x32INTO32(pBiquadState->coefs[0],templ,ynL,14) + + // ynL+= ((-B2 (Q30) * y(n-2)L (Q16) ) >>30) in Q16 + MUL32x32INTO32(pBiquadState->coefs[1],pBiquadState->pDelays[3],templ,30) + ynL+=templ; + + // ynL+= ((-B1 (Q30) * y(n-1)L (Q16) ) >>30) in Q16 + MUL32x32INTO32(pBiquadState->coefs[2],pBiquadState->pDelays[2],templ,30) + ynL+=templ; + + /************************************************************************** + UPDATING THE DELAYS + ***************************************************************************/ + pBiquadState->pDelays[3]=pBiquadState->pDelays[2]; // y(n-2)L=y(n-1)L + pBiquadState->pDelays[1]=pBiquadState->pDelays[0]; // x(n-2)L=x(n-1)L + pBiquadState->pDelays[2]=ynL; // Update y(n-1)L in Q16 + pBiquadState->pDelays[0]=(*pDataIn++); // Update x(n-1)L in Q0 + + /************************************************************************** + WRITING THE OUTPUT + ***************************************************************************/ + *pDataOut++=(LVM_INT16)(ynL>>16); // Write Left output in Q0 + + } + + } + diff --git a/media/libeffects/lvm/lib/Common/src/BP_1I_D16F32Cll_TRC_WRA_01_Init.c b/media/libeffects/lvm/lib/Common/src/BP_1I_D16F32Cll_TRC_WRA_01_Init.c new file mode 100755 index 0000000..c560085 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BP_1I_D16F32Cll_TRC_WRA_01_Init.c @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/*-------------------------------------------------------------------------*/ +#include "BIQUAD.h" +#include "BP_1I_D16F32Cll_TRC_WRA_01_Private.h" + + +/*-------------------------------------------------------------------------*/ +/* FUNCTION: */ +/* BP_1I_D16F32Cll_TRC_WRA_01_Init */ +/* */ +/* DESCRIPTION: */ +/* These functions initializes a Band pass filter (BIQUAD) */ +/* biquadratic Filter Sections. */ +/* */ +/* PARAMETERS: */ +/* pInstance - output, returns the pointer to the State Variable */ +/* This state pointer must be passed to any subsequent */ +/* call to "Biquad" functions. */ +/* pTaps - input, pointer to the taps memory */ +/* pCoef - input, pointer to the coefficient structure */ +/* N - M coefficient factor of QM.N */ +/* */ +/* The coefficients are modified in the init() function such that lower */ +/* half word is right shifted by one and most significant bit of the lower */ +/* word is made to be zero. */ +/* */ +/* Reason: For MIPS effciency,we are using DSP 32*16 multiplication */ +/* instruction. But we have 32*32 multiplication. This can be realized by two 32*16 */ +/* multiplication. But 16th bit in the 32 bit word is not a sign bit. So this is done */ +/* by putting 16th bit to zero and lossing one bit precision by division of lower */ +/* half word by 2. */ +/* RETURNS: */ +/* void return code */ +/*-------------------------------------------------------------------------*/ +void BP_1I_D16F32Cll_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance, + Biquad_1I_Order2_Taps_t *pTaps, + BP_C32_Coefs_t *pCoef) +{ + PFilter_State pBiquadState = (PFilter_State) pInstance; + pBiquadState->pDelays =(LVM_INT32 *) pTaps; + + pBiquadState->coefs[0] = pCoef->A0; + pBiquadState->coefs[1] = pCoef->B2; + pBiquadState->coefs[2] = pCoef->B1; +} +/*-------------------------------------------------------------------------*/ +/* End Of File: BP_1I_D16F32Cll_TRC_WRA_01_Init.c */ + diff --git a/media/libeffects/lvm/lib/Common/src/BP_1I_D16F32Cll_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/BP_1I_D16F32Cll_TRC_WRA_01_Private.h new file mode 100755 index 0000000..76777f6 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BP_1I_D16F32Cll_TRC_WRA_01_Private.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef _BP_1I_D16F32CLL_TRC_WRA_01_PRIVATE_H_ +#define _BP_1I_D16F32CLL_TRC_WRA_01_PRIVATE_H_ +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/* The internal state variables are implemented in a (for the user) hidden structure */ +/* In this (private) file, the internal structure is declared fro private use. */ +typedef struct _Filter_State_ +{ + LVM_INT32 * pDelays; /* pointer to the delayed samples (data of 32 bits) */ + LVM_INT32 coefs[3]; /* pointer to the filter coefficients */ +}Filter_State; + +typedef Filter_State * PFilter_State ; + +#endif /*_BP_1I_D16F32CLL_TRC_WRA_01_PRIVATE_H_*/ diff --git a/media/libeffects/lvm/lib/Common/src/BP_1I_D32F32C30_TRC_WRA_02.c b/media/libeffects/lvm/lib/Common/src/BP_1I_D32F32C30_TRC_WRA_02.c new file mode 100755 index 0000000..2b3555f --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BP_1I_D32F32C30_TRC_WRA_02.c @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "BP_1I_D32F32Cll_TRC_WRA_02_Private.h" +#include "LVM_Macros.h" + + +/************************************************************************** + ASSUMPTIONS: + COEFS- + pBiquadState->coefs[0] is A0, + pBiquadState->coefs[1] is -B2, + pBiquadState->coefs[2] is -B1, these are in Q30 format + + DELAYS- + pBiquadState->pDelays[0] is x(n-1)L in Q0 format + pBiquadState->pDelays[1] is x(n-2)L in Q0 format + pBiquadState->pDelays[2] is y(n-1)L in Q0 format + pBiquadState->pDelays[3] is y(n-2)L in Q0 format +***************************************************************************/ + +void BP_1I_D32F32C30_TRC_WRA_02 ( Biquad_Instance_t *pInstance, + LVM_INT32 *pDataIn, + LVM_INT32 *pDataOut, + LVM_INT16 NrSamples) + { + LVM_INT32 ynL,templ; + LVM_INT16 ii; + PFilter_State pBiquadState = (PFilter_State) pInstance; + + for (ii = NrSamples; ii != 0; ii--) + { + + + /************************************************************************** + PROCESSING OF THE LEFT CHANNEL + ***************************************************************************/ + // ynL= (A0 (Q30) * (x(n)L (Q0) - x(n-2)L (Q0) ) >>30) in Q0 + templ=(*pDataIn)-pBiquadState->pDelays[1]; + MUL32x32INTO32(pBiquadState->coefs[0],templ,ynL,30) + + // ynL+= ((-B2 (Q30) * y(n-2)L (Q0) ) >>30) in Q0 + MUL32x32INTO32(pBiquadState->coefs[1],pBiquadState->pDelays[3],templ,30) + ynL+=templ; + + // ynL+= ((-B1 (Q30) * y(n-1)L (Q0) ) >>30) in Q0 + MUL32x32INTO32(pBiquadState->coefs[2],pBiquadState->pDelays[2],templ,30) + ynL+=templ; + + /************************************************************************** + UPDATING THE DELAYS + ***************************************************************************/ + pBiquadState->pDelays[3]=pBiquadState->pDelays[2]; // y(n-2)L=y(n-1)L + pBiquadState->pDelays[1]=pBiquadState->pDelays[0]; // x(n-2)L=x(n-1)L + pBiquadState->pDelays[2]=ynL; // Update y(n-1)L in Q0 + pBiquadState->pDelays[0]=(*pDataIn++); // Update x(n-1)L in Q0 + + /************************************************************************** + WRITING THE OUTPUT + ***************************************************************************/ + *pDataOut++=ynL; // Write Left output in Q0 + + } + + } + diff --git a/media/libeffects/lvm/lib/Common/src/BP_1I_D32F32Cll_TRC_WRA_02_Init.c b/media/libeffects/lvm/lib/Common/src/BP_1I_D32F32Cll_TRC_WRA_02_Init.c new file mode 100755 index 0000000..f3f4571 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BP_1I_D32F32Cll_TRC_WRA_02_Init.c @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/*-------------------------------------------------------------------------*/ +#include "BIQUAD.h" +#include "BP_1I_D32F32Cll_TRC_WRA_02_Private.h" + +/*-------------------------------------------------------------------------*/ +/* FUNCTION: */ +/* BP_1I_D32F32Cll_TRC_WRA_02_Init */ +/* */ +/* DESCRIPTION: */ +/* These functions initializes a BIQUAD filter defined as a cascade of */ +/* biquadratic Filter Sections. */ +/* */ +/* PARAMETERS: */ +/* pInstance - output, returns the pointer to the State Variable */ +/* This state pointer must be passed to any subsequent */ +/* call to "Biquad" functions. */ +/* pTaps - input, pointer to the taps memory */ +/* pCoef - input, pointer to the coefficient structure */ +/* N - M coefficient factor of QM.N */ +/* RETURNS: */ +/* void return code */ +/*-------------------------------------------------------------------------*/ +void BP_1I_D32F32Cll_TRC_WRA_02_Init ( Biquad_Instance_t *pInstance, + Biquad_1I_Order2_Taps_t *pTaps, + BP_C32_Coefs_t *pCoef) +{ + PFilter_State pBiquadState = (PFilter_State) pInstance; + pBiquadState->pDelays =(LVM_INT32 *) pTaps; + + pBiquadState->coefs[0]=pCoef->A0; + + pBiquadState->coefs[1]=pCoef->B2; + + pBiquadState->coefs[2]=pCoef->B1; +} +/*-------------------------------------------------------------------------*/ +/* End Of File: BP_1I_D32F32Cll_TRC_WRA_02_Init.c */ + diff --git a/media/libeffects/lvm/lib/Common/src/BP_1I_D32F32Cll_TRC_WRA_02_Private.h b/media/libeffects/lvm/lib/Common/src/BP_1I_D32F32Cll_TRC_WRA_02_Private.h new file mode 100755 index 0000000..8884537 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BP_1I_D32F32Cll_TRC_WRA_02_Private.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef _BP_1I_D32F32CLL_TRC_WRA_02_PRIVATE_H_ +#define _BP_1I_D32F32CLL_TRC_WRA_02_PRIVATE_H_ +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/* The internal state variables are implemented in a (for the user) hidden structure */ +/* In this (private) file, the internal structure is declared fro private use. */ +typedef struct _Filter_State_ +{ + LVM_INT32 * pDelays; /* pointer to the delayed samples (data of 32 bits) */ + LVM_INT32 coefs[3]; /* pointer to the filter coefficients */ +}Filter_State; + +typedef Filter_State * PFilter_State ; + +#endif /*_BP_1I_D32F32CLL_TRC_WRA_02_PRIVATE_H_*/ diff --git a/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F16C15_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F16C15_TRC_WRA_01.c new file mode 100755 index 0000000..00e3b52 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F16C15_TRC_WRA_01.c @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "BQ_1I_D16F16Css_TRC_WRA_01_Private.h" +#include "LVM_Macros.h" + +/************************************************************************** + ASSUMPTIONS: + COEFS- + pBiquadState->coefs[0] is A2, pBiquadState->coefs[1] is A1 + pBiquadState->coefs[2] is A0, pBiquadState->coefs[3] is -B2 + pBiquadState->coefs[4] is -B1, these are in Q15 format + + DELAYS- + pBiquadState->pDelays[0] is x(n-1)L in Q0 format + pBiquadState->pDelays[1] is x(n-2)L in Q0 format + pBiquadState->pDelays[2] is y(n-1)L in Q0 format + pBiquadState->pDelays[3] is y(n-2)L in Q0 format +***************************************************************************/ + +void BQ_1I_D16F16C15_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples) + { + LVM_INT32 ynL; + LVM_INT16 ii; + PFilter_State pBiquadState = (PFilter_State) pInstance; + + for (ii = NrSamples; ii != 0; ii--) + { + + + /************************************************************************** + PROCESSING OF THE LEFT CHANNEL + ***************************************************************************/ + // ynL=A2 (Q15) * x(n-2)L (Q0) in Q15 + ynL=(LVM_INT32)pBiquadState->coefs[0]* pBiquadState->pDelays[1]; + + // ynL+=A1 (Q15) * x(n-1)L (Q0) in Q15 + ynL+=(LVM_INT32)pBiquadState->coefs[1]* pBiquadState->pDelays[0]; + + // ynL+=A0 (Q15) * x(n)L (Q0) in Q15 + ynL+=(LVM_INT32)pBiquadState->coefs[2]* (*pDataIn); + + // ynL+= (-B2 (Q15) * y(n-2)L (Q0) ) in Q15 + ynL+=(LVM_INT32)pBiquadState->coefs[3]*pBiquadState->pDelays[3]; + + // ynL+= (-B1 (Q15) * y(n-1)L (Q0) ) in Q15 + ynL+=(LVM_INT32)pBiquadState->coefs[4]*pBiquadState->pDelays[2]; + + ynL=ynL>>15; // ynL in Q0 format + /************************************************************************** + UPDATING THE DELAYS + ***************************************************************************/ + pBiquadState->pDelays[3]=pBiquadState->pDelays[2]; // y(n-2)L=y(n-1)L + pBiquadState->pDelays[1]=pBiquadState->pDelays[0]; // x(n-2)L=x(n-1)L + pBiquadState->pDelays[2]=ynL; // Update y(n-1)L in Q0 + pBiquadState->pDelays[0]=(*pDataIn++); // Update x(n-1)L in Q0 + + /************************************************************************** + WRITING THE OUTPUT + ***************************************************************************/ + *pDataOut++=(LVM_INT16)ynL; // Write Left output in Q0 + + + } + + } + diff --git a/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F16Css_TRC_WRA_01_Init.c b/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F16Css_TRC_WRA_01_Init.c new file mode 100755 index 0000000..3fedc45 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F16Css_TRC_WRA_01_Init.c @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/*-------------------------------------------------------------------------*/ +#include "BIQUAD.h" +#include "BQ_1I_D16F16Css_TRC_WRA_01_Private.h" + +/*-------------------------------------------------------------------------*/ +/* FUNCTION: */ +/* BQ_1I_D16F16Css_TRC_WRA_01_Init */ +/* */ +/* DESCRIPTION: */ +/* These functions initializes a BIQUAD filter defined as a cascade of */ +/* biquadratic Filter Sections. */ +/* */ +/* PARAMETERS: */ +/* pInstance - output, returns the pointer to the State Variable */ +/* This state pointer must be passed to any subsequent */ +/* call to "Biquad" functions. */ +/* pTaps - input, pointer to the taps memory */ +/* pCoef - input, pointer to the coefficient structure */ +/* N - M coefficient factor of QM.N */ +/* RETURNS: */ +/* void return code */ +/*-------------------------------------------------------------------------*/ +void BQ_1I_D16F16Css_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance, + Biquad_1I_Order2_Taps_t *pTaps, + BQ_C16_Coefs_t *pCoef) +{ + LVM_INT16 temp; + PFilter_State pBiquadState = (PFilter_State) pInstance; + pBiquadState->pDelays =(LVM_INT32 *) pTaps ; + + temp=pCoef->A2; + pBiquadState->coefs[0]=temp; + temp=pCoef->A1; + pBiquadState->coefs[1]=temp; + temp=pCoef->A0; + pBiquadState->coefs[2]=temp; + temp=pCoef->B2; + pBiquadState->coefs[3]=temp; + temp=pCoef->B1; + pBiquadState->coefs[4]=temp; +} +/*-------------------------------------------------------------------------*/ +/* End Of File: BQ_1I_D16F16Css_TRC_WRA_01_Init.c */ + diff --git a/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F16Css_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F16Css_TRC_WRA_01_Private.h new file mode 100755 index 0000000..18dacd3 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F16Css_TRC_WRA_01_Private.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef _BQ_1I_D16F16CSS_TRC_WRA_01_PRIVATE_H_ +#define _BQ_1I_D16F16CSS_TRC_WRA_01_PRIVATE_H_ +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/* The internal state variables are implemented in a (for the user) hidden structure */ +/* In this (private) file, the internal structure is declared fro private use. */ +typedef struct _Filter_State_ +{ + LVM_INT32 * pDelays; /* pointer to the delayed samples (data of 32 bits) */ + LVM_INT16 coefs[5]; /* pointer to the filter coefficients */ +}Filter_State; + +typedef Filter_State * PFilter_State ; + +#endif /*_BQ_1I_D16F16CSS_TRC_WRA_01_PRIVATE_H_ */ diff --git a/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F32C14_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F32C14_TRC_WRA_01.c new file mode 100755 index 0000000..cdff1d9 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F32C14_TRC_WRA_01.c @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "BQ_1I_D16F32Css_TRC_WRA_01_Private.h" +#include "LVM_Macros.h" + +/************************************************************************** + ASSUMPTIONS: + COEFS- + pBiquadState->coefs[0] is A2, pBiquadState->coefs[1] is A1 + pBiquadState->coefs[2] is A0, pBiquadState->coefs[3] is -B2 + pBiquadState->coefs[4] is -B1, these are in Q14 format + + DELAYS- + pBiquadState->pDelays[0] is x(n-1)L in Q0 format + pBiquadState->pDelays[1] is x(n-2)L in Q0 format + pBiquadState->pDelays[2] is y(n-1)L in Q16 format + pBiquadState->pDelays[3] is y(n-2)L in Q16 format +***************************************************************************/ + +void BQ_1I_D16F32C14_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples) + { + LVM_INT32 ynL,templ; + LVM_INT16 ii; + PFilter_State pBiquadState = (PFilter_State) pInstance; + + for (ii = NrSamples; ii != 0; ii--) + { + + + /************************************************************************** + PROCESSING OF THE LEFT CHANNEL + ***************************************************************************/ + // ynL=A2 (Q14) * x(n-2)L (Q0) in Q14 + ynL=(LVM_INT32)pBiquadState->coefs[0]* pBiquadState->pDelays[1]; + + // ynL+=A1 (Q14) * x(n-1)L (Q0) in Q14 + ynL+=(LVM_INT32)pBiquadState->coefs[1]* pBiquadState->pDelays[0]; + + // ynL+=A0 (Q14) * x(n)L (Q0) in Q14 + ynL+=(LVM_INT32)pBiquadState->coefs[2]* (*pDataIn); + + // ynL+= ( (-B2 (Q14) * y(n-2)L (Q16) )>>16) in Q14 + MUL32x16INTO32(pBiquadState->pDelays[3],pBiquadState->coefs[3],templ,16) + ynL+=templ; + + // ynL+= ( (-B1 (Q14) * y(n-1)L (Q16) )>>16) in Q14 + MUL32x16INTO32(pBiquadState->pDelays[2],pBiquadState->coefs[4],templ,16) + ynL+=templ; + + /************************************************************************** + UPDATING THE DELAYS + ***************************************************************************/ + pBiquadState->pDelays[3]=pBiquadState->pDelays[2]; // y(n-2)L=y(n-1)L + pBiquadState->pDelays[1]=pBiquadState->pDelays[0]; // x(n-2)L=x(n-1)L + pBiquadState->pDelays[2]=ynL<<2; // Update y(n-1)L in Q16 + pBiquadState->pDelays[0]=(*pDataIn++); // Update x(n-1)L in Q0 + + /************************************************************************** + WRITING THE OUTPUT + ***************************************************************************/ + *pDataOut++=(LVM_INT16)(ynL>>14); // Write Left output in Q0 + + } + } + diff --git a/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F32Css_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F32Css_TRC_WRA_01_Private.h new file mode 100755 index 0000000..bc88847 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F32Css_TRC_WRA_01_Private.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef _BQ_1I_D16F32CSS_TRC_WRA_01_PRIVATE_H_ +#define _BQ_1I_D16F32CSS_TRC_WRA_01_PRIVATE_H_ +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/* The internal state variables are implemented in a (for the user) hidden structure */ +/* In this (private) file, the internal structure is declared fro private use. */ +typedef struct _Filter_State_ +{ + LVM_INT32 * pDelays; /* pointer to the delayed samples (data of 32 bits) */ + LVM_INT16 coefs[5]; /* pointer to the filter coefficients */ +}Filter_State; + +typedef Filter_State * PFilter_State ; + +#endif /*_BQ_1I_D16F32CSS_TRC_WRA_01_PRIVATE_H_*/ diff --git a/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F32Css_TRC_WRA_01_init.c b/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F32Css_TRC_WRA_01_init.c new file mode 100755 index 0000000..520c969 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BQ_1I_D16F32Css_TRC_WRA_01_init.c @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/*-------------------------------------------------------------------------*/ +#include "BIQUAD.h" +#include "BQ_1I_D16F32Css_TRC_WRA_01_Private.h" + + +/*-------------------------------------------------------------------------*/ +/* FUNCTION: */ +/* BQ_1I_D16F32Css_TRC_WRA_01_Init */ +/* */ +/* DESCRIPTION: */ +/* These functions initializes a BIQUAD filter defined as a cascade of */ +/* biquadratic Filter Sections. */ +/* */ +/* PARAMETERS: */ +/* pInstance - output, returns the pointer to the State Variable */ +/* This state pointer must be passed to any subsequent */ +/* call to "Biquad" functions. */ +/* pTaps - input, pointer to the taps memory */ +/* pCoef - input, pointer to the coefficient structure */ +/* N - M coefficient factor of QM.N */ +/* RETURNS: */ +/* void return code */ +/*-------------------------------------------------------------------------*/ +void BQ_1I_D16F32Css_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance, + Biquad_1I_Order2_Taps_t *pTaps, + BQ_C16_Coefs_t *pCoef) +{ + LVM_INT16 temp; + PFilter_State pBiquadState = (PFilter_State) pInstance; + pBiquadState->pDelays =(LVM_INT32 *) pTaps ; + + temp=pCoef->A2; + pBiquadState->coefs[0]=temp; + temp=pCoef->A1; + pBiquadState->coefs[1]=temp; + temp=pCoef->A0; + pBiquadState->coefs[2]=temp; + temp=pCoef->B2; + pBiquadState->coefs[3]=temp; + temp=pCoef->B1; + pBiquadState->coefs[4]=temp; +} +/*-------------------------------------------------------------------------*/ +/* End Of File: BQ_1I_D16F32Css_TRC_WRA_01_Init */ + diff --git a/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16C14_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16C14_TRC_WRA_01.c new file mode 100755 index 0000000..c267a90 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16C14_TRC_WRA_01.c @@ -0,0 +1,123 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "BQ_2I_D16F16Css_TRC_WRA_01_Private.h" +#include "LVM_Macros.h" + + +/************************************************************************** + ASSUMPTIONS: + COEFS- + pBiquadState->coefs[0] is A2, pBiquadState->coefs[1] is A1 + pBiquadState->coefs[2] is A0, pBiquadState->coefs[3] is -B2 + pBiquadState->coefs[4] is -B1, these are in Q14 format + + DELAYS- + pBiquadState->pDelays[0] is x(n-1)L in Q0 format + pBiquadState->pDelays[1] is x(n-1)R in Q0 format + pBiquadState->pDelays[2] is x(n-2)L in Q0 format + pBiquadState->pDelays[3] is x(n-2)R in Q0 format + pBiquadState->pDelays[4] is y(n-1)L in Q0 format + pBiquadState->pDelays[5] is y(n-1)R in Q0 format + pBiquadState->pDelays[6] is y(n-2)L in Q0 format + pBiquadState->pDelays[7] is y(n-2)R in Q0 format +***************************************************************************/ + +void BQ_2I_D16F16C14_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples) + { + LVM_INT32 ynL,ynR; + LVM_INT16 ii; + PFilter_State pBiquadState = (PFilter_State) pInstance; + + for (ii = NrSamples; ii != 0; ii--) + { + + /************************************************************************** + PROCESSING OF THE LEFT CHANNEL + ***************************************************************************/ + // ynL=A2 (Q14) * x(n-2)L (Q0) in Q14 + ynL=(LVM_INT32)pBiquadState->coefs[0]* pBiquadState->pDelays[2]; + + // ynL+=A1 (Q14) * x(n-1)L (Q0) in Q14 + ynL+=(LVM_INT32)pBiquadState->coefs[1]* pBiquadState->pDelays[0]; + + // ynL+=A0 (Q14) * x(n)L (Q0) in Q14 + ynL+=(LVM_INT32)pBiquadState->coefs[2]* (*pDataIn); + + // ynL+= ( -B2 (Q14) * y(n-2)L (Q0) ) in Q14 + ynL+=(LVM_INT32)pBiquadState->coefs[3]*pBiquadState->pDelays[6]; + + // ynL+=( -B1 (Q14) * y(n-1)L (Q0) ) in Q14 + ynL+=(LVM_INT32)pBiquadState->coefs[4]*pBiquadState->pDelays[4]; + + ynL=ynL>>14; // ynL in Q0 format + + /************************************************************************** + PROCESSING OF THE RIGHT CHANNEL + ***************************************************************************/ + // ynR=A2 (Q14) * x(n-2)R (Q0) in Q14 + ynR=(LVM_INT32)pBiquadState->coefs[0]*pBiquadState->pDelays[3]; + + // ynR+=A1 (Q14) * x(n-1)R (Q0) in Q14 + ynR+=(LVM_INT32)pBiquadState->coefs[1]*pBiquadState->pDelays[1]; + + // ynR+=A0 (Q14) * x(n)R (Q0) in Q14 + ynR+=(LVM_INT32)pBiquadState->coefs[2]*(*(pDataIn+1)); + + // ynR+= ( -B2 (Q14) * y(n-2)R (Q0) ) in Q14 + ynR+=(LVM_INT32)pBiquadState->coefs[3]*pBiquadState->pDelays[7]; + + // ynR+=( -B1 (Q14) * y(n-1)R (Q0) ) in Q14 + ynR+=(LVM_INT32)pBiquadState->coefs[4]*pBiquadState->pDelays[5]; + + ynR=ynR>>14; // ynL in Q0 format + /************************************************************************** + UPDATING THE DELAYS + ***************************************************************************/ + pBiquadState->pDelays[7]=pBiquadState->pDelays[5]; // y(n-2)R=y(n-1)R + pBiquadState->pDelays[6]=pBiquadState->pDelays[4]; // y(n-2)L=y(n-1)L + pBiquadState->pDelays[3]=pBiquadState->pDelays[1]; // x(n-2)R=x(n-1)R + pBiquadState->pDelays[2]=pBiquadState->pDelays[0]; // x(n-2)L=x(n-1)L + pBiquadState->pDelays[5]=ynR; // Update y(n-1)R in Q0 + pBiquadState->pDelays[4]=ynL; // Update y(n-1)L in Q0 + pBiquadState->pDelays[0]=(*pDataIn++); // Update x(n-1)L in Q0 + pBiquadState->pDelays[1]=(*pDataIn++); // Update x(n-1)R in Q0 + + /************************************************************************** + WRITING THE OUTPUT + ***************************************************************************/ + *pDataOut++=(LVM_INT16)ynL; // Write Left output in Q0 + *pDataOut++=(LVM_INT16)ynR; // Write Right ouput in Q0 + + + } + + } + diff --git a/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16C15_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16C15_TRC_WRA_01.c new file mode 100755 index 0000000..ded2bb3 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16C15_TRC_WRA_01.c @@ -0,0 +1,123 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "BQ_2I_D16F16Css_TRC_WRA_01_Private.h" +#include "LVM_Macros.h" + + +/************************************************************************** + ASSUMPTIONS: + COEFS- + pBiquadState->coefs[0] is A2, pBiquadState->coefs[1] is A1 + pBiquadState->coefs[2] is A0, pBiquadState->coefs[3] is -B2 + pBiquadState->coefs[4] is -B1, these are in Q15 format + + DELAYS- + pBiquadState->pDelays[0] is x(n-1)L in Q0 format + pBiquadState->pDelays[1] is x(n-1)R in Q0 format + pBiquadState->pDelays[2] is x(n-2)L in Q0 format + pBiquadState->pDelays[3] is x(n-2)R in Q0 format + pBiquadState->pDelays[4] is y(n-1)L in Q0 format + pBiquadState->pDelays[5] is y(n-1)R in Q0 format + pBiquadState->pDelays[6] is y(n-2)L in Q0 format + pBiquadState->pDelays[7] is y(n-2)R in Q0 format +***************************************************************************/ + +void BQ_2I_D16F16C15_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples) + { + LVM_INT32 ynL,ynR; + LVM_INT16 ii; + PFilter_State pBiquadState = (PFilter_State) pInstance; + + for (ii = NrSamples; ii != 0; ii--) + { + + + /************************************************************************** + PROCESSING OF THE LEFT CHANNEL + ***************************************************************************/ + // ynL=A2 (Q15) * x(n-2)L (Q0) in Q15 + ynL=(LVM_INT32)pBiquadState->coefs[0]* pBiquadState->pDelays[2]; + + // ynL+=A1 (Q15) * x(n-1)L (Q0) in Q15 + ynL+=(LVM_INT32)pBiquadState->coefs[1]* pBiquadState->pDelays[0]; + + // ynL+=A0 (Q15) * x(n)L (Q0) in Q15 + ynL+=(LVM_INT32)pBiquadState->coefs[2]* (*pDataIn); + + // ynL+= ( -B2 (Q15) * y(n-2)L (Q0) ) in Q15 + ynL+=(LVM_INT32)pBiquadState->coefs[3]*pBiquadState->pDelays[6]; + + // ynL+=( -B1 (Q15) * y(n-1)L (Q0) ) in Q15 + ynL+=(LVM_INT32)pBiquadState->coefs[4]*pBiquadState->pDelays[4]; + + ynL=ynL>>15; // ynL in Q0 format + + /************************************************************************** + PROCESSING OF THE RIGHT CHANNEL + ***************************************************************************/ + // ynR=A2 (Q15) * x(n-2)R (Q0) in Q15 + ynR=(LVM_INT32)pBiquadState->coefs[0]*pBiquadState->pDelays[3]; + + // ynR+=A1 (Q15) * x(n-1)R (Q0) in Q15 + ynR+=(LVM_INT32)pBiquadState->coefs[1]*pBiquadState->pDelays[1]; + + // ynR+=A0 (Q15) * x(n)R (Q0) in Q15 + ynR+=(LVM_INT32)pBiquadState->coefs[2]*(*(pDataIn+1)); + + // ynR+= ( -B2 (Q15) * y(n-2)R (Q0) ) in Q15 + ynR+=(LVM_INT32)pBiquadState->coefs[3]*pBiquadState->pDelays[7]; + + // ynR+=( -B1 (Q15) * y(n-1)R (Q0) ) in Q15 + ynR+=(LVM_INT32)pBiquadState->coefs[4]*pBiquadState->pDelays[5]; + + ynR=ynR>>15; // ynL in Q0 format + /************************************************************************** + UPDATING THE DELAYS + ***************************************************************************/ + pBiquadState->pDelays[7]=pBiquadState->pDelays[5]; // y(n-2)R=y(n-1)R + pBiquadState->pDelays[6]=pBiquadState->pDelays[4]; // y(n-2)L=y(n-1)L + pBiquadState->pDelays[3]=pBiquadState->pDelays[1]; // x(n-2)R=x(n-1)R + pBiquadState->pDelays[2]=pBiquadState->pDelays[0]; // x(n-2)L=x(n-1)L + pBiquadState->pDelays[5]=ynR; // Update y(n-1)R in Q0 + pBiquadState->pDelays[4]=ynL; // Update y(n-1)L in Q0 + pBiquadState->pDelays[0]=(*pDataIn++); // Update x(n-1)L in Q0 + pBiquadState->pDelays[1]=(*pDataIn++); // Update x(n-1)R in Q0 + + /************************************************************************** + WRITING THE OUTPUT + ***************************************************************************/ + *pDataOut++=(LVM_INT16)ynL; // Write Left output in Q0 + *pDataOut++=(LVM_INT16)ynR; // Write Right ouput in Q0 + + } + + } + diff --git a/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16Css_TRC_WRA_01_Init.c b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16Css_TRC_WRA_01_Init.c new file mode 100755 index 0000000..b0cd1b9 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16Css_TRC_WRA_01_Init.c @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/*-------------------------------------------------------------------------*/ +#include "BIQUAD.h" +#include "BQ_2I_D16F16Css_TRC_WRA_01_Private.h" + + +/*-------------------------------------------------------------------------*/ +/* FUNCTION: */ +/* BQ_2I_D16F16Css_TRC_WRA_01_Init */ +/* */ +/* DESCRIPTION: */ +/* These functions initializes a BIQUAD filter defined as a cascade of */ +/* biquadratic Filter Sections. */ +/* */ +/* PARAMETERS: */ +/* pInstance - output, returns the pointer to the State Variable */ +/* This state pointer must be passed to any subsequent */ +/* call to "Biquad" functions. */ +/* pTaps - input, pointer to the taps memory */ +/* pCoef - input, pointer to the coefficient structure */ +/* N - M coefficient factor of QM.N */ +/* RETURNS: */ +/* void return code */ +/*-------------------------------------------------------------------------*/ +void BQ_2I_D16F16Css_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance, + Biquad_2I_Order2_Taps_t *pTaps, + BQ_C16_Coefs_t *pCoef) +{ + LVM_INT16 temp; + PFilter_State pBiquadState = (PFilter_State) pInstance; + pBiquadState->pDelays =(LVM_INT32 *) pTaps ; + + temp=pCoef->A2; + pBiquadState->coefs[0]=temp; + temp=pCoef->A1; + pBiquadState->coefs[1]=temp; + temp=pCoef->A0; + pBiquadState->coefs[2]=temp; + temp=pCoef->B2; + pBiquadState->coefs[3]=temp; + temp=pCoef->B1; + pBiquadState->coefs[4]=temp; +} +/*-------------------------------------------------------------------------*/ +/* End Of File: BQ_2I_D16F16Css_TRC_WRA_01_Init.c */ + diff --git a/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16Css_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16Css_TRC_WRA_01_Private.h new file mode 100755 index 0000000..bcb0093 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F16Css_TRC_WRA_01_Private.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _BQ_2I_D16F16CSS_TRC_WRA_01_PRIVATE_H_ +#define _BQ_2I_D16F16CSS_TRC_WRA_01_PRIVATE_H_ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/* The internal state variables are implemented in a (for the user) hidden structure */ +/* In this (private) file, the internal structure is declared fro private use. */ +typedef struct _Filter_State_ +{ + LVM_INT32 * pDelays; /* pointer to the delayed samples (data of 32 bits) */ + LVM_INT16 coefs[5]; /* pointer to the filter coefficients */ +}Filter_State; + +typedef Filter_State * PFilter_State ; + +#endif /* _BQ_2I_D16F16CSS_TRC_WRA_01_PRIVATE_H_ */ diff --git a/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32C13_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32C13_TRC_WRA_01.c new file mode 100755 index 0000000..ae743f2 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32C13_TRC_WRA_01.c @@ -0,0 +1,127 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "BQ_2I_D16F32Css_TRC_WRA_01_Private.h" +#include "LVM_Macros.h" + + +/************************************************************************** + ASSUMPTIONS: + COEFS- + pBiquadState->coefs[0] is A2, pBiquadState->coefs[1] is A1 + pBiquadState->coefs[2] is A0, pBiquadState->coefs[3] is -B2 + pBiquadState->coefs[4] is -B1, these are in Q13 format + + DELAYS- + pBiquadState->pDelays[0] is x(n-1)L in Q0 format + pBiquadState->pDelays[1] is x(n-1)R in Q0 format + pBiquadState->pDelays[2] is x(n-2)L in Q0 format + pBiquadState->pDelays[3] is x(n-2)R in Q0 format + pBiquadState->pDelays[4] is y(n-1)L in Q16 format + pBiquadState->pDelays[5] is y(n-1)R in Q16 format + pBiquadState->pDelays[6] is y(n-2)L in Q16 format + pBiquadState->pDelays[7] is y(n-2)R in Q16 format +***************************************************************************/ + +void BQ_2I_D16F32C13_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples) + { + LVM_INT32 ynL,ynR,templ; + LVM_INT16 ii; + PFilter_State pBiquadState = (PFilter_State) pInstance; + + for (ii = NrSamples; ii != 0; ii--) + { + + + /************************************************************************** + PROCESSING OF THE LEFT CHANNEL + ***************************************************************************/ + /* ynL=A2 (Q13) * x(n-2)L (Q0) in Q13*/ + ynL=(LVM_INT32)pBiquadState->coefs[0]* pBiquadState->pDelays[2]; + + /* ynL+=A1 (Q13) * x(n-1)L (Q0) in Q13*/ + ynL+=(LVM_INT32)pBiquadState->coefs[1]* pBiquadState->pDelays[0]; + + /* ynL+=A0 (Q13) * x(n)L (Q0) in Q13*/ + ynL+=(LVM_INT32)pBiquadState->coefs[2]* (*pDataIn); + + /* ynL+= ( (-B2 (Q13) * y(n-2)L (Q16) )>>16) in Q13 */ + MUL32x16INTO32(pBiquadState->pDelays[6],pBiquadState->coefs[3],templ,16) + ynL+=templ; + + /* ynL+=( (-B1 (Q13) * y(n-1)L (Q16) )>>16) in Q13 */ + MUL32x16INTO32(pBiquadState->pDelays[4],pBiquadState->coefs[4],templ,16) + ynL+=templ; + + /************************************************************************** + PROCESSING OF THE RIGHT CHANNEL + ***************************************************************************/ + /* ynR=A2 (Q13) * x(n-2)R (Q0) in Q13*/ + ynR=(LVM_INT32)pBiquadState->coefs[0]*pBiquadState->pDelays[3]; + + /* ynR+=A1 (Q13) * x(n-1)R (Q0) in Q13*/ + ynR+=(LVM_INT32)pBiquadState->coefs[1]*pBiquadState->pDelays[1]; + + /* ynR+=A0 (Q13) * x(n)R (Q0) in Q13*/ + ynR+=(LVM_INT32)pBiquadState->coefs[2]*(*(pDataIn+1)); + + /* ynR+= ( (-B2 (Q13) * y(n-2)R (Q16) )>>16) in Q13*/ + MUL32x16INTO32(pBiquadState->pDelays[7],pBiquadState->coefs[3],templ,16) + ynR+=templ; + + /* ynR+=( (-B1 (Q13) * y(n-1)R (Q16) )>>16) in Q13 */ + MUL32x16INTO32(pBiquadState->pDelays[5],pBiquadState->coefs[4],templ,16) + ynR+=templ; + + /************************************************************************** + UPDATING THE DELAYS + ***************************************************************************/ + pBiquadState->pDelays[7]=pBiquadState->pDelays[5]; /* y(n-2)R=y(n-1)R*/ + pBiquadState->pDelays[6]=pBiquadState->pDelays[4]; /* y(n-2)L=y(n-1)L*/ + pBiquadState->pDelays[3]=pBiquadState->pDelays[1]; /* x(n-2)R=x(n-1)R*/ + pBiquadState->pDelays[2]=pBiquadState->pDelays[0]; /* x(n-2)L=x(n-1)L*/ + pBiquadState->pDelays[5]=ynR<<3; /* Update y(n-1)R in Q16*/ + pBiquadState->pDelays[4]=ynL<<3; /* Update y(n-1)L in Q16*/ + pBiquadState->pDelays[0]=(*pDataIn); /* Update x(n-1)L in Q0*/ + pDataIn++; + pBiquadState->pDelays[1]=(*pDataIn); /* Update x(n-1)R in Q0*/ + pDataIn++; + + /************************************************************************** + WRITING THE OUTPUT + ***************************************************************************/ + *pDataOut=(LVM_INT16)(ynL>>13); /* Write Left output in Q0*/ + pDataOut++; + *pDataOut=(LVM_INT16)(ynR>>13); /* Write Right ouput in Q0*/ + pDataOut++; + } + + } + diff --git a/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32C14_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32C14_TRC_WRA_01.c new file mode 100755 index 0000000..a0ca2cc --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32C14_TRC_WRA_01.c @@ -0,0 +1,126 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "BQ_2I_D16F32Css_TRC_WRA_01_Private.h" +#include "LVM_Macros.h" + +/************************************************************************** + ASSUMPTIONS: + COEFS- + pBiquadState->coefs[0] is A2, pBiquadState->coefs[1] is A1 + pBiquadState->coefs[2] is A0, pBiquadState->coefs[3] is -B2 + pBiquadState->coefs[4] is -B1, these are in Q14 format + + DELAYS- + pBiquadState->pDelays[0] is x(n-1)L in Q0 format + pBiquadState->pDelays[1] is x(n-1)R in Q0 format + pBiquadState->pDelays[2] is x(n-2)L in Q0 format + pBiquadState->pDelays[3] is x(n-2)R in Q0 format + pBiquadState->pDelays[4] is y(n-1)L in Q16 format + pBiquadState->pDelays[5] is y(n-1)R in Q16 format + pBiquadState->pDelays[6] is y(n-2)L in Q16 format + pBiquadState->pDelays[7] is y(n-2)R in Q16 format +***************************************************************************/ + +void BQ_2I_D16F32C14_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples) + { + LVM_INT32 ynL,ynR,templ; + LVM_INT16 ii; + PFilter_State pBiquadState = (PFilter_State) pInstance; + + for (ii = NrSamples; ii != 0; ii--) + { + + + /************************************************************************** + PROCESSING OF THE LEFT CHANNEL + ***************************************************************************/ + /* ynL=A2 (Q14) * x(n-2)L (Q0) in Q14*/ + ynL=(LVM_INT32)pBiquadState->coefs[0]* pBiquadState->pDelays[2]; + + /* ynL+=A1 (Q14) * x(n-1)L (Q0) in Q14*/ + ynL+=(LVM_INT32)pBiquadState->coefs[1]* pBiquadState->pDelays[0]; + + /* ynL+=A0 (Q14) * x(n)L (Q0) in Q14*/ + ynL+=(LVM_INT32)pBiquadState->coefs[2]* (*pDataIn); + + /* ynL+= ( (-B2 (Q14) * y(n-2)L (Q16) )>>16) in Q14 */ + MUL32x16INTO32(pBiquadState->pDelays[6],pBiquadState->coefs[3],templ,16) + ynL+=templ; + + /* ynL+=( (-B1 (Q14) * y(n-1)L (Q16) )>>16) in Q14 */ + MUL32x16INTO32(pBiquadState->pDelays[4],pBiquadState->coefs[4],templ,16) + ynL+=templ; + + /************************************************************************** + PROCESSING OF THE RIGHT CHANNEL + ***************************************************************************/ + /* ynR=A2 (Q14) * x(n-2)R (Q0) in Q14*/ + ynR=(LVM_INT32)pBiquadState->coefs[0]*pBiquadState->pDelays[3]; + + /* ynR+=A1 (Q14) * x(n-1)R (Q0) in Q14*/ + ynR+=(LVM_INT32)pBiquadState->coefs[1]*pBiquadState->pDelays[1]; + + /* ynR+=A0 (Q14) * x(n)R (Q0) in Q14*/ + ynR+=(LVM_INT32)pBiquadState->coefs[2]*(*(pDataIn+1)); + + /* ynR+= ( (-B2 (Q14) * y(n-2)R (Q16) )>>16) in Q14*/ + MUL32x16INTO32(pBiquadState->pDelays[7],pBiquadState->coefs[3],templ,16) + ynR+=templ; + + /* ynR+=( (-B1 (Q14) * y(n-1)R (Q16) )>>16) in Q14 */ + MUL32x16INTO32(pBiquadState->pDelays[5],pBiquadState->coefs[4],templ,16) + ynR+=templ; + + /************************************************************************** + UPDATING THE DELAYS + ***************************************************************************/ + pBiquadState->pDelays[7]=pBiquadState->pDelays[5]; /* y(n-2)R=y(n-1)R*/ + pBiquadState->pDelays[6]=pBiquadState->pDelays[4]; /* y(n-2)L=y(n-1)L*/ + pBiquadState->pDelays[3]=pBiquadState->pDelays[1]; /* x(n-2)R=x(n-1)R*/ + pBiquadState->pDelays[2]=pBiquadState->pDelays[0]; /* x(n-2)L=x(n-1)L*/ + pBiquadState->pDelays[5]=ynR<<2; /* Update y(n-1)R in Q16*/ + pBiquadState->pDelays[4]=ynL<<2; /* Update y(n-1)L in Q16*/ + pBiquadState->pDelays[0]=(*pDataIn); /* Update x(n-1)L in Q0*/ + pDataIn++; + pBiquadState->pDelays[1]=(*pDataIn); /* Update x(n-1)R in Q0*/ + pDataIn++; + + /************************************************************************** + WRITING THE OUTPUT + ***************************************************************************/ + *pDataOut=(LVM_INT16)(ynL>>14); /* Write Left output in Q0*/ + pDataOut++; + *pDataOut=(LVM_INT16)(ynR>>14); /* Write Right ouput in Q0*/ + pDataOut++; + } + + } + diff --git a/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32C15_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32C15_TRC_WRA_01.c new file mode 100755 index 0000000..f1ab815 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32C15_TRC_WRA_01.c @@ -0,0 +1,126 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "BQ_2I_D16F32Css_TRC_WRA_01_Private.h" +#include "LVM_Macros.h" + +/************************************************************************** + ASSUMPTIONS: + COEFS- + pBiquadState->coefs[0] is A2, pBiquadState->coefs[1] is A1 + pBiquadState->coefs[2] is A0, pBiquadState->coefs[3] is -B2 + pBiquadState->coefs[4] is -B1, these are in Q15 format + + DELAYS- + pBiquadState->pDelays[0] is x(n-1)L in Q0 format + pBiquadState->pDelays[1] is x(n-1)R in Q0 format + pBiquadState->pDelays[2] is x(n-2)L in Q0 format + pBiquadState->pDelays[3] is x(n-2)R in Q0 format + pBiquadState->pDelays[4] is y(n-1)L in Q16 format + pBiquadState->pDelays[5] is y(n-1)R in Q16 format + pBiquadState->pDelays[6] is y(n-2)L in Q16 format + pBiquadState->pDelays[7] is y(n-2)R in Q16 format +***************************************************************************/ + +void BQ_2I_D16F32C15_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples) + { + LVM_INT32 ynL,ynR,templ; + LVM_INT16 ii; + PFilter_State pBiquadState = (PFilter_State) pInstance; + + for (ii = NrSamples; ii != 0; ii--) + { + + + /************************************************************************** + PROCESSING OF THE LEFT CHANNEL + ***************************************************************************/ + /* ynL=A2 (Q15) * x(n-2)L (Q0) in Q15*/ + ynL=(LVM_INT32)pBiquadState->coefs[0]* pBiquadState->pDelays[2]; + + /* ynL+=A1 (Q15) * x(n-1)L (Q0) in Q15*/ + ynL+=(LVM_INT32)pBiquadState->coefs[1]* pBiquadState->pDelays[0]; + + /* ynL+=A0 (Q15) * x(n)L (Q0) in Q15*/ + ynL+=(LVM_INT32)pBiquadState->coefs[2]* (*pDataIn); + + /* ynL+= ( (-B2 (Q15) * y(n-2)L (Q16) )>>16) in Q15 */ + MUL32x16INTO32(pBiquadState->pDelays[6],pBiquadState->coefs[3],templ,16) + ynL+=templ; + + /* ynL+=( (-B1 (Q15) * y(n-1)L (Q16) )>>16) in Q15 */ + MUL32x16INTO32(pBiquadState->pDelays[4],pBiquadState->coefs[4],templ,16) + ynL+=templ; + + /************************************************************************** + PROCESSING OF THE RIGHT CHANNEL + ***************************************************************************/ + /* ynR=A2 (Q15) * x(n-2)R (Q0) in Q15*/ + ynR=(LVM_INT32)pBiquadState->coefs[0]*pBiquadState->pDelays[3]; + + /* ynR+=A1 (Q15) * x(n-1)R (Q0) in Q15*/ + ynR+=(LVM_INT32)pBiquadState->coefs[1]*pBiquadState->pDelays[1]; + + /* ynR+=A0 (Q15) * x(n)R (Q0) in Q15*/ + ynR+=(LVM_INT32)pBiquadState->coefs[2]*(*(pDataIn+1)); + + /* ynR+= ( (-B2 (Q15) * y(n-2)R (Q16) )>>16) in Q15 */ + MUL32x16INTO32(pBiquadState->pDelays[7],pBiquadState->coefs[3],templ,16) + ynR+=templ; + + /* ynR+=( (-B1 (Q15) * y(n-1)R (Q16) )>>16) in Q15 */ + MUL32x16INTO32(pBiquadState->pDelays[5],pBiquadState->coefs[4],templ,16) + ynR+=templ; + + /************************************************************************** + UPDATING THE DELAYS + ***************************************************************************/ + pBiquadState->pDelays[7]=pBiquadState->pDelays[5]; /* y(n-2)R=y(n-1)R*/ + pBiquadState->pDelays[6]=pBiquadState->pDelays[4]; /* y(n-2)L=y(n-1)L*/ + pBiquadState->pDelays[3]=pBiquadState->pDelays[1]; /* x(n-2)R=x(n-1)R*/ + pBiquadState->pDelays[2]=pBiquadState->pDelays[0]; /* x(n-2)L=x(n-1)L*/ + pBiquadState->pDelays[5]=ynR<<1; /* Update y(n-1)R in Q16*/ + pBiquadState->pDelays[4]=ynL<<1; /* Update y(n-1)L in Q16*/ + pBiquadState->pDelays[0]=(*pDataIn); /* Update x(n-1)L in Q0*/ + pDataIn++; + pBiquadState->pDelays[1]=(*pDataIn); /* Update x(n-1)R in Q0*/ + pDataIn++; + + /************************************************************************** + WRITING THE OUTPUT + ***************************************************************************/ + *pDataOut=(LVM_INT16)(ynL>>15); /* Write Left output in Q0*/ + pDataOut++; + *pDataOut=(LVM_INT16)(ynR>>15); /* Write Right ouput in Q0*/ + pDataOut++; + } + + } + diff --git a/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32Css_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32Css_TRC_WRA_01_Private.h new file mode 100755 index 0000000..3cbb58b --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32Css_TRC_WRA_01_Private.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _BQ_2I_D16F32CSS_TRC_WRA_01_PRIVATE_H_ +#define _BQ_2I_D16F32CSS_TRC_WRA_01_PRIVATE_H_ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/* The internal state variables are implemented in a (for the user) hidden structure */ +/* In this (private) file, the internal structure is declared fro private use. */ +typedef struct _Filter_State_ +{ + LVM_INT32 * pDelays; /* pointer to the delayed samples (data of 32 bits) */ + LVM_INT16 coefs[5]; /* pointer to the filter coefficients */ +}Filter_State; + +typedef Filter_State * PFilter_State ; + +#endif /* _BQ_2I_D16F32CSS_TRC_WRA_01_PRIVATE_H_ */ diff --git a/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32Css_TRC_WRA_01_init.c b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32Css_TRC_WRA_01_init.c new file mode 100755 index 0000000..0c6b33e --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BQ_2I_D16F32Css_TRC_WRA_01_init.c @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ +#include "BIQUAD.h" +#include "BQ_2I_D16F32Css_TRC_WRA_01_Private.h" + + +/*-------------------------------------------------------------------------*/ +/* FUNCTION: */ +/* BQ_2I_D16F32Css_TRC_WRA_01_Init */ +/* */ +/* DESCRIPTION: */ +/* These functions initializes a BIQUAD filter defined as a cascade of */ +/* biquadratic Filter Sections. */ +/* */ +/* PARAMETERS: */ +/* pInstance - output, returns the pointer to the State Variable */ +/* This state pointer must be passed to any subsequent */ +/* call to "Biquad" functions. */ +/* pTaps - input, pointer to the taps memory */ +/* pCoef - input, pointer to the coefficient structure */ +/* N - M coefficient factor of QM.N */ +/* RETURNS: */ +/* void return code */ +/*-------------------------------------------------------------------------*/ +void BQ_2I_D16F32Css_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance, + Biquad_2I_Order2_Taps_t *pTaps, + BQ_C16_Coefs_t *pCoef) +{ + LVM_INT16 temp; + PFilter_State pBiquadState = (PFilter_State) pInstance; + pBiquadState->pDelays =(LVM_INT32 *) pTaps ; + + temp=pCoef->A2; + pBiquadState->coefs[0]=temp; + temp=pCoef->A1; + pBiquadState->coefs[1]=temp; + temp=pCoef->A0; + pBiquadState->coefs[2]=temp; + temp=pCoef->B2; + pBiquadState->coefs[3]=temp; + temp=pCoef->B1; + pBiquadState->coefs[4]=temp; +} +/*-------------------------------------------------------------------------*/ +/* End Of File: BQ_2I_D16F32Css_TRC_WRA_01_Init */ + diff --git a/media/libeffects/lvm/lib/Common/src/BQ_2I_D32F32C30_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/BQ_2I_D32F32C30_TRC_WRA_01.c new file mode 100755 index 0000000..51278cf --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BQ_2I_D32F32C30_TRC_WRA_01.c @@ -0,0 +1,135 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "BQ_2I_D32F32Cll_TRC_WRA_01_Private.h" +#include "LVM_Macros.h" + +/************************************************************************** + ASSUMPTIONS: + COEFS- + pBiquadState->coefs[0] is A2, pBiquadState->coefs[1] is A1 + pBiquadState->coefs[2] is A0, pBiquadState->coefs[3] is -B2 + pBiquadState->coefs[4] is -B1, these are in Q30 format + + DELAYS- + pBiquadState->pDelays[0] is x(n-1)L in Q0 format + pBiquadState->pDelays[1] is x(n-1)R in Q0 format + pBiquadState->pDelays[2] is x(n-2)L in Q0 format + pBiquadState->pDelays[3] is x(n-2)R in Q0 format + pBiquadState->pDelays[4] is y(n-1)L in Q0 format + pBiquadState->pDelays[5] is y(n-1)R in Q0 format + pBiquadState->pDelays[6] is y(n-2)L in Q0 format + pBiquadState->pDelays[7] is y(n-2)R in Q0 format +***************************************************************************/ + +void BQ_2I_D32F32C30_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT32 *pDataIn, + LVM_INT32 *pDataOut, + LVM_INT16 NrSamples) + + + { + LVM_INT32 ynL,ynR,templ,tempd; + LVM_INT16 ii; + PFilter_State pBiquadState = (PFilter_State) pInstance; + + for (ii = NrSamples; ii != 0; ii--) + { + + + /************************************************************************** + PROCESSING OF THE LEFT CHANNEL + ***************************************************************************/ + /* ynL= ( A2 (Q30) * x(n-2)L (Q0) ) >>30 in Q0*/ + MUL32x32INTO32(pBiquadState->coefs[0],pBiquadState->pDelays[2],ynL,30) + + /* ynL+= ( A1 (Q30) * x(n-1)L (Q0) ) >> 30 in Q0*/ + MUL32x32INTO32(pBiquadState->coefs[1],pBiquadState->pDelays[0],templ,30) + ynL+=templ; + + /* ynL+= ( A0 (Q30) * x(n)L (Q0) ) >> 30 in Q0*/ + MUL32x32INTO32(pBiquadState->coefs[2],*pDataIn,templ,30) + ynL+=templ; + + /* ynL+= (-B2 (Q30) * y(n-2)L (Q0) ) >> 30 in Q0*/ + MUL32x32INTO32(pBiquadState->coefs[3],pBiquadState->pDelays[6],templ,30) + ynL+=templ; + + /* ynL+= (-B1 (Q30) * y(n-1)L (Q0) ) >> 30 in Q0 */ + MUL32x32INTO32(pBiquadState->coefs[4],pBiquadState->pDelays[4],templ,30) + ynL+=templ; + + /************************************************************************** + PROCESSING OF THE RIGHT CHANNEL + ***************************************************************************/ + /* ynR= ( A2 (Q30) * x(n-2)R (Q0) ) >> 30 in Q0*/ + MUL32x32INTO32(pBiquadState->coefs[0],pBiquadState->pDelays[3],ynR,30) + + /* ynR+= ( A1 (Q30) * x(n-1)R (Q0) ) >> 30 in Q0*/ + MUL32x32INTO32(pBiquadState->coefs[1],pBiquadState->pDelays[1],templ,30) + ynR+=templ; + + /* ynR+= ( A0 (Q30) * x(n)R (Q0) ) >> 30 in Q0*/ + tempd=*(pDataIn+1); + MUL32x32INTO32(pBiquadState->coefs[2],tempd,templ,30) + ynR+=templ; + + /* ynR+= (-B2 (Q30) * y(n-2)R (Q0) ) >> 30 in Q0*/ + MUL32x32INTO32(pBiquadState->coefs[3],pBiquadState->pDelays[7],templ,30) + ynR+=templ; + + /* ynR+= (-B1 (Q30) * y(n-1)R (Q0) ) >> 30 in Q0 */ + MUL32x32INTO32(pBiquadState->coefs[4],pBiquadState->pDelays[5],templ,30) + ynR+=templ; + + /************************************************************************** + UPDATING THE DELAYS + ***************************************************************************/ + pBiquadState->pDelays[7]=pBiquadState->pDelays[5]; /* y(n-2)R=y(n-1)R*/ + pBiquadState->pDelays[6]=pBiquadState->pDelays[4]; /* y(n-2)L=y(n-1)L*/ + pBiquadState->pDelays[3]=pBiquadState->pDelays[1]; /* x(n-2)R=x(n-1)R*/ + pBiquadState->pDelays[2]=pBiquadState->pDelays[0]; /* x(n-2)L=x(n-1)L*/ + pBiquadState->pDelays[5]=(LVM_INT32)ynR; /* Update y(n-1)R in Q0*/ + pBiquadState->pDelays[4]=(LVM_INT32)ynL; /* Update y(n-1)L in Q0*/ + pBiquadState->pDelays[0]=(*pDataIn); /* Update x(n-1)L in Q0*/ + pDataIn++; + pBiquadState->pDelays[1]=(*pDataIn); /* Update x(n-1)R in Q0*/ + pDataIn++; + + /************************************************************************** + WRITING THE OUTPUT + ***************************************************************************/ + *pDataOut=(LVM_INT32)ynL; /* Write Left output in Q0*/ + pDataOut++; + *pDataOut=(LVM_INT32)ynR; /* Write Right ouput in Q0*/ + pDataOut++; + + + } + + } + diff --git a/media/libeffects/lvm/lib/Common/src/BQ_2I_D32F32Cll_TRC_WRA_01_Init.c b/media/libeffects/lvm/lib/Common/src/BQ_2I_D32F32Cll_TRC_WRA_01_Init.c new file mode 100755 index 0000000..7c460d3 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BQ_2I_D32F32Cll_TRC_WRA_01_Init.c @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/*-------------------------------------------------------------------------*/ +#include "BIQUAD.h" +#include "BQ_2I_D32F32Cll_TRC_WRA_01_Private.h" + +/*-------------------------------------------------------------------------*/ +/* FUNCTION: */ +/* BQ_2I_D32F32Cll_TRC_WRA_01_Init */ +/* */ +/* DESCRIPTION: */ +/* These functions initializes a BIQUAD filter defined as a cascade of */ +/* biquadratic Filter Sections. */ +/* */ +/* PARAMETERS: */ +/* pInstance - output, returns the pointer to the State Variable */ +/* This state pointer must be passed to any subsequent */ +/* call to "Biquad" functions. */ +/* pTaps - input, pointer to the taps memory */ +/* pCoef - input, pointer to the coefficient structure */ +/* N - M coefficient factor of QM.N */ +/* RETURNS: */ +/* void return code */ +/*-------------------------------------------------------------------------*/ +void BQ_2I_D32F32Cll_TRC_WRA_01_Init ( Biquad_Instance_t *pInstance, + Biquad_2I_Order2_Taps_t *pTaps, + BQ_C32_Coefs_t *pCoef) +{ + LVM_INT32 temp; + PFilter_State pBiquadState = (PFilter_State) pInstance; + pBiquadState->pDelays =(LVM_INT32 *) pTaps ; + + temp=pCoef->A2; + pBiquadState->coefs[0]=temp; + temp=pCoef->A1; + pBiquadState->coefs[1]=temp; + temp=pCoef->A0; + pBiquadState->coefs[2]=temp; + temp=pCoef->B2; + pBiquadState->coefs[3]=temp; + temp=pCoef->B1; + pBiquadState->coefs[4]=temp; +} +/*-------------------------------------------------------------------------*/ +/* End Of File: BQ_2I_D32F32C32_TRC_WRA_01_Init.c */ + diff --git a/media/libeffects/lvm/lib/Common/src/BQ_2I_D32F32Cll_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/BQ_2I_D32F32Cll_TRC_WRA_01_Private.h new file mode 100755 index 0000000..fb4f2dd --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/BQ_2I_D32F32Cll_TRC_WRA_01_Private.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _BQ_2I_D32F32CLL_TRC_WRA_01_PRIVATE_H_ +#define _BQ_2I_D32F32CLL_TRC_WRA_01_PRIVATE_H_ + + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/* The internal state variables are implemented in a (for the user) hidden structure */ +/* In this (private) file, the internal structure is declared fro private use. */ +typedef struct _Filter_State_ +{ + LVM_INT32 * pDelays; /* pointer to the delayed samples (data of 32 bits) */ + LVM_INT32 coefs[5]; /* pointer to the filter coefficients */ +}Filter_State; + +typedef Filter_State * PFilter_State ; + +#endif /* _BQ_2I_D32F32CLL_TRC_WRA_01_PRIVATE_H_*/ diff --git a/media/libeffects/lvm/lib/Common/src/CompLim_private.h b/media/libeffects/lvm/lib/Common/src/CompLim_private.h new file mode 100755 index 0000000..07a8833 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/CompLim_private.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************************** + + $Author: beq07716 $ + $Revision: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +#ifndef _COMP_LIM_PRIVATE_ +#define _COMP_LIM_PRIVATE_ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "CompLim.h" + +/********************************************************************************** + DEFINITIONS +***********************************************************************************/ + +#define FS_48K 48000 + +#define INTEGER_16 0xFFFF /* 65535*/ +#define INTEGER_15 0x7FFF /* 32767*/ + +#define GAIN_6DB 1 +#define GAIN_12DB 2 +#define GAIN_18DB 3 +#define GAIN_24DB 4 + +#endif /* #ifndef _COMP_LIM_PRIVATE_ */ + +/*** End of file ******************************************************************/ + diff --git a/media/libeffects/lvm/lib/Common/src/Copy_16.c b/media/libeffects/lvm/lib/Common/src/Copy_16.c new file mode 100755 index 0000000..6ee1ff6 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/Copy_16.c @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************************** + + $Author: beq07716 $ + $Revision: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION COPY_16 +***********************************************************************************/ + +void Copy_16( const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n ) +{ + LVM_INT16 ii; + + if (src > dst) + { + for (ii = n; ii != 0; ii--) + { + *dst = *src; + dst++; + src++; + } + } + else + { + src += n - 1; + dst += n - 1; + for (ii = n; ii != 0; ii--) + { + *dst = *src; + dst--; + src--; + } + } + + return; +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/Core_MixHard_2St_D32C31_SAT.c b/media/libeffects/lvm/lib/Common/src/Core_MixHard_2St_D32C31_SAT.c new file mode 100755 index 0000000..adac24f --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/Core_MixHard_2St_D32C31_SAT.c @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "Mixer_private.h" +#include "LVM_Macros.h" + +/********************************************************************************** + FUNCTION CORE_MIXHARD_2ST_D32C31_SAT +***********************************************************************************/ + +void Core_MixHard_2St_D32C31_SAT( Mix_2St_Cll_t *pInstance, + const LVM_INT32 *src1, + const LVM_INT32 *src2, + LVM_INT32 *dst, + LVM_INT16 n) +{ + LVM_INT32 Temp1,Temp2,Temp3; + LVM_INT16 ii; + LVM_INT16 Current1Short; + LVM_INT16 Current2Short; + + Current1Short = (LVM_INT16)(pInstance->Current1 >> 16); + Current2Short = (LVM_INT16)(pInstance->Current2 >> 16); + + for (ii = n; ii != 0; ii--){ + Temp1=*src1++; + MUL32x16INTO32(Temp1,Current1Short,Temp3,15) + Temp2=*src2++; + MUL32x16INTO32(Temp2,Current2Short,Temp1,15) + Temp2=(Temp1>>1)+(Temp3>>1); + if (Temp2 > 0x3FFFFFFF) + Temp2 = 0x7FFFFFFF; + else if (Temp2 < - 0x40000000) + Temp2 = 0x80000000; + else + Temp2=(Temp2<<1); + *dst++ = Temp2; + } +} + + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/Core_MixInSoft_D32C31_SAT.c b/media/libeffects/lvm/lib/Common/src/Core_MixInSoft_D32C31_SAT.c new file mode 100755 index 0000000..d557f6e --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/Core_MixInSoft_D32C31_SAT.c @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "Mixer_private.h" +#include "LVM_Macros.h" + +/********************************************************************************** + FUNCTION CORE_MIXSOFT_1ST_D32C31_WRA +***********************************************************************************/ + +void Core_MixInSoft_D32C31_SAT( Mix_1St_Cll_t *pInstance, + const LVM_INT32 *src, + LVM_INT32 *dst, + LVM_INT16 n) +{ + LVM_INT32 Temp1,Temp2,Temp3; + LVM_INT16 OutLoop; + LVM_INT16 InLoop; + LVM_INT32 TargetTimesOneMinAlpha; + LVM_INT32 CurrentTimesAlpha; + LVM_INT16 ii,jj; + LVM_INT16 CurrentShort; + + InLoop = (LVM_INT16)(n >> 2); /* Process per 4 samples */ + OutLoop = (LVM_INT16)(n - (InLoop << 2)); + + MUL32x32INTO32((0x7FFFFFFF-pInstance->Alpha),pInstance->Target,TargetTimesOneMinAlpha,31); /* Q31 * Q0 in Q0 */ + if (pInstance->Target >= pInstance->Current){ + TargetTimesOneMinAlpha +=2; /* Ceil*/ + } + + if (OutLoop){ + MUL32x32INTO32(pInstance->Current,pInstance->Alpha,CurrentTimesAlpha,31); /* Q0 * Q31 in Q0 */ + pInstance->Current = TargetTimesOneMinAlpha + CurrentTimesAlpha; /* Q0 + Q0 into Q0*/ + CurrentShort = (LVM_INT16)(pInstance->Current>>16); /* From Q31 to Q15*/ + + for (ii = OutLoop; ii != 0; ii--){ + Temp1=*src++; + Temp2=*dst; + MUL32x16INTO32(Temp1,CurrentShort,Temp3,15) + Temp1=(Temp2>>1)+(Temp3>>1); + + if (Temp1 > 0x3FFFFFFF) + Temp1 = 0x7FFFFFFF; + else if (Temp1 < - 0x40000000) + Temp1 = 0x80000000; + else + Temp1=(Temp1<<1); + *dst++ = Temp1; + } + } + + for (ii = InLoop; ii != 0; ii--){ + MUL32x32INTO32(pInstance->Current,pInstance->Alpha,CurrentTimesAlpha,31); /* Q0 * Q31 in Q0 */ + pInstance->Current = TargetTimesOneMinAlpha + CurrentTimesAlpha; /* Q0 + Q0 into Q0*/ + CurrentShort = (LVM_INT16)(pInstance->Current>>16); /* From Q31 to Q15*/ + + for (jj = 4; jj!=0 ; jj--){ + Temp1=*src++; + Temp2=*dst; + MUL32x16INTO32(Temp1,CurrentShort,Temp3,15) + Temp1=(Temp2>>1)+(Temp3>>1); + + if (Temp1 > 0x3FFFFFFF) + Temp1 = 0x7FFFFFFF; + else if (Temp1 < - 0x40000000) + Temp1 = 0x80000000; + else + Temp1=(Temp1<<1); + *dst++ = Temp1; + } + } +} + + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/Core_MixSoft_1St_D32C31_WRA.c b/media/libeffects/lvm/lib/Common/src/Core_MixSoft_1St_D32C31_WRA.c new file mode 100755 index 0000000..7b4e66d --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/Core_MixSoft_1St_D32C31_WRA.c @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "Mixer_private.h" +#include "LVM_Macros.h" + +/********************************************************************************** + FUNCTION CORE_MIXSOFT_1ST_D32C31_WRA +***********************************************************************************/ + +void Core_MixSoft_1St_D32C31_WRA( Mix_1St_Cll_t *pInstance, + const LVM_INT32 *src, + LVM_INT32 *dst, + LVM_INT16 n) +{ + LVM_INT32 Temp1,Temp2; + LVM_INT16 OutLoop; + LVM_INT16 InLoop; + LVM_INT32 TargetTimesOneMinAlpha; + LVM_INT32 CurrentTimesAlpha; + LVM_INT16 CurrentShort; + LVM_INT16 ii; + + InLoop = (LVM_INT16)(n >> 2); /* Process per 4 samples */ + OutLoop = (LVM_INT16)(n - (InLoop << 2)); + + MUL32x32INTO32((0x7FFFFFFF-pInstance->Alpha),pInstance->Target,TargetTimesOneMinAlpha,31) /* Q31 * Q31 in Q31 */ + if (pInstance->Target >= pInstance->Current) + { + TargetTimesOneMinAlpha +=2; /* Ceil*/ + } + + if (OutLoop!=0) + { + MUL32x32INTO32(pInstance->Current,pInstance->Alpha,CurrentTimesAlpha,31) /* Q31 * Q31 in Q31 */ + pInstance->Current = TargetTimesOneMinAlpha + CurrentTimesAlpha; /* Q31 + Q31 into Q31*/ + CurrentShort = (LVM_INT16)(pInstance->Current>>16); /* From Q31 to Q15*/ + + for (ii = OutLoop; ii != 0; ii--) + { + Temp1=*src; + src++; + + MUL32x16INTO32(Temp1,CurrentShort,Temp2,15) + *dst = Temp2; + dst++; + } + } + + for (ii = InLoop; ii != 0; ii--) + { + MUL32x32INTO32(pInstance->Current,pInstance->Alpha,CurrentTimesAlpha,31) /* Q31 * Q31 in Q31 */ + pInstance->Current = TargetTimesOneMinAlpha + CurrentTimesAlpha; /* Q31 + Q31 into Q31*/ + CurrentShort = (LVM_INT16)(pInstance->Current>>16); /* From Q31 to Q15*/ + Temp1=*src; + src++; + + MUL32x16INTO32(Temp1,CurrentShort,Temp2,15) + *dst = Temp2; + dst++; + + Temp1=*src; + src++; + + MUL32x16INTO32(Temp1,CurrentShort,Temp2,15) + *dst = Temp2; + dst++; + + Temp1=*src; + src++; + + MUL32x16INTO32(Temp1,CurrentShort,Temp2,15) + *dst = Temp2; + dst++; + + Temp1=*src; + src++; + MUL32x16INTO32(Temp1,CurrentShort,Temp2,15) + *dst = Temp2; + dst++; + } +} + + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/DC_2I_D16_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/DC_2I_D16_TRC_WRA_01.c new file mode 100755 index 0000000..187fe68 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/DC_2I_D16_TRC_WRA_01.c @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "DC_2I_D16_TRC_WRA_01_Private.h" +#include "LVM_Macros.h" + +void DC_2I_D16_TRC_WRA_01( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples) + { + LVM_INT32 LeftDC,RightDC; + LVM_INT32 Diff; + LVM_INT32 j; + PFilter_State pBiquadState = (PFilter_State) pInstance; + + LeftDC = pBiquadState->LeftDC; + RightDC = pBiquadState->RightDC; + for(j=NrSamples-1;j>=0;j--) + { + /* Subtract DC an saturate */ + Diff=*(pDataIn++)-(LeftDC>>16); + if (Diff > 32767) { + Diff = 32767; } + else if (Diff < -32768) { + Diff = -32768; } + *(pDataOut++)=(LVM_INT16)Diff; + if (Diff < 0) { + LeftDC -= DC_D16_STEP; } + else { + LeftDC += DC_D16_STEP; } + + + /* Subtract DC an saturate */ + Diff=*(pDataIn++)-(RightDC>>16); + if (Diff > 32767) { + Diff = 32767; } + else if (Diff < -32768) { + Diff = -32768; } + *(pDataOut++)=(LVM_INT16)Diff; + if (Diff < 0) { + RightDC -= DC_D16_STEP; } + else { + RightDC += DC_D16_STEP; } + + } + pBiquadState->LeftDC = LeftDC; + pBiquadState->RightDC = RightDC; + + + } + diff --git a/media/libeffects/lvm/lib/Common/src/DC_2I_D16_TRC_WRA_01_Init.c b/media/libeffects/lvm/lib/Common/src/DC_2I_D16_TRC_WRA_01_Init.c new file mode 100755 index 0000000..292641b --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/DC_2I_D16_TRC_WRA_01_Init.c @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "DC_2I_D16_TRC_WRA_01_Private.h" + +void DC_2I_D16_TRC_WRA_01_Init(Biquad_Instance_t *pInstance) +{ + PFilter_State pBiquadState = (PFilter_State) pInstance; + pBiquadState->LeftDC = 0; + pBiquadState->RightDC = 0; +} + diff --git a/media/libeffects/lvm/lib/Common/src/DC_2I_D16_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/DC_2I_D16_TRC_WRA_01_Private.h new file mode 100755 index 0000000..2514a77 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/DC_2I_D16_TRC_WRA_01_Private.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _DC_2I_D16_TRC_WRA_01_PRIVATE_H_ +#define _DC_2I_D16_TRC_WRA_01_PRIVATE_H_ + +#define DC_D16_STEP 0x200; + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + + +/* The internal state variables are implemented in a (for the user) hidden structure */ +/* In this (private) file, the internal structure is declared fro private use.*/ +typedef struct _Filter_State_ +{ + LVM_INT32 LeftDC; /* LeftDC */ + LVM_INT32 RightDC; /* RightDC */ +}Filter_State; + +typedef Filter_State * PFilter_State ; + +#endif /* _DC_2I_D16_TRC_WRA_01_PRIVATE_H_ */ diff --git a/media/libeffects/lvm/lib/Common/src/DelayAllPass_Sat_32x16To32.c b/media/libeffects/lvm/lib/Common/src/DelayAllPass_Sat_32x16To32.c new file mode 100755 index 0000000..cda72ac --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/DelayAllPass_Sat_32x16To32.c @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "LVM_Types.h" +#include "LVM_Macros.h" +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION DelayAllPass_32x32 +***********************************************************************************/ + +void DelayAllPass_Sat_32x16To32( LVM_INT32 *delay, /* Delay buffer */ + LVM_UINT16 size, /* Delay size */ + LVM_INT16 coeff, /* All pass filter coefficient */ + LVM_UINT16 DelayOffset, /* Simple delay offset */ + LVM_UINT16 *pAllPassOffset, /* All pass filter delay offset */ + LVM_INT32 *dst, /* Source/destination */ + LVM_INT16 n) /* Number of samples */ +{ + LVM_INT16 i; + LVM_UINT16 AllPassOffset = *pAllPassOffset; + LVM_INT32 temp; + LVM_INT32 a,b,c; + + for (i = 0; i < n; i++) + { + + MUL32x16INTO32(delay[AllPassOffset], coeff, temp, 15) + a = temp; + b = delay[DelayOffset]; + DelayOffset++; + + c = a + b; + if ((((c ^ a) & (c ^ b)) >> 31) != 0) /* overflow / underflow */ + { + if(a < 0) + { + c = 0x80000000l; + } + else + { + c = 0x7FFFFFFFl; + } + } + *dst = c; + dst++; + + + MUL32x16INTO32(c, -coeff, temp, 15) + a = temp; + b = delay[AllPassOffset]; + c = a + b; + if ((((c ^ a) & (c ^ b)) >> 31)!=0) /* overflow / underflow */ + { + if(a < 0) + { + c = 0x80000000l; + } + else + { + c = 0x7FFFFFFFl; + } + } + delay[AllPassOffset] = c; + AllPassOffset++; + + /* Make the delay buffer a circular buffer */ + if (DelayOffset >= size) + { + DelayOffset = 0; + } + + if (AllPassOffset >= size) + { + AllPassOffset = 0; + } + } + + /* Update the offset */ + *pAllPassOffset = AllPassOffset; + + return; +} + +/**********************************************************************************/ + diff --git a/media/libeffects/lvm/lib/Common/src/DelayMix_16x16.c b/media/libeffects/lvm/lib/Common/src/DelayMix_16x16.c new file mode 100755 index 0000000..ee41701 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/DelayMix_16x16.c @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************************** + + $Author: beq07716 $ + $Revision: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION DelayMix_16x16 +***********************************************************************************/ + +void DelayMix_16x16(const LVM_INT16 *src, /* Source 1, to be delayed */ + LVM_INT16 *delay, /* Delay buffer */ + LVM_INT16 size, /* Delay size */ + LVM_INT16 *dst, /* Source/destination */ + LVM_INT16 *pOffset, /* Delay offset */ + LVM_INT16 n) /* Number of stereo samples */ +{ + LVM_INT16 i; + LVM_INT16 Offset = *pOffset; + LVM_INT16 temp; + + for (i=0; i> 1); + *dst = temp; + dst++; + + delay[Offset] = *src; + Offset++; + src++; + + + /* Right channel */ + temp = (LVM_INT16)((LVM_UINT32)((LVM_INT32)(*dst) - (LVM_INT32)delay[Offset]) >> 1); + *dst = temp; + dst++; + + delay[Offset] = *src; + Offset++; + src++; + + /* Make the reverb delay buffer a circular buffer */ + if (Offset >= size) + { + Offset = 0; + } + } + + /* Update the offset */ + *pOffset = Offset; + + return; +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/DelayWrite_32.c b/media/libeffects/lvm/lib/Common/src/DelayWrite_32.c new file mode 100755 index 0000000..0ae4c42 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/DelayWrite_32.c @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION DelayMix_16x16 +***********************************************************************************/ + +void DelayWrite_32(const LVM_INT32 *src, /* Source 1, to be delayed */ + LVM_INT32 *delay, /* Delay buffer */ + LVM_UINT16 size, /* Delay size */ + LVM_UINT16 *pOffset, /* Delay offset */ + LVM_INT16 n) /* Number of samples */ +{ + LVM_INT16 i; + LVM_INT16 Offset = (LVM_INT16)*pOffset; + + for (i=0; i= size) + { + Offset = 0; + } + } + + /* Update the offset */ + *pOffset = (LVM_UINT16)Offset; + + return; +} + +/**********************************************************************************/ + diff --git a/media/libeffects/lvm/lib/Common/src/FO_1I_D16F16C15_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/FO_1I_D16F16C15_TRC_WRA_01.c new file mode 100755 index 0000000..831a115 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/FO_1I_D16F16C15_TRC_WRA_01.c @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "FO_1I_D16F16Css_TRC_WRA_01_Private.h" +#include "LVM_Macros.h" + +/************************************************************************** + ASSUMPTIONS: + COEFS- + pBiquadState->coefs[0] is A1, + pBiquadState->coefs[1] is A0, + pBiquadState->coefs[2] is -B1, these are in Q15 format + + DELAYS- + pBiquadState->pDelays[0] is x(n-1)L in Q0 format + pBiquadState->pDelays[1] is y(n-1)L in Q0 format +***************************************************************************/ + +void FO_1I_D16F16C15_TRC_WRA_01( Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples) + { + LVM_INT32 ynL; + LVM_INT16 ii; + PFilter_State pBiquadState = (PFilter_State) pInstance; + + for (ii = NrSamples; ii != 0; ii--) + { + + /************************************************************************** + PROCESSING OF THE LEFT CHANNEL + ***************************************************************************/ + // ynL=A1 (Q15) * x(n-1)L (Q0) in Q15 + ynL=(LVM_INT32)pBiquadState->coefs[0]* pBiquadState->pDelays[0]; + + // ynL+=A0 (Q15) * x(n)L (Q0) in Q15 + ynL+=(LVM_INT32)pBiquadState->coefs[1]* (*pDataIn); + + // ynL+= (-B1 (Q15) * y(n-1)L (Q0) ) in Q15 + ynL+=(LVM_INT32)pBiquadState->coefs[2]*pBiquadState->pDelays[1]; + + + ynL=(LVM_INT16)(ynL>>15); // ynL in Q0 format + /************************************************************************** + UPDATING THE DELAYS + ***************************************************************************/ + pBiquadState->pDelays[1]=ynL; // Update y(n-1)L in Q0 + pBiquadState->pDelays[0]=(*pDataIn++); // Update x(n-1)L in Q0 + + /************************************************************************** + WRITING THE OUTPUT + ***************************************************************************/ + *pDataOut++=(LVM_INT16)ynL; // Write Left output in Q0 + + } + + } + diff --git a/media/libeffects/lvm/lib/Common/src/FO_1I_D16F16Css_TRC_WRA_01_Init.c b/media/libeffects/lvm/lib/Common/src/FO_1I_D16F16Css_TRC_WRA_01_Init.c new file mode 100755 index 0000000..4675084 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/FO_1I_D16F16Css_TRC_WRA_01_Init.c @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/*-------------------------------------------------------------------------*/ +#include "BIQUAD.h" +#include "FO_1I_D16F16Css_TRC_WRA_01_Private.h" + + +/*-------------------------------------------------------------------------*/ +/* FUNCTION: */ +/* FO_1I_D16F16Css_TRC_WRA_01_Init */ +/* */ +/* DESCRIPTION: */ +/* These functions initializes a BIQUAD filter defined as a cascade of */ +/* biquadratic Filter Sections. */ +/* */ +/* PARAMETERS: */ +/* pInstance - output, returns the pointer to the State Variable */ +/* This state pointer must be passed to any subsequent */ +/* call to "Biquad" functions. */ +/* pTaps - input, pointer to the taps memory */ +/* pCoef - input, pointer to the coefficient structure */ +/* N - M coefficient factor of QM.N */ +/* RETURNS: */ +/* void return code */ +/*-------------------------------------------------------------------------*/ +void FO_1I_D16F16Css_TRC_WRA_01_Init( Biquad_Instance_t *pInstance, + Biquad_1I_Order1_Taps_t *pTaps, + FO_C16_Coefs_t *pCoef) +{ + LVM_INT16 temp; + PFilter_State pBiquadState = (PFilter_State) pInstance; + pBiquadState->pDelays =(LVM_INT32 *) pTaps; + + temp=pCoef->A1; + pBiquadState->coefs[0]=temp; + temp=pCoef->A0; + pBiquadState->coefs[1]=temp; + temp=pCoef->B1; + pBiquadState->coefs[2]=temp; +} +/*------------------------------------------------*/ +/* End Of File: FO_1I_D16F16Css_TRC_WRA_01_Init.c */ + diff --git a/media/libeffects/lvm/lib/Common/src/FO_1I_D16F16Css_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/FO_1I_D16F16Css_TRC_WRA_01_Private.h new file mode 100755 index 0000000..e1a818c --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/FO_1I_D16F16Css_TRC_WRA_01_Private.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _FO_1I_D16F16CSS_TRC_WRA_01_PRIVATE_H_ +#define _FO_1I_D16F16CSS_TRC_WRA_01_PRIVATE_H_ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ */ +/* */ +/************************************************************************/ + +/* The internal state variables are implemented in a (for the user) hidden structure */ +/* In this (private) file, the internal structure is declared fro private use. */ +typedef struct _Filter_State_ +{ + LVM_INT32* pDelays; /* pointer to the delayed samples (data of 32 bits) */ + LVM_INT16 coefs[3]; /* pointer to the filter coefficients */ +}Filter_State; + +typedef Filter_State * PFilter_State ; + +#endif /* _FO_1I_D16F16CSS_TRC_WRA_01_PRIVATE_H_ */ diff --git a/media/libeffects/lvm/lib/Common/src/FO_1I_D32F32C31_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/FO_1I_D32F32C31_TRC_WRA_01.c new file mode 100755 index 0000000..9bdc5b4 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/FO_1I_D32F32C31_TRC_WRA_01.c @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "FO_1I_D32F32Cll_TRC_WRA_01_Private.h" +#include "LVM_Macros.h" + + +/************************************************************************** + ASSUMPTIONS: + COEFS- + pBiquadState->coefs[0] is A1, + pBiquadState->coefs[1] is A0, + pBiquadState->coefs[2] is -B1, these are in Q31 format + + DELAYS- + pBiquadState->pDelays[0] is x(n-1)L in Q0 format + pBiquadState->pDelays[1] is y(n-1)L in Q0 format +***************************************************************************/ + +void FO_1I_D32F32C31_TRC_WRA_01( Biquad_Instance_t *pInstance, + LVM_INT32 *pDataIn, + LVM_INT32 *pDataOut, + LVM_INT16 NrSamples) + { + LVM_INT32 ynL,templ; + LVM_INT16 ii; + PFilter_State pBiquadState = (PFilter_State) pInstance; + + for (ii = NrSamples; ii != 0; ii--) + { + + /************************************************************************** + PROCESSING OF THE LEFT CHANNEL + ***************************************************************************/ + // ynL=A1 (Q31) * x(n-1)L (Q0) >>31 in Q0 + MUL32x32INTO32(pBiquadState->coefs[0],pBiquadState->pDelays[0],ynL,31) + + // ynL+=A0 (Q31) * x(n)L (Q0) >> 31 in Q0 + MUL32x32INTO32(pBiquadState->coefs[1],*pDataIn,templ,31) + ynL+=templ; + + // ynL+= (-B1 (Q31) * y(n-1)L (Q0) ) >> 31 in Q0 + MUL32x32INTO32(pBiquadState->coefs[2],pBiquadState->pDelays[1],templ,31) + ynL+=templ; + + /************************************************************************** + UPDATING THE DELAYS + ***************************************************************************/ + pBiquadState->pDelays[1]=ynL; // Update y(n-1)L in Q0 + pBiquadState->pDelays[0]=(*pDataIn++); // Update x(n-1)L in Q0 + + /************************************************************************** + WRITING THE OUTPUT + ***************************************************************************/ + *pDataOut++=(LVM_INT32)ynL; // Write Left output in Q0 + } + + } + diff --git a/media/libeffects/lvm/lib/Common/src/FO_1I_D32F32Cll_TRC_WRA_01_Init.c b/media/libeffects/lvm/lib/Common/src/FO_1I_D32F32Cll_TRC_WRA_01_Init.c new file mode 100755 index 0000000..eea0b64 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/FO_1I_D32F32Cll_TRC_WRA_01_Init.c @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "FO_1I_D32F32Cll_TRC_WRA_01_Private.h" + + +/*-------------------------------------------------------------------------*/ +/* FUNCTION: */ +/* FO_1I_D32F32Cll_TRC_WRA_01_Init */ +/* */ +/* DESCRIPTION: */ +/* These functions initializes a BIQUAD filter defined as a cascade of */ +/* biquadratic Filter Sections. */ +/* */ +/* PARAMETERS: */ +/* pInstance - output, returns the pointer to the State Variable */ +/* This state pointer must be passed to any subsequent */ +/* call to "Biquad" functions. */ +/* pTaps - input, pointer to the taps memory */ +/* pCoef - input, pointer to the coefficient structure */ +/* N - M coefficient factor of QM.N */ +/* RETURNS: */ +/* void return code */ +/*-------------------------------------------------------------------------*/ +void FO_1I_D32F32Cll_TRC_WRA_01_Init( Biquad_Instance_t *pInstance, + Biquad_1I_Order1_Taps_t *pTaps, + FO_C32_Coefs_t *pCoef) +{ + LVM_INT32 temp; + PFilter_State pBiquadState = (PFilter_State) pInstance; + pBiquadState->pDelays = (LVM_INT32 *) pTaps; + + temp=pCoef->A1; + pBiquadState->coefs[0]=temp; + temp=pCoef->A0; + pBiquadState->coefs[1]=temp; + temp=pCoef->B1; + pBiquadState->coefs[2]=temp; +} +/*------------------------------------------------*/ +/* End Of File: FO_1I_D32F32Cll_TRC_WRA_01_Init.c */ + diff --git a/media/libeffects/lvm/lib/Common/src/FO_1I_D32F32Cll_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/FO_1I_D32F32Cll_TRC_WRA_01_Private.h new file mode 100755 index 0000000..9329150 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/FO_1I_D32F32Cll_TRC_WRA_01_Private.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#ifndef _FO_1I_D32F32CLL_TRC_WRA_01_PRIVATE_H_ +#define _FO_1I_D32F32CLL_TRC_WRA_01_PRIVATE_H_ + + +/* The internal state variables are implemented in a (for the user) hidden structure */ +/* In this (private) file, the internal structure is declared fro private use. */ +typedef struct _Filter_State_ +{ + LVM_INT32 * pDelays; /* pointer to the delayed samples (data of 32 bits) */ + LVM_INT32 coefs[3]; /* pointer to the filter coefficients */ +}Filter_State; + +typedef Filter_State * PFilter_State ; + +#endif /* _FO_1I_D32F32CLL_TRC_WRA_01_PRIVATE_H_ */ diff --git a/media/libeffects/lvm/lib/Common/src/FO_2I_D16F32C15_LShx_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/FO_2I_D16F32C15_LShx_TRC_WRA_01.c new file mode 100755 index 0000000..4b219a2 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/FO_2I_D16F32C15_LShx_TRC_WRA_01.c @@ -0,0 +1,137 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "FO_2I_D16F32Css_LShx_TRC_WRA_01_Private.h" +#include "LVM_Macros.h" + +/************************************************************************** +ASSUMPTIONS: +COEFS- +pBiquadState->coefs[0] is A1, +pBiquadState->coefs[1] is A0, +pBiquadState->coefs[2] is -B1, these are in Q15 format +pBiquadState->Shift is Shift value +DELAYS- +pBiquadState->pDelays[0] is x(n-1)L in Q15 format +pBiquadState->pDelays[1] is y(n-1)L in Q30 format +pBiquadState->pDelays[2] is x(n-1)R in Q15 format +pBiquadState->pDelays[3] is y(n-1)R in Q30 format +***************************************************************************/ + +void FO_2I_D16F32C15_LShx_TRC_WRA_01(Biquad_Instance_t *pInstance, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT16 NrSamples) + { + LVM_INT32 ynL,ynR; + LVM_INT32 Temp; + LVM_INT32 NegSatValue; + LVM_INT16 ii; + LVM_INT16 Shift; + PFilter_State pBiquadState = (PFilter_State) pInstance; + + NegSatValue = LVM_MAXINT_16 +1; + NegSatValue = -NegSatValue; + + Shift = pBiquadState->Shift; + + + for (ii = NrSamples; ii != 0; ii--) + { + + /************************************************************************** + PROCESSING OF THE LEFT CHANNEL + ***************************************************************************/ + + // ynL =A1 (Q15) * x(n-1)L (Q15) in Q30 + ynL=(LVM_INT32)pBiquadState->coefs[0]* pBiquadState->pDelays[0]; + // ynR =A1 (Q15) * x(n-1)R (Q15) in Q30 + ynR=(LVM_INT32)pBiquadState->coefs[0]* pBiquadState->pDelays[2]; + + + // ynL+=A0 (Q15) * x(n)L (Q15) in Q30 + ynL+=(LVM_INT32)pBiquadState->coefs[1]* (*pDataIn); + // ynR+=A0 (Q15) * x(n)L (Q15) in Q30 + ynR+=(LVM_INT32)pBiquadState->coefs[1]* (*(pDataIn+1)); + + + // ynL += (-B1 (Q15) * y(n-1)L (Q30) ) in Q30 + MUL32x16INTO32(pBiquadState->pDelays[1],pBiquadState->coefs[2],Temp,15); + ynL +=Temp; + // ynR += (-B1 (Q15) * y(n-1)R (Q30) ) in Q30 + MUL32x16INTO32(pBiquadState->pDelays[3],pBiquadState->coefs[2],Temp,15); + ynR +=Temp; + + + /************************************************************************** + UPDATING THE DELAYS + ***************************************************************************/ + pBiquadState->pDelays[1]=ynL; // Update y(n-1)L in Q30 + pBiquadState->pDelays[0]=(*pDataIn++); // Update x(n-1)L in Q15 + + pBiquadState->pDelays[3]=ynR; // Update y(n-1)R in Q30 + pBiquadState->pDelays[2]=(*pDataIn++); // Update x(n-1)R in Q15 + + /************************************************************************** + WRITING THE OUTPUT + ***************************************************************************/ + /*Apply shift: Instead of left shift on 16-bit result, right shift of (15-shift) is applied + for better SNR*/ + ynL = ynL>>(15-Shift); + ynR = ynR>>(15-Shift); + + /*Saturate results*/ + if(ynL > LVM_MAXINT_16) + { + ynL = LVM_MAXINT_16; + } + else + { + if(ynL < NegSatValue) + { + ynL = NegSatValue; + } + } + + if(ynR > LVM_MAXINT_16) + { + ynR = LVM_MAXINT_16; + } + else + { + if(ynR < NegSatValue) + { + ynR = NegSatValue; + } + } + + *pDataOut++=(LVM_INT16)ynL; + *pDataOut++=(LVM_INT16)ynR; + } + + } + diff --git a/media/libeffects/lvm/lib/Common/src/FO_2I_D16F32Css_LShx_TRC_WRA_01_Init.c b/media/libeffects/lvm/lib/Common/src/FO_2I_D16F32Css_LShx_TRC_WRA_01_Init.c new file mode 100755 index 0000000..7f212f5 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/FO_2I_D16F32Css_LShx_TRC_WRA_01_Init.c @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/*-------------------------------------------------------------------------*/ +#include "BIQUAD.h" +#include "FO_2I_D16F32Css_LShx_TRC_WRA_01_Private.h" + +/*-------------------------------------------------------------------------*/ +/* FUNCTION: */ +/* FO_2I_D16F32Css_LShx_TRC_WRA_01_Init */ +/* */ +/* DESCRIPTION: */ +/* These functions initializes a BIQUAD filter defined as a cascade of */ +/* biquadratic Filter Sections. */ +/* */ +/* PARAMETERS: */ +/* pInstance - output, returns the pointer to the State Variable */ +/* This state pointer must be passed to any subsequent */ +/* call to "Biquad" functions. */ +/* pTaps - input, pointer to the taps memory */ +/* pCoef - input, pointer to the coefficient structure */ +/* N - M coefficient factor of QM.N */ +/* RETURNS: */ +/* void return code */ +/*-------------------------------------------------------------------------*/ +void FO_2I_D16F32Css_LShx_TRC_WRA_01_Init(Biquad_Instance_t *pInstance, + Biquad_2I_Order1_Taps_t *pTaps, + FO_C16_LShx_Coefs_t *pCoef) +{ + LVM_INT16 temp; + PFilter_State pBiquadState = (PFilter_State) pInstance; + pBiquadState->pDelays =(LVM_INT32 *) pTaps ; + + temp=pCoef->A1; + pBiquadState->coefs[0]=temp; + temp=pCoef->A0; + pBiquadState->coefs[1]=temp; + temp=pCoef->B1; + pBiquadState->coefs[2]=temp; + + temp=pCoef->Shift; + pBiquadState->Shift = temp; +} +/*-------------------------------------------------------------------------*/ +/* End Of File: FO_2I_D16F32Css_LShx_TRC_WRA_01_Init.c */ + diff --git a/media/libeffects/lvm/lib/Common/src/FO_2I_D16F32Css_LShx_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/FO_2I_D16F32Css_LShx_TRC_WRA_01_Private.h new file mode 100755 index 0000000..6a4564a --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/FO_2I_D16F32Css_LShx_TRC_WRA_01_Private.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _FO_2I_D16F32CSS_LSHX_TRC_WRA_01_PRIVATE_H_ +#define _FO_2I_D16F32CSS_LSHX_TRC_WRA_01_PRIVATE_H_ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/* The internal state variables are implemented in a (for the user) hidden structure */ +/* In this (private) file, the internal structure is declared fro private use. */ +typedef struct _Filter_State_ +{ + LVM_INT32 *pDelays; /* pointer to the delayed samples (data of 32 bits) */ + LVM_INT16 coefs[3]; /* pointer to the filter coefficients */ + LVM_INT16 Shift; /* Shift value*/ +}Filter_State; + +typedef Filter_State * PFilter_State ; + +#endif /* _FO_2I_D16F32CSS_LSHX_TRC_WRA_01_PRIVATE_H_ */ diff --git a/media/libeffects/lvm/lib/Common/src/Filters.h b/media/libeffects/lvm/lib/Common/src/Filters.h new file mode 100755 index 0000000..a274f32 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/Filters.h @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************************ + + $Author: beq07716 $ + $Revision: 1001 $ + $Date: 2010-06-28 13:23:02 +0200 (Mon, 28 Jun 2010) $ + +*************************************************************************************/ + +#ifndef FILTERS_H +#define FILTERS_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "LVM_Types.h" + +/************************************************************************************/ +/* */ +/* Structures */ +/* */ +/************************************************************************************/ + +/* + * Biquad with coefficients A0, A1, A2, B1 and B2 coefficients + */ +/* Single precision (16-bit) Biquad section coefficients */ +typedef struct +{ + LVM_INT16 A0; + LVM_INT16 A1; + LVM_INT16 A2; + LVM_INT16 B1; + LVM_INT16 B2; + LVM_UINT16 Scale; +} BiquadA012B12CoefsSP_t; + + +/* + * Biquad with coefficients A0, A1 and B1 coefficients + */ +/* Single precision (16-bit) Biquad section coefficients */ +typedef struct +{ + LVM_INT16 A0; + LVM_INT16 A1; + LVM_INT16 B1; + LVM_UINT16 Scale; +} BiquadA01B1CoefsSP_t; + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* FILTERS_H */ + diff --git a/media/libeffects/lvm/lib/Common/src/From2iToMS_16x16.c b/media/libeffects/lvm/lib/Common/src/From2iToMS_16x16.c new file mode 100755 index 0000000..fb00768 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/From2iToMS_16x16.c @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************************** + + $Author: beq07716 $ + $Revision: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION From2iToMS_16x16 +***********************************************************************************/ + +void From2iToMS_16x16( const LVM_INT16 *src, + LVM_INT16 *dstM, + LVM_INT16 *dstS, + LVM_INT16 n ) +{ + LVM_INT32 temp1,left,right; + LVM_INT16 ii; + for (ii = n; ii != 0; ii--) + { + left = (LVM_INT32)*src; + src++; + + right = (LVM_INT32)*src; + src++; + + /* Compute M signal*/ + temp1 = (left+right)>>1; + *dstM = (LVM_INT16)temp1; + dstM++; + + /* Compute S signal*/ + temp1 = (left-right)>>1; + *dstS = (LVM_INT16)temp1; + dstS++; + } + + return; +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/From2iToMono_16.c b/media/libeffects/lvm/lib/Common/src/From2iToMono_16.c new file mode 100755 index 0000000..0ebb4ae --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/From2iToMono_16.c @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************************** + + $Author: beq07716 $ + $Revision: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION From2iToMono_16 +***********************************************************************************/ + +void From2iToMono_16( const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n) +{ + LVM_INT16 ii; + LVM_INT32 Temp; + for (ii = n; ii != 0; ii--) + { + Temp = (LVM_INT32)*src; + src++; + + Temp += (LVM_INT32)*src; + src++; + + *dst = (LVM_INT16)(Temp >>1); + dst++; + } + + return; +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/From2iToMono_32.c b/media/libeffects/lvm/lib/Common/src/From2iToMono_32.c new file mode 100755 index 0000000..5181368 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/From2iToMono_32.c @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************************** + + $Author: beq07716 $ + $Revision: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION From2iToMono_32 +***********************************************************************************/ + +void From2iToMono_32( const LVM_INT32 *src, + LVM_INT32 *dst, + LVM_INT16 n) +{ + LVM_INT16 ii; + LVM_INT32 Temp; + + for (ii = n; ii != 0; ii--) + { + Temp = (*src>>1); + src++; + + Temp +=(*src>>1); + src++; + + *dst = Temp; + dst++; + } + + return; +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/InstAlloc.c b/media/libeffects/lvm/lib/Common/src/InstAlloc.c new file mode 100755 index 0000000..ff900e0 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/InstAlloc.c @@ -0,0 +1,194 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "InstAlloc.h" + +/**************************************************************************************** + * Name : InstAlloc_Init() + * Input : pms - Pointer to the INST_ALLOC instance + StartAddr - Base address of the instance memory + * Returns : Error code + * Description : Initializes the instance distribution and memory size calculation function + * Remarks : + ****************************************************************************************/ + +void InstAlloc_Init( INST_ALLOC *pms, + void *StartAddr ) +{ + pms->TotalSize = 3; + pms->pNextMember = (LVM_UINT32)(((LVM_UINT32)StartAddr + 3) & 0xFFFFFFFC);/* This code will fail if the platform address space is more than 32-bits*/ +} + + +/**************************************************************************************** + * Name : InstAlloc_AddMember() + * Input : pms - Pointer to the INST_ALLOC instance + Size - The size in bytes of the new added member + * Returns : A pointer to the new added member + * Description : Allocates space for a new member in the instance memory and returns + a pointer to this new member. The start address of all members will + be 32 bit alligned. + * Remarks : + ****************************************************************************************/ + +void* InstAlloc_AddMember( INST_ALLOC *pms, + LVM_UINT32 Size ) +{ + void *NewMemberAddress; /* Variable to temporarily store the return value */ + NewMemberAddress = (void*)pms->pNextMember; + + Size = ((Size + 3) & 0xFFFFFFFC); /* Ceil the size to a multiple of four */ + + pms->TotalSize += Size; + pms->pNextMember += Size; + + return(NewMemberAddress); +} + + +/**************************************************************************************** + * Name : InstAlloc_GetTotal() + * Input : pms - Pointer to the INST_ALLOC instance + * Returns : The instance memory size + * Description : This functions returns the calculated instance memory size + * Remarks : + ****************************************************************************************/ + +LVM_UINT32 InstAlloc_GetTotal( INST_ALLOC *pms) +{ + if (pms->TotalSize > 3) + { + return(pms->TotalSize); + } + else + { + return 0; /* No memory added */ + } +} + + +void InstAlloc_InitAll( INST_ALLOC *pms, + LVM_MemoryTable_st *pMemoryTable) +{ + LVM_UINT32 StartAddr; + + StartAddr = (LVM_UINT32)pMemoryTable->Region[LVM_PERSISTENT_SLOW_DATA].pBaseAddress; + + pms[0].TotalSize = 3; + pms[0].pNextMember = (LVM_UINT32)(((LVM_UINT32)StartAddr + 3) & 0xFFFFFFFC); + + + StartAddr = (LVM_UINT32)pMemoryTable->Region[LVM_PERSISTENT_FAST_DATA].pBaseAddress; + + pms[1].TotalSize = 3; + pms[1].pNextMember = (LVM_UINT32)(((LVM_UINT32)StartAddr + 3) & 0xFFFFFFFC); + + + StartAddr = (LVM_UINT32)pMemoryTable->Region[LVM_PERSISTENT_FAST_COEF].pBaseAddress; + + pms[2].TotalSize = 3; + pms[2].pNextMember = (LVM_UINT32)(((LVM_UINT32)StartAddr + 3) & 0xFFFFFFFC); + + + StartAddr = (LVM_UINT32)pMemoryTable->Region[LVM_TEMPORARY_FAST].pBaseAddress; + + pms[3].TotalSize = 3; + pms[3].pNextMember = (LVM_UINT32)(((LVM_UINT32)StartAddr + 3) & 0xFFFFFFFC); + +} + +/**************************************************************************************** + * Name : InstAlloc_InitAll_NULL() + * Input : pms - Pointer to array of four INST_ALLOC instances + * Returns : Nothing + * Description : This function reserves Size of 3 bytes for all memory regions and + * intializes pNextMember for all regions to 0 + * Remarks : + ****************************************************************************************/ + +void InstAlloc_InitAll_NULL( INST_ALLOC *pms) +{ + pms[0].TotalSize = 3; + pms[0].pNextMember = 0; + + + pms[1].TotalSize = 3; + pms[1].pNextMember = 0; + + pms[2].TotalSize = 3; + pms[2].pNextMember = 0; + + pms[3].TotalSize = 3; + pms[3].pNextMember = 0; + +} + + +void* InstAlloc_AddMemberAll( INST_ALLOC *pms, + LVM_UINT32 Size[], + LVM_MemoryTable_st *pMemoryTable) +{ + void *NewMemberAddress; /* Variable to temporarily store the return value */ + + /* coverity[returned_pointer] Ignore coverity warning that ptr is not used */ + NewMemberAddress = InstAlloc_AddMember(&pms[LVM_PERSISTENT_SLOW_DATA], Size[LVM_PERSISTENT_SLOW_DATA]); + + pMemoryTable->Region[LVM_PERSISTENT_SLOW_DATA].Size = InstAlloc_GetTotal(&pms[LVM_PERSISTENT_SLOW_DATA]); + pMemoryTable->Region[LVM_PERSISTENT_SLOW_DATA].Type = LVM_PERSISTENT_SLOW_DATA; + pMemoryTable->Region[LVM_PERSISTENT_SLOW_DATA].pBaseAddress = LVM_NULL; + + NewMemberAddress = InstAlloc_AddMember(&pms[LVM_PERSISTENT_FAST_DATA], Size[LVM_PERSISTENT_FAST_DATA]); + + pMemoryTable->Region[LVM_PERSISTENT_FAST_DATA].Size = InstAlloc_GetTotal(&pms[LVM_PERSISTENT_FAST_DATA]); + pMemoryTable->Region[LVM_PERSISTENT_FAST_DATA].Type = LVM_PERSISTENT_FAST_DATA; + pMemoryTable->Region[LVM_PERSISTENT_FAST_DATA].pBaseAddress = LVM_NULL; + + NewMemberAddress = InstAlloc_AddMember(&pms[LVM_PERSISTENT_FAST_COEF], Size[LVM_PERSISTENT_FAST_COEF]); + + pMemoryTable->Region[LVM_PERSISTENT_FAST_COEF].Size = InstAlloc_GetTotal(&pms[LVM_PERSISTENT_FAST_COEF]); + pMemoryTable->Region[LVM_PERSISTENT_FAST_COEF].Type = LVM_PERSISTENT_FAST_COEF; + pMemoryTable->Region[LVM_PERSISTENT_FAST_COEF].pBaseAddress = LVM_NULL; + + NewMemberAddress = InstAlloc_AddMember(&pms[LVM_TEMPORARY_FAST], Size[LVM_TEMPORARY_FAST]); + + pMemoryTable->Region[LVM_TEMPORARY_FAST].Size = InstAlloc_GetTotal(&pms[LVM_TEMPORARY_FAST]); + pMemoryTable->Region[LVM_TEMPORARY_FAST].Type = LVM_TEMPORARY_FAST; + pMemoryTable->Region[LVM_TEMPORARY_FAST].pBaseAddress = LVM_NULL; + + return(NewMemberAddress); +} + + +void* InstAlloc_AddMemberAllRet( INST_ALLOC *pms, + LVM_UINT32 Size[], + void **ptr) +{ + ptr[0] = InstAlloc_AddMember(&pms[LVM_PERSISTENT_SLOW_DATA], Size[LVM_PERSISTENT_SLOW_DATA]); + ptr[1] = InstAlloc_AddMember(&pms[LVM_PERSISTENT_FAST_DATA], Size[LVM_PERSISTENT_FAST_DATA]); + ptr[2] = InstAlloc_AddMember(&pms[LVM_PERSISTENT_FAST_COEF], Size[LVM_PERSISTENT_FAST_COEF]); + ptr[3] = InstAlloc_AddMember(&pms[LVM_TEMPORARY_FAST], Size[LVM_TEMPORARY_FAST]); + + return (ptr[0]); +} diff --git a/media/libeffects/lvm/lib/Common/src/Int16LShiftToInt32_16x32.c b/media/libeffects/lvm/lib/Common/src/Int16LShiftToInt32_16x32.c new file mode 100755 index 0000000..e6be756 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/Int16LShiftToInt32_16x32.c @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************************** + + $Author: beq07716 $ + $Revision: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION INT16LSHIFTTOINT32_16X32 +***********************************************************************************/ + +void Int16LShiftToInt32_16x32(const LVM_INT16 *src, + LVM_INT32 *dst, + LVM_INT16 n, + LVM_INT16 shift ) +{ + LVM_INT16 ii; + + src += n-1; + dst += n-1; + + for (ii = n; ii != 0; ii--) + { + *dst = ( ((LVM_INT32)*src) << shift); + src--; + dst--; + } + + return; +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/Int32RShiftToInt16_Sat_32x16.c b/media/libeffects/lvm/lib/Common/src/Int32RShiftToInt16_Sat_32x16.c new file mode 100755 index 0000000..b21eef5 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/Int32RShiftToInt16_Sat_32x16.c @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************************** + + $Author: beq07716 $ + $Revision: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION INT32RSHIFTTOINT16_SAT_32X16 +***********************************************************************************/ + +void Int32RShiftToInt16_Sat_32x16(const LVM_INT32 *src, + LVM_INT16 *dst, + LVM_INT16 n, + LVM_INT16 shift ) +{ + LVM_INT32 temp; + LVM_INT16 ii; + + for (ii = n; ii != 0; ii--) + { + temp = *src >> shift; + src++; + + if (temp > 0x00007FFF) + { + *dst = 0x7FFF; + } + else if (temp < -0x00008000) + { + *dst = - 0x8000; + } + else + { + *dst = (LVM_INT16)temp; + } + + dst++; + } + + return; +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/JoinTo2i_32x32.c b/media/libeffects/lvm/lib/Common/src/JoinTo2i_32x32.c new file mode 100755 index 0000000..e04f1c3 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/JoinTo2i_32x32.c @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION JoinTo2i_32x32 +***********************************************************************************/ + +void JoinTo2i_32x32( const LVM_INT32 *srcL, + const LVM_INT32 *srcR, + LVM_INT32 *dst, + LVM_INT16 n ) +{ + LVM_INT16 ii; + + srcL += n-1; + srcR += n-1; + dst += ((2*n)-1); + + for (ii = n; ii != 0; ii--) + { + *dst = *srcR; + dst--; + srcR--; + + *dst = *srcL; + dst--; + srcL--; + } + + return; +} + +/**********************************************************************************/ + diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Core_MixHard_1St_2i_D16C31_SAT.c b/media/libeffects/lvm/lib/Common/src/LVC_Core_MixHard_1St_2i_D16C31_SAT.c new file mode 100755 index 0000000..c1d2b2c --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVC_Core_MixHard_1St_2i_D16C31_SAT.c @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************************** + + $Author: beq07716 $ + $Revision: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "LVC_Mixer_Private.h" +#include "LVM_Macros.h" +#include "ScalarArithmetic.h" + + +/********************************************************************************** + FUNCTION LVC_Core_MixHard_1St_2i_D16C31_SAT +***********************************************************************************/ + +void LVC_Core_MixHard_1St_2i_D16C31_SAT( LVMixer3_st *ptrInstance1, + LVMixer3_st *ptrInstance2, + const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n) +{ + LVM_INT32 Temp; + LVM_INT16 ii; + LVM_INT16 Current1Short; + LVM_INT16 Current2Short; + Mix_Private_st *pInstance1=(Mix_Private_st *)(ptrInstance1->PrivateParams); + Mix_Private_st *pInstance2=(Mix_Private_st *)(ptrInstance2->PrivateParams); + + + Current1Short = (LVM_INT16)(pInstance1->Current >> 16); + Current2Short = (LVM_INT16)(pInstance2->Current >> 16); + + for (ii = n; ii != 0; ii--) + { + Temp = ((LVM_INT32)*(src++) * (LVM_INT32)Current1Short)>>15; + if (Temp > 0x00007FFF) + *dst++ = 0x7FFF; + else if (Temp < -0x00008000) + *dst++ = - 0x8000; + else + *dst++ = (LVM_INT16)Temp; + + Temp = ((LVM_INT32)*(src++) * (LVM_INT32)Current2Short)>>15; + if (Temp > 0x00007FFF) + *dst++ = 0x7FFF; + else if (Temp < -0x00008000) + *dst++ = - 0x8000; + else + *dst++ = (LVM_INT16)Temp; + } + + +} +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Core_MixHard_2St_D16C31_SAT.c b/media/libeffects/lvm/lib/Common/src/LVC_Core_MixHard_2St_D16C31_SAT.c new file mode 100755 index 0000000..2bb212c --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVC_Core_MixHard_2St_D16C31_SAT.c @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************************** + + $Author: beq07716 $ + $Revision: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "LVC_Mixer_Private.h" + +/********************************************************************************** + FUNCTION LVCore_MIXHARD_2ST_D16C31_SAT +***********************************************************************************/ + +void LVC_Core_MixHard_2St_D16C31_SAT( LVMixer3_st *ptrInstance1, + LVMixer3_st *ptrInstance2, + const LVM_INT16 *src1, + const LVM_INT16 *src2, + LVM_INT16 *dst, + LVM_INT16 n) +{ + LVM_INT32 Temp; + LVM_INT16 ii; + LVM_INT16 Current1Short; + LVM_INT16 Current2Short; + Mix_Private_st *pInstance1=(Mix_Private_st *)(ptrInstance1->PrivateParams); + Mix_Private_st *pInstance2=(Mix_Private_st *)(ptrInstance2->PrivateParams); + + + Current1Short = (LVM_INT16)(pInstance1->Current >> 16); + Current2Short = (LVM_INT16)(pInstance2->Current >> 16); + + for (ii = n; ii != 0; ii--){ + Temp = (((LVM_INT32)*(src1++) * (LVM_INT32)Current1Short)>>15) + + (((LVM_INT32)*(src2++) * (LVM_INT32)Current2Short)>>15); + if (Temp > 0x00007FFF) + *dst++ = 0x7FFF; + else if (Temp < -0x00008000) + *dst++ = - 0x8000; + else + *dst++ = (LVM_INT16)Temp; + } +} + + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Core_MixInSoft_D16C31_SAT.c b/media/libeffects/lvm/lib/Common/src/LVC_Core_MixInSoft_D16C31_SAT.c new file mode 100755 index 0000000..0408f42 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVC_Core_MixInSoft_D16C31_SAT.c @@ -0,0 +1,136 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************************** + + $Author: beq07716 $ + $Revision: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "LVC_Mixer_Private.h" +#include "LVM_Macros.h" + +/********************************************************************************** + FUNCTION LVCore_MIXSOFT_1ST_D16C31_WRA +***********************************************************************************/ + +void LVC_Core_MixInSoft_D16C31_SAT( LVMixer3_st *ptrInstance, + const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n) +{ + + LVM_INT16 OutLoop; + LVM_INT16 InLoop; + LVM_INT16 CurrentShort; + LVM_INT32 ii,jj; + Mix_Private_st *pInstance=(Mix_Private_st *)(ptrInstance->PrivateParams); + LVM_INT32 Delta=pInstance->Delta; + LVM_INT32 Current=pInstance->Current; + LVM_INT32 Target=pInstance->Target; + LVM_INT32 Temp; + + InLoop = (LVM_INT16)(n >> 2); /* Process per 4 samples */ + OutLoop = (LVM_INT16)(n - (InLoop << 2)); + + if(Current Target) + Current = Target; + + CurrentShort = (LVM_INT16)(Current>>16); /* From Q31 to Q15*/ + + for (ii = OutLoop; ii != 0; ii--){ + Temp = ((LVM_INT32)*dst) + (((LVM_INT32)*(src++) * CurrentShort)>>15); /* Q15 + Q15*Q15>>15 into Q15 */ + if (Temp > 0x00007FFF) + *dst++ = 0x7FFF; + else if (Temp < -0x00008000) + *dst++ = - 0x8000; + else + *dst++ = (LVM_INT16)Temp; + } + } + + for (ii = InLoop; ii != 0; ii--){ + ADD2_SAT_32x32(Current,Delta,Temp); /* Q31 + Q31 into Q31*/ + Current=Temp; + if (Current > Target) + Current = Target; + + CurrentShort = (LVM_INT16)(Current>>16); /* From Q31 to Q15*/ + + for (jj = 4; jj!=0 ; jj--){ + Temp = ((LVM_INT32)*dst) + (((LVM_INT32)*(src++) * CurrentShort)>>15); /* Q15 + Q15*Q15>>15 into Q15 */ + if (Temp > 0x00007FFF) + *dst++ = 0x7FFF; + else if (Temp < -0x00008000) + *dst++ = - 0x8000; + else + *dst++ = (LVM_INT16)Temp; + } + } + } + else{ + if (OutLoop){ + Current -= Delta; /* Q31 + Q31 into Q31*/ + if (Current < Target) + Current = Target; + + CurrentShort = (LVM_INT16)(Current>>16); /* From Q31 to Q15*/ + + for (ii = OutLoop; ii != 0; ii--){ + Temp = ((LVM_INT32)*dst) + (((LVM_INT32)*(src++) * CurrentShort)>>15); /* Q15 + Q15*Q15>>15 into Q15 */ + if (Temp > 0x00007FFF) + *dst++ = 0x7FFF; + else if (Temp < -0x00008000) + *dst++ = - 0x8000; + else + *dst++ = (LVM_INT16)Temp; + } + } + + for (ii = InLoop; ii != 0; ii--){ + Current -= Delta; /* Q31 + Q31 into Q31*/ + if (Current < Target) + Current = Target; + + CurrentShort = (LVM_INT16)(Current>>16); /* From Q31 to Q15*/ + + for (jj = 4; jj!=0 ; jj--){ + Temp = ((LVM_INT32)*dst) + (((LVM_INT32)*(src++) * CurrentShort)>>15); /* Q15 + Q15*Q15>>15 into Q15 */ + if (Temp > 0x00007FFF) + *dst++ = 0x7FFF; + else if (Temp < -0x00008000) + *dst++ = - 0x8000; + else + *dst++ = (LVM_INT16)Temp; + } + } + } + pInstance->Current=Current; +} + + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Core_MixSoft_1St_2i_D16C31_WRA.c b/media/libeffects/lvm/lib/Common/src/LVC_Core_MixSoft_1St_2i_D16C31_WRA.c new file mode 100755 index 0000000..2847d47 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVC_Core_MixSoft_1St_2i_D16C31_WRA.c @@ -0,0 +1,151 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************************** + + $Author: beq07716 $ + $Revision: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "LVC_Mixer_Private.h" +#include "ScalarArithmetic.h" +#include "LVM_Macros.h" + +/********************************************************************************** + FUNCTION LVC_Core_MixSoft_1St_2i_D16C31_WRA +***********************************************************************************/ + +void LVC_Core_MixSoft_1St_2i_D16C31_WRA( LVMixer3_st *ptrInstance1, + LVMixer3_st *ptrInstance2, + const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n) +{ + LVM_INT16 OutLoop; + LVM_INT16 InLoop; + LVM_INT16 CurrentShortL; + LVM_INT16 CurrentShortR; + LVM_INT32 ii; + Mix_Private_st *pInstanceL=(Mix_Private_st *)(ptrInstance1->PrivateParams); + Mix_Private_st *pInstanceR=(Mix_Private_st *)(ptrInstance2->PrivateParams); + + LVM_INT32 DeltaL=pInstanceL->Delta; + LVM_INT32 CurrentL=pInstanceL->Current; + LVM_INT32 TargetL=pInstanceL->Target; + + LVM_INT32 DeltaR=pInstanceR->Delta; + LVM_INT32 CurrentR=pInstanceR->Current; + LVM_INT32 TargetR=pInstanceR->Target; + + LVM_INT32 Temp; + + InLoop = (LVM_INT16)(n >> 2); /* Process per 4 samples */ + OutLoop = (LVM_INT16)(n - (InLoop << 2)); + + if (OutLoop) + { + if(CurrentL TargetL) + CurrentL = TargetL; + } + else + { + CurrentL -= DeltaL; /* Q31 + Q31 into Q31*/ + if (CurrentL < TargetL) + CurrentL = TargetL; + } + + if(CurrentR TargetR) + CurrentR = TargetR; + } + else + { + CurrentR -= DeltaR; /* Q31 + Q31 into Q31*/ + if (CurrentR < TargetR) + CurrentR = TargetR; + } + + CurrentShortL = (LVM_INT16)(CurrentL>>16); /* From Q31 to Q15*/ + CurrentShortR = (LVM_INT16)(CurrentR>>16); /* From Q31 to Q15*/ + + for (ii = OutLoop*2; ii != 0; ii-=2) + { + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShortL)>>15); /* Q15*Q15>>15 into Q15 */ + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShortR)>>15); /* Q15*Q15>>15 into Q15 */ + } + } + + for (ii = InLoop*2; ii != 0; ii-=2) + { + if(CurrentL TargetL) + CurrentL = TargetL; + } + else + { + CurrentL -= DeltaL; /* Q31 + Q31 into Q31*/ + if (CurrentL < TargetL) + CurrentL = TargetL; + } + + if(CurrentR TargetR) + CurrentR = TargetR; + } + else + { + CurrentR -= DeltaR; /* Q31 + Q31 into Q31*/ + if (CurrentR < TargetR) + CurrentR = TargetR; + } + + CurrentShortL = (LVM_INT16)(CurrentL>>16); /* From Q31 to Q15*/ + CurrentShortR = (LVM_INT16)(CurrentR>>16); /* From Q31 to Q15*/ + + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShortL)>>15); /* Q15*Q15>>15 into Q15 */ + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShortR)>>15); /* Q15*Q15>>15 into Q15 */ + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShortL)>>15); + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShortR)>>15); + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShortL)>>15); + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShortR)>>15); + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShortL)>>15); + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShortR)>>15); + } + pInstanceL->Current=CurrentL; + pInstanceR->Current=CurrentR; + +} +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Core_MixSoft_1St_D16C31_WRA.c b/media/libeffects/lvm/lib/Common/src/LVC_Core_MixSoft_1St_D16C31_WRA.c new file mode 100755 index 0000000..78f0122 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVC_Core_MixSoft_1St_D16C31_WRA.c @@ -0,0 +1,114 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************************** + + $Author: beq07716 $ + $Revision: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "LVC_Mixer_Private.h" +#include "LVM_Macros.h" +#include "ScalarArithmetic.h" + +/********************************************************************************** + FUNCTION LVCore_MIXSOFT_1ST_D16C31_WRA +***********************************************************************************/ + +void LVC_Core_MixSoft_1St_D16C31_WRA( LVMixer3_st *ptrInstance, + const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n) +{ + LVM_INT16 OutLoop; + LVM_INT16 InLoop; + LVM_INT16 CurrentShort; + LVM_INT32 ii; + Mix_Private_st *pInstance=(Mix_Private_st *)(ptrInstance->PrivateParams); + LVM_INT32 Delta=pInstance->Delta; + LVM_INT32 Current=pInstance->Current; + LVM_INT32 Target=pInstance->Target; + LVM_INT32 Temp; + + InLoop = (LVM_INT16)(n >> 2); /* Process per 4 samples */ + OutLoop = (LVM_INT16)(n - (InLoop << 2)); + + if(Current Target) + Current = Target; + + CurrentShort = (LVM_INT16)(Current>>16); /* From Q31 to Q15*/ + + for (ii = OutLoop; ii != 0; ii--){ + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShort)>>15); /* Q15*Q15>>15 into Q15 */ + } + } + + for (ii = InLoop; ii != 0; ii--){ + ADD2_SAT_32x32(Current,Delta,Temp); /* Q31 + Q31 into Q31*/ + Current=Temp; + if (Current > Target) + Current = Target; + + CurrentShort = (LVM_INT16)(Current>>16); /* From Q31 to Q15*/ + + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShort)>>15); /* Q15*Q15>>15 into Q15 */ + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShort)>>15); + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShort)>>15); + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShort)>>15); + } + } + else{ + if (OutLoop){ + Current -= Delta; /* Q31 + Q31 into Q31*/ + if (Current < Target) + Current = Target; + + CurrentShort = (LVM_INT16)(Current>>16); /* From Q31 to Q15*/ + + for (ii = OutLoop; ii != 0; ii--){ + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShort)>>15); /* Q15*Q15>>15 into Q15 */ + } + } + + for (ii = InLoop; ii != 0; ii--){ + Current -= Delta; /* Q31 + Q31 into Q31*/ + if (Current < Target) + Current = Target; + + CurrentShort = (LVM_INT16)(Current>>16); /* From Q31 to Q15*/ + + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShort)>>15); /* Q15*Q15>>15 into Q15 */ + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShort)>>15); + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShort)>>15); + *(dst++) = (LVM_INT16)(((LVM_INT32)*(src++) * (LVM_INT32)CurrentShort)>>15); + } + } + pInstance->Current=Current; +} + + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/LVC_MixInSoft_D16C31_SAT.c b/media/libeffects/lvm/lib/Common/src/LVC_MixInSoft_D16C31_SAT.c new file mode 100755 index 0000000..52be129 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVC_MixInSoft_D16C31_SAT.c @@ -0,0 +1,120 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************************** + + $Author: beq07716 $ + $Revision: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "LVC_Mixer_Private.h" +#include "VectorArithmetic.h" +#include "ScalarArithmetic.h" + +/********************************************************************************** + DEFINITIONS +***********************************************************************************/ + +#define TRUE 1 +#define FALSE 0 + +/********************************************************************************** + FUNCTION MIXINSOFT_D16C31_SAT +***********************************************************************************/ + +void LVC_MixInSoft_D16C31_SAT( LVMixer3_1St_st *ptrInstance, + LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n) +{ + char HardMixing = TRUE; + LVM_INT32 TargetGain; + Mix_Private_st *pInstance=(Mix_Private_st *)(ptrInstance->MixerStream[0].PrivateParams); + + if(n<=0) return; + + /****************************************************************************** + SOFT MIXING + *******************************************************************************/ + if (pInstance->Current != pInstance->Target) + { + if(pInstance->Delta == 0x7FFFFFFF){ + pInstance->Current = pInstance->Target; + TargetGain=pInstance->Target>>(16-pInstance->Shift); // TargetGain in Q16.15 format + LVC_Mixer_SetTarget(&(ptrInstance->MixerStream[0]),TargetGain); + }else if (Abs_32(pInstance->Current-pInstance->Target) < pInstance->Delta){ + pInstance->Current = pInstance->Target; /* Difference is not significant anymore. Make them equal. */ + TargetGain=pInstance->Target>>(16-pInstance->Shift); // TargetGain in Q16.15 format + LVC_Mixer_SetTarget(&(ptrInstance->MixerStream[0]),TargetGain); + }else{ + /* Soft mixing has to be applied */ + HardMixing = FALSE; + if(pInstance->Shift!=0){ + Shift_Sat_v16xv16 ((LVM_INT16)pInstance->Shift,src,src,n); + LVC_Core_MixInSoft_D16C31_SAT( &(ptrInstance->MixerStream[0]), src, dst, n); + } + else + LVC_Core_MixInSoft_D16C31_SAT( &(ptrInstance->MixerStream[0]), src, dst, n); + } + } + + /****************************************************************************** + HARD MIXING + *******************************************************************************/ + + if (HardMixing){ + if (pInstance->Target != 0){ /* Nothing to do in case Target = 0 */ + if ((pInstance->Target>>16) == 0x7FFF){ + if(pInstance->Shift!=0) + Shift_Sat_v16xv16 ((LVM_INT16)pInstance->Shift,src,src,n); + Add2_Sat_16x16( src, dst, n ); + } + else{ + if(pInstance->Shift!=0) + Shift_Sat_v16xv16 ((LVM_INT16)pInstance->Shift,src,src,n); + Mac3s_Sat_16x16(src,(LVM_INT16)(pInstance->Target>>16),dst,n); + pInstance->Current = pInstance->Target; /* In case the LVCore function would have changed the Current value */ + } + } + } + + + /****************************************************************************** + CALL BACK + *******************************************************************************/ + + if (ptrInstance->MixerStream[0].CallbackSet){ + if (Abs_32(pInstance->Current-pInstance->Target) < pInstance->Delta){ + pInstance->Current = pInstance->Target; /* Difference is not significant anymore. Make them equal. */ + TargetGain=pInstance->Target>>(16-pInstance->Shift); // TargetGain in Q16.15 format + LVC_Mixer_SetTarget(ptrInstance->MixerStream,TargetGain); + ptrInstance->MixerStream[0].CallbackSet = FALSE; + if (ptrInstance->MixerStream[0].pCallBack != 0){ + (*ptrInstance->MixerStream[0].pCallBack) ( ptrInstance->MixerStream[0].pCallbackHandle, ptrInstance->MixerStream[0].pGeneralPurpose,ptrInstance->MixerStream[0].CallbackParam ); + } + } + } + +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/LVC_MixSoft_1St_2i_D16C31_SAT.c b/media/libeffects/lvm/lib/Common/src/LVC_MixSoft_1St_2i_D16C31_SAT.c new file mode 100755 index 0000000..d832e06 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVC_MixSoft_1St_2i_D16C31_SAT.c @@ -0,0 +1,160 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************************** + + $Author: beq07716 $ + $Revision: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "LVC_Mixer_Private.h" +#include "VectorArithmetic.h" +#include "ScalarArithmetic.h" + +/********************************************************************************** + DEFINITIONS +***********************************************************************************/ + +#define TRUE 1 +#define FALSE 0 + +/********************************************************************************** + FUNCTION LVC_MixSoft_1St_2i_D16C31_SAT +***********************************************************************************/ + +void LVC_MixSoft_1St_2i_D16C31_SAT( LVMixer3_2St_st *ptrInstance, + const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n) +{ + char HardMixing = TRUE; + LVM_INT32 TargetGain; + Mix_Private_st *pInstance1=(Mix_Private_st *)(ptrInstance->MixerStream[0].PrivateParams); + Mix_Private_st *pInstance2=(Mix_Private_st *)(ptrInstance->MixerStream[1].PrivateParams); + + if(n<=0) return; + + /****************************************************************************** + SOFT MIXING + *******************************************************************************/ + if ((pInstance1->Current != pInstance1->Target)||(pInstance2->Current != pInstance2->Target)) + { + if(pInstance1->Delta == 0x7FFFFFFF) + { + pInstance1->Current = pInstance1->Target; + TargetGain=pInstance1->Target>>16; // TargetGain in Q16.15 format, no integer part + LVC_Mixer_SetTarget(&(ptrInstance->MixerStream[0]),TargetGain); + } + else if (Abs_32(pInstance1->Current-pInstance1->Target) < pInstance1->Delta) + { + pInstance1->Current = pInstance1->Target; /* Difference is not significant anymore. Make them equal. */ + TargetGain=pInstance1->Target>>16; // TargetGain in Q16.15 format, no integer part + LVC_Mixer_SetTarget(&(ptrInstance->MixerStream[0]),TargetGain); + } + else + { + /* Soft mixing has to be applied */ + HardMixing = FALSE; + } + + if(HardMixing == TRUE) + { + if(pInstance2->Delta == 0x7FFFFFFF) + { + pInstance2->Current = pInstance2->Target; + TargetGain=pInstance2->Target>>16; // TargetGain in Q16.15 format, no integer part + LVC_Mixer_SetTarget(&(ptrInstance->MixerStream[1]),TargetGain); + } + else if (Abs_32(pInstance2->Current-pInstance2->Target) < pInstance2->Delta) + { + pInstance2->Current = pInstance2->Target; /* Difference is not significant anymore. Make them equal. */ + TargetGain=pInstance2->Target>>16; // TargetGain in Q16.15 format, no integer part + LVC_Mixer_SetTarget(&(ptrInstance->MixerStream[1]),TargetGain); + } + else + { + /* Soft mixing has to be applied */ + HardMixing = FALSE; + } + } + + if(HardMixing == FALSE) + { + LVC_Core_MixSoft_1St_2i_D16C31_WRA( &(ptrInstance->MixerStream[0]),&(ptrInstance->MixerStream[1]), src, dst, n); + } + } + + /****************************************************************************** + HARD MIXING + *******************************************************************************/ + + if (HardMixing) + { + if (((pInstance1->Target>>16) == 0x7FFF)&&((pInstance2->Target>>16) == 0x7FFF)) + { + if(src!=dst) + { + Copy_16(src, dst, n); + } + } + else + { + LVC_Core_MixHard_1St_2i_D16C31_SAT(&(ptrInstance->MixerStream[0]),&(ptrInstance->MixerStream[1]), src, dst, n); + } + } + + /****************************************************************************** + CALL BACK + *******************************************************************************/ + + if (ptrInstance->MixerStream[0].CallbackSet) + { + if (Abs_32(pInstance1->Current-pInstance1->Target) < pInstance1->Delta) + { + pInstance1->Current = pInstance1->Target; /* Difference is not significant anymore. Make them equal. */ + TargetGain=pInstance1->Target>>(16-pInstance1->Shift); // TargetGain in Q16.15 format + LVC_Mixer_SetTarget(&ptrInstance->MixerStream[0],TargetGain); + ptrInstance->MixerStream[0].CallbackSet = FALSE; + if (ptrInstance->MixerStream[0].pCallBack != 0) + { + (*ptrInstance->MixerStream[0].pCallBack) ( ptrInstance->MixerStream[0].pCallbackHandle, ptrInstance->MixerStream[0].pGeneralPurpose,ptrInstance->MixerStream[0].CallbackParam ); + } + } + } + if (ptrInstance->MixerStream[1].CallbackSet) + { + if (Abs_32(pInstance2->Current-pInstance2->Target) < pInstance2->Delta) + { + pInstance2->Current = pInstance2->Target; /* Difference is not significant anymore. Make them equal. */ + TargetGain=pInstance2->Target>>(16-pInstance2->Shift); // TargetGain in Q16.15 format + LVC_Mixer_SetTarget(&ptrInstance->MixerStream[1],TargetGain); + ptrInstance->MixerStream[1].CallbackSet = FALSE; + if (ptrInstance->MixerStream[1].pCallBack != 0) + { + (*ptrInstance->MixerStream[1].pCallBack) ( ptrInstance->MixerStream[1].pCallbackHandle, ptrInstance->MixerStream[1].pGeneralPurpose,ptrInstance->MixerStream[1].CallbackParam ); + } + } + } +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/LVC_MixSoft_1St_D16C31_SAT.c b/media/libeffects/lvm/lib/Common/src/LVC_MixSoft_1St_D16C31_SAT.c new file mode 100755 index 0000000..cfb1239 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVC_MixSoft_1St_D16C31_SAT.c @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************************** + + $Author: beq07716 $ + $Revision: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "LVC_Mixer_Private.h" +#include "VectorArithmetic.h" +#include "ScalarArithmetic.h" + +/********************************************************************************** + DEFINITIONS +***********************************************************************************/ + +#define TRUE 1 +#define FALSE 0 + +/********************************************************************************** + FUNCTION LVMixer3_MIXSOFT_1ST_D16C31_SAT +***********************************************************************************/ + +void LVC_MixSoft_1St_D16C31_SAT( LVMixer3_1St_st *ptrInstance, + const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n) +{ + char HardMixing = TRUE; + LVM_INT32 TargetGain; + Mix_Private_st *pInstance=(Mix_Private_st *)(ptrInstance->MixerStream[0].PrivateParams); + + if(n<=0) return; + + /****************************************************************************** + SOFT MIXING + *******************************************************************************/ + if (pInstance->Current != pInstance->Target) + { + if(pInstance->Delta == 0x7FFFFFFF){ + pInstance->Current = pInstance->Target; + TargetGain=pInstance->Target>>(16-pInstance->Shift); // TargetGain in Q16.15 format + LVC_Mixer_SetTarget(&(ptrInstance->MixerStream[0]),TargetGain); + }else if (Abs_32(pInstance->Current-pInstance->Target) < pInstance->Delta){ + pInstance->Current = pInstance->Target; /* Difference is not significant anymore. Make them equal. */ + TargetGain=pInstance->Target>>(16-pInstance->Shift); // TargetGain in Q16.15 format + LVC_Mixer_SetTarget(&(ptrInstance->MixerStream[0]),TargetGain); + }else{ + /* Soft mixing has to be applied */ + HardMixing = FALSE; + if(pInstance->Shift!=0){ + Shift_Sat_v16xv16 ((LVM_INT16)pInstance->Shift,src,dst,n); + LVC_Core_MixSoft_1St_D16C31_WRA( &(ptrInstance->MixerStream[0]), dst, dst, n); + } + else + LVC_Core_MixSoft_1St_D16C31_WRA( &(ptrInstance->MixerStream[0]), src, dst, n); + } + } + + /****************************************************************************** + HARD MIXING + *******************************************************************************/ + + if (HardMixing){ + if (pInstance->Target == 0) + LoadConst_16(0, dst, n); + else if(pInstance->Shift!=0){ + Shift_Sat_v16xv16 ((LVM_INT16)pInstance->Shift,src,dst,n); + if ((pInstance->Target>>16) != 0x7FFF) + Mult3s_16x16( dst, (LVM_INT16)(pInstance->Target>>16), dst, n ); + } + else { + if ((pInstance->Target>>16) != 0x7FFF) + Mult3s_16x16( src, (LVM_INT16)(pInstance->Target>>16), dst, n ); + else if(src!=dst) + Copy_16(src, dst, n); + } + + } + + /****************************************************************************** + CALL BACK + *******************************************************************************/ + + if (ptrInstance->MixerStream[0].CallbackSet){ + if (Abs_32(pInstance->Current-pInstance->Target) < pInstance->Delta){ + pInstance->Current = pInstance->Target; /* Difference is not significant anymore. Make them equal. */ + TargetGain=pInstance->Target>>(16-pInstance->Shift); // TargetGain in Q16.15 format + LVC_Mixer_SetTarget(ptrInstance->MixerStream,TargetGain); + ptrInstance->MixerStream[0].CallbackSet = FALSE; + if (ptrInstance->MixerStream[0].pCallBack != 0){ + (*ptrInstance->MixerStream[0].pCallBack) ( ptrInstance->MixerStream[0].pCallbackHandle, ptrInstance->MixerStream[0].pGeneralPurpose,ptrInstance->MixerStream[0].CallbackParam ); + } + } + } +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/LVC_MixSoft_2St_D16C31_SAT.c b/media/libeffects/lvm/lib/Common/src/LVC_MixSoft_2St_D16C31_SAT.c new file mode 100755 index 0000000..6184736 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVC_MixSoft_2St_D16C31_SAT.c @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************************** + + $Author: beq07716 $ + $Revision: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "LVC_Mixer_Private.h" +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION LVC_MixSoft_2St_D16C31_SAT.c +***********************************************************************************/ + +void LVC_MixSoft_2St_D16C31_SAT( LVMixer3_2St_st *ptrInstance, + const LVM_INT16 *src1, + LVM_INT16 *src2, + LVM_INT16 *dst, + LVM_INT16 n) +{ + Mix_Private_st *pInstance1=(Mix_Private_st *)(ptrInstance->MixerStream[0].PrivateParams); + Mix_Private_st *pInstance2=(Mix_Private_st *)(ptrInstance->MixerStream[1].PrivateParams); + + if(n<=0) return; + + /****************************************************************************** + SOFT MIXING + *******************************************************************************/ + if ((pInstance1->Current == pInstance1->Target)&&(pInstance1->Current == 0)){ + LVC_MixSoft_1St_D16C31_SAT( (LVMixer3_1St_st *)(&ptrInstance->MixerStream[1]), src2, dst, n); + } + else if ((pInstance2->Current == pInstance2->Target)&&(pInstance2->Current == 0)){ + LVC_MixSoft_1St_D16C31_SAT( (LVMixer3_1St_st *)(&ptrInstance->MixerStream[0]), src1, dst, n); + } + else if ((pInstance1->Current != pInstance1->Target) || (pInstance2->Current != pInstance2->Target)) + { + LVC_MixSoft_1St_D16C31_SAT((LVMixer3_1St_st *)(&ptrInstance->MixerStream[0]), src1, dst, n); + LVC_MixInSoft_D16C31_SAT( (LVMixer3_1St_st *)(&ptrInstance->MixerStream[1]), src2, dst, n); + } + else{ + /****************************************************************************** + HARD MIXING + *******************************************************************************/ + if(pInstance2->Shift!=0) + Shift_Sat_v16xv16 ((LVM_INT16)pInstance2->Shift,src2,src2,n); + if(pInstance1->Shift!=0) + { + Shift_Sat_v16xv16 ((LVM_INT16)pInstance1->Shift,src1,dst,n); + LVC_Core_MixHard_2St_D16C31_SAT( &ptrInstance->MixerStream[0], &ptrInstance->MixerStream[1], dst, src2, dst, n); + } + else + LVC_Core_MixHard_2St_D16C31_SAT( &ptrInstance->MixerStream[0], &ptrInstance->MixerStream[1], src1, src2, dst, n); + } +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Mixer.h b/media/libeffects/lvm/lib/Common/src/LVC_Mixer.h new file mode 100755 index 0000000..3b32e21 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVC_Mixer.h @@ -0,0 +1,144 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************************** + + $Author: beq07716 $ + $Revision: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +#ifndef __LVC_MIXER_H__ +#define __LVC_MIXER_H__ + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +#include "LVM_Types.h" + +/********************************************************************************** + INSTANCE MEMORY TYPE DEFINITION +***********************************************************************************/ + +/* LVMixer3_st structure stores Instance parameters for one audio stream */ +typedef struct +{ + LVM_INT32 PrivateParams[4]; /* Private Instance params for Audio Stream */ + LVM_INT16 CallbackSet; /* Boolean. Should be set by calling application each time the target value is updated */ + LVM_INT16 CallbackParam; /* Parameter that will be used in the calback function */ + void *pCallbackHandle; /* Pointer to the instance of the callback function */ + void *pGeneralPurpose; /* Pointer for general purpose usage */ + LVM_Callback pCallBack; /* Pointer to the callback function */ +} LVMixer3_st; + +typedef struct +{ + LVMixer3_st MixerStream[1]; /* Instance Params for one Audio Stream */ +} LVMixer3_1St_st; + +typedef struct +{ + LVMixer3_st MixerStream[2]; /* Instance Params for two Audio Streams */ +} LVMixer3_2St_st; + +typedef struct +{ + LVMixer3_st MixerStream[3]; /* Instance Params for three Audio Streams */ +} LVMixer3_3St_st; + +/********************************************************************************** + FUNCTION PROTOTYPES (HIGH LEVEL FUNCTIONS) +***********************************************************************************/ + +/* Function names should be unique within first 16 characters */ +#define LVMixer3_MixSoft_1St_D16C31_SAT LVMixer3_1St_D16C31_SAT_MixSoft +#define LVMixer3_MixInSoft_D16C31_SAT LVMixer3_D16C31_SAT_MixInSoft +#define LVMixer3_MixSoft_2St_D16C31_SAT LVMixer3_2St_D16C31_SAT_MixSoft +#define LVMixer3_MixSoft_3St_D16C31_SAT LVMixer3_3St_D16C31_SAT_MixSoft + + +/*** General functions ************************************************************/ + +/**********************************************************************************/ +/* This time constant calculation function assumes the mixer will be called with */ +/* large block sizes. When the block size is small, especially if less than 4, */ +/* then the calculation will give an incorrect value for alpha, see the mixer */ +/* documentation for further details. */ +/* ********************************************************************************/ +void LVC_Mixer_SetTarget( LVMixer3_st *pStream, + LVM_INT32 TargetGain); + +LVM_INT32 LVC_Mixer_GetTarget( LVMixer3_st *pStream); + +LVM_INT32 LVC_Mixer_GetCurrent( LVMixer3_st *pStream); + +void LVC_Mixer_Init( LVMixer3_st *pStream, + LVM_INT32 TargetGain, + LVM_INT32 CurrentGain); + +void LVC_Mixer_SetTimeConstant( LVMixer3_st *pStream, + LVM_INT32 Tc_millisec, + LVM_Fs_en Fs, + LVM_INT16 NumChannels); + +void LVC_Mixer_VarSlope_SetTimeConstant( LVMixer3_st *pStream, + LVM_INT32 Tc_millisec, + LVM_Fs_en Fs, + LVM_INT16 NumChannels); + +/*** 16 bit functions *************************************************************/ + +void LVC_MixSoft_1St_D16C31_SAT( LVMixer3_1St_st *pInstance, + const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n); + +void LVC_MixInSoft_D16C31_SAT( LVMixer3_1St_st *pInstance, + LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n); + +void LVC_MixSoft_2St_D16C31_SAT( LVMixer3_2St_st *pInstance, + const LVM_INT16 *src1, + LVM_INT16 *src2, + LVM_INT16 *dst, /* dst cannot be equal to src2 */ + LVM_INT16 n); + +/**********************************************************************************/ +/* For applying different gains to Left and right chennals */ +/* MixerStream[0] applies to Left channel */ +/* MixerStream[1] applies to Right channel */ +/* Gain values should not be more that 1.0 */ +/**********************************************************************************/ +void LVC_MixSoft_1St_2i_D16C31_SAT( LVMixer3_2St_st *pInstance, + const LVM_INT16 *src, + LVM_INT16 *dst, /* dst can be equal to src */ + LVM_INT16 n); /* Number of stereo samples */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/**********************************************************************************/ + +#endif //#ifndef __LVC_MIXER_H__ + diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Mixer_GetCurrent.c b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_GetCurrent.c new file mode 100755 index 0000000..09658ba --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_GetCurrent.c @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 839 $*/ +/* $Date: 2010-06-16 14:15:52 +0200 (Wed, 16 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "LVM_Types.h" +#include "LVM_Macros.h" +#include "LVC_Mixer_Private.h" + + +/************************************************************************/ +/* FUNCTION: */ +/* LVMixer3_GetCurrent */ +/* */ +/* DESCRIPTION: */ +/* This function returns the CurrentGain in Q16.15 format */ +/* */ +/* RETURNS: */ +/* CurrentGain - CurrentGain value in Q 16.15 format */ +/* */ +/************************************************************************/ + +LVM_INT32 LVC_Mixer_GetCurrent( LVMixer3_st *pStream) +{ + LVM_INT32 CurrentGain; + Mix_Private_st *pInstance=(Mix_Private_st *)pStream->PrivateParams; + CurrentGain=pInstance->Current>>(16-pInstance->Shift); // CurrentGain in Q16.15 format + return CurrentGain; +} diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Mixer_GetTarget.c b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_GetTarget.c new file mode 100755 index 0000000..ed2cf94 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_GetTarget.c @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 839 $*/ +/* $Date: 2010-06-16 14:15:52 +0200 (Wed, 16 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "LVM_Types.h" +#include "LVM_Macros.h" +#include "LVC_Mixer_Private.h" + +/************************************************************************/ +/* FUNCTION: */ +/* LVMixer3_GetTarget */ +/* */ +/* DESCRIPTION: */ +/* This function returns the TargetGain in Q16.15 format */ +/* */ +/* RETURNS: */ +/* TargetGain - TargetGain value in Q 16.15 format */ +/* */ +/************************************************************************/ + +LVM_INT32 LVC_Mixer_GetTarget( LVMixer3_st *pStream) +{ + LVM_INT32 TargetGain; + Mix_Private_st *pInstance=(Mix_Private_st *)pStream->PrivateParams; + + TargetGain=pInstance->Target>>(16-pInstance->Shift); // TargetGain in Q16.15 format + + return TargetGain; +} diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Mixer_Init.c b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_Init.c new file mode 100755 index 0000000..c61e468 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_Init.c @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "LVM_Types.h" +#include "LVM_Macros.h" +#include "LVC_Mixer_Private.h" + +/************************************************************************/ +/* FUNCTION: */ +/* LVMixer3_Init */ +/* */ +/* DESCRIPTION: */ +/* This intialization function intializes the private instance */ +/* paramters for a given Audio Stream based on TargetGain and */ +/* CurrentGain */ +/* This function caclulates the "Shift" required to provide the */ +/* integer part of TargetGain and fractional gain values "Target" and */ +/* "Current" based on maximum(TargetGain,CurrentGain) */ +/* E.g. CurrentGain=1.9 and TargetGain=2.5 then based on */ +/* MaxGain of 2.5, Shift = 2, Current=1.9/4=0.475, Target=2.5/4=0.625 */ +/* Therefore integer gain of 4 is provided by Left Shift of 2 and */ +/* fraction gain is provided through Current=0.475 and Target=0.625 */ +/* PARAMETERS: */ +/* pStream - ptr to Instance Parameter Structure LVMixer3_st for an*/ +/* Audio Stream */ +/* TargetGain - TargetGain value in Q 16.15 format */ +/* CurrentGain - CurrentGain value in Q 16.15 format */ +/* */ +/* RETURNS: */ +/* void */ +/* */ +/************************************************************************/ + +void LVC_Mixer_Init( LVMixer3_st *pStream, + LVM_INT32 TargetGain, + LVM_INT32 CurrentGain) +{ + LVM_INT16 Shift=0; + LVM_INT32 MaxGain=TargetGain; // MaxGain is in Q16.15 format + Mix_Private_st *pInstance=(Mix_Private_st *)pStream->PrivateParams; + if(CurrentGain>MaxGain) + MaxGain=CurrentGain; // MaxGain=max(CurrentGain,TargetGain) + + MaxGain=MaxGain>>15; // MaxGain in Q31.0 format i.e Integer part only + while(MaxGain>0){ // Update Shift required to provide integer gain + Shift++; + MaxGain=MaxGain>>1; + } + pInstance->Target=TargetGain<<(16-Shift); // Update fractional gain Target + pInstance->Current=CurrentGain<<(16-Shift); // Update fractional gain Current + pInstance->Shift=Shift; // Update Shift +} + diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Mixer_Private.h b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_Private.h new file mode 100755 index 0000000..d61d670 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_Private.h @@ -0,0 +1,136 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************************** + + $Author: beq07716 $ + $Revision: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +#ifndef __LVC_MIXER_PRIVATE_H__ +#define __LVC_MIXER_PRIVATE_H__ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "LVC_Mixer.h" +#include "VectorArithmetic.h" + +/* Instance parameter structure */ +typedef struct +{ + /* General */ + LVM_INT32 Target; /* 32 bit number specifying fractional value of Target Gain */ + LVM_INT32 Current; /* 32 bit number specifying fractional valude of Current Gain */ + LVM_INT32 Shift; /* Left Shift for Integer part of Gain */ + LVM_INT32 Delta; /* 32 bit number specifying the fractional value of Delta Gain */ +} Mix_Private_st; + + + +/********************************************************************************** + DEFINITIONS +***********************************************************************************/ +#define LVCore_MixInSoft_D32C31_SAT LVCore_InSoft_D32C31_SAT +#define LVCore_MixSoft_1St_D32C31_WRA LVCore_Soft_1St_D32C31_WRA +#define LVCore_MixHard_2St_D32C31_SAT LVCore_Hard_2St_D32C31_SAT + +/********************************************************************************** + FUNCTION PROTOTYPES (LOW LEVEL SUBFUNCTIONS) +***********************************************************************************/ + +/*** 16 bit functions *************************************************************/ + +void LVC_Core_MixInSoft_D16C31_SAT( LVMixer3_st *pInstance, + const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n); + +void LVC_Core_MixSoft_1St_D16C31_WRA( LVMixer3_st *pInstance, + const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n); + +void LVC_Core_MixHard_2St_D16C31_SAT( LVMixer3_st *pInstance1, + LVMixer3_st *pInstance2, + const LVM_INT16 *src1, + const LVM_INT16 *src2, + LVM_INT16 *dst, + LVM_INT16 n); + +/**********************************************************************************/ +/* For applying different gains to Left and right chennals */ +/* ptrInstance1 applies to Left channel */ +/* ptrInstance2 applies to Right channel */ +/* Gain values should not be more that 1.0 */ +/**********************************************************************************/ + +void LVC_Core_MixSoft_1St_2i_D16C31_WRA( LVMixer3_st *ptrInstance1, + LVMixer3_st *ptrInstance2, + const LVM_INT16 *src, + LVM_INT16 *dst, /* dst can be equal to src */ + LVM_INT16 n); /* Number of stereo samples */ + +/**********************************************************************************/ +/* For applying different gains to Left and right chennals */ +/* ptrInstance1 applies to Left channel */ +/* ptrInstance2 applies to Right channel */ +/* Gain values should not be more that 1.0 */ +/**********************************************************************************/ +void LVC_Core_MixHard_1St_2i_D16C31_SAT( LVMixer3_st *ptrInstance1, + LVMixer3_st *ptrInstance2, + const LVM_INT16 *src, + LVM_INT16 *dst, /* dst can be equal to src */ + LVM_INT16 n); /* Number of stereo samples */ + + + +/*** 32 bit functions *************************************************************/ + +void LVC_Core_MixInSoft_D32C31_SAT( LVMixer3_st *pInstance, + const LVM_INT32 *src, + LVM_INT32 *dst, + LVM_INT16 n); + +void LVC_Core_MixSoft_1St_D32C31_WRA( LVMixer3_st *pInstance, + const LVM_INT32 *src, + LVM_INT32 *dst, + LVM_INT16 n); + +void LVC_Core_MixHard_2St_D32C31_SAT( LVMixer3_st *pInstance1, + LVMixer3_st *pInstance2, + const LVM_INT32 *src1, + const LVM_INT32 *src2, + LVM_INT32 *dst, + LVM_INT16 n); + +/**********************************************************************************/ + +#endif //#ifndef __LVC_MIXER_PRIVATE_H__ + + + + + + + + + + diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Mixer_SetTarget.c b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_SetTarget.c new file mode 100755 index 0000000..4d3fe0c --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_SetTarget.c @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "LVM_Types.h" +#include "LVM_Macros.h" +#include "LVC_Mixer_Private.h" + +/************************************************************************/ +/* FUNCTION: */ +/* LVMixer3_SetTarget */ +/* */ +/* DESCRIPTION: */ +/* This function updates the private instance parameters: Shift,Target,*/ +/* Current for a given Audio Stream based on new value of TargetGain */ +/* */ +/* This function caclulates the "Shift" required to provide the */ +/* integer part of TargetGain and fractional gain values "Target" and */ +/* "Current" based on maximum(TargetGain,CurrentGain) */ +/* E.g. CurrentGain=1.9 and TargetGain=2.5 then based on */ +/* MaxGain of 2.5, Shift = 2, Current=1.9/4=0.475, Target=2.5/4=0.625 */ +/* Therefore integer gain of 4 is provided by Left Shift of 2 and */ +/* fraction gain is provided through Current=0.475 and Target=0.625 */ +/* PARAMETERS: */ +/* pStream - ptr to Instance Parameter Structure LVMixer3_st */ +/* for an Audio Stream */ +/* TargetGain - TargetGain value in Q 16.15 format */ +/* */ +/* RETURNS: */ +/* void */ +/* */ +/************************************************************************/ + +void LVC_Mixer_SetTarget(LVMixer3_st *pStream, + LVM_INT32 TargetGain) +{ + LVM_INT32 Shift=0; + LVM_INT32 CurrentGain; + LVM_INT32 MaxGain=TargetGain; // MaxGain is in Q16.15 format + Mix_Private_st *pInstance=(Mix_Private_st *)pStream->PrivateParams; + CurrentGain=pInstance->Current>>(16-pInstance->Shift); // CurrentGain in Q16.15 format + if(CurrentGain>MaxGain) + MaxGain=CurrentGain; // MaxGain=max(CurrentGain,TargetGain) + + MaxGain=MaxGain>>15; // MaxGain in Q31.0 format i.e Integer part only + while(MaxGain>0){ // Update Shift required to provide integer gain + Shift++; + MaxGain=MaxGain>>1; + } + pInstance->Target=TargetGain<<(16-Shift); // Update fractional gain Target + pInstance->Current=CurrentGain<<(16-Shift); // Update fractional gain Current + pInstance->Shift=Shift; // Update Shift +} diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Mixer_SetTimeConstant.c b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_SetTimeConstant.c new file mode 100755 index 0000000..df0fd37 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_SetTimeConstant.c @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "LVM_Types.h" +#include "LVM_Macros.h" +#include "LVC_Mixer_Private.h" + +/************************************************************************/ +/* FUNCTION: */ +/* LVMixer3_SetTimeConstant */ +/* */ +/* DESCRIPTION: */ +/* This function calculates the step change for fractional gain for a */ +/* given time constant, sample rate and num channels */ +/* Delta=(2147483647*4*1000)/(NumChannels*SampleRate*Tc_millisec) */ +/* in Q 0.31 format */ +/* */ +/* PARAMETERS: */ +/* pStream - ptr to Instance Parameter Structure LVMixer3_st for an*/ +/* Audio Stream */ +/* Tc_millisec - TimeConstant i.e time required in milli second to */ +/* go from linear fractional gain of 0 to 0.99999999 */ +/* Fs - LVM_Fs_en enumerator for Sampling Frequency */ +/* NumChannels - Number of channels in Audio Stream 1=Mono, 2=Stereo */ +/* */ +/* UPDATES: */ +/* Delta - the step change for fractional gain per 4 samples */ +/* in Q0.31 format for a given Time Constant, */ +/* Sample Rate and NumChannels */ +/* RETURNS: */ +/* void */ +/************************************************************************/ + +void LVC_Mixer_SetTimeConstant(LVMixer3_st *pStream, + LVM_INT32 Tc_millisec, + LVM_Fs_en Fs, + LVM_INT16 NumChannels) +{ + LVM_INT32 DeltaTable[9]={1073741824, + 779132389, + 715827882, + 536870912, + 389566194, + 357913941, + 268435456, + 194783097, + 178956971}; + Mix_Private_st *pInstance=(Mix_Private_st *)pStream->PrivateParams; + LVM_INT32 Delta=DeltaTable[Fs]; + Delta=Delta>>(NumChannels-1); + + if(Tc_millisec==0) + Delta=0x7FFFFFFF; + else + Delta=Delta/Tc_millisec; + + if(Delta==0) + Delta=1; // If Time Constant is so large that Delta is 0, assign minimum value to Delta + + pInstance->Delta=Delta; // Delta=(2147483647*4*1000)/(NumChannels*SampleRate*Tc_millisec) in Q 0.31 format +} diff --git a/media/libeffects/lvm/lib/Common/src/LVC_Mixer_VarSlope_SetTimeConstant.c b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_VarSlope_SetTimeConstant.c new file mode 100755 index 0000000..420af9a --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVC_Mixer_VarSlope_SetTimeConstant.c @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "LVM_Types.h" +#include "LVM_Macros.h" +#include "LVC_Mixer_Private.h" + + +/************************************************************************/ +/* FUNCTION: */ +/* LVMixer3_VarSlope_SetTimeConstant */ +/* */ +/* DESCRIPTION: */ +/* This function calculates the step change for fractional gain for a */ +/* given time constant, sample rate and num channels */ +/* Delta=(2147483647*4*1000)/(NumChannels*SampleRate*Tc_millisec) */ +/* in Q 0.31 format */ +/* */ +/* PARAMETERS: */ +/* pStream - ptr to Instance Parameter Structure LVMixer3_st for an*/ +/* Audio Stream */ +/* Tc_millisec - TimeConstant i.e time required in milli second to */ +/* go from linear fractional gain of 0 to 0.99999999 */ +/* Fs - LVM_Fs_en enumerator for Sampling Frequency */ +/* NumChannels - Number of channels in Audio Stream 1=Mono, 2=Stereo */ +/* */ +/* UPDATES: */ +/* Delta - the step change for fractional gain per 4 samples */ +/* in Q0.31 format for a given Time Constant, */ +/* Sample Rate and NumChannels */ +/* RETURNS: */ +/* void */ +/************************************************************************/ + +void LVC_Mixer_VarSlope_SetTimeConstant( LVMixer3_st *pStream, + LVM_INT32 Tc_millisec, + LVM_Fs_en Fs, + LVM_INT16 NumChannels) +{ + LVM_INT32 DeltaTable[9]={1073741824, + 779132389, + 715827882, + 536870912, + 389566194, + 357913941, + 268435456, + 194783097, + 178956971}; + Mix_Private_st *pInstance=(Mix_Private_st *)pStream->PrivateParams; + LVM_INT32 Delta=DeltaTable[Fs]; + + LVM_INT32 Current; + LVM_INT32 Target; + + Delta=Delta>>(NumChannels-1); + + /* Get gain values */ + Current = LVC_Mixer_GetCurrent( pStream ); + Target = LVC_Mixer_GetTarget( pStream ); + + if (Current != Target) + { + Tc_millisec = Tc_millisec * 32767 / (Current - Target); + if (Tc_millisec<0) Tc_millisec = -Tc_millisec; + + if(Tc_millisec==0) + Delta=0x7FFFFFFF; + else + Delta=Delta/Tc_millisec; + + if(Delta==0) + Delta=1; // If Time Constant is so large that Delta is 0, assign minimum value to Delta + } + else + { + Delta =1; // Minimum value for proper call-backs (setting it to zero has some problems, to be corrected) + } + + + pInstance->Delta=Delta; // Delta=(2147483647*4*1000)/(NumChannels*SampleRate*Tc_millisec) in Q 0.31 format +} diff --git a/media/libeffects/lvm/lib/Common/src/LVM_FO_HPF.c b/media/libeffects/lvm/lib/Common/src/LVM_FO_HPF.c new file mode 100755 index 0000000..37c199e --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVM_FO_HPF.c @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: nxp27078 $*/ +/* $Revision: 762 $*/ +/* $Date: 2010-06-11 14:50:33 +0200 (vr, 11 jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "LVM_Types.h" +#include "LVM_Macros.h" +#include "ScalarArithmetic.h" +#include "BIQUAD.h" +#include "Filter.h" + + +/*-------------------------------------------------------------------------*/ +/* FUNCTION: */ +/* void LVM_FO_LPF( LVM_INT32 w , */ +/* FO_C32_Coefs_t *pCoeffs); */ +/* */ +/* */ +/* DESCRIPTION: */ +/* This function calculates the coefficient of first order low pass */ +/* filter. It uses the equations: */ +/* */ +/* B1 = (tan(w/2) - 1 ) / (tan(w/2) + 1 ) */ +/* A0 = (1 - B1) / 2 */ +/* A1 = A0 */ +/* */ +/* The value of B1 is then calculated directly from the value w by a */ +/* polynomial expansion using a 9th order polynomial. It uses the */ +/* following table of 32-bit integer polynomial coefficients: */ +/* */ +/* Coefficient Value */ +/* A0 -8388571 */ +/* A1 33547744 */ +/* A2 -66816791 */ +/* A3 173375308 */ +/* A4 -388437573 */ +/* A5 752975383 */ +/* A6 -1103016663 */ +/* A7 1121848567 */ +/* A8 -688078159 */ +/* A9 194669577 */ +/* A10 8 */ +/* */ +/* Y = (A0 + A1*X + A2*X2 + A3*X3 + ….. + AN*xN) << AN+1 */ +/* */ +/* */ +/* PARAMETERS: */ +/* */ +/* w Sample rate in radians, where: */ +/* w = 2 * Pi * Fc / Fs */ +/* Fc is the corner frequency in Hz */ +/* Fs is the sample rate in Hz */ +/* w is in Q2.29 format and data range is [0 Pi] */ +/* pCoeffs Points to the filter coefficients calculated here */ +/* in Q1.30 format */ +/* RETURNS: */ +/* */ +/*-------------------------------------------------------------------------*/ + +LVM_INT32 LVM_FO_HPF( LVM_INT32 w, + FO_C32_Coefs_t *pCoeffs) +{ + LVM_INT32 Y,Coefficients[13]={ -8388571, + 33547744, + -66816791, + 173375308, + -388437573, + 752975383, + -1103016663, + 1121848567, + -688078159, + 194669577, + 8, + 0, + 0}; + Y=LVM_Polynomial( (LVM_UINT16)9, + Coefficients, + w); + pCoeffs->B1=-Y; /* Store -B1 in filter structure instead of B1!*/ + /* A0=(1-B1)/2= B1/2 - 0.5*/ + Y=Y>>1; /* A0=Y=B1/2*/ + Y=Y-0x40000000; /* A0=Y=(B1/2 - 0.5)*/ + MUL32x16INTO32(Y, FILTER_LOSS ,pCoeffs->A0 ,15) /* Apply loss to avoid overflow*/ + pCoeffs->A1=-pCoeffs->A0; /* Store A1=-A0*/ + + return 1; +} + diff --git a/media/libeffects/lvm/lib/Common/src/LVM_FO_LPF.c b/media/libeffects/lvm/lib/Common/src/LVM_FO_LPF.c new file mode 100755 index 0000000..6c73d59 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVM_FO_LPF.c @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: nxp27078 $*/ +/* $Revision: 762 $*/ +/* $Date: 2010-06-11 14:50:33 +0200 (vr, 11 jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "LVM_Types.h" +#include "LVM_Macros.h" +#include "ScalarArithmetic.h" +#include "BIQUAD.h" +#include "Filter.h" + + +/*-------------------------------------------------------------------------*/ +/* FUNCTION: */ +/* void LVM_FO_LPF( LVM_INT32 w , */ +/* FO_C32_Coefs_t *pCoeffs); */ +/* */ +/* */ +/* DESCRIPTION: */ +/* This function calculates the coefficient of first order low pass */ +/* filter. It uses the equations: */ +/* */ +/* B1 = (tan(w/2) - 1 ) / (tan(w/2) + 1 ) */ +/* A0 = (1 + B1) / 2 */ +/* A1 = A0 */ +/* */ +/* The value of B1 is then calculated directly from the value w by a */ +/* polynomial expansion using a 9th order polynomial. It uses the */ +/* following table of 32-bit integer polynomial coefficients: */ +/* */ +/* Coefficient Value */ +/* A0 -8388571 */ +/* A1 33547744 */ +/* A2 -66816791 */ +/* A3 173375308 */ +/* A4 -388437573 */ +/* A5 752975383 */ +/* A6 -1103016663 */ +/* A7 1121848567 */ +/* A8 -688078159 */ +/* A9 194669577 */ +/* A10 8 */ +/* */ +/* Y = (A0 + A1*X + A2*X2 + A3*X3 + ….. + AN*xN) << AN+1 */ +/* */ +/* */ +/* PARAMETERS: */ +/* */ +/* w Sample rate in radians, where: */ +/* w = 2 * Pi * Fc / Fs */ +/* Fc is the corner frequency in Hz */ +/* Fs is the sample rate in Hz */ +/* w is in Q2.29 format and data range is [0 Pi] */ +/* pCoeffs Points to the filter coefficients calculated here */ +/* in Q1.30 format */ +/* RETURNS: */ +/* */ +/*-------------------------------------------------------------------------*/ + +LVM_INT32 LVM_FO_LPF( LVM_INT32 w, + FO_C32_Coefs_t *pCoeffs) +{ + LVM_INT32 Y,Coefficients[13]={ -8388571, + 33547744, + -66816791, + 173375308, + -388437573, + 752975383, + -1103016663, + 1121848567, + -688078159, + 194669577, + 8}; + Y=LVM_Polynomial( (LVM_UINT16)9, + Coefficients, + w); + pCoeffs->B1=-Y; // Store -B1 in filter structure instead of B1! + // A0=(1+B1)/2= B1/2 + 0.5 + Y=Y>>1; // A0=Y=B1/2 + Y=Y+0x40000000; // A0=Y=(B1/2 + 0.5) + MUL32x16INTO32(Y, FILTER_LOSS ,pCoeffs->A0 ,15) // Apply loss to avoid overflow + pCoeffs->A1=pCoeffs->A0; + return 1; +} + diff --git a/media/libeffects/lvm/lib/Common/src/LVM_GetOmega.c b/media/libeffects/lvm/lib/Common/src/LVM_GetOmega.c new file mode 100755 index 0000000..1cc10db --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVM_GetOmega.c @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: nxp27078 $*/ +/* $Revision: 762 $*/ +/* $Date: 2010-06-11 14:50:33 +0200 (vr, 11 jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "LVM_Types.h" +#include "Filter.h" +#include "LVM_Macros.h" + +/************************************************************************************/ +/* */ +/* Defines and Tables for 2*Pi/Fs */ +/* */ +/************************************************************************************/ + +#define LVVDL_2PiBy_8000 1727108826 /* In Q41 format */ +#define LVVDL_2PiBy_11025 1253230894 /* In Q41 format */ +#define LVVDL_2PiBy_12000 1151405884 /* In Q41 format */ + +#define LVVDL_2PiByFs_SHIFT1 12 /* Qformat shift for 8kHz, 11.025kHz and 12kHz i.e. 12=41-29 */ +#define LVVDL_2PiByFs_SHIFT2 13 /* Qformat shift for 16kHz, 22.050kHz and 24kHz i.e. 13=42-29 */ +#define LVVDL_2PiByFs_SHIFT3 14 /* Qformat shift for 32kHz, 44.1kHz and 48kHz i.e. 14=43-29 */ + +const LVM_INT32 LVVDL_2PiOnFsTable[] = {LVVDL_2PiBy_8000 , /* 8kHz in Q41, 16kHz in Q42, 32kHz in Q43 */ + LVVDL_2PiBy_11025, /* 11025 Hz in Q41, 22050Hz in Q42, 44100 Hz in Q43*/ + LVVDL_2PiBy_12000}; /* 12kHz in Q41, 24kHz in Q42, 48kHz in Q43 */ + + +const LVM_INT32 LVVDL_2PiOnFsShiftTable[]={LVVDL_2PiByFs_SHIFT1 , /* 8kHz, 11025Hz, 12kHz */ + LVVDL_2PiByFs_SHIFT2, /* 16kHz, 22050Hz, 24kHz*/ + LVVDL_2PiByFs_SHIFT3}; /* 32kHz, 44100Hz, 48kHz */ + +/*-------------------------------------------------------------------------*/ +/* FUNCTION: */ +/* LVM_GetOmega */ +/* */ +/* LVM_INT32 LVM_GetOmega(LVM_UINT16 Fc, */ +/* LVM_Fs_en Fs) */ +/* */ +/* DESCRIPTION: */ +/* This function calculates the value of w using Fc and Fs */ +/* */ +/* PARAMETERS: */ +/* */ +/* LVM_UINT16 Fc The corner frequency in Hz Q16.0 format */ +/* LVM_Fs_en Fs The SampleRate */ +/* RETURNS: */ +/* w=2*pi*Fc/Fs in Q2.29 format */ +/*-------------------------------------------------------------------------*/ + +LVM_INT32 LVM_GetOmega(LVM_UINT16 Fc, + LVM_Fs_en Fs) +{ + LVM_INT32 w; + MUL32x32INTO32((LVM_INT32)Fc,LVVDL_2PiOnFsTable[Fs%3],w,LVVDL_2PiOnFsShiftTable[Fs/3]) + return w; +} + diff --git a/media/libeffects/lvm/lib/Common/src/LVM_Mixer_FilterCoeffs.h b/media/libeffects/lvm/lib/Common/src/LVM_Mixer_FilterCoeffs.h new file mode 100755 index 0000000..00235e0 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVM_Mixer_FilterCoeffs.h @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/************************************************************************************/ +/* */ +/* Mixer library tables */ +/* */ +/* Coefficients and table values for the mixer library, generated by the Matlab */ +/* Script: Mixer_GenerateCoeffs.m */ +/* */ +/************************************************************************************/ + +#ifndef __LVM_MIXER_FILTER_COEFFS_H__ +#define __LVM_MIXER_FILTER_COEFFS_H__ + + +/************************************************************************************/ +/* */ +/* Alpha Time Constant table */ +/* */ +/************************************************************************************/ + +#define Alpha_TableSize 50 /* The number of table entires */ +#define ALPHA_0 2147480769 /* Floating point Alpha = 0.999999 */ +#define ALPHA_1 2147479577 /* Floating point Alpha = 0.999998 */ +#define ALPHA_2 2147477892 /* Floating point Alpha = 0.999997 */ +#define ALPHA_3 2147475510 /* Floating point Alpha = 0.999996 */ +#define ALPHA_4 2147472141 /* Floating point Alpha = 0.999995 */ +#define ALPHA_5 2147467377 /* Floating point Alpha = 0.999992 */ +#define ALPHA_6 2147460642 /* Floating point Alpha = 0.999989 */ +#define ALPHA_7 2147451118 /* Floating point Alpha = 0.999985 */ +#define ALPHA_8 2147437651 /* Floating point Alpha = 0.999979 */ +#define ALPHA_9 2147418608 /* Floating point Alpha = 0.999970 */ +#define ALPHA_10 2147391683 /* Floating point Alpha = 0.999957 */ +#define ALPHA_11 2147353611 /* Floating point Alpha = 0.999939 */ +#define ALPHA_12 2147299779 /* Floating point Alpha = 0.999914 */ +#define ALPHA_13 2147223662 /* Floating point Alpha = 0.999879 */ +#define ALPHA_14 2147116037 /* Floating point Alpha = 0.999829 */ +#define ALPHA_15 2146963865 /* Floating point Alpha = 0.999758 */ +#define ALPHA_16 2146748712 /* Floating point Alpha = 0.999658 */ +#define ALPHA_17 2146444522 /* Floating point Alpha = 0.999516 */ +#define ALPHA_18 2146014472 /* Floating point Alpha = 0.999316 */ +#define ALPHA_19 2145406527 /* Floating point Alpha = 0.999033 */ +#define ALPHA_20 2144547188 /* Floating point Alpha = 0.998633 */ +#define ALPHA_21 2143332669 /* Floating point Alpha = 0.998067 */ +#define ALPHA_22 2141616514 /* Floating point Alpha = 0.997268 */ +#define ALPHA_23 2139192215 /* Floating point Alpha = 0.996139 */ +#define ALPHA_24 2135768939 /* Floating point Alpha = 0.994545 */ +#define ALPHA_25 2130937774 /* Floating point Alpha = 0.992295 */ +#define ALPHA_26 2124125153 /* Floating point Alpha = 0.989123 */ +#define ALPHA_27 2114529263 /* Floating point Alpha = 0.984654 */ +#define ALPHA_28 2101034612 /* Floating point Alpha = 0.978370 */ +#define ALPHA_29 2082100030 /* Floating point Alpha = 0.969553 */ +#define ALPHA_30 2055617398 /* Floating point Alpha = 0.957221 */ +#define ALPHA_31 2018744824 /* Floating point Alpha = 0.940051 */ +#define ALPHA_32 1967733015 /* Floating point Alpha = 0.916297 */ +#define ALPHA_33 1897794587 /* Floating point Alpha = 0.883729 */ +#define ALPHA_34 1803123234 /* Floating point Alpha = 0.839645 */ +#define ALPHA_35 1677262220 /* Floating point Alpha = 0.781036 */ +#define ALPHA_36 1514142675 /* Floating point Alpha = 0.705078 */ +#define ALPHA_37 1310197875 /* Floating point Alpha = 0.610108 */ +#define ALPHA_38 1067813480 /* Floating point Alpha = 0.497239 */ +#define ALPHA_39 799601371 /* Floating point Alpha = 0.372343 */ +#define ALPHA_40 531183049 /* Floating point Alpha = 0.247351 */ +#define ALPHA_41 297904007 /* Floating point Alpha = 0.138722 */ +#define ALPHA_42 131499768 /* Floating point Alpha = 0.061234 */ +#define ALPHA_43 41375282 /* Floating point Alpha = 0.019267 */ +#define ALPHA_44 8065899 /* Floating point Alpha = 0.003756 */ +#define ALPHA_45 799076 /* Floating point Alpha = 0.000372 */ +#define ALPHA_46 30398 /* Floating point Alpha = 0.000014 */ +#define ALPHA_47 299 /* Floating point Alpha = 0.000000 */ +#define ALPHA_48 0 /* Floating point Alpha = 0.000000 */ +#define ALPHA_49 0 /* Floating point Alpha = 0.000000 */ +#define ALPHA_50 0 /* Floating point Alpha = 0.000000 */ + + +#endif diff --git a/media/libeffects/lvm/lib/Common/src/LVM_Mixer_TimeConstant.c b/media/libeffects/lvm/lib/Common/src/LVM_Mixer_TimeConstant.c new file mode 100755 index 0000000..db6975a --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVM_Mixer_TimeConstant.c @@ -0,0 +1,165 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "LVM_Types.h" +#include "LVM_Macros.h" +#include "Mixer.h" +#include "LVM_Mixer_FilterCoeffs.h" + + +/************************************************************************/ +/* FUNCTION: */ +/* LVM_Mix_GetTimeConstant */ +/* */ +/* DESCRIPTION: */ +/* This function calculates the filter coefficient using the following */ +/* equation: */ +/* Alpha = exp(ln(0.1)/ (tc * Update + 1.0)) */ +/* */ +/* This is to be used with the follow first order filter, called at a */ +/* rate of Update times a second. tc is the required time constant in */ +/* units of 100us. */ +/* */ +/* Output(n) = Alpha * Output(n-1) + (1 - Alpha) * Target(n) */ +/* */ +/* The function assumes the block size is large, i.e. the update rate */ +/* is approximately a fixed, and correct factor of the value of Fs */ +/* given in the call. This is especially not true when the block size */ +/* is very small, see the mixer documentation for further details. */ +/* */ +/* The function does not support all possible combinations of input */ +/* values: */ +/* */ +/* 1. NumChannels is limited to the values 1 (Mono) and 2 (Stereo) */ +/* 2. The product tc * Fs is limited approximately to the range */ +/* 8 < (tc * Fs) < 2^35 */ +/* */ +/* PARAMETERS: */ +/* tc - the time constant in 100us steps, i.e. 10 = 1ms */ +/* Fs - the filter update rate in Hz */ +/* NumChannels - Number of channels 1=Mono, 2=Stereo */ +/* */ +/* RETURNS: */ +/* Alpha - the filter coefficient Q31 format */ +/* */ +/************************************************************************/ + +LVM_UINT32 LVM_Mixer_TimeConstant(LVM_UINT32 tc, + LVM_UINT16 Fs, + LVM_UINT16 NumChannels) +{ + + LVM_UINT32 Product; + LVM_INT16 Interpolate; + LVM_UINT16 Shift; + LVM_INT32 Diff; + LVM_UINT32 Table[] = {ALPHA_0, /* Log spaced look-up table */ + ALPHA_1, + ALPHA_2, + ALPHA_3, + ALPHA_4, + ALPHA_5, + ALPHA_6, + ALPHA_7, + ALPHA_8, + ALPHA_9, + ALPHA_10, + ALPHA_11, + ALPHA_12, + ALPHA_13, + ALPHA_14, + ALPHA_15, + ALPHA_16, + ALPHA_17, + ALPHA_18, + ALPHA_19, + ALPHA_20, + ALPHA_21, + ALPHA_22, + ALPHA_23, + ALPHA_24, + ALPHA_25, + ALPHA_26, + ALPHA_27, + ALPHA_28, + ALPHA_29, + ALPHA_30, + ALPHA_31, + ALPHA_32, + ALPHA_33, + ALPHA_34, + ALPHA_35, + ALPHA_36, + ALPHA_37, + ALPHA_38, + ALPHA_39, + ALPHA_40, + ALPHA_41, + ALPHA_42, + ALPHA_43, + ALPHA_44, + ALPHA_45, + ALPHA_46, + ALPHA_47, + ALPHA_48, + ALPHA_49, + ALPHA_50}; + + + /* Calculate the product of the time constant and the sample rate */ + Product = ((tc >> 16) * (LVM_UINT32)Fs) << 13; /* Stereo value */ + Product = Product + (((tc & 0x0000FFFF) * (LVM_UINT32)Fs) >> 3); + + if (NumChannels == 1) + { + Product = Product >> 1; /* Mono value */ + } + + /* Normalize to get the table index and interpolation factor */ + for (Shift=0; Shift<((Alpha_TableSize-1)/2); Shift++) + { + if ((Product & 0x80000000)!=0) + { + break; + } + + Product = Product << 1; + } + Shift = (LVM_UINT16)((Shift << 1)); + + if ((Product & 0x40000000)==0) + { + Shift++; + } + + Interpolate = (LVM_INT16)((Product >> 15) & 0x00007FFF); + + Diff = (LVM_INT32)(Table[Shift] - Table[Shift+1]); + MUL32x16INTO32(Diff,Interpolate,Diff,15) + Product = Table[Shift+1] + (LVM_UINT32)Diff; + + return Product; +} diff --git a/media/libeffects/lvm/lib/Common/src/LVM_Polynomial.c b/media/libeffects/lvm/lib/Common/src/LVM_Polynomial.c new file mode 100755 index 0000000..b8cf4b4 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVM_Polynomial.c @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "LVM_Types.h" +#include "LVM_Macros.h" +#include "ScalarArithmetic.h" + +/*-------------------------------------------------------------------------*/ +/* FUNCTION: */ +/* LVM_Polynomial */ +/* */ +/* DESCRIPTION: */ +/* This function performs polynomial expansion */ +/* Y = (A0 + A1*X + A2*X2 + A3*X3 + ….. + AN*xN) << AN+1 */ +/* */ +/* LVM_INT32 LVM_Polynomial(LVM_UINT16 N, */ +/* LVM_INT32 *pCoefficients, */ +/* LVM_INT32 X) */ +/* */ +/* PARAMETERS: */ +/* */ +/* N is the polynomial order */ +/* pCoefficients is the ptr to polynomial coefficients A0,A1.. in Q.31 */ +/* X is the input variable */ +/* */ +/* RETURNS: */ +/* The result of the polynomial expansion in Q1.31 format */ +/*-------------------------------------------------------------------------*/ + +LVM_INT32 LVM_Polynomial(LVM_UINT16 N, + LVM_INT32 *pCoefficients, + LVM_INT32 X) +{ + LVM_INT32 i; + LVM_INT32 Y,A,XTemp,Temp,sign; + + Y=*pCoefficients; /* Y=A0*/ + pCoefficients++; + + if((LVM_UINT32)X==0x80000000) + { + Temp=-1; + sign=Temp; + for(i=1;i<=N;i++) + { + Y+=((*pCoefficients)*sign); + pCoefficients++; + sign*=Temp; + } + + + } + else + { + XTemp=X; + for(i=N-1;i>=0;i--) + { + A=*pCoefficients; + pCoefficients++; + + MUL32x32INTO32(A,XTemp,Temp,31) + Y+=Temp; + + MUL32x32INTO32(XTemp,X,Temp,31) + XTemp=Temp; + } + } + A=*pCoefficients; + pCoefficients++; + + if(A<0) + { + A=Abs_32(A); + Y=Y>>A; + } + else + { + Y = Y<TimerArmed){ + pInstancePr->RemainingTimeInSamples -= BlockSize; + if (pInstancePr->RemainingTimeInSamples <= 0){ + pInstancePr->TimerArmed = 0; + (*pInstancePr->pCallBack) ( pInstancePr->pCallbackInstance, + pInstancePr->pCallBackParams, + pInstancePr->CallBackParam ); + } + } +} + +/****************************************************************************************/ +/* END OF FILE */ +/****************************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/LVM_Timer_Init.c b/media/libeffects/lvm/lib/Common/src/LVM_Timer_Init.c new file mode 100755 index 0000000..e473038 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVM_Timer_Init.c @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: My Project */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/****************************************************************************************/ +/* INCLUDE FILES */ +/****************************************************************************************/ + +#include "LVM_Timer.h" +#include "LVM_Timer_Private.h" +#include "LVM_Macros.h" + +/****************************************************************************************/ +/* DEFINITIONS */ +/****************************************************************************************/ + +#define OneOverThousandInQ24 16777 + +/****************************************************************************************/ +/* INIT FUNCTION */ +/****************************************************************************************/ + +void LVM_Timer_Init ( LVM_Timer_Instance_t *pInstance, + LVM_Timer_Params_t *pParams ){ + + LVM_Timer_Instance_Private_t *pInstancePr; + pInstancePr = (LVM_Timer_Instance_Private_t *)pInstance; + + pInstancePr->CallBackParam = pParams->CallBackParam; + pInstancePr->pCallBackParams = pParams->pCallBackParams; + pInstancePr->pCallbackInstance = pParams->pCallbackInstance; + pInstancePr->pCallBack = pParams->pCallBack; + pInstancePr->TimerArmed = 1; + + MUL32x16INTO32(pParams->SamplingRate,OneOverThousandInQ24,pInstancePr->RemainingTimeInSamples,16); /* (Q0 * Q24) >>16 into Q8*/ + MUL32x16INTO32(pInstancePr->RemainingTimeInSamples,pParams->TimeInMs,pInstancePr->RemainingTimeInSamples,8); /* (Q8 * Q0) >>8 into Q0*/ +} + +/****************************************************************************************/ +/* END OF FILE */ +/****************************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/LVM_Timer_Private.h b/media/libeffects/lvm/lib/Common/src/LVM_Timer_Private.h new file mode 100755 index 0000000..04d5af6 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LVM_Timer_Private.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: My Project */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#ifndef LVM_TIMER_PRIVATE_H +#define LVM_TIMER_PRIVATE_H + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +#include "LVM_Types.h" + +/****************************************************************************************/ +/* TYPE DEFINITIONS */ +/****************************************************************************************/ + +typedef struct +{ + LVM_INT32 RemainingTimeInSamples; + LVM_INT32 CallBackParam; + LVM_INT32 *pCallBackParams; + void *pCallbackInstance; + void (*pCallBack)(void*,void*,LVM_INT32); + LVM_INT16 TimerArmed; /* Boolean, true between init and callback */ + +} LVM_Timer_Instance_Private_t; + +/****************************************************************************************/ +/* END OF HEADER */ +/****************************************************************************************/ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* LVM_TIMER_PRIVATE_H */ diff --git a/media/libeffects/lvm/lib/Common/src/LoadConst_16.c b/media/libeffects/lvm/lib/Common/src/LoadConst_16.c new file mode 100755 index 0000000..bc2735f --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LoadConst_16.c @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************************** + + $Author: beq07716 $ + $Revision: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION LoadConst_16 +***********************************************************************************/ + +void LoadConst_16(const LVM_INT16 val, + LVM_INT16 *dst, + LVM_INT16 n ) +{ + LVM_INT16 ii; + + for (ii = n; ii != 0; ii--) + { + *dst = val; + dst++; + } + + return; +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/LoadConst_32.c b/media/libeffects/lvm/lib/Common/src/LoadConst_32.c new file mode 100755 index 0000000..19d5d4e --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/LoadConst_32.c @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION LoadConst_32 +***********************************************************************************/ + +void LoadConst_32(const LVM_INT32 val, + LVM_INT32 *dst, + LVM_INT16 n ) +{ + LVM_INT16 ii; + + for (ii = n; ii != 0; ii--) + { + *dst = val; + dst++; + } + + return; +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/MSTo2i_Sat_16x16.c b/media/libeffects/lvm/lib/Common/src/MSTo2i_Sat_16x16.c new file mode 100755 index 0000000..1949f3c --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/MSTo2i_Sat_16x16.c @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************************** + + $Author: beq07716 $ + $Revision: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION MSTO2I_SAT_16X16 +***********************************************************************************/ + +void MSTo2i_Sat_16x16(const LVM_INT16 *srcM, + const LVM_INT16 *srcS, + LVM_INT16 *dst, + LVM_INT16 n ) +{ + LVM_INT32 temp,mVal,sVal; + LVM_INT16 ii; + + + for (ii = n; ii != 0; ii--) + { + mVal=(LVM_INT32)*srcM; + srcM++; + + sVal=(LVM_INT32)*srcS; + srcS++; + + temp = mVal + sVal; + + if (temp > 0x00007FFF) + { + *dst = 0x7FFF; + } + else if (temp < -0x00008000) + { + *dst = - 0x8000; + } + else + { + *dst = (LVM_INT16)temp; + } + dst++; + + temp = mVal - sVal; + + if (temp > 0x00007FFF) + { + *dst = 0x7FFF; + } + else if (temp < -0x00008000) + { + *dst = - 0x8000; + } + else + { + *dst = (LVM_INT16)temp; + } + dst++; + } + + return; +} +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/Mac3s_Sat_16x16.c b/media/libeffects/lvm/lib/Common/src/Mac3s_Sat_16x16.c new file mode 100755 index 0000000..ef04ae8 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/Mac3s_Sat_16x16.c @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************************** + + %created_by: sra % (CM/S) + %name: Mac3s_Sat_16x16.c % (CM/S) + %version: 1 % (CM/S) + %date_created: Fri Nov 13 12:07:13 2009 % (CM/S) + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" +#include "LVM_Macros.h" + +/********************************************************************************** + FUNCTION Mac3S_16X16 +***********************************************************************************/ + +void Mac3s_Sat_16x16( const LVM_INT16 *src, + const LVM_INT16 val, + LVM_INT16 *dst, + LVM_INT16 n) +{ + LVM_INT16 ii; + LVM_INT16 srcval; + LVM_INT32 Temp,dInVal; + + + for (ii = n; ii != 0; ii--) + { + srcval=*src; + src++; + + Temp = (srcval *val)>>15; + + dInVal = (LVM_INT32)*dst; + + Temp = Temp + dInVal; + + if (Temp > 0x00007FFF) + { + *dst = 0x7FFF; + } + else if (Temp < -0x00008000) + { + *dst = - 0x8000; + } + else + { + *dst = (LVM_INT16)Temp; + } + + dst++; + } + + return; +} + +/**********************************************************************************/ + + + diff --git a/media/libeffects/lvm/lib/Common/src/Mac3s_Sat_32x16.c b/media/libeffects/lvm/lib/Common/src/Mac3s_Sat_32x16.c new file mode 100755 index 0000000..746a273 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/Mac3s_Sat_32x16.c @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" +#include "LVM_Macros.h" + +/********************************************************************************** + FUNCTION MAC3S_16X16 +***********************************************************************************/ + +void Mac3s_Sat_32x16( const LVM_INT32 *src, + const LVM_INT16 val, + LVM_INT32 *dst, + LVM_INT16 n) +{ + LVM_INT16 ii; + LVM_INT32 srcval,temp, dInVal, dOutVal; + + + for (ii = n; ii != 0; ii--) + { + srcval=*src; + src++; + + MUL32x16INTO32(srcval,val,temp,15) + + dInVal = *dst; + dOutVal = temp + dInVal; + + + if ((((dOutVal ^ temp) & (dOutVal ^ dInVal)) >> 31)!=0) /* overflow / underflow */ + { + if(temp<0) + { + dOutVal=0x80000000l; + } + else + { + dOutVal=0x7FFFFFFFl; + } + } + + *dst = dOutVal; + dst++; + } + + return; +} + +/**********************************************************************************/ + + + diff --git a/media/libeffects/lvm/lib/Common/src/MixInSoft_D32C31_SAT.c b/media/libeffects/lvm/lib/Common/src/MixInSoft_D32C31_SAT.c new file mode 100755 index 0000000..36de6c1 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/MixInSoft_D32C31_SAT.c @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "Mixer_private.h" +#include "VectorArithmetic.h" + +/********************************************************************************** + DEFINITIONS +***********************************************************************************/ + +#define TRUE 1 +#define FALSE 0 + +/********************************************************************************** + FUNCTION MIXINSOFT_D32C31_SAT +***********************************************************************************/ + +void MixInSoft_D32C31_SAT( Mix_1St_Cll_t *pInstance, + const LVM_INT32 *src, + LVM_INT32 *dst, + LVM_INT16 n) +{ + char HardMixing = TRUE; + + if(n<=0) return; + + /****************************************************************************** + SOFT MIXING + *******************************************************************************/ + if (pInstance->Current != pInstance->Target) + { + if(pInstance->Alpha == 0){ + pInstance->Current = pInstance->Target; + }else if ((pInstance->Current-pInstance->Target Current-pInstance->Target > -POINT_ZERO_ONE_DB)){ + pInstance->Current = pInstance->Target; /* Difference is not significant anymore. Make them equal. */ + }else{ + /* Soft mixing has to be applied */ + HardMixing = FALSE; + Core_MixInSoft_D32C31_SAT( pInstance, src, dst, n); + } + } + + /****************************************************************************** + HARD MIXING + *******************************************************************************/ + + if (HardMixing){ + if (pInstance->Target != 0){ /* Nothing to do in case Target = 0 */ + if ((pInstance->Target>>16) == 0x7FFF) + Add2_Sat_32x32( src, dst, n ); + else{ + Core_MixInSoft_D32C31_SAT( pInstance, src, dst, n); + pInstance->Current = pInstance->Target; /* In case the core function would have changed the Current value */ + } + } + } + + /****************************************************************************** + CALL BACK + *******************************************************************************/ + /* Call back before the hard mixing, because in this case, hard mixing makes + use of the core soft mix function which can change the Current value! */ + + if (pInstance->CallbackSet){ + if ((pInstance->Current-pInstance->Target Current-pInstance->Target > -POINT_ZERO_ONE_DB)){ + pInstance->Current = pInstance->Target; /* Difference is not significant anymore. Make them equal. */ + pInstance->CallbackSet = FALSE; + if (pInstance->pCallBack != 0){ + (*pInstance->pCallBack) ( pInstance->pCallbackHandle, pInstance->pGeneralPurpose,pInstance->CallbackParam ); + } + } + } +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/MixSoft_1St_D32C31_WRA.c b/media/libeffects/lvm/lib/Common/src/MixSoft_1St_D32C31_WRA.c new file mode 100755 index 0000000..5cf1a29 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/MixSoft_1St_D32C31_WRA.c @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "Mixer_private.h" +#include "VectorArithmetic.h" + +/********************************************************************************** + DEFINITIONS +***********************************************************************************/ + +#define TRUE 1 +#define FALSE 0 + + + +/********************************************************************************** + FUNCTION MIXSOFT_1ST_D32C31_WRA +***********************************************************************************/ + +void MixSoft_1St_D32C31_WRA( Mix_1St_Cll_t *pInstance, + const LVM_INT32 *src, + LVM_INT32 *dst, + LVM_INT16 n) +{ + char HardMixing = TRUE; + + if(n<=0) return; + + /****************************************************************************** + SOFT MIXING + *******************************************************************************/ + if (pInstance->Current != pInstance->Target) + { + if(pInstance->Alpha == 0){ + pInstance->Current = pInstance->Target; + }else if ((pInstance->Current-pInstance->Target Current-pInstance->Target > -POINT_ZERO_ONE_DB)){ + pInstance->Current = pInstance->Target; /* Difference is not significant anymore. Make them equal. */ + }else{ + /* Soft mixing has to be applied */ + HardMixing = FALSE; + Core_MixSoft_1St_D32C31_WRA( pInstance, src, dst, n); + } + } + + /****************************************************************************** + HARD MIXING + *******************************************************************************/ + + if (HardMixing){ + if (pInstance->Target == 0) + LoadConst_32(0, dst, n); + else if ((pInstance->Target>>16) == 0x7FFF){ + if (src != dst) + Copy_16((LVM_INT16*)src, (LVM_INT16*)dst, (LVM_INT16)(n * 2)); + } + else + Mult3s_32x16( src, (LVM_INT16)(pInstance->Current>>16), dst, n ); + } + + /****************************************************************************** + CALL BACK + *******************************************************************************/ + + if (pInstance->CallbackSet){ + if ((pInstance->Current-pInstance->Target Current-pInstance->Target > -POINT_ZERO_ONE_DB)){ + pInstance->Current = pInstance->Target; /* Difference is not significant anymore. Make them equal. */ + pInstance->CallbackSet = FALSE; + if (pInstance->pCallBack != 0){ + (*pInstance->pCallBack) ( pInstance->pCallbackHandle, pInstance->pGeneralPurpose,pInstance->CallbackParam ); + } + } + } +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/MixSoft_2St_D32C31_SAT.c b/media/libeffects/lvm/lib/Common/src/MixSoft_2St_D32C31_SAT.c new file mode 100755 index 0000000..b03f0ba --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/MixSoft_2St_D32C31_SAT.c @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "Mixer_private.h" +#include "VectorArithmetic.h" + + +/********************************************************************************** + FUNCTION MIXSOFT_2ST_D32C31_SAT +***********************************************************************************/ + +void MixSoft_2St_D32C31_SAT( Mix_2St_Cll_t *pInstance, + const LVM_INT32 *src1, + const LVM_INT32 *src2, + LVM_INT32 *dst, + LVM_INT16 n) +{ + + if(n<=0) return; + + /****************************************************************************** + SOFT MIXING + *******************************************************************************/ + if ((pInstance->Current1 != pInstance->Target1) || (pInstance->Current2 != pInstance->Target2)) + { + MixSoft_1St_D32C31_WRA( (Mix_1St_Cll_t*) pInstance, src1, dst, n); + MixInSoft_D32C31_SAT( (Mix_1St_Cll_t*) &pInstance->Alpha2, src2, dst, n); + } + + /****************************************************************************** + HARD MIXING + *******************************************************************************/ + + else + { + if (pInstance->Current1 == 0) + MixSoft_1St_D32C31_WRA( (Mix_1St_Cll_t*) &pInstance->Alpha2, src2, dst, n); + else if (pInstance->Current2 == 0) + MixSoft_1St_D32C31_WRA( (Mix_1St_Cll_t*) pInstance, src1, dst, n); + else + Core_MixHard_2St_D32C31_SAT( pInstance, src1, src2, dst, n); + } +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/Mixer_private.h b/media/libeffects/lvm/lib/Common/src/Mixer_private.h new file mode 100755 index 0000000..d012548 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/Mixer_private.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************************** + + $Author: beq07716 $ + $Revision: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +#ifndef __MIXER_PRIVATE_H__ +#define __MIXER_PRIVATE_H__ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "Mixer.h" + +#define POINT_ZERO_ONE_DB 2473805 /* 0.01 dB on a full scale signal = (10^(0.01/20) -1) * 2^31 */ + +/********************************************************************************** + DEFINITIONS +***********************************************************************************/ + +/**********************************************************************************/ + +#endif //#ifndef __MIXER_PRIVATE_H__ + diff --git a/media/libeffects/lvm/lib/Common/src/MonoTo2I_16.c b/media/libeffects/lvm/lib/Common/src/MonoTo2I_16.c new file mode 100755 index 0000000..b053e55 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/MonoTo2I_16.c @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************************** + + $Author: beq07716 $ + $Revision: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION MonoTo2I_16 +***********************************************************************************/ + +void MonoTo2I_16( const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n) +{ + LVM_INT16 ii; + src += (n-1); + dst += ((n*2)-1); + + for (ii = n; ii != 0; ii--) + { + *dst = *src; + dst--; + + *dst = *src; + dst--; + src--; + } + + return; +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/MonoTo2I_32.c b/media/libeffects/lvm/lib/Common/src/MonoTo2I_32.c new file mode 100755 index 0000000..e8164bb --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/MonoTo2I_32.c @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION MonoTo2I_32 +***********************************************************************************/ + +void MonoTo2I_32( const LVM_INT32 *src, + LVM_INT32 *dst, + LVM_INT16 n) +{ + LVM_INT16 ii; + src += (n-1); + dst += ((n*2)-1); + + for (ii = n; ii != 0; ii--) + { + *dst = *src; + dst--; + + *dst = *src; + dst--; + src--; + } + + return; +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/Mult3s_32x16.c b/media/libeffects/lvm/lib/Common/src/Mult3s_32x16.c new file mode 100755 index 0000000..ee83524 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/Mult3s_32x16.c @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" +#include "LVM_Macros.h" + +/********************************************************************************** +FUNCTION MULT3S_16X16 +***********************************************************************************/ + +void Mult3s_32x16( const LVM_INT32 *src, + const LVM_INT16 val, + LVM_INT32 *dst, + LVM_INT16 n) +{ + LVM_INT16 ii; + LVM_INT32 srcval,temp; + + for (ii = n; ii != 0; ii--) + { + srcval=*src; + src++; + + MUL32x16INTO32(srcval,val,temp,15) + + *dst = temp; + dst++; + } + + return; +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/NonLinComp_D16.c b/media/libeffects/lvm/lib/Common/src/NonLinComp_D16.c new file mode 100755 index 0000000..1428777 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/NonLinComp_D16.c @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************************** + + $Author: beq07716 $ + $Revision: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/****************************************************************************************/ +/* */ +/* Includes */ +/* */ +/****************************************************************************************/ + +#include "CompLim_private.h" + +/****************************************************************************************/ +/* */ +/* FUNCTION: NonLinComp_D16 */ +/* */ +/* DESCRIPTION: */ +/* Non-linear compression by companding. The function works on a sample by sample */ +/* basis by increasing the level near the zero crossing. This gives a ttrade-off */ +/* between THD and compression. It uses the equation: */ +/* */ +/* Output = Input + K * (Input - Input^2) if Input > 0 */ +/* = Input + K * (Input + Input^2) if Input <= 0 */ +/* */ +/* The value of K controls the amount of compression and as a side effect the amount */ +/* distortion introduced. The amount of compression is signal dependent and the values */ +/* given below are approximate. */ +/* */ +/* Gain (fractional) Gain (integer) Compression Pk-Pk THD */ +/* 1.0 32767 +6dB 16dB */ +/* 0.78 25559 +5dB 19dB */ +/* 0.6 19661 +4dB 21dB */ +/* 0.41 13435 +3dB 24dB */ +/* 0.26 8520 +2dB 28dB */ +/* 0.12 3932 +1dB 34dB */ +/* 0.0 0 +0dB 98dB */ +/* */ +/* PARAMETERS: */ +/* Gain - compression control parameter */ +/* pDataIn - pointer to the input data buffer */ +/* pDataOut - pointer to the output data buffer */ +/* BlockLength - number of samples to process */ +/* */ +/* RETURNS: */ +/* None */ +/* */ +/* NOTES: */ +/* */ +/****************************************************************************************/ + +void NonLinComp_D16(LVM_INT16 Gain, + LVM_INT16 *pDataIn, + LVM_INT16 *pDataOut, + LVM_INT32 BlockLength) +{ + + LVM_INT16 Sample; /* Input samples */ + LVM_INT32 SampleNo; /* Sample index */ + LVM_INT16 Temp; + + + /* + * Process a block of samples + */ + for(SampleNo = 0; SampleNo> 15); + if(Sample >0) + { + Sample = (LVM_INT16)(Sample + ((Gain * (Sample - Temp)) >> 15)); + } + else + { + Sample = (LVM_INT16)(Sample + ((Gain * (Sample + Temp)) >> 15)); + } + } + + + /* + * Save the output + */ + *pDataOut = Sample; + pDataOut++; + + + } + +} + diff --git a/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32C14G11_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32C14G11_TRC_WRA_01.c new file mode 100755 index 0000000..06cfe88 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32C14G11_TRC_WRA_01.c @@ -0,0 +1,130 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "PK_2I_D32F32CssGss_TRC_WRA_01_Private.h" +#include "LVM_Macros.h" + +/************************************************************************** + ASSUMPTIONS: + COEFS- + pBiquadState->coefs[0] is A0, + pBiquadState->coefs[1] is -B2, + pBiquadState->coefs[2] is -B1, these are in Q14 format + pBiquadState->coefs[3] is Gain, in Q11 format + + + DELAYS- + pBiquadState->pDelays[0] is x(n-1)L in Q0 format + pBiquadState->pDelays[1] is x(n-1)R in Q0 format + pBiquadState->pDelays[2] is x(n-2)L in Q0 format + pBiquadState->pDelays[3] is x(n-2)R in Q0 format + pBiquadState->pDelays[4] is y(n-1)L in Q0 format + pBiquadState->pDelays[5] is y(n-1)R in Q0 format + pBiquadState->pDelays[6] is y(n-2)L in Q0 format + pBiquadState->pDelays[7] is y(n-2)R in Q0 format +***************************************************************************/ +void PK_2I_D32F32C14G11_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT32 *pDataIn, + LVM_INT32 *pDataOut, + LVM_INT16 NrSamples) + { + LVM_INT32 ynL,ynR,ynLO,ynRO,templ; + LVM_INT16 ii; + PFilter_State pBiquadState = (PFilter_State) pInstance; + + for (ii = NrSamples; ii != 0; ii--) + { + + + /************************************************************************** + PROCESSING OF THE LEFT CHANNEL + ***************************************************************************/ + /* ynL= (A0 (Q14) * (x(n)L (Q0) - x(n-2)L (Q0) ) >>14) in Q0*/ + templ=(*pDataIn)-pBiquadState->pDelays[2]; + MUL32x16INTO32(templ,pBiquadState->coefs[0],ynL,14) + + /* ynL+= ((-B2 (Q14) * y(n-2)L (Q0) ) >>14) in Q0*/ + MUL32x16INTO32(pBiquadState->pDelays[6],pBiquadState->coefs[1],templ,14) + ynL+=templ; + + /* ynL+= ((-B1 (Q14) * y(n-1)L (Q0) ) >>14) in Q0 */ + MUL32x16INTO32(pBiquadState->pDelays[4],pBiquadState->coefs[2],templ,14) + ynL+=templ; + + /* ynLO= ((Gain (Q11) * ynL (Q0))>>11) in Q0*/ + MUL32x16INTO32(ynL,pBiquadState->coefs[3],ynLO,11) + + /* ynLO=( ynLO(Q0) + x(n)L (Q0) ) in Q0*/ + ynLO+= (*pDataIn); + + /************************************************************************** + PROCESSING OF THE RIGHT CHANNEL + ***************************************************************************/ + /* ynR= (A0 (Q14) * (x(n)R (Q0) - x(n-2)R (Q0) ) >>14) in Q0*/ + templ=(*(pDataIn+1))-pBiquadState->pDelays[3]; + MUL32x16INTO32(templ,pBiquadState->coefs[0],ynR,14) + + /* ynR+= ((-B2 (Q14) * y(n-2)R (Q0) ) >>14) in Q0*/ + MUL32x16INTO32(pBiquadState->pDelays[7],pBiquadState->coefs[1],templ,14) + ynR+=templ; + + /* ynR+= ((-B1 (Q14) * y(n-1)R (Q0) ) >>14) in Q0 */ + MUL32x16INTO32(pBiquadState->pDelays[5],pBiquadState->coefs[2],templ,14) + ynR+=templ; + + /* ynRO= ((Gain (Q11) * ynR (Q0))>>11) in Q0*/ + MUL32x16INTO32(ynR,pBiquadState->coefs[3],ynRO,11) + + /* ynRO=( ynRO(Q0) + x(n)R (Q0) ) in Q0*/ + ynRO+= (*(pDataIn+1)); + + /************************************************************************** + UPDATING THE DELAYS + ***************************************************************************/ + pBiquadState->pDelays[7]=pBiquadState->pDelays[5]; /* y(n-2)R=y(n-1)R*/ + pBiquadState->pDelays[6]=pBiquadState->pDelays[4]; /* y(n-2)L=y(n-1)L*/ + pBiquadState->pDelays[3]=pBiquadState->pDelays[1]; /* x(n-2)R=x(n-1)R*/ + pBiquadState->pDelays[2]=pBiquadState->pDelays[0]; /* x(n-2)L=x(n-1)L*/ + pBiquadState->pDelays[5]=ynR; /* Update y(n-1)R in Q0*/ + pBiquadState->pDelays[4]=ynL; /* Update y(n-1)L in Q0*/ + pBiquadState->pDelays[0]=(*pDataIn); /* Update x(n-1)L in Q0*/ + pDataIn++; + pBiquadState->pDelays[1]=(*pDataIn); /* Update x(n-1)R in Q0*/ + pDataIn++; + + /************************************************************************** + WRITING THE OUTPUT + ***************************************************************************/ + *pDataOut=ynLO; /* Write Left output in Q0*/ + pDataOut++; + *pDataOut=ynRO; /* Write Right ouput in Q0*/ + pDataOut++; + + } + + } + diff --git a/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32C30G11_TRC_WRA_01.c b/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32C30G11_TRC_WRA_01.c new file mode 100755 index 0000000..5b78f62 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32C30G11_TRC_WRA_01.c @@ -0,0 +1,128 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "PK_2I_D32F32CllGss_TRC_WRA_01_Private.h" +#include "LVM_Macros.h" + +/************************************************************************** + ASSUMPTIONS: + COEFS- + pBiquadState->coefs[0] is A0, + pBiquadState->coefs[1] is -B2, + pBiquadState->coefs[2] is -B1, these are in Q30 format + pBiquadState->coefs[3] is Gain, in Q11 format + + + DELAYS- + pBiquadState->pDelays[0] is x(n-1)L in Q0 format + pBiquadState->pDelays[1] is x(n-1)R in Q0 format + pBiquadState->pDelays[2] is x(n-2)L in Q0 format + pBiquadState->pDelays[3] is x(n-2)R in Q0 format + pBiquadState->pDelays[4] is y(n-1)L in Q0 format + pBiquadState->pDelays[5] is y(n-1)R in Q0 format + pBiquadState->pDelays[6] is y(n-2)L in Q0 format + pBiquadState->pDelays[7] is y(n-2)R in Q0 format +***************************************************************************/ +void PK_2I_D32F32C30G11_TRC_WRA_01 ( Biquad_Instance_t *pInstance, + LVM_INT32 *pDataIn, + LVM_INT32 *pDataOut, + LVM_INT16 NrSamples) + { + LVM_INT32 ynL,ynR,ynLO,ynRO,templ; + LVM_INT16 ii; + PFilter_State pBiquadState = (PFilter_State) pInstance; + + for (ii = NrSamples; ii != 0; ii--) + { + + + /************************************************************************** + PROCESSING OF THE LEFT CHANNEL + ***************************************************************************/ + /* ynL= (A0 (Q30) * (x(n)L (Q0) - x(n-2)L (Q0) ) >>30) in Q0*/ + templ=(*pDataIn)-pBiquadState->pDelays[2]; + MUL32x32INTO32(templ,pBiquadState->coefs[0],ynL,30) + + /* ynL+= ((-B2 (Q30) * y(n-2)L (Q0) ) >>30) in Q0*/ + MUL32x32INTO32(pBiquadState->pDelays[6],pBiquadState->coefs[1],templ,30) + ynL+=templ; + + /* ynL+= ((-B1 (Q30) * y(n-1)L (Q0) ) >>30) in Q0 */ + MUL32x32INTO32(pBiquadState->pDelays[4],pBiquadState->coefs[2],templ,30) + ynL+=templ; + + /* ynLO= ((Gain (Q11) * ynL (Q0))>>11) in Q0*/ + MUL32x16INTO32(ynL,pBiquadState->coefs[3],ynLO,11) + /* ynLO=( ynLO(Q0) + x(n)L (Q0) ) in Q0*/ + ynLO+= (*pDataIn); + + /************************************************************************** + PROCESSING OF THE RIGHT CHANNEL + ***************************************************************************/ + /* ynR= (A0 (Q30) * (x(n)R (Q0) - x(n-2)R (Q0) ) >>30) in Q0*/ + templ=(*(pDataIn+1))-pBiquadState->pDelays[3]; + MUL32x32INTO32(templ,pBiquadState->coefs[0],ynR,30) + + /* ynR+= ((-B2 (Q30) * y(n-2)R (Q0) ) >>30) in Q0*/ + MUL32x32INTO32(pBiquadState->pDelays[7],pBiquadState->coefs[1],templ,30) + ynR+=templ; + + /* ynR+= ((-B1 (Q30) * y(n-1)R (Q0) ) >>30) in Q0 */ + MUL32x32INTO32(pBiquadState->pDelays[5],pBiquadState->coefs[2],templ,30) + ynR+=templ; + + /* ynRO= ((Gain (Q11) * ynR (Q0))>>11) in Q0*/ + MUL32x16INTO32(ynR,pBiquadState->coefs[3],ynRO,11) + + /* ynRO=( ynRO(Q0) + x(n)R (Q0) ) in Q0*/ + ynRO+= (*(pDataIn+1)); + + /************************************************************************** + UPDATING THE DELAYS + ***************************************************************************/ + pBiquadState->pDelays[7]=pBiquadState->pDelays[5]; /* y(n-2)R=y(n-1)R*/ + pBiquadState->pDelays[6]=pBiquadState->pDelays[4]; /* y(n-2)L=y(n-1)L*/ + pBiquadState->pDelays[3]=pBiquadState->pDelays[1]; /* x(n-2)R=x(n-1)R*/ + pBiquadState->pDelays[2]=pBiquadState->pDelays[0]; /* x(n-2)L=x(n-1)L*/ + pBiquadState->pDelays[5]=ynR; /* Update y(n-1)R in Q0*/ + pBiquadState->pDelays[4]=ynL; /* Update y(n-1)L in Q0*/ + pBiquadState->pDelays[0]=(*pDataIn); /* Update x(n-1)L in Q0*/ + pDataIn++; + pBiquadState->pDelays[1]=(*pDataIn); /* Update x(n-1)R in Q0*/ + pDataIn++; + + /************************************************************************** + WRITING THE OUTPUT + ***************************************************************************/ + *pDataOut=ynLO; /* Write Left output in Q0*/ + pDataOut++; + *pDataOut=ynRO; /* Write Right ouput in Q0*/ + pDataOut++; + } + + } + diff --git a/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CllGss_TRC_WRA_01_Init.c b/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CllGss_TRC_WRA_01_Init.c new file mode 100755 index 0000000..e7bcd0c --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CllGss_TRC_WRA_01_Init.c @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "PK_2I_D32F32CllGss_TRC_WRA_01_Private.h" + + +void PK_2I_D32F32CllGss_TRC_WRA_01_Init(Biquad_Instance_t *pInstance, + Biquad_2I_Order2_Taps_t *pTaps, + PK_C32_Coefs_t *pCoef) +{ + PFilter_State pBiquadState = (PFilter_State) pInstance; + pBiquadState->pDelays =(LVM_INT32 *) pTaps; + + pBiquadState->coefs[0]=pCoef->A0; + + pBiquadState->coefs[1]=pCoef->B2; + + pBiquadState->coefs[2]=pCoef->B1; + + pBiquadState->coefs[3]=pCoef->G; + +} + diff --git a/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CllGss_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CllGss_TRC_WRA_01_Private.h new file mode 100755 index 0000000..741f504 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CllGss_TRC_WRA_01_Private.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _PK_2I_D32F32CLLGSS_TRC_WRA_01_PRIVATE_H_ +#define _PK_2I_D32F32CLLGSS_TRC_WRA_01_PRIVATE_H_ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/* The internal state variables are implemented in a (for the user) hidden structure */ +/* In this (private) file, the internal structure is declared fro private use. */ +typedef struct _Filter_State_ +{ + LVM_INT32 * pDelays; /* pointer to the delayed samples (data of 32 bits) */ + LVM_INT32 coefs[5]; /* pointer to the filter coefficients */ +}Filter_State; + +typedef Filter_State * PFilter_State ; + +#endif /* _PK_2I_D32F32CLLGSS_TRC_WRA_01_PRIVATE_H_ */ diff --git a/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CssGss_TRC_WRA_01_Init.c b/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CssGss_TRC_WRA_01_Init.c new file mode 100755 index 0000000..f02305e --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CssGss_TRC_WRA_01_Init.c @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +#include "BIQUAD.h" +#include "PK_2I_D32F32CssGss_TRC_WRA_01_Private.h" + +void PK_2I_D32F32CssGss_TRC_WRA_01_Init(Biquad_Instance_t *pInstance, + Biquad_2I_Order2_Taps_t *pTaps, + PK_C16_Coefs_t *pCoef) +{ + PFilter_State pBiquadState = (PFilter_State) pInstance; + pBiquadState->pDelays =(LVM_INT32 *) pTaps; + + pBiquadState->coefs[0]=pCoef->A0; + + pBiquadState->coefs[1]=pCoef->B2; + + pBiquadState->coefs[2]=pCoef->B1; + + pBiquadState->coefs[3]=pCoef->G; + +} + diff --git a/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CssGss_TRC_WRA_01_Private.h b/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CssGss_TRC_WRA_01_Private.h new file mode 100755 index 0000000..ca31669 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/PK_2I_D32F32CssGss_TRC_WRA_01_Private.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _PK_2I_D32F32CSSGSS_TRC_WRA_01_PRIVATE_H_ +#define _PK_2I_D32F32CSSGSS_TRC_WRA_01_PRIVATE_H_ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + + +/* The internal state variables are implemented in a (for the user) hidden structure */ +/* In this (private) file, the internal structure is declared fro private use. */ +typedef struct _Filter_State_ +{ + LVM_INT32 * pDelays; /* pointer to the delayed samples (data of 32 bits) */ + LVM_INT32 coefs[5]; /* pointer to the filter coefficients */ +}Filter_State; + +typedef Filter_State * PFilter_State ; + +#endif /* _PK_2I_D32F32CSSGSS_TRC_WRA_01_PRIVATE_H_ */ diff --git a/media/libeffects/lvm/lib/Common/src/Shift_Sat_v16xv16.c b/media/libeffects/lvm/lib/Common/src/Shift_Sat_v16xv16.c new file mode 100755 index 0000000..e449a7f --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/Shift_Sat_v16xv16.c @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************************** + + $Author: beq07716 $ + $Revision: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION Shift_Sat_v16xv16 +***********************************************************************************/ + +void Shift_Sat_v16xv16 (const LVM_INT16 val, + const LVM_INT16 *src, + LVM_INT16 *dst, + LVM_INT16 n) +{ + LVM_INT32 temp; + LVM_INT32 ii; + LVM_INT16 RShift; + if(val>0) + { + for (ii = n; ii != 0; ii--) + { + temp = (LVM_INT32)*src; + src++; + + temp = temp << val; + + if (temp > 0x00007FFF) + { + *dst = 0x7FFF; + } + else if (temp < -0x00008000) + { + *dst = - 0x8000; + } + else + { + *dst = (LVM_INT16)temp; + } + dst++; + } + } + else if(val<0) + { + RShift=(LVM_INT16)(-val); + + for (ii = n; ii != 0; ii--) + { + *dst = (LVM_INT16)(*src >> RShift); + dst++; + src++; + } + } + else + { + if(src!=dst) + { + Copy_16(src,dst,n); + } + } + return; +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/Shift_Sat_v32xv32.c b/media/libeffects/lvm/lib/Common/src/Shift_Sat_v32xv32.c new file mode 100755 index 0000000..0ab98ea --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/Shift_Sat_v32xv32.c @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: */ +/* $Author: beq07716 $*/ +/* $Revision: 1000 $*/ +/* $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION Shift_Sat_v32xv32 +***********************************************************************************/ + +void Shift_Sat_v32xv32 (const LVM_INT16 val, + const LVM_INT32 *src, + LVM_INT32 *dst, + LVM_INT16 n) +{ + LVM_INT32 ii; + LVM_INT16 RShift; + + if(val>0) + { + LVM_INT32 a,b; + + for (ii = n; ii != 0; ii--) + { + a=*src; + src++; + + b=(a<>val) != a ) /* if overflow occured, right shift will show difference*/ + { + if(a<0) + { + b=0x80000000l; + } + else + { + b=0x7FFFFFFFl; + } + } + + *dst = b; + dst++; + } + } + else if(val<0) + { + RShift=(LVM_INT16)(-val); + for (ii = n; ii != 0; ii--) + { + *dst = (*src >> RShift); + dst++; + src++; + } + } + else + { + if(src!=dst) + { + Copy_16((LVM_INT16 *)src,(LVM_INT16 *)dst,(LVM_INT16)(n<<1)); + } + } + return; +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/dB_to_Lin32.c b/media/libeffects/lvm/lib/Common/src/dB_to_Lin32.c new file mode 100755 index 0000000..ac0343f --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/dB_to_Lin32.c @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* %created_by: sra % (CM/S)*/ +/* %name: dB_to_Lin32.c % (CM/S)*/ +/* %version: 2 % (CM/S)*/ +/* %date_created: Wed Jun 18 11:27:46 2008 % (CM/S)*/ +/* */ +/************************************************************************/ + +/*######################################################################################*/ +/* Include files */ +/*######################################################################################*/ + +#include "ScalarArithmetic.h" + + +/**************************************************************************************** + * Name : dB_to_Lin32() + * Input : Signed 16-bit integer + * MSB (16) = sign bit + * (15->05) = integer part + * (04->01) = decimal part + * Output : Signed 32-bit integer + * MSB (32) = sign bit + * (31->16) = integer part + * (15->01) = decimal part + * Returns : Lin value format 1.16.15 + * Description : + * Remarks : Makes an approximation to the conversion by counting the number + * of 6dB steps for use as shifts and then interpolates with a remainder + * with the equation: + * + * Correction = (Remainder / 1.5029) - (Remainder^2 / 6) + * + * The two coefficients are scaled from 0x40000000 in 96 steps and calculated + * as follows: + * + * FIRST_COEF = 0x80000000 / (96 * 1.5029) + * SECOND_COEF = 0x80000000 / (96^2 * 6) + * + ****************************************************************************************/ + +#define FOUR_OVER_SIX 21846 /* (4 / 6) * 2^15 */ +#define SIX_DB 96 /* 6 * 16 or 6dB in Q11.4 format */ +#define FIRST_COEF_NEG 14884305 +#define FIRST_COEF_POS 7442152 /* FIRST_COEF_NEG / 2 */ +#define SECOND_COEF 38836 +#define MAX_VALUE 1536 /* 96 * 16 */ + +LVM_INT32 dB_to_Lin32(LVM_INT16 db_fix) +{ + LVM_INT32 Lin_val_32; + LVM_INT16 Shift; + LVM_INT32 Remain; + + + /* + * Check sign of the input + */ + if (db_fix<0) + { + if (db_fix > -MAX_VALUE) + { + Shift = (LVM_INT16)((((LVM_UINT32)(-db_fix) >> 4) * FOUR_OVER_SIX) >> 17); /* Number of 6dB steps in Q11.4 format */ + Remain = -db_fix - (Shift * SIX_DB); + Remain = (0x7FFFFFFF - (Remain * FIRST_COEF_NEG)) + (Remain * Remain * SECOND_COEF); + Lin_val_32 = (LVM_INT32)((LVM_UINT32)Remain >> (16 + Shift)); + } + else + { + Lin_val_32 = 0; + } + } + else + { + if (db_fix < MAX_VALUE) + { + Shift = (LVM_INT16)((((LVM_UINT32)db_fix >> 4) * FOUR_OVER_SIX) >> 17); /* Number of 6dB steps in Q11.4 format */ + Remain = db_fix - (Shift * SIX_DB); + Remain = 0x3FFFFFFF + (Remain * FIRST_COEF_POS) + (Remain * Remain * SECOND_COEF); + Lin_val_32 = (LVM_INT32)((LVM_UINT32)Remain >> (15 - Shift)); + } + else + { + Lin_val_32 = 0x7FFFFFFF; + } + } + + + return Lin_val_32; /* format 1.16.15 */ +} + diff --git a/media/libeffects/lvm/lib/Common/src/mult3s_16x16.c b/media/libeffects/lvm/lib/Common/src/mult3s_16x16.c new file mode 100755 index 0000000..b500979 --- /dev/null +++ b/media/libeffects/lvm/lib/Common/src/mult3s_16x16.c @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************************** + + $Author: beq07716 $ + $Revision: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/********************************************************************************** + INCLUDE FILES +***********************************************************************************/ + +#include "VectorArithmetic.h" + +/********************************************************************************** + FUNCTION MULT3S_16X16 +***********************************************************************************/ + +void Mult3s_16x16( const LVM_INT16 *src, + const LVM_INT16 val, + LVM_INT16 *dst, + LVM_INT16 n) +{ + LVM_INT16 ii; + LVM_INT32 temp; + + for (ii = n; ii != 0; ii--) + { + temp = (LVM_INT32)(*src) * (LVM_INT32)val; + src++; + + *dst = (LVM_INT16)(temp >> 15); + dst++; + } + + return; +} + +/**********************************************************************************/ diff --git a/media/libeffects/lvm/lib/Eq/lib/LVEQNB.h b/media/libeffects/lvm/lib/Eq/lib/LVEQNB.h new file mode 100755 index 0000000..7ba583f --- /dev/null +++ b/media/libeffects/lvm/lib/Eq/lib/LVEQNB.h @@ -0,0 +1,484 @@ +/* + * 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: 1005 $ + $Date: 2010-06-28 13:58:28 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/****************************************************************************************/ +/* */ +/* Header file for the application layer interface of the N-Band equaliser. */ +/* */ +/* This files includes all definitions, types, structures and function */ +/* prototypes required by the calling layer. All other types, structures and */ +/* functions are private. */ +/* */ +/****************************************************************************************/ +/* */ +/* Note: 1 */ +/* ======= */ +/* The algorithm can execute either with separate input and output buffers or with */ +/* a common buffer, i.e. the data is processed in-place. */ +/* */ +/****************************************************************************************/ +/* */ +/* Note: 2 */ +/* ======= */ +/* Two data formats are support Stereo and Mono-In-Stereo. The data is interleaved as */ +/* follows: */ +/* Byte Offset Stereo Input Mono-In-Stereo Input */ +/* =========== ============ ==================== */ +/* 0 Left Sample #1 Mono Sample #1 */ +/* 2 Right Sample #1 Mono Sample #1 */ +/* 4 Left Sample #2 Mono Sample #2 */ +/* 6 Right Sample #2 Mono Sample #2 */ +/* . . . */ +/* . . . */ +/* */ +/* Mono format data is not supported, the calling routine must convert a Mono stream */ +/* in to Mono-In-Stereo format. */ +/* */ +/****************************************************************************************/ +/* */ +/* Note: 3 */ +/* ======= */ +/* The format of the data in the filter band definition structure is as follows: */ +/* */ +/* Gain is in integer dB, range -15dB to +15dB inclusive */ +/* Frequency is the centre frequency in Hz, range DC to Nyquist */ +/* QFactor is the Q multiplied by 100, range 0.25 (25) to 12 (1200) */ +/* */ +/* Example: */ +/* Gain = 7 7dB gain */ +/* Frequency = 2467 Centre frequency = 2.467kHz */ +/* QFactor = 1089 Q = 10.89 */ +/* */ +/* The equaliser filters are passed as a pointer to and array of filter band */ +/* definitions structures. There must be one filter definition for each band. */ +/* */ +/****************************************************************************************/ + + +#ifndef __LVEQNB_H__ +#define __LVEQNB_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/****************************************************************************************/ +/* */ +/* Includes */ +/* */ +/****************************************************************************************/ + +#include "LVM_Types.h" +#include "LVM_Common.h" + +/****************************************************************************************/ +/* */ +/* Definitions */ +/* */ +/****************************************************************************************/ + +/* Memory table */ +#define LVEQNB_MEMREGION_INSTANCE 0 /* Offset to the instance memory region */ +#define LVEQNB_MEMREGION_PERSISTENT_DATA 1 /* Offset to persistent data memory region */ +#define LVEQNB_MEMREGION_PERSISTENT_COEF 2 /* Offset to persistent coefficient region */ +#define LVEQNB_MEMREGION_SCRATCH 3 /* Offset to data scratch memory region */ +#define LVEQNB_NR_MEMORY_REGIONS 4 /* Number of memory regions */ + +/* Callback events */ +#define LVEQNB_EVENT_NONE 0x0000 /* Not a valid event */ +#define LVEQNB_EVENT_ALGOFF 0x0001 /* EQNB has completed switch off */ + +/****************************************************************************************/ +/* */ +/* Types */ +/* */ +/****************************************************************************************/ + +/* Instance handle */ +typedef void *LVEQNB_Handle_t; + + +/* Operating modes */ +typedef enum +{ + LVEQNB_BYPASS = 0, + LVEQNB_ON = 1, + LVEQNB_MODE_MAX = LVM_MAXINT_32 +} LVEQNB_Mode_en; + + +/* Filter mode control */ +typedef enum +{ + LVEQNB_FILTER_OFF = 0, + LVEQNB_FILTER_ON = 1, + LVEQNB_FILTER_DUMMY = LVM_MAXINT_32 +} LVEQNB_FilterMode_en; + + +/* Memory Types */ +typedef enum +{ + LVEQNB_PERSISTENT = 0, + LVEQNB_PERSISTENT_DATA = 1, + LVEQNB_PERSISTENT_COEF = 2, + LVEQNB_SCRATCH = 3, + LVEQNB_MEMORY_MAX = LVM_MAXINT_32 +} LVEQNB_MemoryTypes_en; + + +/* Function return status */ +typedef enum +{ + LVEQNB_SUCCESS = 0, /* Successful return from a routine */ + LVEQNB_ALIGNMENTERROR = 1, /* Memory alignment error */ + LVEQNB_NULLADDRESS = 2, /* NULL allocation address */ + LVEQNB_TOOMANYSAMPLES = 3, /* Maximum block size exceeded */ + LVEQNB_STATUS_MAX = LVM_MAXINT_32 +} LVEQNB_ReturnStatus_en; + + +/****************************************************************************************/ +/* */ +/* Linked enumerated type and capability definitions */ +/* */ +/* The capability definitions are used to define the required capabilities at */ +/* initialisation, these are added together to give the capability word. The */ +/* enumerated type is used to select the mode through a control function at run time. */ +/* */ +/* The capability definition is related to the enumerated type value by the equation: */ +/* */ +/* Capability_value = 2^Enumerated_value */ +/* */ +/* For example, a module could be configurd at initialisation to support two sample */ +/* rates only by calling the init function with the value: */ +/* Capabilities.SampleRate = LVEQNB_CAP_32000 + LVEQNB_CAP_44100; */ +/* */ +/* and at run time it would be passed the value LVEQNB_FS_32000 through the control */ +/* function to select operation at 32kHz */ +/* */ +/****************************************************************************************/ + +/* + * Supported source data formats + */ +#define LVEQNB_CAP_STEREO 1 +#define LVEQNB_CAP_MONOINSTEREO 2 + +typedef enum +{ + LVEQNB_STEREO = 0, + LVEQNB_MONOINSTEREO = 1, + LVEQNB_SOURCE_MAX = LVM_MAXINT_32 +} LVEQNB_SourceFormat_en; + + +/* + * Supported sample rates in samples per second + */ +#define LVEQNB_CAP_FS_8000 1 +#define LVEQNB_CAP_FS_11025 2 +#define LVEQNB_CAP_FS_12000 4 +#define LVEQNB_CAP_FS_16000 8 +#define LVEQNB_CAP_FS_22050 16 +#define LVEQNB_CAP_FS_24000 32 +#define LVEQNB_CAP_FS_32000 64 +#define LVEQNB_CAP_FS_44100 128 +#define LVEQNB_CAP_FS_48000 256 + +typedef enum +{ + LVEQNB_FS_8000 = 0, + LVEQNB_FS_11025 = 1, + LVEQNB_FS_12000 = 2, + LVEQNB_FS_16000 = 3, + LVEQNB_FS_22050 = 4, + LVEQNB_FS_24000 = 5, + LVEQNB_FS_32000 = 6, + LVEQNB_FS_44100 = 7, + LVEQNB_FS_48000 = 8, + LVEQNB_FS_MAX = LVM_MAXINT_32 +} LVEQNB_Fs_en; + + +/****************************************************************************************/ +/* */ +/* Structures */ +/* */ +/****************************************************************************************/ + +/* Memory region definition */ +typedef struct +{ + LVM_UINT32 Size; /* Region size in bytes */ + LVM_UINT16 Alignment; /* Region alignment in bytes */ + LVEQNB_MemoryTypes_en Type; /* Region type */ + void *pBaseAddress; /* Pointer to the region base address */ +} LVEQNB_MemoryRegion_t; + + +/* Memory table containing the region definitions */ +typedef struct +{ + LVEQNB_MemoryRegion_t Region[LVEQNB_NR_MEMORY_REGIONS]; /* One definition for each region */ +} LVEQNB_MemTab_t; + + +/* Equaliser band definition */ +typedef struct +{ + LVM_INT16 Gain; /* Band gain in dB */ + LVM_UINT16 Frequency; /* Band centre frequency in Hz */ + LVM_UINT16 QFactor; /* Band quality factor */ +} LVEQNB_BandDef_t; + + +/* Parameter structure */ +typedef struct +{ + /* General parameters */ + LVEQNB_Mode_en OperatingMode; + LVEQNB_Fs_en SampleRate; + LVEQNB_SourceFormat_en SourceFormat; + + /* Equaliser parameters */ + LVM_UINT16 NBands; /* Number of bands */ + LVEQNB_BandDef_t *pBandDefinition; /* Pointer to equaliser definitions */ + +} LVEQNB_Params_t; + + +/* Capability structure */ +typedef struct +{ + /* General parameters */ + LVM_UINT16 SampleRate; + LVM_UINT16 SourceFormat; + LVM_UINT16 MaxBlockSize; + LVM_UINT16 MaxBands; + + /* Callback parameters */ + LVM_Callback CallBack; /* Bundle callback */ + void *pBundleInstance; /* Bundle instance handle */ + +} LVEQNB_Capabilities_t; + + +/****************************************************************************************/ +/* */ +/* Function Prototypes */ +/* */ +/****************************************************************************************/ + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVEQNB_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) the memory */ +/* base address pointers are NULL on return. */ +/* */ +/* When the function is called for free (hInstance = Instance Handle) the memory */ +/* table returns the allocated memory and base addresses used during initialisation. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance Handle */ +/* pMemoryTable Pointer to an empty memory definition table */ +/* pCapabilities Pointer to the default capabilities */ +/* */ +/* RETURNS: */ +/* LVEQNB_SUCCESS Succeeded */ +/* LVEQNB_NULLADDRESS When any of pMemoryTable and pCapabilities is NULL address */ +/* */ +/* NOTES: */ +/* 1. This function may be interrupted by the LVEQNB_Process function */ +/* */ +/****************************************************************************************/ + +LVEQNB_ReturnStatus_en LVEQNB_Memory(LVEQNB_Handle_t hInstance, + LVEQNB_MemTab_t *pMemoryTable, + LVEQNB_Capabilities_t *pCapabilities); + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVEQNB_Init */ +/* */ +/* DESCRIPTION: */ +/* Create and initialisation function for the N-Band equalliser module */ +/* */ +/* This function can be used to create an algorithm instance by calling with */ +/* hInstance set to 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 */ +/* LVEQNB_Memory before calling this function. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance handle */ +/* pMemoryTable Pointer to the memory definition table */ +/* pCapabilities Pointer to the initialisation capabilities */ +/* */ +/* RETURNS: */ +/* LVEQNB_SUCCESS Initialisation succeeded */ +/* LVEQNB_NULLADDRESS When pCapabilities or pMemoryTableis or phInstance are NULL */ +/* LVEQNB_NULLADDRESS One or more of the memory regions has a NULL base address */ +/* pointer for a memory region with a non-zero size. */ +/* */ +/* */ +/* 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 LVEQNB_Process function */ +/* */ +/****************************************************************************************/ + +LVEQNB_ReturnStatus_en LVEQNB_Init(LVEQNB_Handle_t *phInstance, + LVEQNB_MemTab_t *pMemoryTable, + LVEQNB_Capabilities_t *pCapabilities); + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVEQNB_GetParameters */ +/* */ +/* DESCRIPTION: */ +/* Request the equaliser module parameters. The current parameter set is returned */ +/* via the parameter pointer. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance handle */ +/* pParams Pointer to an empty parameter structure */ +/* */ +/* RETURNS: */ +/* LVEQNB_SUCCESS Succeeds */ +/* LVEQNB_NULLADDRESS Instance or pParams is NULL pointer */ +/* */ +/* NOTES: */ +/* 1. This function may be interrupted by the LVEQNB_Process function */ +/* */ +/****************************************************************************************/ + +LVEQNB_ReturnStatus_en LVEQNB_GetParameters(LVEQNB_Handle_t hInstance, + LVEQNB_Params_t *pParams); + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVEQNB_GetCapabilities */ +/* */ +/* DESCRIPTION: */ +/* Request the equaliser module capabilities. The capabilities set is returned */ +/* via the pointer. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance handle */ +/* pCapabilities Pointer to an empty capability structure */ +/* */ +/* RETURNS: */ +/* LVEQNB_SUCCESS Succeeds */ +/* LVEQNB_NULLADDRESS hInstance or pCapabilities is NULL */ +/* */ +/* NOTES: */ +/* 1. This function may be interrupted by the LVEQNB_Process function */ +/* */ +/****************************************************************************************/ + +LVEQNB_ReturnStatus_en LVEQNB_GetCapabilities(LVEQNB_Handle_t hInstance, + LVEQNB_Capabilities_t *pCapabilities); + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVEQNB_Control */ +/* */ +/* DESCRIPTION: */ +/* Sets or changes the equaliser module parameters. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance handle */ +/* pParams Pointer to a parameter structure */ +/* */ +/* RETURNS: */ +/* LVEQNB_SUCCESS Succeeded */ +/* LVEQNB_NULLADDRESS Instance or pParams is NULL pointer */ +/* LVEQNB_NULLADDRESS NULL address for the equaliser filter definitions and the */ +/* number of bands is non-zero */ +/* */ +/* NOTES: */ +/* 1. This function may be interrupted by the LVEQNB_Process function */ +/* */ +/****************************************************************************************/ + +LVEQNB_ReturnStatus_en LVEQNB_Control(LVEQNB_Handle_t hInstance, + LVEQNB_Params_t *pParams); + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVEQNB_Process */ +/* */ +/* DESCRIPTION: */ +/* Process function for the LifeVibes module. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance handle */ +/* pInData Pointer to the input data */ +/* pOutData Pointer to the output data */ +/* NumSamples Number of samples in the input buffer */ +/* */ +/* RETURNS: */ +/* LVEQNB_SUCCESS Succeeded */ +/* LVEQNB_NULLADDRESS When hInstance, pInData or pOutData are NULL */ +/* LVEQNB_ALIGNMENTERROR When pInData or pOutData are not 32-bit aligned */ +/* LVEQNB_TOOMANYSAMPLES NumSamples was larger than the maximum block size */ +/* */ +/* NOTES: */ +/* */ +/****************************************************************************************/ + +LVEQNB_ReturnStatus_en LVEQNB_Process(LVEQNB_Handle_t hInstance, + const LVM_INT16 *pInData, + LVM_INT16 *pOutData, + LVM_UINT16 NumSamples); + + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __LVEQNB__ */ + diff --git a/media/libeffects/lvm/lib/Eq/src/LVEQNB_CalcCoef.c b/media/libeffects/lvm/lib/Eq/src/LVEQNB_CalcCoef.c new file mode 100755 index 0000000..4881049 --- /dev/null +++ b/media/libeffects/lvm/lib/Eq/src/LVEQNB_CalcCoef.c @@ -0,0 +1,306 @@ +/* + * 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: 1005 $ + $Date: 2010-06-28 13:58:28 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/****************************************************************************************/ +/* */ +/* Includes */ +/* */ +/****************************************************************************************/ + +#include "LVEQNB_Private.h" + + +/****************************************************************************************/ +/* */ +/* Defines */ +/* */ +/****************************************************************************************/ + +#define PI 3.14159265358979 + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVEQNB_DoublePrecCoefs */ +/* */ +/* DESCRIPTION: */ +/* Calculate double precision coefficients for a peaking filter */ +/* */ +/* PARAMETERS: */ +/* Fs Sampling frequency index */ +/* pFilterDefinition Pointer to the filter definition */ +/* pCoefficients Pointer to the coefficients */ +/* */ +/* RETURNS: */ +/* LVEQNB_SUCCESS Always succeeds */ +/* */ +/* NOTES: */ +/* 1. The equations used are as follows: */ +/* */ +/* G = 10^(GaindB/20) - 1 */ +/* t0 = 2 * Pi * Fc / Fs */ +/* D = 1 if GaindB >= 0 */ +/* D = 1 / (1 + G) if GaindB < 0 */ +/* */ +/* b2 = -0.5 * (2Q - D * t0) / (2Q + D * t0) */ +/* b1 = (0.5 - b2) * (1 - coserr(t0)) */ +/* a0 = (0.5 + b2) / 2 */ +/* */ +/* Where: */ +/* GaindB is the gain in dBs, range -15dB to +15dB */ +/* Fc is the centre frequency, DC to Fs/50 */ +/* Fs is the sample frequency, 8000 to 48000 in descrete steps */ +/* Q is the Q factor, 0.25 to 12 (represented by 25 to 1200) */ +/* */ +/* 2. The double precision coefficients are only used when fc is less than fs/85, so */ +/* the cosine of t0 is always close to 1.0. Instead of calculating the cosine */ +/* itself the difference from the value 1.0 is calculated, this can be done with */ +/* lower precision maths. */ +/* */ +/* 3. The value of the B2 coefficient is only calculated as a single precision value, */ +/* small errors in this value have a combined effect on the Q and Gain but not the */ +/* the frequency of the filter. */ +/* */ +/****************************************************************************************/ + + +LVEQNB_ReturnStatus_en LVEQNB_DoublePrecCoefs(LVM_UINT16 Fs, + LVEQNB_BandDef_t *pFilterDefinition, + PK_C32_Coefs_t *pCoefficients) +{ + + extern LVM_INT16 LVEQNB_GainTable[]; + extern LVM_INT16 LVEQNB_TwoPiOnFsTable[]; + extern LVM_INT16 LVEQNB_DTable[]; + extern LVM_INT16 LVEQNB_DPCosCoef[]; + + /* + * Get the filter definition + */ + LVM_INT16 Gain = pFilterDefinition->Gain; + LVM_UINT16 Frequency = pFilterDefinition->Frequency; + LVM_UINT16 QFactor = pFilterDefinition->QFactor; + + /* + * Intermediate variables and temporary values + */ + LVM_INT32 T0; + LVM_INT16 D; + LVM_INT32 A0; + LVM_INT32 B1; + LVM_INT32 B2; + LVM_INT32 Dt0; + LVM_INT32 B2_Den; + LVM_INT32 B2_Num; + LVM_INT32 CosErr; + LVM_INT16 coef; + LVM_INT32 factor; + LVM_INT16 t0; + LVM_INT16 i; + + /* + * Calculating the intermediate values + */ + T0 = (LVM_INT32)Frequency * LVEQNB_TwoPiOnFsTable[Fs]; /* T0 = 2 * Pi * Fc / Fs */ + if (Gain >= 0) + { + D = LVEQNB_DTable[15]; /* D = 1 if GaindB >= 0 */ + } + else + { + D = LVEQNB_DTable[Gain+15]; /* D = 1 / (1 + G) if GaindB < 0 */ + } + + /* + * Calculate the B2 coefficient + */ + Dt0 = D * (T0 >> 10); + B2_Den = ((LVM_INT32)QFactor << 19) + (Dt0 >> 2); + B2_Num = (Dt0 >> 3) - ((LVM_INT32)QFactor << 18); + B2 = (B2_Num / (B2_Den >> 16)) << 15; + + /* + * Calculate the cosine error by a polynomial expansion using the equation: + * + * CosErr += coef(n) * t0^n For n = 0 to 4 + */ + T0 = (T0 >> 6) * 0x7f53; /* Scale to 1.0 in 16-bit for range 0 to fs/50 */ + t0 = (LVM_INT16)(T0 >> 16); + factor = 0x7fff; /* Initialise to 1.0 for the a0 coefficient */ + CosErr = 0; /* Initialise the error to zero */ + for (i=1; i<5; i++) + { + coef = LVEQNB_DPCosCoef[i]; /* Get the nth coefficient */ + CosErr += (factor * coef) >> 5; /* The nth partial sum */ + factor = (factor * t0) >> 15; /* Calculate t0^n */ + } + CosErr = CosErr << (LVEQNB_DPCosCoef[0]); /* Correct the scaling */ + + /* + * Calculate the B1 and A0 coefficients + */ + B1 = (0x40000000 - B2); /* B1 = (0.5 - b2/2) */ + A0 = ((B1 >> 16) * (CosErr >> 10)) >> 6; /* Temporary storage for (0.5 - b2/2) * coserr(t0) */ + B1 -= A0; /* B1 = (0.5 - b2/2) * (1 - coserr(t0)) */ + A0 = (0x40000000 + B2) >> 1; /* A0 = (0.5 + b2) */ + + /* + * Write coeff into the data structure + */ + pCoefficients->A0 = A0; + pCoefficients->B1 = B1; + pCoefficients->B2 = B2; + pCoefficients->G = LVEQNB_GainTable[Gain+15]; + + return(LVEQNB_SUCCESS); + +} + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVEQNB_SinglePrecCoefs */ +/* */ +/* DESCRIPTION: */ +/* Calculate single precision coefficients for a peaking filter */ +/* */ +/* PARAMETERS: */ +/* Fs Sampling frequency index */ +/* pFilterDefinition Pointer to the filter definition */ +/* pCoefficients Pointer to the coefficients */ +/* */ +/* RETURNS: */ +/* LVEQNB_SUCCESS Always succeeds */ +/* */ +/* NOTES: */ +/* 1. The equations used are as follows: */ +/* */ +/* G = 10^(GaindB/20) - 1 */ +/* t0 = 2 * Pi * Fc / Fs */ +/* D = 1 if GaindB >= 0 */ +/* D = 1 / (1 + G) if GaindB < 0 */ +/* */ +/* b2 = -0.5 * (2Q - D * t0) / (2Q + D * t0) */ +/* b1 = (0.5 - b2) * cos(t0) */ +/* a0 = (0.5 + b2) / 2 */ +/* */ +/* Where: */ +/* GaindB is the gain in dBs, range -15dB to +15dB */ +/* Fc is the centre frequency, DC to Nyquist */ +/* Fs is the sample frequency, 8000 to 48000 in descrete steps */ +/* Q is the Q factor, 0.25 to 12 */ +/* */ +/****************************************************************************************/ + + +LVEQNB_ReturnStatus_en LVEQNB_SinglePrecCoefs(LVM_UINT16 Fs, + LVEQNB_BandDef_t *pFilterDefinition, + PK_C16_Coefs_t *pCoefficients) +{ + + extern LVM_INT16 LVEQNB_GainTable[]; + extern LVM_INT16 LVEQNB_TwoPiOnFsTable[]; + extern LVM_INT16 LVEQNB_DTable[]; + extern LVM_INT16 LVEQNB_CosCoef[]; + + + /* + * Get the filter definition + */ + LVM_INT16 Gain = pFilterDefinition->Gain; + LVM_UINT16 Frequency = pFilterDefinition->Frequency; + LVM_UINT16 QFactor = pFilterDefinition->QFactor; + + + /* + * Intermediate variables and temporary values + */ + LVM_INT32 T0; + LVM_INT16 D; + LVM_INT32 A0; + LVM_INT32 B1; + LVM_INT32 B2; + LVM_INT32 Dt0; + LVM_INT32 B2_Den; + LVM_INT32 B2_Num; + LVM_INT32 COS_T0; + LVM_INT16 coef; + LVM_INT32 factor; + LVM_INT16 t0; + LVM_INT16 i; + + /* + * Calculating the intermediate values + */ + T0 = (LVM_INT32)Frequency * LVEQNB_TwoPiOnFsTable[Fs]; /* T0 = 2 * Pi * Fc / Fs */ + if (Gain >= 0) + { + D = LVEQNB_DTable[15]; /* D = 1 if GaindB >= 0 */ + } + else + { + D = LVEQNB_DTable[Gain+15]; /* D = 1 / (1 + G) if GaindB < 0 */ + } + + /* + * Calculate the B2 coefficient + */ + Dt0 = D * (T0 >> 10); + B2_Den = ((LVM_INT32)QFactor << 19) + (Dt0 >> 2); + B2_Num = (Dt0 >> 3) - ((LVM_INT32)QFactor << 18); + B2 = (B2_Num / (B2_Den >> 16)) << 15; + + /* + * Calculate the cosine by a polynomial expansion using the equation: + * + * Cos += coef(n) * t0^n For n = 0 to 6 + */ + T0 = (T0 >> 10) * 20859; /* Scale to 1.0 in 16-bit for range 0 to fs/2 */ + t0 = (LVM_INT16)(T0 >> 16); + factor = 0x7fff; /* Initialise to 1.0 for the a0 coefficient */ + COS_T0 = 0; /* Initialise the error to zero */ + for (i=1; i<7; i++) + { + coef = LVEQNB_CosCoef[i]; /* Get the nth coefficient */ + COS_T0 += (factor * coef) >> 5; /* The nth partial sum */ + factor = (factor * t0) >> 15; /* Calculate t0^n */ + } + COS_T0 = COS_T0 << (LVEQNB_CosCoef[0]+6); /* Correct the scaling */ + + + B1 = ((0x40000000 - B2) >> 16) * (COS_T0 >> 16); /* B1 = (0.5 - b2/2) * cos(t0) */ + A0 = (0x40000000 + B2) >> 1; /* A0 = (0.5 + b2/2) */ + + /* + * Write coeff into the data structure + */ + pCoefficients->A0 = (LVM_INT16)(A0>>16); + pCoefficients->B1 = (LVM_INT16)(B1>>15); + pCoefficients->B2 = (LVM_INT16)(B2>>16); + pCoefficients->G = LVEQNB_GainTable[Gain+15]; + + + return(LVEQNB_SUCCESS); + +} diff --git a/media/libeffects/lvm/lib/Eq/src/LVEQNB_Coeffs.h b/media/libeffects/lvm/lib/Eq/src/LVEQNB_Coeffs.h new file mode 100755 index 0000000..87d7145 --- /dev/null +++ b/media/libeffects/lvm/lib/Eq/src/LVEQNB_Coeffs.h @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef __LVEQNB_COEFFS_H__ +#define __LVEQNB_COEFFS_H__ + + +/************************************************************************************/ +/* */ +/* Gain table for (10^(Gain/20) - 1) */ +/* */ +/************************************************************************************/ + +#define LVEQNB_GAINSHIFT 11 /* As a power of 2 */ +#define LVEQNB_Gain_Neg15_dB -1684 /* Floating point value -0.822172 */ +#define LVEQNB_Gain_Neg14_dB -1639 /* Floating point value -0.800474 */ +#define LVEQNB_Gain_Neg13_dB -1590 /* Floating point value -0.776128 */ +#define LVEQNB_Gain_Neg12_dB -1534 /* Floating point value -0.748811 */ +#define LVEQNB_Gain_Neg11_dB -1471 /* Floating point value -0.718162 */ +#define LVEQNB_Gain_Neg10_dB -1400 /* Floating point value -0.683772 */ +#define LVEQNB_Gain_Neg9_dB -1321 /* Floating point value -0.645187 */ +#define LVEQNB_Gain_Neg8_dB -1233 /* Floating point value -0.601893 */ +#define LVEQNB_Gain_Neg7_dB -1133 /* Floating point value -0.553316 */ +#define LVEQNB_Gain_Neg6_dB -1022 /* Floating point value -0.498813 */ +#define LVEQNB_Gain_Neg5_dB -896 /* Floating point value -0.437659 */ +#define LVEQNB_Gain_Neg4_dB -756 /* Floating point value -0.369043 */ +#define LVEQNB_Gain_Neg3_dB -598 /* Floating point value -0.292054 */ +#define LVEQNB_Gain_Neg2_dB -421 /* Floating point value -0.205672 */ +#define LVEQNB_Gain_Neg1_dB -223 /* Floating point value -0.108749 */ +#define LVEQNB_Gain_0_dB 0 /* Floating point value 0.000000 */ +#define LVEQNB_Gain_1_dB 250 /* Floating point value 0.122018 */ +#define LVEQNB_Gain_2_dB 530 /* Floating point value 0.258925 */ +#define LVEQNB_Gain_3_dB 845 /* Floating point value 0.412538 */ +#define LVEQNB_Gain_4_dB 1198 /* Floating point value 0.584893 */ +#define LVEQNB_Gain_5_dB 1594 /* Floating point value 0.778279 */ +#define LVEQNB_Gain_6_dB 2038 /* Floating point value 0.995262 */ +#define LVEQNB_Gain_7_dB 2537 /* Floating point value 1.238721 */ +#define LVEQNB_Gain_8_dB 3096 /* Floating point value 1.511886 */ +#define LVEQNB_Gain_9_dB 3724 /* Floating point value 1.818383 */ +#define LVEQNB_Gain_10_dB 4428 /* Floating point value 2.162278 */ +#define LVEQNB_Gain_11_dB 5219 /* Floating point value 2.548134 */ +#define LVEQNB_Gain_12_dB 6105 /* Floating point value 2.981072 */ +#define LVEQNB_Gain_13_dB 7100 /* Floating point value 3.466836 */ +#define LVEQNB_Gain_14_dB 8216 /* Floating point value 4.011872 */ +#define LVEQNB_Gain_15_dB 9469 /* Floating point value 4.623413 */ + + +/************************************************************************************/ +/* */ +/* Frequency table for 2*Pi/Fs */ +/* */ +/************************************************************************************/ + +#define LVEQNB_FREQSHIFT 25 /* As a power of 2 */ +#define LVEQNB_2PiOn_8000 26354 /* Floating point value 0.000785 */ +#define LVEQNB_2PiOn_11025 19123 /* Floating point value 0.000570 */ +#define LVEQNB_2PiOn_12000 17569 /* Floating point value 0.000524 */ +#define LVEQNB_2PiOn_16000 13177 /* Floating point value 0.000393 */ +#define LVEQNB_2PiOn_22050 9561 /* Floating point value 0.000285 */ +#define LVEQNB_2PiOn_24000 8785 /* Floating point value 0.000262 */ +#define LVEQNB_2PiOn_32000 6588 /* Floating point value 0.000196 */ +#define LVEQNB_2PiOn_44100 4781 /* Floating point value 0.000142 */ +#define LVEQNB_2PiOn_48000 4392 /* Floating point value 0.000131 */ + + +/************************************************************************************/ +/* */ +/* 50D table for 50 / ( 1 + Gain ) */ +/* */ +/************************************************************************************/ + +#define LVEQNB_100DSHIFT 5 /* As a power of 2 */ +#define LVEQNB_100D_Neg15_dB 17995 /* Floating point value 5.623413 */ +#define LVEQNB_100D_Neg14_dB 16038 /* Floating point value 5.011872 */ +#define LVEQNB_100D_Neg13_dB 14294 /* Floating point value 4.466836 */ +#define LVEQNB_100D_Neg12_dB 12739 /* Floating point value 3.981072 */ +#define LVEQNB_100D_Neg11_dB 11354 /* Floating point value 3.548134 */ +#define LVEQNB_100D_Neg10_dB 10119 /* Floating point value 3.162278 */ +#define LVEQNB_100D_Neg9_dB 9019 /* Floating point value 2.818383 */ +#define LVEQNB_100D_Neg8_dB 8038 /* Floating point value 2.511886 */ +#define LVEQNB_100D_Neg7_dB 7164 /* Floating point value 2.238721 */ +#define LVEQNB_100D_Neg6_dB 6385 /* Floating point value 1.995262 */ +#define LVEQNB_100D_Neg5_dB 5690 /* Floating point value 1.778279 */ +#define LVEQNB_100D_Neg4_dB 5072 /* Floating point value 1.584893 */ +#define LVEQNB_100D_Neg3_dB 4520 /* Floating point value 1.412538 */ +#define LVEQNB_100D_Neg2_dB 4029 /* Floating point value 1.258925 */ +#define LVEQNB_100D_Neg1_dB 3590 /* Floating point value 1.122018 */ +#define LVEQNB_100D_0_dB 3200 /* Floating point value 1.000000 */ + + +#endif diff --git a/media/libeffects/lvm/lib/Eq/src/LVEQNB_Control.c b/media/libeffects/lvm/lib/Eq/src/LVEQNB_Control.c new file mode 100755 index 0000000..88f6fb0 --- /dev/null +++ b/media/libeffects/lvm/lib/Eq/src/LVEQNB_Control.c @@ -0,0 +1,501 @@ +/* + * 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: 1223 $ + $Date: 2010-07-15 14:27:01 +0200 (Thu, 15 Jul 2010) $ + +***********************************************************************************/ + +/****************************************************************************************/ +/* */ +/* Includes */ +/* */ +/****************************************************************************************/ + +#include "LVEQNB.h" +#include "LVEQNB_Private.h" +#include "VectorArithmetic.h" +#include "BIQUAD.h" + + +/****************************************************************************************/ +/* */ +/* Defines */ +/* */ +/****************************************************************************************/ + +#define LOW_FREQ 298 /* 32768/110 for low test frequency */ +#define HIGH_FREQ 386 /* 32768/85 for high test frequency */ + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVEQNB_GetParameters */ +/* */ +/* DESCRIPTION: */ +/* Request the N-Band equaliser parameters. The current parameter set is returned via */ +/* the parameter pointer. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance handle */ +/* pParams Pointer to an empty parameter structure */ +/* */ +/* RETURNS: */ +/* LVEQNB_SUCCESS Succeeds */ +/* LVEQNB_NULLADDRESS Instance or pParams is NULL pointer */ +/* */ +/* NOTES: */ +/* 1. This function may be interrupted by the LVEQNB_Process function */ +/* */ +/****************************************************************************************/ + +LVEQNB_ReturnStatus_en LVEQNB_GetParameters(LVEQNB_Handle_t hInstance, + LVEQNB_Params_t *pParams) +{ + + LVEQNB_Instance_t *pInstance =(LVEQNB_Instance_t *)hInstance; + + /* + * Check for error conditions + */ + if((hInstance == LVM_NULL) || (pParams == LVM_NULL)) + { + return LVEQNB_NULLADDRESS; + } + + *pParams = pInstance->Params; + + return(LVEQNB_SUCCESS); +} + + +/************************************************************************************/ +/* */ +/* FUNCTION: LVEQNB_GetCapabilities */ +/* */ +/* DESCRIPTION: */ +/* Get the N-Band equaliser capabilities. The current capabilities are returned */ +/* via the pointer. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance handle */ +/* pCapabilities Pointer to an empty capability structure */ +/* */ +/* RETURNS: */ +/* LVEQNB_Success Succeeds */ +/* LVEQNB_NULLADDRESS hInstance or pCapabilities is NULL */ +/* */ +/* NOTES: */ +/* 1. This function may be interrupted by the LVEQNB_Process function */ +/* */ +/************************************************************************************/ + +LVEQNB_ReturnStatus_en LVEQNB_GetCapabilities(LVEQNB_Handle_t hInstance, + LVEQNB_Capabilities_t *pCapabilities) +{ + + LVEQNB_Instance_t *pInstance =(LVEQNB_Instance_t *)hInstance; + + if((hInstance == LVM_NULL) || (pCapabilities == LVM_NULL)) + { + return LVEQNB_NULLADDRESS; + } + + *pCapabilities = pInstance->Capabilities; + + return(LVEQNB_SUCCESS); +} + + +/************************************************************************************/ +/* */ +/* FUNCTION: LVEQNB_SetFilters */ +/* */ +/* DESCRIPTION: */ +/* Sets the filter type based on the definition. */ +/* */ +/* PARAMETERS: */ +/* pInstance Pointer to the instance */ +/* pParams Initialisation parameters */ +/* */ +/* RETURNS: */ +/* void Nothing */ +/* */ +/* NOTES: */ +/* 1. To select the biquad type the follow rules are applied: */ +/* Double precision if (fc <= fs/110) */ +/* Double precision if (fs/110 < fc < fs/85) & (Q>3) */ +/* Single precision otherwise */ +/* */ +/************************************************************************************/ + +void LVEQNB_SetFilters(LVEQNB_Instance_t *pInstance, + LVEQNB_Params_t *pParams) +{ + + extern const LVM_UINT16 LVEQNB_SampleRateTab[]; /* Sample rate table */ + LVM_UINT16 i; /* Filter band index */ + LVM_UINT32 fs = (LVM_UINT32)LVEQNB_SampleRateTab[(LVM_UINT16)pParams->SampleRate]; /* Sample rate */ + LVM_UINT32 fc; /* Filter centre frequency */ + LVM_INT16 QFactor; /* Filter Q factor */ + + + pInstance->NBands = pParams->NBands; + + for (i=0; iNBands; i++) + { + /* + * Get the filter settings + */ + fc = (LVM_UINT32)pParams->pBandDefinition[i].Frequency; /* Get the band centre frequency */ + QFactor = (LVM_INT16)pParams->pBandDefinition[i].QFactor; /* Get the band Q factor */ + + + /* + * For each filter set the type of biquad required + */ + pInstance->pBiquadType[i] = LVEQNB_SinglePrecision; /* Default to single precision */ + if ((fc << 15) <= (LOW_FREQ * fs)) + { + /* + * fc <= fs/110 + */ + pInstance->pBiquadType[i] = LVEQNB_DoublePrecision; + } + else if (((fc << 15) <= (HIGH_FREQ * fs)) && (QFactor > 300)) + { + /* + * (fs/110 < fc < fs/85) & (Q>3) + */ + pInstance->pBiquadType[i] = LVEQNB_DoublePrecision; + } + + + /* + * Check for out of range frequencies + */ + if (fc > (fs >> 1)) + { + pInstance->pBiquadType[i] = LVEQNB_OutOfRange; + } + + + /* + * Copy the filter definition to persistant memory + */ + pInstance->pBandDefinitions[i] = pParams->pBandDefinition[i]; + + } +} + + +/************************************************************************************/ +/* */ +/* FUNCTION: LVEQNB_SetCoefficients */ +/* */ +/* DESCRIPTION: */ +/* Sets the filter coefficients. This uses the type to select single or double */ +/* precision coefficients. */ +/* */ +/* PARAMETERS: */ +/* pInstance Pointer to the instance */ +/* pParams Initialisation parameters */ +/* */ +/************************************************************************************/ + +void LVEQNB_SetCoefficients(LVEQNB_Instance_t *pInstance) +{ + + LVM_UINT16 i; /* Filter band index */ + LVEQNB_BiquadType_en BiquadType; /* Filter biquad type */ + + + /* + * Set the coefficients for each band by the init function + */ + for (i=0; iParams.NBands; i++) + { + + /* + * Check band type for correct initialisation method and recalculate the coefficients + */ + BiquadType = pInstance->pBiquadType[i]; + switch (BiquadType) + { + case LVEQNB_DoublePrecision: + { + PK_C32_Coefs_t Coefficients; + + /* + * Calculate the double precision coefficients + */ + LVEQNB_DoublePrecCoefs((LVM_UINT16)pInstance->Params.SampleRate, + &pInstance->pBandDefinitions[i], + &Coefficients); + + /* + * Set the coefficients + */ + PK_2I_D32F32CllGss_TRC_WRA_01_Init(&pInstance->pEQNB_FilterState[i], + &pInstance->pEQNB_Taps[i], + &Coefficients); + break; + } + + case LVEQNB_SinglePrecision: + { + PK_C16_Coefs_t Coefficients; + + /* + * Calculate the single precision coefficients + */ + LVEQNB_SinglePrecCoefs((LVM_UINT16)pInstance->Params.SampleRate, + &pInstance->pBandDefinitions[i], + &Coefficients); + + /* + * Set the coefficients + */ + PK_2I_D32F32CssGss_TRC_WRA_01_Init(&pInstance->pEQNB_FilterState[i], + &pInstance->pEQNB_Taps[i], + &Coefficients); + break; + } + default: + break; + } + } + +} + + +/************************************************************************************/ +/* */ +/* FUNCTION: LVEQNB_ClearFilterHistory */ +/* */ +/* DESCRIPTION: */ +/* Clears the filter data history */ +/* */ +/* PARAMETERS: */ +/* pInstance Pointer to the instance */ +/* */ +/************************************************************************************/ + +void LVEQNB_ClearFilterHistory(LVEQNB_Instance_t *pInstance) +{ + LVM_INT16 *pTapAddress; + LVM_INT16 NumTaps; + + + pTapAddress = (LVM_INT16 *)pInstance->pEQNB_Taps; + NumTaps = (LVM_INT16)((pInstance->Capabilities.MaxBands * sizeof(Biquad_2I_Order2_Taps_t))/sizeof(LVM_INT16)); + + if (NumTaps != 0) + { + LoadConst_16(0, /* Clear the history, value 0 */ + pTapAddress, /* Destination */ + NumTaps); /* Number of words */ + } +} + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVEQNB_Control */ +/* */ +/* DESCRIPTION: */ +/* Sets or changes the LifeVibes module parameters. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance handle */ +/* pParams Pointer to a parameter structure */ +/* */ +/* RETURNS: */ +/* LVEQNB_Success Always succeeds */ +/* LVEQNB_NULLADDRESS Instance or pParams is NULL pointer */ +/* LVEQNB_NULLADDRESS NULL address for the equaliser filter definitions and the */ +/* number of bands is non-zero */ +/* */ +/* NOTES: */ +/* 1. This function may be interrupted by the LVEQNB_Process function */ +/* */ +/****************************************************************************************/ + +LVEQNB_ReturnStatus_en LVEQNB_Control(LVEQNB_Handle_t hInstance, + LVEQNB_Params_t *pParams) +{ + + LVEQNB_Instance_t *pInstance = (LVEQNB_Instance_t *)hInstance; + LVM_INT16 bChange = LVM_FALSE; + LVM_INT16 i = 0; + LVEQNB_Mode_en OperatingModeSave ; + + /* + * Check for error conditions + */ + if((hInstance == LVM_NULL) || (pParams == LVM_NULL)) + { + return LVEQNB_NULLADDRESS; + } + + if((pParams->NBands !=0) && (pParams->pBandDefinition==LVM_NULL)) + { + return LVEQNB_NULLADDRESS; + } + + OperatingModeSave = pInstance->Params.OperatingMode; + + /* Set the alpha factor of the mixer */ + if (pParams->SampleRate != pInstance->Params.SampleRate) + { + LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->BypassMixer.MixerStream[0],LVEQNB_BYPASS_MIXER_TC,(LVM_Fs_en)pParams->SampleRate,2); + LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->BypassMixer.MixerStream[1],LVEQNB_BYPASS_MIXER_TC,(LVM_Fs_en)pParams->SampleRate,2); + } + + + if( (pInstance->Params.NBands != pParams->NBands ) || + (pInstance->Params.OperatingMode != pParams->OperatingMode ) || + (pInstance->Params.pBandDefinition != pParams->pBandDefinition ) || + (pInstance->Params.SampleRate != pParams->SampleRate ) || + (pInstance->Params.SourceFormat != pParams->SourceFormat )) + { + + bChange = LVM_TRUE; + } + else + { + for(i = 0; i < pParams->NBands; i++) + { + + if((pInstance->pBandDefinitions[i].Frequency != pParams->pBandDefinition[i].Frequency )|| + (pInstance->pBandDefinitions[i].Gain != pParams->pBandDefinition[i].Gain )|| + (pInstance->pBandDefinitions[i].QFactor != pParams->pBandDefinition[i].QFactor )) + { + + bChange = LVM_TRUE; + } + } + } + + + if(bChange){ + + /* + * If the sample rate has changed clear the history + */ + if (pInstance->Params.SampleRate != pParams->SampleRate) + { + LVEQNB_ClearFilterHistory(pInstance); /* Clear the history */ + } + + /* + * Update the instance parameters + */ + pInstance->Params = *pParams; + + + /* + * Reset the filters except if the algo is switched off + */ + if(pParams->OperatingMode != LVEQNB_BYPASS){ + /* + * Reset the filters as all parameters could have changed + */ + LVEQNB_SetFilters(pInstance, /* Instance pointer */ + pParams); /* New parameters */ + + /* + * Update the filters + */ + LVEQNB_SetCoefficients(pInstance); /* Instance pointer */ + } + + if(pParams->OperatingMode != OperatingModeSave) + { + if(pParams->OperatingMode == LVEQNB_ON) + { + LVC_Mixer_SetTarget(&pInstance->BypassMixer.MixerStream[0],LVM_MAXINT_16); + LVC_Mixer_SetTarget(&pInstance->BypassMixer.MixerStream[1],0); + + pInstance->BypassMixer.MixerStream[0].CallbackSet = 1; + pInstance->BypassMixer.MixerStream[1].CallbackSet = 1; + } + else + { + /* Stay on the ON operating mode until the transition is done */ + pInstance->Params.OperatingMode = LVEQNB_ON; + + LVC_Mixer_SetTarget(&pInstance->BypassMixer.MixerStream[0],0); + LVC_Mixer_SetTarget(&pInstance->BypassMixer.MixerStream[1],LVM_MAXINT_16); + pInstance->BypassMixer.MixerStream[0].CallbackSet = 1; + pInstance->BypassMixer.MixerStream[1].CallbackSet = 1; + } + LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->BypassMixer.MixerStream[0],LVEQNB_BYPASS_MIXER_TC,(LVM_Fs_en)pParams->SampleRate,2); + LVC_Mixer_VarSlope_SetTimeConstant(&pInstance->BypassMixer.MixerStream[1],LVEQNB_BYPASS_MIXER_TC,(LVM_Fs_en)pParams->SampleRate,2); + + pInstance->bInOperatingModeTransition = LVM_TRUE; + } + + } + return(LVEQNB_SUCCESS); +} + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVEQNB_BypassMixerCallBack */ +/* */ +/* DESCRIPTION: */ +/* CallBack function of the mixer */ +/* transition */ +/* */ +/****************************************************************************************/ +LVM_INT32 LVEQNB_BypassMixerCallBack (void* hInstance, + void *pGeneralPurpose, + LVM_INT16 CallbackParam) +{ + LVEQNB_Instance_t *pInstance =(LVEQNB_Instance_t *)hInstance; + LVM_Callback CallBack = pInstance->Capabilities.CallBack; + + (void) pGeneralPurpose; + + /* + * Send an ALGOFF event if the ON->OFF switch transition is finished + */ + if((LVC_Mixer_GetTarget(&pInstance->BypassMixer.MixerStream[0]) == 0x00000000) && + (CallbackParam == 0)){ + pInstance->Params.OperatingMode = LVEQNB_BYPASS; + if (CallBack != LVM_NULL){ + CallBack(pInstance->Capabilities.pBundleInstance, LVM_NULL, ALGORITHM_EQNB_ID|LVEQNB_EVENT_ALGOFF); + } + } + + /* + * Exit transition state + */ + pInstance->bInOperatingModeTransition = LVM_FALSE; + + return 1; +} + + + + + + diff --git a/media/libeffects/lvm/lib/Eq/src/LVEQNB_Init.c b/media/libeffects/lvm/lib/Eq/src/LVEQNB_Init.c new file mode 100755 index 0000000..a29fe05 --- /dev/null +++ b/media/libeffects/lvm/lib/Eq/src/LVEQNB_Init.c @@ -0,0 +1,329 @@ +/* + * 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: 1005 $ + $Date: 2010-06-28 13:58:28 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + + +/****************************************************************************************/ +/* */ +/* Includes */ +/* */ +/****************************************************************************************/ + +#include "LVEQNB.h" +#include "LVEQNB_Private.h" +#include "InstAlloc.h" + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVEQNB_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) the memory */ +/* base address pointers are NULL on return. */ +/* */ +/* When the function is called for free (hInstance = Instance Handle) the memory */ +/* table returns the allocated memory and base addresses used during initialisation. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance Handle */ +/* pMemoryTable Pointer to an empty memory definition table */ +/* pCapabilities Pointer to the instance capabilities */ +/* */ +/* RETURNS: */ +/* LVEQNB_SUCCESS Succeeded */ +/* LVEQNB_NULLADDRESS When any of pMemoryTable and pCapabilities is NULL address */ +/* */ +/* NOTES: */ +/* 1. This function may be interrupted by the LVEQNB_Process function */ +/* */ +/****************************************************************************************/ + +LVEQNB_ReturnStatus_en LVEQNB_Memory(LVEQNB_Handle_t hInstance, + LVEQNB_MemTab_t *pMemoryTable, + LVEQNB_Capabilities_t *pCapabilities) +{ + + INST_ALLOC AllocMem; + LVEQNB_Instance_t *pInstance = (LVEQNB_Instance_t *)hInstance; + + + if((pMemoryTable == LVM_NULL)|| (pCapabilities == LVM_NULL)) + { + return LVEQNB_NULLADDRESS; + } + + + /* + * Fill in the memory table + */ + if (hInstance == LVM_NULL) + { + /* + * Instance memory + */ + InstAlloc_Init(&AllocMem, + LVM_NULL); + InstAlloc_AddMember(&AllocMem, /* Low pass filter */ + sizeof(LVEQNB_Instance_t)); + pMemoryTable->Region[LVEQNB_MEMREGION_INSTANCE].Size = InstAlloc_GetTotal(&AllocMem); + pMemoryTable->Region[LVEQNB_MEMREGION_INSTANCE].Alignment = LVEQNB_INSTANCE_ALIGN; + pMemoryTable->Region[LVEQNB_MEMREGION_INSTANCE].Type = LVEQNB_PERSISTENT; + pMemoryTable->Region[LVEQNB_MEMREGION_INSTANCE].pBaseAddress = LVM_NULL; + + + /* + * Persistant data memory + */ + InstAlloc_Init(&AllocMem, + LVM_NULL); + InstAlloc_AddMember(&AllocMem, /* Low pass filter */ + sizeof(Biquad_2I_Order2_Taps_t)); + InstAlloc_AddMember(&AllocMem, /* High pass filter */ + sizeof(Biquad_2I_Order2_Taps_t)); + InstAlloc_AddMember(&AllocMem, + (pCapabilities->MaxBands * sizeof(Biquad_2I_Order2_Taps_t))); /* Equaliser Biquad Taps */ + InstAlloc_AddMember(&AllocMem, + (pCapabilities->MaxBands * sizeof(LVEQNB_BandDef_t))); /* Filter definitions */ + InstAlloc_AddMember(&AllocMem, + (pCapabilities->MaxBands * sizeof(LVEQNB_BiquadType_en))); /* Biquad types */ + pMemoryTable->Region[LVEQNB_MEMREGION_PERSISTENT_DATA].Size = InstAlloc_GetTotal(&AllocMem); + pMemoryTable->Region[LVEQNB_MEMREGION_PERSISTENT_DATA].Alignment = LVEQNB_DATA_ALIGN; + pMemoryTable->Region[LVEQNB_MEMREGION_PERSISTENT_DATA].Type = LVEQNB_PERSISTENT_DATA; + pMemoryTable->Region[LVEQNB_MEMREGION_PERSISTENT_DATA].pBaseAddress = LVM_NULL; + + /* + * Persistant coefficient memory + */ + InstAlloc_Init(&AllocMem, + LVM_NULL); + InstAlloc_AddMember(&AllocMem, /* Low pass filter */ + sizeof(Biquad_Instance_t)); + InstAlloc_AddMember(&AllocMem, /* High pass filter */ + sizeof(Biquad_Instance_t)); + InstAlloc_AddMember(&AllocMem, + pCapabilities->MaxBands * sizeof(Biquad_Instance_t)); /* Equaliser Biquad Instance */ + pMemoryTable->Region[LVEQNB_MEMREGION_PERSISTENT_COEF].Size = InstAlloc_GetTotal(&AllocMem); + pMemoryTable->Region[LVEQNB_MEMREGION_PERSISTENT_COEF].Alignment = LVEQNB_COEF_ALIGN; + pMemoryTable->Region[LVEQNB_MEMREGION_PERSISTENT_COEF].Type = LVEQNB_PERSISTENT_COEF; + pMemoryTable->Region[LVEQNB_MEMREGION_PERSISTENT_COEF].pBaseAddress = LVM_NULL; + + /* + * Scratch memory + */ + InstAlloc_Init(&AllocMem, + LVM_NULL); + InstAlloc_AddMember(&AllocMem, /* Low pass filter */ + LVEQNB_SCRATCHBUFFERS*sizeof(LVM_INT16)*pCapabilities->MaxBlockSize); + pMemoryTable->Region[LVEQNB_MEMREGION_SCRATCH].Size = InstAlloc_GetTotal(&AllocMem); + pMemoryTable->Region[LVEQNB_MEMREGION_SCRATCH].Alignment = LVEQNB_SCRATCH_ALIGN; + pMemoryTable->Region[LVEQNB_MEMREGION_SCRATCH].Type = LVEQNB_SCRATCH; + pMemoryTable->Region[LVEQNB_MEMREGION_SCRATCH].pBaseAddress = LVM_NULL; + } + else + { + /* Read back memory allocation table */ + *pMemoryTable = pInstance->MemoryTable; + } + + return(LVEQNB_SUCCESS); +} + + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVEQNB_Init */ +/* */ +/* DESCRIPTION: */ +/* Create and initialisation function for the N-Band equaliser module */ +/* */ +/* This function can be used to create an algorithm instance by calling with */ +/* hInstance set to 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 */ +/* DBE_Memory before calling this function. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance handle */ +/* pMemoryTable Pointer to the memory definition table */ +/* pCapabilities Pointer to the instance capabilities */ +/* */ +/* RETURNS: */ +/* LVEQNB_SUCCESS Initialisation succeeded */ +/* LVEQNB_NULLADDRESS When pCapabilities or pMemoryTableis or phInstance are NULL */ +/* LVEQNB_NULLADDRESS One or more of the memory regions has a NULL base address */ +/* pointer for a memory region with a non-zero size. */ +/* */ +/* 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 LVEQNB_Process function */ +/* */ +/****************************************************************************************/ + +LVEQNB_ReturnStatus_en LVEQNB_Init(LVEQNB_Handle_t *phInstance, + LVEQNB_MemTab_t *pMemoryTable, + LVEQNB_Capabilities_t *pCapabilities) +{ + + LVEQNB_Instance_t *pInstance; + LVM_UINT32 MemSize; + INST_ALLOC AllocMem; + LVM_INT32 i; + + /* + * Check for NULL pointers + */ + if((phInstance == LVM_NULL) || (pMemoryTable == LVM_NULL) || (pCapabilities == LVM_NULL)) + { + return LVEQNB_NULLADDRESS; + } + + /* + * Check the memory table for NULL pointers + */ + for (i = 0; i < LVEQNB_NR_MEMORY_REGIONS; i++) + { + if (pMemoryTable->Region[i].Size!=0) + { + if (pMemoryTable->Region[i].pBaseAddress==LVM_NULL) + { + return(LVEQNB_NULLADDRESS); + } + } + } + + /* + * Set the instance handle if not already initialised + */ + + InstAlloc_Init(&AllocMem, pMemoryTable->Region[LVEQNB_MEMREGION_INSTANCE].pBaseAddress); + + if (*phInstance == LVM_NULL) + { + *phInstance = InstAlloc_AddMember(&AllocMem, sizeof(LVEQNB_Instance_t)); + } + pInstance =(LVEQNB_Instance_t *)*phInstance; + + + + /* + * Save the memory table in the instance structure + */ + pInstance->Capabilities = *pCapabilities; + + + /* + * Save the memory table in the instance structure and + * set the structure pointers + */ + pInstance->MemoryTable = *pMemoryTable; + + /* + * Allocate coefficient memory + */ + InstAlloc_Init(&AllocMem, + pMemoryTable->Region[LVEQNB_MEMREGION_PERSISTENT_COEF].pBaseAddress); + + pInstance->pEQNB_FilterState = InstAlloc_AddMember(&AllocMem, + pCapabilities->MaxBands * sizeof(Biquad_Instance_t)); /* Equaliser Biquad Instance */ + + + + /* + * Allocate data memory + */ + InstAlloc_Init(&AllocMem, + pMemoryTable->Region[LVEQNB_MEMREGION_PERSISTENT_DATA].pBaseAddress); + + MemSize = (pCapabilities->MaxBands * sizeof(Biquad_2I_Order2_Taps_t)); + pInstance->pEQNB_Taps = (Biquad_2I_Order2_Taps_t *)InstAlloc_AddMember(&AllocMem, + MemSize); + MemSize = (pCapabilities->MaxBands * sizeof(LVEQNB_BandDef_t)); + pInstance->pBandDefinitions = (LVEQNB_BandDef_t *)InstAlloc_AddMember(&AllocMem, + MemSize); + MemSize = (pCapabilities->MaxBands * sizeof(LVEQNB_BiquadType_en)); + pInstance->pBiquadType = (LVEQNB_BiquadType_en *)InstAlloc_AddMember(&AllocMem, + MemSize); + + + /* + * Internally map, structure and allign scratch memory + */ + InstAlloc_Init(&AllocMem, + pMemoryTable->Region[LVEQNB_MEMREGION_SCRATCH].pBaseAddress); + + pInstance->pFastTemporary = (LVM_INT16 *)InstAlloc_AddMember(&AllocMem, + sizeof(LVM_INT16)); + + /* + * Update the instance parameters + */ + pInstance->Params.NBands = 0; + pInstance->Params.OperatingMode = LVEQNB_BYPASS; + pInstance->Params.pBandDefinition = LVM_NULL; + pInstance->Params.SampleRate = LVEQNB_FS_8000; + pInstance->Params.SourceFormat = LVEQNB_STEREO; + + /* + * Initialise the filters + */ + LVEQNB_SetFilters(pInstance, /* Set the filter types */ + &pInstance->Params); + + LVEQNB_SetCoefficients(pInstance); /* Set the filter coefficients */ + + LVEQNB_ClearFilterHistory(pInstance); /* Clear the filter history */ + + /* + * Initialise the bypass variables + */ + pInstance->BypassMixer.MixerStream[0].CallbackSet = 0; + pInstance->BypassMixer.MixerStream[0].CallbackParam = 0; + pInstance->BypassMixer.MixerStream[0].pCallbackHandle = (void*)pInstance; + pInstance->BypassMixer.MixerStream[0].pCallBack = LVEQNB_BypassMixerCallBack; + LVC_Mixer_Init(&pInstance->BypassMixer.MixerStream[0],0,0); + LVC_Mixer_SetTimeConstant(&pInstance->BypassMixer.MixerStream[0],0,LVM_FS_8000,2); + + pInstance->BypassMixer.MixerStream[1].CallbackSet = 1; + pInstance->BypassMixer.MixerStream[1].CallbackParam = 0; + pInstance->BypassMixer.MixerStream[1].pCallbackHandle = LVM_NULL; + pInstance->BypassMixer.MixerStream[1].pCallBack = LVM_NULL; + LVC_Mixer_Init(&pInstance->BypassMixer.MixerStream[1],0,LVM_MAXINT_16); + LVC_Mixer_SetTimeConstant(&pInstance->BypassMixer.MixerStream[1],0,LVM_FS_8000,2); + + pInstance->bInOperatingModeTransition = LVM_FALSE; + + return(LVEQNB_SUCCESS); +} + diff --git a/media/libeffects/lvm/lib/Eq/src/LVEQNB_Private.h b/media/libeffects/lvm/lib/Eq/src/LVEQNB_Private.h new file mode 100755 index 0000000..0ae84af --- /dev/null +++ b/media/libeffects/lvm/lib/Eq/src/LVEQNB_Private.h @@ -0,0 +1,141 @@ +/* + * 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: 1005 $ + $Date: 2010-06-28 13:58:28 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +#ifndef __LVEQNB_PRIVATE_H__ +#define __LVEQNB_PRIVATE_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/****************************************************************************************/ +/* */ +/* Includes */ +/* */ +/****************************************************************************************/ + +#include "LVEQNB.h" /* Calling or Application layer definitions */ +#include "BIQUAD.h" +#include "LVC_Mixer.h" + +/****************************************************************************************/ +/* */ +/* Defines */ +/* */ +/****************************************************************************************/ + +/* General */ +#define LVEQNB_INVALID 0xFFFF /* Invalid init parameter */ + +/* Memory */ +#define LVEQNB_INSTANCE_ALIGN 4 /* 32-bit alignment for instance structures */ +#define LVEQNB_DATA_ALIGN 4 /* 32-bit alignment for structures */ +#define LVEQNB_COEF_ALIGN 4 /* 32-bit alignment for long words */ +#define LVEQNB_SCRATCHBUFFERS 4 /* Number of buffers required for inplace processing */ +#define LVEQNB_SCRATCH_ALIGN 4 /* 32-bit alignment for long data */ + +#define LVEQNB_BYPASS_MIXER_TC 100 /* Bypass Mixer TC */ + +/****************************************************************************************/ +/* */ +/* Types */ +/* */ +/****************************************************************************************/ + +/* Filter biquad types */ +typedef enum +{ + LVEQNB_SinglePrecision = 0, + LVEQNB_DoublePrecision = 1, + LVEQNB_OutOfRange = 2, + LVEQNB_BIQUADTYPE_MAX = LVM_MAXINT_32 +} LVEQNB_BiquadType_en; + + +/****************************************************************************************/ +/* */ +/* Structures */ +/* */ +/****************************************************************************************/ + + + +/* Instance structure */ +typedef struct +{ + /* Public parameters */ + LVEQNB_MemTab_t MemoryTable; /* Instance memory allocation table */ + LVEQNB_Params_t Params; /* Instance parameters */ + LVEQNB_Capabilities_t Capabilities; /* Instance capabilities */ + + /* Aligned memory pointers */ + LVM_INT16 *pFastTemporary; /* Fast temporary data base address */ + + /* Process variables */ + Biquad_2I_Order2_Taps_t *pEQNB_Taps; /* Equaliser Taps */ + Biquad_Instance_t *pEQNB_FilterState; /* State for each filter band */ + + /* Filter definitions and call back */ + LVM_UINT16 NBands; /* Number of bands */ + LVEQNB_BandDef_t *pBandDefinitions; /* Filter band definitions */ + LVEQNB_BiquadType_en *pBiquadType; /* Filter biquad types */ + + /* Bypass variable */ + LVMixer3_2St_st BypassMixer; /* Bypass mixer used in transitions */ + LVM_INT16 bInOperatingModeTransition; /* Operating mode transition flag */ + +} LVEQNB_Instance_t; + + +/****************************************************************************************/ +/* */ +/* Function prototypes */ +/* */ +/****************************************************************************************/ + +void LVEQNB_SetFilters(LVEQNB_Instance_t *pInstance, + LVEQNB_Params_t *pParams); + +void LVEQNB_SetCoefficients(LVEQNB_Instance_t *pInstance); + +void LVEQNB_ClearFilterHistory(LVEQNB_Instance_t *pInstance); + +LVEQNB_ReturnStatus_en LVEQNB_SinglePrecCoefs(LVM_UINT16 Fs, + LVEQNB_BandDef_t *pFilterDefinition, + PK_C16_Coefs_t *pCoefficients); + +LVEQNB_ReturnStatus_en LVEQNB_DoublePrecCoefs(LVM_UINT16 Fs, + LVEQNB_BandDef_t *pFilterDefinition, + PK_C32_Coefs_t *pCoefficients); + +LVM_INT32 LVEQNB_BypassMixerCallBack (void* hInstance, void *pGeneralPurpose, LVM_INT16 CallbackParam); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __LVEQNB_PRIVATE_H__ */ + diff --git a/media/libeffects/lvm/lib/Eq/src/LVEQNB_Process.c b/media/libeffects/lvm/lib/Eq/src/LVEQNB_Process.c new file mode 100755 index 0000000..e29e881 --- /dev/null +++ b/media/libeffects/lvm/lib/Eq/src/LVEQNB_Process.c @@ -0,0 +1,208 @@ +/* + * 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: 1005 $ + $Date: 2010-06-28 13:58:28 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +/****************************************************************************************/ +/* */ +/* Includes */ +/* */ +/****************************************************************************************/ + +#include "LVEQNB.h" +#include "LVEQNB_Private.h" +#include "VectorArithmetic.h" +#include "BIQUAD.h" + + +/****************************************************************************************/ +/* */ +/* Defines */ +/* */ +/****************************************************************************************/ + +#define SHIFT 13 + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVEQNB_Process */ +/* */ +/* DESCRIPTION: */ +/* Process function for the N-Band Equaliser module. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance handle */ +/* pInData Pointer to the input data */ +/* pOutData Pointer to the output data */ +/* NumSamples Number of samples in the input buffer */ +/* */ +/* RETURNS: */ +/* LVEQNB_SUCCESS Succeeded */ +/* LVEQNB_NULLADDRESS When hInstance, pInData or pOutData are NULL */ +/* LVEQNB_ALIGNMENTERROR When pInData or pOutData are not 32-bit aligned */ +/* LVEQNB_TOOMANYSAMPLES NumSamples was larger than the maximum block size */ +/* */ +/* NOTES: */ +/* */ +/****************************************************************************************/ + +LVEQNB_ReturnStatus_en LVEQNB_Process(LVEQNB_Handle_t hInstance, + const LVM_INT16 *pInData, + LVM_INT16 *pOutData, + LVM_UINT16 NumSamples) +{ + + LVM_UINT16 i; + Biquad_Instance_t *pBiquad; + LVEQNB_Instance_t *pInstance = (LVEQNB_Instance_t *)hInstance; + LVM_INT32 *pScratch; + + + /* Check for NULL pointers */ + if((hInstance == LVM_NULL) || (pInData == LVM_NULL) || (pOutData == LVM_NULL)) + { + return LVEQNB_NULLADDRESS; + } + + /* Check if the input and output data buffers are 32-bit aligned */ + if ((((LVM_INT32)pInData % 4) != 0) || (((LVM_INT32)pOutData % 4) != 0)) + { + return LVEQNB_ALIGNMENTERROR; + } + + pScratch = (LVM_INT32 *)pInstance->pFastTemporary; + + /* + * Check the number of samples is not too large + */ + if (NumSamples > pInstance->Capabilities.MaxBlockSize) + { + return(LVEQNB_TOOMANYSAMPLES); + } + + if (pInstance->Params.OperatingMode == LVEQNB_ON) + { + /* + * Convert from 16-bit to 32-bit + */ + Int16LShiftToInt32_16x32((LVM_INT16 *)pInData, /* Source */ + pScratch, /* Destination */ + (LVM_INT16)(2*NumSamples), /* Left and Right */ + SHIFT); /* Scaling shift */ + + /* + * For each section execte the filter unless the gain is 0dB + */ + if (pInstance->NBands != 0) + { + for (i=0; iNBands; i++) + { + /* + * Check if band is non-zero dB gain + */ + if (pInstance->pBandDefinitions[i].Gain != 0) + { + /* + * Get the address of the biquad instance + */ + pBiquad = &pInstance->pEQNB_FilterState[i]; + + + /* + * Select single or double precision as required + */ + switch (pInstance->pBiquadType[i]) + { + case LVEQNB_SinglePrecision: + { + PK_2I_D32F32C14G11_TRC_WRA_01(pBiquad, + (LVM_INT32 *)pScratch, + (LVM_INT32 *)pScratch, + (LVM_INT16)NumSamples); + break; + } + + case LVEQNB_DoublePrecision: + { + PK_2I_D32F32C30G11_TRC_WRA_01(pBiquad, + (LVM_INT32 *)pScratch, + (LVM_INT32 *)pScratch, + (LVM_INT16)NumSamples); + break; + } + default: + break; + } + } + } + } + + + if(pInstance->bInOperatingModeTransition == LVM_TRUE){ + /* + * Convert from 32-bit to 16- bit and saturate + */ + Int32RShiftToInt16_Sat_32x16(pScratch, /* Source */ + (LVM_INT16 *)pScratch, /* Destination */ + (LVM_INT16)(2*NumSamples), /* Left and Right */ + SHIFT); /* Scaling shift */ + + LVC_MixSoft_2St_D16C31_SAT(&pInstance->BypassMixer, + (LVM_INT16 *)pScratch, + (LVM_INT16 *)pInData, + (LVM_INT16 *)pScratch, + (LVM_INT16)(2*NumSamples)); + + Copy_16((LVM_INT16*)pScratch, /* Source */ + pOutData, /* Destination */ + (LVM_INT16)(2*NumSamples)); /* Left and Right samples */ + } + else{ + + /* + * Convert from 32-bit to 16- bit and saturate + */ + Int32RShiftToInt16_Sat_32x16(pScratch, /* Source */ + pOutData, /* Destination */ + (LVM_INT16 )(2*NumSamples), /* Left and Right */ + SHIFT); /* Scaling shift */ + } + } + else + { + /* + * Mode is OFF so copy the data if necessary + */ + if (pInData != pOutData) + { + Copy_16(pInData, /* Source */ + pOutData, /* Destination */ + (LVM_INT16)(2*NumSamples)); /* Left and Right samples */ + } + } + + + + return(LVEQNB_SUCCESS); + +} diff --git a/media/libeffects/lvm/lib/Eq/src/LVEQNB_Tables.c b/media/libeffects/lvm/lib/Eq/src/LVEQNB_Tables.c new file mode 100755 index 0000000..33c07da --- /dev/null +++ b/media/libeffects/lvm/lib/Eq/src/LVEQNB_Tables.c @@ -0,0 +1,203 @@ +/* + * 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: 1005 $ + $Date: 2010-06-28 13:58:28 +0200 (Mon, 28 Jun 2010) $ + +*************************************************************************************/ + + +/************************************************************************************/ +/* */ +/* Includes */ +/* */ +/************************************************************************************/ + +#include "LVEQNB.h" +#include "LVEQNB_Coeffs.h" + + +/************************************************************************************/ +/* */ +/* Sample rate table */ +/* */ +/************************************************************************************/ + +/* + * Sample rate table for converting between the enumerated type and the actual + * frequency + */ +const LVM_UINT16 LVEQNB_SampleRateTab[] = {8000, /* 8kS/s */ + 11025, + 12000, + 16000, + 22050, + 24000, + 32000, + 44100, + 48000}; /* 48kS/s */ + + +/************************************************************************************/ +/* */ +/* Coefficient calculation tables */ +/* */ +/************************************************************************************/ + +/* + * Table for 2 * Pi / Fs + */ +const LVM_INT16 LVEQNB_TwoPiOnFsTable[] = {LVEQNB_2PiOn_8000, /* 8kS/s */ + LVEQNB_2PiOn_11025, + LVEQNB_2PiOn_12000, + LVEQNB_2PiOn_16000, + LVEQNB_2PiOn_22050, + LVEQNB_2PiOn_24000, + LVEQNB_2PiOn_32000, + LVEQNB_2PiOn_44100, + LVEQNB_2PiOn_48000}; /* 48kS/s */ + +/* + * Gain table + */ +const LVM_INT16 LVEQNB_GainTable[] = {LVEQNB_Gain_Neg15_dB, /* -15dB gain */ + LVEQNB_Gain_Neg14_dB, + LVEQNB_Gain_Neg13_dB, + LVEQNB_Gain_Neg12_dB, + LVEQNB_Gain_Neg11_dB, + LVEQNB_Gain_Neg10_dB, + LVEQNB_Gain_Neg9_dB, + LVEQNB_Gain_Neg8_dB, + LVEQNB_Gain_Neg7_dB, + LVEQNB_Gain_Neg6_dB, + LVEQNB_Gain_Neg5_dB, + LVEQNB_Gain_Neg4_dB, + LVEQNB_Gain_Neg3_dB, + LVEQNB_Gain_Neg2_dB, + LVEQNB_Gain_Neg1_dB, + LVEQNB_Gain_0_dB, /* 0dB gain */ + LVEQNB_Gain_1_dB, + LVEQNB_Gain_2_dB, + LVEQNB_Gain_3_dB, + LVEQNB_Gain_4_dB, + LVEQNB_Gain_5_dB, + LVEQNB_Gain_6_dB, + LVEQNB_Gain_7_dB, + LVEQNB_Gain_8_dB, + LVEQNB_Gain_9_dB, + LVEQNB_Gain_10_dB, + LVEQNB_Gain_11_dB, + LVEQNB_Gain_12_dB, + LVEQNB_Gain_13_dB, + LVEQNB_Gain_14_dB, + LVEQNB_Gain_15_dB}; /* +15dB gain */ + + +/* + * D table for 100 / (Gain + 1) + */ +const LVM_INT16 LVEQNB_DTable[] = {LVEQNB_100D_Neg15_dB, /* -15dB gain */ + LVEQNB_100D_Neg14_dB, + LVEQNB_100D_Neg13_dB, + LVEQNB_100D_Neg12_dB, + LVEQNB_100D_Neg11_dB, + LVEQNB_100D_Neg10_dB, + LVEQNB_100D_Neg9_dB, + LVEQNB_100D_Neg8_dB, + LVEQNB_100D_Neg7_dB, + LVEQNB_100D_Neg6_dB, + LVEQNB_100D_Neg5_dB, + LVEQNB_100D_Neg4_dB, + LVEQNB_100D_Neg3_dB, + LVEQNB_100D_Neg2_dB, + LVEQNB_100D_Neg1_dB, + LVEQNB_100D_0_dB}; /* 0dB gain */ + + +/************************************************************************************/ +/* */ +/* Filter polynomial coefficients */ +/* */ +/************************************************************************************/ + +/* + * Coefficients for calculating the cosine with the equation: + * + * Cos(x) = (2^Shifts)*(a0 + a1*x + a2*x^2 + a3*x^3 + a4*x^4 + a5*x^5) + * + * These coefficients expect the input, x, to be in the range 0 to 32768 respresenting + * a range of 0 to Pi. The output is in the range 32767 to -32768 representing the range + * +1.0 to -1.0 + */ +const LVM_INT16 LVEQNB_CosCoef[] = {3, /* Shifts */ + 4096, /* a0 */ + -36, /* a1 */ + -19725, /* a2 */ + -2671, /* a3 */ + 23730, /* a4 */ + -9490}; /* a5 */ + +/* + * Coefficients for calculating the cosine error with the equation: + * + * CosErr(x) = (2^Shifts)*(a0 + a1*x + a2*x^2 + a3*x^3) + * + * These coefficients expect the input, x, to be in the range 0 to 32768 respresenting + * a range of 0 to Pi/25. The output is in the range 0 to 32767 representing the range + * 0.0 to 0.0078852986 + * + * This is used to give a double precision cosine over the range 0 to Pi/25 using the + * the equation: + * + * Cos(x) = 1.0 - CosErr(x) + */ +const LVM_INT16 LVEQNB_DPCosCoef[] = {1, /* Shifts */ + 0, /* a0 */ + -6, /* a1 */ + 16586, /* a2 */ + -44}; /* a3 */ + +/************************************************************************************/ +/* */ +/* Bypass mixer time constants (100ms) */ +/* */ +/************************************************************************************/ + +#define LVEQNB_MIX_TC_Fs8000 32580 /* Floating point value 0.994262695 */ +#define LVEQNB_MIX_TC_Fs11025 32632 /* Floating point value 0.995849609 */ +#define LVEQNB_MIX_TC_Fs12000 32643 /* Floating point value 0.996185303 */ +#define LVEQNB_MIX_TC_Fs16000 32674 /* Floating point value 0.997131348 */ +#define LVEQNB_MIX_TC_Fs22050 32700 /* Floating point value 0.997924805 */ +#define LVEQNB_MIX_TC_Fs24000 32705 /* Floating point value 0.998077393 */ +#define LVEQNB_MIX_TC_Fs32000 32721 /* Floating point value 0.998565674 */ +#define LVEQNB_MIX_TC_Fs44100 32734 /* Floating point value 0.998962402 */ +#define LVEQNB_MIX_TC_Fs48000 32737 /* Floating point value 0.999053955 */ + + +const LVM_INT16 LVEQNB_MixerTCTable[] = { + LVEQNB_MIX_TC_Fs8000, + LVEQNB_MIX_TC_Fs11025, + LVEQNB_MIX_TC_Fs12000, + LVEQNB_MIX_TC_Fs16000, + LVEQNB_MIX_TC_Fs22050, + LVEQNB_MIX_TC_Fs24000, + LVEQNB_MIX_TC_Fs32000, + LVEQNB_MIX_TC_Fs44100, + LVEQNB_MIX_TC_Fs48000}; diff --git a/media/libeffects/lvm/lib/SpectrumAnalyzer/lib/LVPSA.h b/media/libeffects/lvm/lib/SpectrumAnalyzer/lib/LVPSA.h new file mode 100755 index 0000000..b9903b2 --- /dev/null +++ b/media/libeffects/lvm/lib/SpectrumAnalyzer/lib/LVPSA.h @@ -0,0 +1,298 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: PSA_01_ARMC_01 */ +/* $Author: beq07716 $*/ +/* $Revision: 1006 $*/ +/* $Date: 2010-06-28 14:01:47 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ +#ifndef _LVPSA_H_ +#define _LVPSA_H_ + + +#include "LVM_Types.h" + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/****************************************************************************************/ +/* */ +/* CONSTANTS DEFINITIONS */ +/* */ +/****************************************************************************************/ + +/* Memory table*/ +#define LVPSA_NR_MEMORY_REGIONS 4 /* Number of memory regions */ + +/****************************************************************************************/ +/* */ +/* TYPES DEFINITIONS */ +/* */ +/****************************************************************************************/ +/* Memory Types */ +typedef enum +{ + LVPSA_PERSISTENT = LVM_PERSISTENT, + LVPSA_PERSISTENT_DATA = LVM_PERSISTENT_DATA, + LVPSA_PERSISTENT_COEF = LVM_PERSISTENT_COEF, + LVPSA_SCRATCH = LVM_SCRATCH, + LVPSA_MEMORY_DUMMY = LVM_MAXINT_32 /* Force 32 bits enum, don't use it! */ +} LVPSA_MemoryTypes_en; + +/* Level detection speed control parameters */ +typedef enum +{ + LVPSA_SPEED_LOW, /* Low speed level detection */ + LVPSA_SPEED_MEDIUM, /* Medium speed level detection */ + LVPSA_SPEED_HIGH, /* High speed level detection */ + LVPSA_SPEED_DUMMY = LVM_MAXINT_32 /* Force 32 bits enum, don't use it! */ +} LVPSA_LevelDetectSpeed_en; + +/* Filter control parameters */ +typedef struct +{ + LVM_UINT16 CenterFrequency; /* Center frequency of the band-pass filter (in Hz) */ + LVM_UINT16 QFactor; /* Quality factor of the filter (in 1/100) */ + LVM_INT16 PostGain; /* Postgain to apply after the filtering (in dB Q16.0) */ + +} LVPSA_FilterParam_t; + +/* LVPSA initialization parameters */ +typedef struct +{ + LVM_UINT16 SpectralDataBufferDuration; /* Spectral data buffer duration in time (ms in Q16.0) */ + LVM_UINT16 MaxInputBlockSize; /* Maximum expected input block size (in samples) */ + LVM_UINT16 nBands; /* Number of bands of the SA */ + LVPSA_FilterParam_t *pFiltersParams; /* Points to nBands filter param structures for filters settings */ + +} LVPSA_InitParams_t, *pLVPSA_InitParams_t; + +/* LVPSA control parameters */ +typedef struct +{ + LVM_Fs_en Fs; /* Input sampling rate */ + LVPSA_LevelDetectSpeed_en LevelDetectionSpeed; /* Level detection speed */ + +} LVPSA_ControlParams_t, *pLVPSA_ControlParams_t; + +/* Memory region definition */ +typedef struct +{ + LVM_UINT32 Size; /* Region size in bytes */ + LVPSA_MemoryTypes_en Type; /* Region type */ + void *pBaseAddress; /* Pointer to the region base address */ +} LVPSA_MemoryRegion_t; + +/* Memory table containing the region definitions */ +typedef struct +{ + LVPSA_MemoryRegion_t Region[LVPSA_NR_MEMORY_REGIONS];/* One definition for each region */ +} LVPSA_MemTab_t; + +/* Audio time type */ +typedef LVM_INT32 LVPSA_Time; + +/* Module instance Handle */ +typedef void *pLVPSA_Handle_t; + +/* LVPSA return codes */ +typedef enum +{ + LVPSA_OK, /* The function ran without any problem */ + LVPSA_ERROR_INVALIDPARAM, /* A parameter is incorrect */ + LVPSA_ERROR_WRONGTIME, /* An incorrect AudioTime is used */ + LVPSA_ERROR_NULLADDRESS, /* A pointer has a NULL value */ + LVPSA_RETURN_DUMMY = LVM_MAXINT_32 /* Force 32 bits enum, don't use it! */ +} LVPSA_RETURN; + + + +/********************************************************************************************************************************* + FUNCTIONS PROTOTYPE +**********************************************************************************************************************************/ +/*********************************************************************************************************************************/ +/* */ +/* FUNCTION: LVPSA_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) the memory */ +/* base address pointers are NULL on return. */ +/* */ +/* When the function is called for free (hInstance = Instance Handle) the memory */ +/* table returns the allocated memory and base addresses used during initialisation. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance Handle */ +/* pMemoryTable Pointer to an empty memory definition table */ +/* pInitParams Pointer to the instance init parameters */ +/* */ +/* RETURNS: */ +/* LVPSA_OK Succeeds */ +/* otherwise Error due to bad parameters */ +/* */ +/*********************************************************************************************************************************/ +LVPSA_RETURN LVPSA_Memory ( pLVPSA_Handle_t hInstance, + LVPSA_MemTab_t *pMemoryTable, + LVPSA_InitParams_t *pInitParams ); + +/*********************************************************************************************************************************/ +/* */ +/* FUNCTION: LVPSA_Init */ +/* */ +/* DESCRIPTION: */ +/* Initializes the LVPSA module. */ +/* */ +/* */ +/* PARAMETERS: */ +/* phInstance Pointer to the instance Handle */ +/* pInitParams Pointer to the instance init parameters */ +/* pControlParams Pointer to the instance control parameters */ +/* pMemoryTable Pointer to the memory definition table */ +/* */ +/* */ +/* RETURNS: */ +/* LVPSA_OK Succeeds */ +/* otherwise Error due to bad parameters */ +/* */ +/*********************************************************************************************************************************/ +LVPSA_RETURN LVPSA_Init ( pLVPSA_Handle_t *phInstance, + LVPSA_InitParams_t *pInitParams, + LVPSA_ControlParams_t *pControlParams, + LVPSA_MemTab_t *pMemoryTable ); + +/*********************************************************************************************************************************/ +/* */ +/* FUNCTION: LVPSA_Control */ +/* */ +/* DESCRIPTION: */ +/* Controls the LVPSA module. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance Handle */ +/* pNewParams Pointer to the instance new control parameters */ +/* */ +/* RETURNS: */ +/* LVPSA_OK Succeeds */ +/* otherwise Error due to bad parameters */ +/* */ +/*********************************************************************************************************************************/ +LVPSA_RETURN LVPSA_Control ( pLVPSA_Handle_t hInstance, + LVPSA_ControlParams_t *pNewParams ); + +/*********************************************************************************************************************************/ +/* */ +/* FUNCTION: LVPSA_Process */ +/* */ +/* DESCRIPTION: */ +/* The process calculates the levels of the frequency bands. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance Handle */ +/* pLVPSA_InputSamples Pointer to the input samples buffer */ +/* InputBlockSize Number of mono samples to process */ +/* AudioTime Playback time of the first input sample */ +/* */ +/* */ +/* RETURNS: */ +/* LVPSA_OK Succeeds */ +/* otherwise Error due to bad parameters */ +/* */ +/*********************************************************************************************************************************/ +LVPSA_RETURN LVPSA_Process ( pLVPSA_Handle_t hInstance, + LVM_INT16 *pLVPSA_InputSamples, + LVM_UINT16 InputBlockSize, + LVPSA_Time AudioTime ); + +/*********************************************************************************************************************************/ +/* */ +/* FUNCTION: LVPSA_GetSpectrum */ +/* */ +/* DESCRIPTION: */ +/* This function is used for memory allocation and free. */ +/* */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance Handle */ +/* GetSpectrumAudioTime Time to retrieve the values at */ +/* pCurrentValues Pointer to an empty buffer : Current level values output */ +/* pPeakValues Pointer to an empty buffer : Peak level values output */ +/* */ +/* */ +/* RETURNS: */ +/* LVPSA_OK Succeeds */ +/* otherwise Error due to bad parameters */ +/* */ +/*********************************************************************************************************************************/ +LVPSA_RETURN LVPSA_GetSpectrum ( pLVPSA_Handle_t hInstance, + LVPSA_Time GetSpectrumAudioTime, + LVM_UINT8 *pCurrentValues, + LVM_UINT8 *pPeakValues ); + +/*********************************************************************************************************************************/ +/* */ +/* FUNCTION: LVPSA_GetControlParams */ +/* */ +/* DESCRIPTION: */ +/* Get the current control parameters of the LVPSA module. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance Handle */ +/* pParams Pointer to an empty control parameters structure */ +/* RETURNS: */ +/* LVPSA_OK Succeeds */ +/* otherwise Error due to bad parameters */ +/* */ +/*********************************************************************************************************************************/ +LVPSA_RETURN LVPSA_GetControlParams ( pLVPSA_Handle_t hInstance, + LVPSA_ControlParams_t *pParams ); + +/*********************************************************************************************************************************/ +/* */ +/* FUNCTION: LVPSA_GetInitParams */ +/* */ +/* DESCRIPTION: */ +/* Get the initialization parameters of the LVPSA module. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance Handle */ +/* pParams Pointer to an empty init parameters structure */ +/* RETURNS: */ +/* LVPSA_OK Succeeds */ +/* otherwise Error due to bad parameters */ +/* */ +/*********************************************************************************************************************************/ +LVPSA_RETURN LVPSA_GetInitParams ( pLVPSA_Handle_t hInstance, + LVPSA_InitParams_t *pParams ); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _LVPSA_H */ diff --git a/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Control.c b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Control.c new file mode 100755 index 0000000..1be8ff0 --- /dev/null +++ b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Control.c @@ -0,0 +1,715 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: PSA_01_ARMC_01 */ +/* $Author: beq07716 $*/ +/* $Revision: 1006 $*/ +/* $Date: 2010-06-28 14:01:47 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ +#include "LVPSA.h" +#include "LVPSA_Private.h" +#include "VectorArithmetic.h" + +#define LOW_FREQ 298 /* 32768/110 for low test frequency */ +#define HIGH_FREQ 386 /* 32768/85 for high test frequency */ + +LVPSA_RETURN LVPSA_SetBPFiltersType ( LVPSA_InstancePr_t *pInst, + LVPSA_ControlParams_t *pParams ); + +LVPSA_RETURN LVPSA_SetQPFCoefficients( LVPSA_InstancePr_t *pInst, + LVPSA_ControlParams_t *pParams ); + +LVPSA_RETURN LVPSA_BPSinglePrecCoefs( LVM_UINT16 Fs, + LVPSA_FilterParam_t *pFilterParams, + BP_C16_Coefs_t *pCoefficients); + +LVPSA_RETURN LVPSA_BPDoublePrecCoefs( LVM_UINT16 Fs, + LVPSA_FilterParam_t *pFilterParams, + BP_C32_Coefs_t *pCoefficients); + +LVPSA_RETURN LVPSA_BPDoublePrecCoefs( LVM_UINT16 Fs, + LVPSA_FilterParam_t *pFilterParams, + BP_C32_Coefs_t *pCoefficients); + +LVPSA_RETURN LVPSA_SetBPFCoefficients( LVPSA_InstancePr_t *pInst, + LVPSA_ControlParams_t *pParams ); + +LVPSA_RETURN LVPSA_ClearFilterHistory( LVPSA_InstancePr_t *pInst); + + + + +/************************************************************************************/ +/* */ +/* FUNCTION: LVPSA_Control */ +/* */ +/* DESCRIPTION: */ +/* Give some new control parameters to the module. */ +/* */ +/* PARAMETERS: */ +/* hInstance Pointer to the instance */ +/* NewParams Structure that contains the new parameters */ +/* */ +/* RETURNS: */ +/* LVPSA_OK Succeeds */ +/* otherwise Error due to bad parameters */ +/* */ +/************************************************************************************/ +LVPSA_RETURN LVPSA_Control ( pLVPSA_Handle_t hInstance, + LVPSA_ControlParams_t *pNewParams ) +{ + + LVPSA_InstancePr_t *pLVPSA_Inst = (LVPSA_InstancePr_t*)hInstance; + + if((hInstance == LVM_NULL) || (pNewParams == LVM_NULL)) + { + return(LVPSA_ERROR_NULLADDRESS); + } + if(pNewParams->Fs >= LVPSA_NR_SUPPORTED_RATE) + { + return(LVPSA_ERROR_INVALIDPARAM); + } + if(pNewParams->LevelDetectionSpeed >= LVPSA_NR_SUPPORTED_SPEED) + { + return(LVPSA_ERROR_INVALIDPARAM); + } + + pLVPSA_Inst->NewParams = *pNewParams; + pLVPSA_Inst->bControlPending = LVM_TRUE; + + return(LVPSA_OK); +} + +/************************************************************************************/ +/* */ +/* FUNCTION: LVPSA_GetControlParams */ +/* */ +/* DESCRIPTION: */ +/* Get the current control parameters of the module */ +/* */ +/* PARAMETERS: */ +/* hInstance Pointer to the instance */ +/* pParams Pointer to an empty control structure */ +/* RETURNS: */ +/* LVPSA_OK Succeeds */ +/* otherwise Error due to bad parameters */ +/* */ +/************************************************************************************/ +LVPSA_RETURN LVPSA_GetControlParams ( pLVPSA_Handle_t hInstance, + LVPSA_ControlParams_t *pParams ) +{ + LVPSA_InstancePr_t *pLVPSA_Inst = (LVPSA_InstancePr_t*)hInstance; + + if((hInstance == LVM_NULL) || (pParams == LVM_NULL)) + { + return(LVPSA_ERROR_NULLADDRESS); + } + + pParams->Fs = pLVPSA_Inst->CurrentParams.Fs; + pParams->LevelDetectionSpeed = pLVPSA_Inst->CurrentParams.LevelDetectionSpeed; + + return(LVPSA_OK); +} + + +/************************************************************************************/ +/* */ +/* FUNCTION: LVPSA_GetInitParams */ +/* */ +/* DESCRIPTION: */ +/* Get the initialization parameters of the module */ +/* */ +/* PARAMETERS: */ +/* hInstance Pointer to the instance */ +/* pParams Pointer to an empty control structure */ +/* RETURNS: */ +/* LVPSA_OK Succeeds */ +/* otherwise Error due to bad parameters */ +/* */ +/************************************************************************************/ +LVPSA_RETURN LVPSA_GetInitParams ( pLVPSA_Handle_t hInstance, + LVPSA_InitParams_t *pParams ) +{ + LVPSA_InstancePr_t *pLVPSA_Inst = (LVPSA_InstancePr_t*)hInstance; + + if((hInstance == LVM_NULL) || (pParams == LVM_NULL)) + { + return(LVPSA_ERROR_NULLADDRESS); + } + + pParams->SpectralDataBufferDuration = pLVPSA_Inst->SpectralDataBufferDuration; + pParams->MaxInputBlockSize = pLVPSA_Inst->MaxInputBlockSize; + pParams->nBands = pLVPSA_Inst->nBands; + pParams->pFiltersParams = pLVPSA_Inst->pFiltersParams; + + return(LVPSA_OK); +} + + +/************************************************************************************/ +/* */ +/* FUNCTION: LVPSA_ApplyNewSettings */ +/* */ +/* DESCRIPTION: */ +/* Reinitialize some parameters and changes filters' coefficients if */ +/* some control parameters have changed. */ +/* */ +/* PARAMETERS: */ +/* pInst Pointer to the instance */ +/* */ +/* RETURNS: */ +/* LVPSA_OK Succeeds */ +/* otherwise Error due to bad parameters */ +/* */ +/* NOTES: */ +/* */ +/************************************************************************************/ +LVPSA_RETURN LVPSA_ApplyNewSettings (LVPSA_InstancePr_t *pInst) +{ + LVM_UINT16 ii; + LVM_UINT16 Freq; + LVPSA_ControlParams_t Params; + extern LVM_INT16 LVPSA_nSamplesBufferUpdate[]; + extern LVM_UINT16 LVPSA_SampleRateTab[]; + extern LVM_UINT16 LVPSA_DownSamplingFactor[]; + + + if(pInst == 0) + { + return(LVPSA_ERROR_NULLADDRESS); + } + + Params = pInst->NewParams; + + /* Modifies filters types and coefficients, clear the taps and + re-initializes parameters if sample frequency has changed */ + if(Params.Fs != pInst->CurrentParams.Fs) + { + pInst->CurrentParams.Fs = Params.Fs; + + /* Initialize the center freqeuncies as a function of the sample rate */ + Freq = (LVM_UINT16) ((LVPSA_SampleRateTab[pInst->CurrentParams.Fs]>>1) / (pInst->nBands + 1)); + for(ii = pInst->nBands; ii > 0; ii--) + { + pInst->pFiltersParams[ii-1].CenterFrequency = (LVM_UINT16) (Freq * ii); + } + + /* Count the number of relevant filters. If the center frequency of the filter is + bigger than the nyquist frequency, then the filter is not relevant and doesn't + need to be used */ + for(ii = pInst->nBands; ii > 0; ii--) + { + if(pInst->pFiltersParams[ii-1].CenterFrequency < (LVPSA_SampleRateTab[pInst->CurrentParams.Fs]>>1)) + { + pInst->nRelevantFilters = ii; + break; + } + } + LVPSA_SetBPFiltersType(pInst, &Params); + LVPSA_SetBPFCoefficients(pInst, &Params); + LVPSA_SetQPFCoefficients(pInst, &Params); + LVPSA_ClearFilterHistory(pInst); + pInst->nSamplesBufferUpdate = (LVM_UINT16)LVPSA_nSamplesBufferUpdate[Params.Fs]; + pInst->BufferUpdateSamplesCount = 0; + pInst->DownSamplingFactor = LVPSA_DownSamplingFactor[Params.Fs]; + pInst->DownSamplingCount = 0; + for(ii = 0; ii < (pInst->nBands * pInst->SpectralDataBufferLength); ii++) + { + pInst->pSpectralDataBufferStart[ii] = 0; + } + for(ii = 0; ii < pInst->nBands; ii++) + { + pInst->pPreviousPeaks[ii] = 0; + } + } + else + { + if(Params.LevelDetectionSpeed != pInst->CurrentParams.LevelDetectionSpeed) + { + LVPSA_SetQPFCoefficients(pInst, &Params); + } + } + + pInst->CurrentParams = pInst->NewParams; + + return (LVPSA_OK); +} +/************************************************************************************/ +/* */ +/* FUNCTION: LVPSA_SetBPFiltersType */ +/* */ +/* DESCRIPTION: */ +/* Sets the filter type based on the BPFilterType. */ +/* */ +/* PARAMETERS: */ +/* pInst Pointer to the instance */ +/* pParams Poniter to conrol parameters */ +/* */ +/* RETURNS: */ +/* LVPSA_OK Always succeeds */ +/* */ +/* NOTES: */ +/* 1. To select the biquad type the follow rules are applied: */ +/* Double precision if (fc <= fs/110) */ +/* Double precision if (fs/110 < fc < fs/85) & (Q>3) */ +/* Single precision otherwise */ +/* */ +/************************************************************************************/ +LVPSA_RETURN LVPSA_SetBPFiltersType ( LVPSA_InstancePr_t *pInst, + LVPSA_ControlParams_t *pParams ) +{ + + extern LVM_UINT16 LVPSA_SampleRateTab[]; /* Sample rate table */ + LVM_UINT16 ii; /* Filter band index */ + LVM_UINT32 fs = (LVM_UINT32)LVPSA_SampleRateTab[(LVM_UINT16)pParams->Fs]; /* Sample rate */ + LVM_UINT32 fc; /* Filter centre frequency */ + LVM_INT16 QFactor; /* Filter Q factor */ + + for (ii = 0; ii < pInst->nRelevantFilters; ii++) + { + /* + * Get the filter settings + */ + fc = (LVM_UINT32)pInst->pFiltersParams[ii].CenterFrequency; /* Get the band centre frequency */ + QFactor =(LVM_INT16) pInst->pFiltersParams[ii].QFactor; /* Get the band Q factor */ + + + /* + * For each filter set the type of biquad required + */ + pInst->pBPFiltersPrecision[ii] = LVPSA_SimplePrecisionFilter; /* Default to single precision */ + if ((LOW_FREQ * fs) >= (fc << 15)) + { + /* + * fc <= fs/110 + */ + pInst->pBPFiltersPrecision[ii] = LVPSA_DoublePrecisionFilter; + } + else + { + if (((LOW_FREQ * fs) < (fc << 15)) && ((fc << 15) < (HIGH_FREQ * fs)) && (QFactor > 300)) + { + /* + * (fs/110 < fc < fs/85) & (Q>3) + */ + pInst->pBPFiltersPrecision[ii] = LVPSA_DoublePrecisionFilter; + } + } + } + + return(LVPSA_OK); +} + +/************************************************************************************/ +/* */ +/* FUNCTION: LVPSA_SetBPFCoefficients */ +/* */ +/* DESCRIPTION: */ +/* Sets the band pass filter coefficients. This uses the type to select */ +/* single or double precision coefficients. */ +/* */ +/* PARAMETERS: */ +/* pInst Pointer to the instance */ +/* Params Initialisation parameters */ +/* */ +/* RETURNS: */ +/* LVPSA_OK Always succeeds */ +/* */ +/* NOTES: */ +/* */ +/************************************************************************************/ +LVPSA_RETURN LVPSA_SetBPFCoefficients( LVPSA_InstancePr_t *pInst, + LVPSA_ControlParams_t *pParams) +{ + + LVM_UINT16 ii; + + /* + * Set the coefficients for each band by the init function + */ + for (ii = 0; ii < pInst->nRelevantFilters; ii++) + { + switch (pInst->pBPFiltersPrecision[ii]) + { + case LVPSA_DoublePrecisionFilter: + { + BP_C32_Coefs_t Coefficients; + + /* + * Calculate the double precision coefficients + */ + LVPSA_BPDoublePrecCoefs((LVM_UINT16)pParams->Fs, + &pInst->pFiltersParams[ii], + &Coefficients); + + /* + * Set the coefficients + */ + BP_1I_D16F32Cll_TRC_WRA_01_Init ( &pInst->pBP_Instances[ii], + &pInst->pBP_Taps[ii], + &Coefficients); + break; + } + + case LVPSA_SimplePrecisionFilter: + { + BP_C16_Coefs_t Coefficients; + + /* + * Calculate the single precision coefficients + */ + LVPSA_BPSinglePrecCoefs((LVM_UINT16)pParams->Fs, + &pInst->pFiltersParams[ii], + &Coefficients); + + /* + * Set the coefficients + */ + BP_1I_D16F16Css_TRC_WRA_01_Init ( &pInst->pBP_Instances[ii], + &pInst->pBP_Taps[ii], + &Coefficients); + break; + } + } + } + + return(LVPSA_OK); +} + + +/************************************************************************************/ +/* */ +/* FUNCTION: LVPSA_SetQPFCoefficients */ +/* */ +/* DESCRIPTION: */ +/* Sets the quasi peak filters coefficients. This uses the chosen */ +/* LevelDetectionSpeed from the control parameters. */ +/* */ +/* PARAMETERS: */ +/* pInst Pointer to the instance */ +/* Params Control parameters */ +/* */ +/* RETURNS: */ +/* LVPSA_OK Always succeeds */ +/* */ +/* NOTES: */ +/* */ +/************************************************************************************/ +LVPSA_RETURN LVPSA_SetQPFCoefficients( LVPSA_InstancePr_t *pInst, + LVPSA_ControlParams_t *pParams ) +{ + LVM_UINT16 ii; + LVM_Fs_en Fs = pParams->Fs; + QPD_C32_Coefs *pCoefficients; + extern QPD_C32_Coefs LVPSA_QPD_Coefs[]; + + + pCoefficients = &LVPSA_QPD_Coefs[(pParams->LevelDetectionSpeed * LVPSA_NR_SUPPORTED_RATE) + Fs]; + + + for (ii = 0; ii < pInst->nRelevantFilters; ii++) + { + LVPSA_QPD_Init (&pInst->pQPD_States[ii], + &pInst->pQPD_Taps[ii], + pCoefficients ); + } + + return(LVPSA_OK); + +} + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVPSA_BPSinglePrecCoefs */ +/* */ +/* DESCRIPTION: */ +/* Calculate single precision coefficients for a band pass filter */ +/* */ +/* PARAMETERS: */ +/* Fs Sampling frequency index */ +/* pFilterParams Pointer to the filter definition */ +/* pCoefficients Pointer to the coefficients */ +/* */ +/* RETURNS: */ +/* LVPSA_OK Always succeeds */ +/* */ +/* NOTES: */ +/* 1. The equations used are as follows: */ +/* */ +/* t0 = 2 * Pi * Fc / Fs */ +/* */ +/* b2 = -0.5 * (2Q - t0) / (2Q + t0) */ +/* b1 = (0.5 - b2) * cos(t0) */ +/* a0 = (0.5 + b2) / 2 */ +/* */ +/* Where: */ +/* Fc is the centre frequency, DC to Nyquist */ +/* Fs is the sample frequency, 8000 to 48000 in descrete steps */ +/* Q is the Q factor, 0.25 to 12 */ +/* */ +/* 2. This function is entirely based on the LVEQNB_SinglePrecCoefs function */ +/* of the n bands equalizer (LVEQNB */ +/* */ +/****************************************************************************************/ +LVPSA_RETURN LVPSA_BPSinglePrecCoefs( LVM_UINT16 Fs, + LVPSA_FilterParam_t *pFilterParams, + BP_C16_Coefs_t *pCoefficients) +{ + + extern LVM_INT16 LVPSA_TwoPiOnFsTable[]; + extern LVM_INT16 LVPSA_CosCoef[]; + + + /* + * Intermediate variables and temporary values + */ + LVM_INT32 T0; + LVM_INT16 D; + LVM_INT32 A0; + LVM_INT32 B1; + LVM_INT32 B2; + LVM_INT32 Dt0; + LVM_INT32 B2_Den; + LVM_INT32 B2_Num; + LVM_INT32 COS_T0; + LVM_INT16 coef; + LVM_INT32 factor; + LVM_INT16 t0; + LVM_INT16 i; + + + /* + * Get the filter definition + */ + LVM_UINT16 Frequency = pFilterParams->CenterFrequency; + LVM_UINT16 QFactor = pFilterParams->QFactor; + + + /* + * Calculating the intermediate values + */ + T0 = (LVM_INT32)Frequency * LVPSA_TwoPiOnFsTable[Fs]; /* T0 = 2 * Pi * Fc / Fs */ + D = 3200; /* Floating point value 1.000000 (1*100*2^5) */ + /* Force D = 1 : the function was originally used for a peaking filter. + The D parameter do not exist for a BandPass filter coefficients */ + + /* + * Calculate the B2 coefficient + */ + Dt0 = D * (T0 >> 10); + B2_Den = (LVM_INT32)(((LVM_UINT32)QFactor << 19) + (LVM_UINT32)(Dt0 >> 2)); + B2_Num = (LVM_INT32)((LVM_UINT32)(Dt0 >> 3) - ((LVM_UINT32)QFactor << 18)); + B2 = (B2_Num / (B2_Den >> 16)) << 15; + + /* + * Calculate the cosine by a polynomial expansion using the equation: + * + * Cos += coef(n) * t0^n For n = 0 to 6 + */ + T0 = (T0 >> 10) * 20859; /* Scale to 1.0 in 16-bit for range 0 to fs/2 */ + t0 = (LVM_INT16)(T0 >> 16); + factor = 0x7fff; /* Initialise to 1.0 for the a0 coefficient */ + COS_T0 = 0; /* Initialise the error to zero */ + for (i=1; i<7; i++) + { + coef = LVPSA_CosCoef[i]; /* Get the nth coefficient */ + COS_T0 += (factor * coef) >> 5; /* The nth partial sum */ + factor = (factor * t0) >> 15; /* Calculate t0^n */ + } + COS_T0 = COS_T0 << (LVPSA_CosCoef[0]+6); /* Correct the scaling */ + + + B1 = ((0x40000000 - B2) >> 16) * (COS_T0 >> 16); /* B1 = (0.5 - b2) * cos(t0) */ + A0 = (0x40000000 + B2) >> 1; /* A0 = (0.5 + b2) / 2 */ + + /* + * Write coeff into the data structure + */ + pCoefficients->A0 = (LVM_INT16)(A0>>16); + pCoefficients->B1 = (LVM_INT16)(B1>>15); + pCoefficients->B2 = (LVM_INT16)(B2>>16); + + + return(LVPSA_OK); +} + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVPSA_BPDoublePrecCoefs */ +/* */ +/* DESCRIPTION: */ +/* Calculate double precision coefficients for a band pass filter */ +/* */ +/* PARAMETERS: */ +/* Fs Sampling frequency index */ +/* pFilterParams Pointer to the filter definition */ +/* pCoefficients Pointer to the coefficients */ +/* */ +/* RETURNS: */ +/* LVPSA_OK Always succeeds */ +/* */ +/* NOTES: */ +/* 1. The equations used are as follows: */ +/* */ +/* t0 = 2 * Pi * Fc / Fs */ +/* */ +/* b2 = -0.5 * (2Q - t0) / (2Q + t0) */ +/* b1 = (0.5 - b2) * (1 - coserr(t0)) */ +/* a0 = (0.5 + b2) / 2 */ +/* */ +/* Where: */ +/* Fc is the centre frequency, DC to Fs/50 */ +/* Fs is the sample frequency, 8000 to 48000 in descrete steps */ +/* Q is the Q factor, 0.25 to 12 (represented by 25 to 1200) */ +/* */ +/* 2. The double precision coefficients are only used when fc is less than fs/85, so */ +/* the cosine of t0 is always close to 1.0. Instead of calculating the cosine */ +/* itself the difference from the value 1.0 is calculated, this can be done with */ +/* lower precision maths. */ +/* */ +/* 3. The value of the B2 coefficient is only calculated as a single precision value, */ +/* small errors in this value have a combined effect on the Q and Gain but not the */ +/* the frequency of the filter. */ +/* */ +/* 4. This function is entirely based on the LVEQNB_DoublePrecCoefs function */ +/* of the n bands equalizer (LVEQNB */ +/* */ +/****************************************************************************************/ +LVPSA_RETURN LVPSA_BPDoublePrecCoefs( LVM_UINT16 Fs, + LVPSA_FilterParam_t *pFilterParams, + BP_C32_Coefs_t *pCoefficients) +{ + + extern LVM_INT16 LVPSA_TwoPiOnFsTable[]; + extern LVM_INT16 LVPSA_DPCosCoef[]; + + /* + * Intermediate variables and temporary values + */ + LVM_INT32 T0; + LVM_INT16 D; + LVM_INT32 A0; + LVM_INT32 B1; + LVM_INT32 B2; + LVM_INT32 Dt0; + LVM_INT32 B2_Den; + LVM_INT32 B2_Num; + LVM_INT32 CosErr; + LVM_INT16 coef; + LVM_INT32 factor; + LVM_INT16 t0; + LVM_INT16 i; + + /* + * Get the filter definition + */ + LVM_UINT16 Frequency = pFilterParams->CenterFrequency; + LVM_UINT16 QFactor = pFilterParams->QFactor; + + + /* + * Calculating the intermediate values + */ + T0 = (LVM_INT32)Frequency * LVPSA_TwoPiOnFsTable[Fs]; /* T0 = 2 * Pi * Fc / Fs */ + D = 3200; /* Floating point value 1.000000 (1*100*2^5) */ + /* Force D = 1 : the function was originally used for a peaking filter. + The D parameter do not exist for a BandPass filter coefficients */ + + /* + * Calculate the B2 coefficient + */ + Dt0 = D * (T0 >> 10); + B2_Den = (LVM_INT32)(((LVM_UINT32)QFactor << 19) + (LVM_UINT32)(Dt0 >> 2)); + B2_Num = (LVM_INT32)((LVM_UINT32)(Dt0 >> 3) - ((LVM_UINT32)QFactor << 18)); + B2 = (B2_Num / (B2_Den >> 16)) << 15; + + /* + * Calculate the cosine error by a polynomial expansion using the equation: + * + * CosErr += coef(n) * t0^n For n = 0 to 4 + */ + T0 = (T0 >> 6) * 0x7f53; /* Scale to 1.0 in 16-bit for range 0 to fs/50 */ + t0 = (LVM_INT16)(T0 >> 16); + factor = 0x7fff; /* Initialise to 1.0 for the a0 coefficient */ + CosErr = 0; /* Initialise the error to zero */ + for (i=1; i<5; i++) + { + coef = LVPSA_DPCosCoef[i]; /* Get the nth coefficient */ + CosErr += (factor * coef) >> 5; /* The nth partial sum */ + factor = (factor * t0) >> 15; /* Calculate t0^n */ + } + CosErr = CosErr << (LVPSA_DPCosCoef[0]); /* Correct the scaling */ + + /* + * Calculate the B1 and A0 coefficients + */ + B1 = (0x40000000 - B2); /* B1 = (0.5 - b2) */ + A0 = ((B1 >> 16) * (CosErr >> 10)) >> 6; /* Temporary storage for (0.5 - b2) * coserr(t0) */ + B1 -= A0; /* B1 = (0.5 - b2) * (1 - coserr(t0)) */ + A0 = (0x40000000 + B2) >> 1; /* A0 = (0.5 + b2) / 2 */ + + /* + * Write coeff into the data structure + */ + pCoefficients->A0 = A0; + pCoefficients->B1 = B1; + pCoefficients->B2 = B2; + + return(LVPSA_OK); +} + +/************************************************************************************/ +/* */ +/* FUNCTION: LVPSA_ClearFilterHistory */ +/* */ +/* DESCRIPTION: */ +/* Clears the filters' data history */ +/* */ +/* PARAMETERS: */ +/* pInst Pointer to the instance */ +/* */ +/* RETURNS: */ +/* LVPSA_OK Always succeeds */ +/* */ +/* NOTES: */ +/* */ +/************************************************************************************/ +LVPSA_RETURN LVPSA_ClearFilterHistory(LVPSA_InstancePr_t *pInst) +{ + LVM_INT8 *pTapAddress; + LVM_UINT32 i; + + /* Band Pass filters taps */ + pTapAddress = (LVM_INT8 *)pInst->pBP_Taps; + for(i = 0; i < pInst->nBands * sizeof(Biquad_1I_Order2_Taps_t); i++) + { + pTapAddress[i] = 0; + } + + /* Quasi-peak filters taps */ + pTapAddress = (LVM_INT8 *)pInst->pQPD_Taps; + for(i = 0; i < pInst->nBands * sizeof(QPD_Taps_t); i++) + { + pTapAddress[i] = 0; + } + + return(LVPSA_OK); +} + diff --git a/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Init.c b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Init.c new file mode 100755 index 0000000..ab45678 --- /dev/null +++ b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Init.c @@ -0,0 +1,197 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: PSA_01_ARMC_01 */ +/* $Author: beq07716 $*/ +/* $Revision: 1006 $*/ +/* $Date: 2010-06-28 14:01:47 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ +#include "LVPSA.h" +#include "LVPSA_Private.h" +#include "InstAlloc.h" + +/************************************************************************************/ +/* */ +/* FUNCTION: LVPSA_Init */ +/* */ +/* DESCRIPTION: */ +/* Initialize the LVPSA module */ +/* */ +/* */ +/* PARAMETERS: */ +/* phInstance Pointer to pointer to the instance */ +/* InitParams Init parameters structure */ +/* ControlParams Control parameters structure */ +/* pMemoryTable Memory table that contains memory areas definition */ +/* */ +/* */ +/* RETURNS: */ +/* LVPSA_OK Succeeds */ +/* otherwise Error due to bad parameters */ +/* */ +/************************************************************************************/ +LVPSA_RETURN LVPSA_Init ( pLVPSA_Handle_t *phInstance, + LVPSA_InitParams_t *pInitParams, + LVPSA_ControlParams_t *pControlParams, + LVPSA_MemTab_t *pMemoryTable ) +{ + LVPSA_InstancePr_t *pLVPSA_Inst; + LVPSA_RETURN errorCode = LVPSA_OK; + LVM_UINT32 ii; + extern LVM_INT16 LVPSA_GainTable[]; + LVM_UINT32 BufferLength = 0; + + /* Ints_Alloc instances, needed for memory alignment management */ + INST_ALLOC Instance; + INST_ALLOC Scratch; + INST_ALLOC Data; + INST_ALLOC Coef; + + /* Check parameters */ + if((phInstance == LVM_NULL) || (pInitParams == LVM_NULL) || (pControlParams == LVM_NULL) || (pMemoryTable == LVM_NULL)) + { + return(LVPSA_ERROR_NULLADDRESS); + } + if( (pInitParams->SpectralDataBufferDuration > LVPSA_MAXBUFFERDURATION) || + (pInitParams->SpectralDataBufferDuration == 0) || + (pInitParams->MaxInputBlockSize > LVPSA_MAXINPUTBLOCKSIZE) || + (pInitParams->MaxInputBlockSize == 0) || + (pInitParams->nBands < LVPSA_NBANDSMIN) || + (pInitParams->nBands > LVPSA_NBANDSMAX) || + (pInitParams->pFiltersParams == 0)) + { + return(LVPSA_ERROR_INVALIDPARAM); + } + for(ii = 0; ii < pInitParams->nBands; ii++) + { + if((pInitParams->pFiltersParams[ii].CenterFrequency > LVPSA_MAXCENTERFREQ) || + (pInitParams->pFiltersParams[ii].PostGain > LVPSA_MAXPOSTGAIN) || + (pInitParams->pFiltersParams[ii].PostGain < LVPSA_MINPOSTGAIN) || + (pInitParams->pFiltersParams[ii].QFactor < LVPSA_MINQFACTOR) || + (pInitParams->pFiltersParams[ii].QFactor > LVPSA_MAXQFACTOR)) + { + return(LVPSA_ERROR_INVALIDPARAM); + } + } + + + /*Inst_Alloc instances initialization */ + InstAlloc_Init( &Instance , pMemoryTable->Region[LVPSA_MEMREGION_INSTANCE].pBaseAddress); + InstAlloc_Init( &Scratch , pMemoryTable->Region[LVPSA_MEMREGION_SCRATCH].pBaseAddress); + InstAlloc_Init( &Data , pMemoryTable->Region[LVPSA_MEMREGION_PERSISTENT_DATA].pBaseAddress); + InstAlloc_Init( &Coef , pMemoryTable->Region[LVPSA_MEMREGION_PERSISTENT_COEF].pBaseAddress); + + + /* Set the instance handle if not already initialised */ + if (*phInstance == LVM_NULL) + { + *phInstance = InstAlloc_AddMember( &Instance, sizeof(LVPSA_InstancePr_t) ); + } + pLVPSA_Inst =(LVPSA_InstancePr_t*)*phInstance; + + + /* Check the memory table for NULL pointers */ + for (ii = 0; ii < LVPSA_NR_MEMORY_REGIONS; ii++) + { + if (pMemoryTable->Region[ii].Size!=0) + { + if (pMemoryTable->Region[ii].pBaseAddress==LVM_NULL) + { + return(LVPSA_ERROR_NULLADDRESS); + } + pLVPSA_Inst->MemoryTable.Region[ii] = pMemoryTable->Region[ii]; + } + } + + /* Initialize module's internal parameters */ + pLVPSA_Inst->bControlPending = LVM_FALSE; + pLVPSA_Inst->nBands = pInitParams->nBands; + pLVPSA_Inst->MaxInputBlockSize = pInitParams->MaxInputBlockSize; + pLVPSA_Inst->SpectralDataBufferDuration = pInitParams->SpectralDataBufferDuration; + pLVPSA_Inst->CurrentParams.Fs = LVM_FS_DUMMY; + pLVPSA_Inst->CurrentParams.LevelDetectionSpeed = LVPSA_SPEED_DUMMY; + + { /* for avoiding QAC warnings */ + LVM_INT32 SDBD=(LVM_INT32)pLVPSA_Inst->SpectralDataBufferDuration; + LVM_INT32 IRTI=(LVM_INT32)LVPSA_InternalRefreshTimeInv; + LVM_INT32 BL; + + MUL32x32INTO32(SDBD,IRTI,BL,LVPSA_InternalRefreshTimeShift) + + BufferLength=(LVM_UINT32)BL; + } + + if((BufferLength * LVPSA_InternalRefreshTime) != pLVPSA_Inst->SpectralDataBufferDuration) + { + pLVPSA_Inst->SpectralDataBufferLength = BufferLength + 1; + } + else + { + pLVPSA_Inst->SpectralDataBufferLength = BufferLength; + } + + + /* Assign the pointers */ + + pLVPSA_Inst->pPostGains = InstAlloc_AddMember( &Instance, pInitParams->nBands * sizeof(LVM_UINT16) ); + pLVPSA_Inst->pFiltersParams = InstAlloc_AddMember( &Instance, pInitParams->nBands * sizeof(LVPSA_FilterParam_t) ); + pLVPSA_Inst->pSpectralDataBufferStart = InstAlloc_AddMember( &Instance, pInitParams->nBands * pLVPSA_Inst->SpectralDataBufferLength * sizeof(LVM_UINT8) ); + pLVPSA_Inst->pPreviousPeaks = InstAlloc_AddMember( &Instance, pInitParams->nBands * sizeof(LVM_UINT8) ); + pLVPSA_Inst->pBPFiltersPrecision = InstAlloc_AddMember( &Instance, pInitParams->nBands * sizeof(LVPSA_BPFilterPrecision_en) ); + + pLVPSA_Inst->pBP_Instances = InstAlloc_AddMember( &Coef, pInitParams->nBands * sizeof(Biquad_Instance_t) ); + pLVPSA_Inst->pQPD_States = InstAlloc_AddMember( &Coef, pInitParams->nBands * sizeof(QPD_State_t) ); + + pLVPSA_Inst->pBP_Taps = InstAlloc_AddMember( &Data, pInitParams->nBands * sizeof(Biquad_1I_Order2_Taps_t) ); + pLVPSA_Inst->pQPD_Taps = InstAlloc_AddMember( &Data, pInitParams->nBands * sizeof(QPD_Taps_t) ); + + + /* Copy filters parameters in the private instance */ + for(ii = 0; ii < pLVPSA_Inst->nBands; ii++) + { + pLVPSA_Inst->pFiltersParams[ii] = pInitParams->pFiltersParams[ii]; + } + + /* Set Post filters gains*/ + for(ii = 0; ii < pLVPSA_Inst->nBands; ii++) + { + pLVPSA_Inst->pPostGains[ii] =(LVM_UINT16) LVPSA_GainTable[pInitParams->pFiltersParams[ii].PostGain + 15]; + } + pLVPSA_Inst->pSpectralDataBufferWritePointer = pLVPSA_Inst->pSpectralDataBufferStart; + + + /* Initialize control dependant internal parameters */ + errorCode = LVPSA_Control (*phInstance, pControlParams); + + if(errorCode!=0) + { + return errorCode; + } + + errorCode = LVPSA_ApplyNewSettings (pLVPSA_Inst); + + if(errorCode!=0) + { + return errorCode; + } + + return(errorCode); +} + diff --git a/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Memory.c b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Memory.c new file mode 100755 index 0000000..059cb4e --- /dev/null +++ b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Memory.c @@ -0,0 +1,177 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: PSA_01_ARMC_01 */ +/* $Author: beq07716 $*/ +/* $Revision: 1006 $*/ +/* $Date: 2010-06-28 14:01:47 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ +#include "LVPSA.h" +#include "LVPSA_Private.h" +#include "InstAlloc.h" + +/****************************************************************************************/ +/* */ +/* FUNCTION: LVEQNB_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) the memory */ +/* base address pointers are NULL on return. */ +/* */ +/* When the function is called for free (hInstance = Instance Handle) the memory */ +/* table returns the allocated memory and base addresses used during initialisation. */ +/* */ +/* PARAMETERS: */ +/* hInstance Instance Handle */ +/* pMemoryTable Pointer to an empty memory definition table */ +/* InitParams Pointer to the instance init parameters */ +/* */ +/* RETURNS: */ +/* LVPSA_OK Succeeds */ +/* otherwise Error due to bad parameters */ +/* */ +/****************************************************************************************/ +LVPSA_RETURN LVPSA_Memory ( pLVPSA_Handle_t hInstance, + LVPSA_MemTab_t *pMemoryTable, + LVPSA_InitParams_t *pInitParams ) +{ + LVM_UINT32 ii; + LVM_UINT32 BufferLength; + INST_ALLOC Instance; + INST_ALLOC Scratch; + INST_ALLOC Data; + INST_ALLOC Coef; + LVPSA_InstancePr_t *pLVPSA_Inst = (LVPSA_InstancePr_t*)hInstance; + + + InstAlloc_Init( &Instance , LVM_NULL); + InstAlloc_Init( &Scratch , LVM_NULL); + InstAlloc_Init( &Data , LVM_NULL); + InstAlloc_Init( &Coef , LVM_NULL); + + + if((pMemoryTable == LVM_NULL) || (pInitParams == LVM_NULL)) + { + return(LVPSA_ERROR_NULLADDRESS); + } + + + /* + * Fill in the memory table + */ + if (hInstance == LVM_NULL) + { + + /* Check init parameter */ + if( (pInitParams->SpectralDataBufferDuration > LVPSA_MAXBUFFERDURATION) || + (pInitParams->SpectralDataBufferDuration == 0) || + (pInitParams->MaxInputBlockSize > LVPSA_MAXINPUTBLOCKSIZE) || + (pInitParams->MaxInputBlockSize == 0) || + (pInitParams->nBands < LVPSA_NBANDSMIN) || + (pInitParams->nBands > LVPSA_NBANDSMAX) || + (pInitParams->pFiltersParams == 0)) + { + return(LVPSA_ERROR_INVALIDPARAM); + } + for(ii = 0; ii < pInitParams->nBands; ii++) + { + if((pInitParams->pFiltersParams[ii].CenterFrequency > LVPSA_MAXCENTERFREQ) || + (pInitParams->pFiltersParams[ii].PostGain > LVPSA_MAXPOSTGAIN) || + (pInitParams->pFiltersParams[ii].PostGain < LVPSA_MINPOSTGAIN) || + (pInitParams->pFiltersParams[ii].QFactor < LVPSA_MINQFACTOR) || + (pInitParams->pFiltersParams[ii].QFactor > LVPSA_MAXQFACTOR)) + { + return(LVPSA_ERROR_INVALIDPARAM); + } + } + + /* + * Instance memory + */ + + InstAlloc_AddMember( &Instance, sizeof(LVPSA_InstancePr_t) ); + InstAlloc_AddMember( &Instance, pInitParams->nBands * sizeof(LVM_UINT16) ); + InstAlloc_AddMember( &Instance, pInitParams->nBands * sizeof(LVPSA_FilterParam_t) ); + + { + /* for avoiding QAC warnings as MUL32x32INTO32 works on LVM_INT32 only*/ + LVM_INT32 SDBD=(LVM_INT32)pInitParams->SpectralDataBufferDuration; + LVM_INT32 IRTI=(LVM_INT32)LVPSA_InternalRefreshTimeInv; + LVM_INT32 BL; + + MUL32x32INTO32(SDBD,IRTI,BL,LVPSA_InternalRefreshTimeShift) + BufferLength=(LVM_UINT32)BL; + } + + + if((BufferLength * LVPSA_InternalRefreshTime) != pInitParams->SpectralDataBufferDuration) + { + BufferLength++; + } + InstAlloc_AddMember( &Instance, pInitParams->nBands * BufferLength * sizeof(LVM_UINT8) ); + InstAlloc_AddMember( &Instance, pInitParams->nBands * sizeof(LVM_UINT8) ); + InstAlloc_AddMember( &Instance, pInitParams->nBands * sizeof(LVPSA_BPFilterPrecision_en) ); + pMemoryTable->Region[LVPSA_MEMREGION_INSTANCE].Size = InstAlloc_GetTotal(&Instance); + pMemoryTable->Region[LVPSA_MEMREGION_INSTANCE].Type = LVPSA_PERSISTENT; + pMemoryTable->Region[LVPSA_MEMREGION_INSTANCE].pBaseAddress = LVM_NULL; + + /* + * Scratch memory + */ + InstAlloc_AddMember( &Scratch, 2 * pInitParams->MaxInputBlockSize * sizeof(LVM_INT16) ); + pMemoryTable->Region[LVPSA_MEMREGION_SCRATCH].Size = InstAlloc_GetTotal(&Scratch); + pMemoryTable->Region[LVPSA_MEMREGION_SCRATCH].Type = LVPSA_SCRATCH; + pMemoryTable->Region[LVPSA_MEMREGION_SCRATCH].pBaseAddress = LVM_NULL; + + /* + * Persistent coefficients memory + */ + InstAlloc_AddMember( &Coef, pInitParams->nBands * sizeof(Biquad_Instance_t) ); + InstAlloc_AddMember( &Coef, pInitParams->nBands * sizeof(QPD_State_t) ); + pMemoryTable->Region[LVPSA_MEMREGION_PERSISTENT_COEF].Size = InstAlloc_GetTotal(&Coef); + pMemoryTable->Region[LVPSA_MEMREGION_PERSISTENT_COEF].Type = LVPSA_PERSISTENT_COEF; + pMemoryTable->Region[LVPSA_MEMREGION_PERSISTENT_COEF].pBaseAddress = LVM_NULL; + + /* + * Persistent data memory + */ + InstAlloc_AddMember( &Data, pInitParams->nBands * sizeof(Biquad_1I_Order2_Taps_t) ); + InstAlloc_AddMember( &Data, pInitParams->nBands * sizeof(QPD_Taps_t) ); + pMemoryTable->Region[LVPSA_MEMREGION_PERSISTENT_DATA].Size = InstAlloc_GetTotal(&Data); + pMemoryTable->Region[LVPSA_MEMREGION_PERSISTENT_DATA].Type = LVPSA_PERSISTENT_DATA; + pMemoryTable->Region[LVPSA_MEMREGION_PERSISTENT_DATA].pBaseAddress = LVM_NULL; + + } + else + { + /* Read back memory allocation table */ + *pMemoryTable = pLVPSA_Inst->MemoryTable; + } + + return(LVPSA_OK); +} + diff --git a/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Private.h b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Private.h new file mode 100755 index 0000000..eb9fa8f --- /dev/null +++ b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Private.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. + */ + +/************************************************************************/ +/* */ +/* Project:: PSA_01_ARMC_01 */ +/* $Author: beq07716 $*/ +/* $Revision: 1006 $*/ +/* $Date: 2010-06-28 14:01:47 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ +#ifndef _LVPSA_PRIVATE_H_ +#define _LVPSA_PRIVATE_H_ + +#include "LVPSA.h" +#include "BIQUAD.h" +#include "LVPSA_QPD.h" +#include "LVM_Macros.h" + + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/********************************************************************************** + CONSTANT DEFINITIONS +***********************************************************************************/ + +/* Memory */ +#define LVPSA_INSTANCE_ALIGN 4 /* 32-bit alignment for structures */ +#define LVPSA_SCRATCH_ALIGN 4 /* 32-bit alignment for long data */ +#define LVPSA_COEF_ALIGN 4 /* 32-bit alignment for long words */ +#define LVPSA_DATA_ALIGN 4 /* 32-bit alignment for long data */ + +#define LVPSA_MEMREGION_INSTANCE 0 /* Offset to instance memory region in memory table */ +#define LVPSA_MEMREGION_PERSISTENT_COEF 1 /* Offset to persistent coefficients memory region in memory table */ +#define LVPSA_MEMREGION_PERSISTENT_DATA 2 /* Offset to persistent taps memory region in memory table */ +#define LVPSA_MEMREGION_SCRATCH 3 /* Offset to scratch memory region in memory table */ + +#define LVPSA_NR_SUPPORTED_RATE 9 /* From 8000Hz to 48000Hz */ +#define LVPSA_NR_SUPPORTED_SPEED 3 /* LOW, MEDIUM, HIGH */ + +#define LVPSA_MAXBUFFERDURATION 4000 /* Maximum length in ms of the levels buffer */ +#define LVPSA_MAXINPUTBLOCKSIZE 5000 /* Maximum length in mono samples of the block to process */ +#define LVPSA_NBANDSMIN 1 /* Minimum number of frequency band */ +#define LVPSA_NBANDSMAX 30 /* Maximum number of frequency band */ +#define LVPSA_MAXCENTERFREQ 20000 /* Maximum possible center frequency */ +#define LVPSA_MINPOSTGAIN -15 /* Minimum possible post gain */ +#define LVPSA_MAXPOSTGAIN 15 /* Maximum possible post gain */ +#define LVPSA_MINQFACTOR 25 /* Minimum possible Q factor */ +#define LVPSA_MAXQFACTOR 1200 /* Maximum possible Q factor */ + +#define LVPSA_MAXLEVELDECAYFACTOR 0x4111 /* Decay factor for the maximum values calculation */ +#define LVPSA_MAXLEVELDECAYSHIFT 14 /* Decay shift for the maximum values calculation */ + +#define LVPSA_MAXUNSIGNEDCHAR 0xFF + +#define LVPSA_FsInvertShift 31 +#define LVPSA_GAINSHIFT 11 +#define LVPSA_FREQSHIFT 25 + +/********************************************************************************** + TYPES DEFINITIONS +***********************************************************************************/ + +#define LVPSA_InternalRefreshTime 0x0014 /* 20 ms (50Hz) in Q16.0 */ +#define LVPSA_InternalRefreshTimeInv 0x0666 /* 1/20ms left shifted by 15 */ +#define LVPSA_InternalRefreshTimeShift 15 + + +/* Precision of the filter */ +typedef enum +{ + LVPSA_SimplePrecisionFilter, /* Simple precision */ + LVPSA_DoublePrecisionFilter /* Double precision */ +} LVPSA_BPFilterPrecision_en; + +typedef struct +{ + LVM_CHAR bControlPending; /* Flag incating a change of the control parameters */ + LVM_UINT16 nBands; /* Number of bands of the spectrum analyzer */ + LVM_UINT16 MaxInputBlockSize; /* Maximum input data buffer size */ + + LVPSA_ControlParams_t CurrentParams; /* Current control parameters of the module */ + LVPSA_ControlParams_t NewParams; /* New control parameters given by the user */ + LVPSA_MemTab_t MemoryTable; + + LVPSA_BPFilterPrecision_en *pBPFiltersPrecision; /* Points a nBands elements array that contains the filter precision for each band */ + Biquad_Instance_t *pBP_Instances; /* Points a nBands elements array that contains the band pass filter instance for each band */ + Biquad_1I_Order2_Taps_t *pBP_Taps; /* Points a nBands elements array that contains the band pass filter taps for each band */ + QPD_State_t *pQPD_States; /* Points a nBands elements array that contains the QPD filter instance for each band */ + QPD_Taps_t *pQPD_Taps; /* Points a nBands elements array that contains the QPD filter taps for each band */ + LVM_UINT16 *pPostGains; /* Points a nBands elements array that contains the post-filter gains for each band */ + + LVPSA_FilterParam_t *pFiltersParams; /* Copy of the filters parameters from the input parameters */ + + + LVM_UINT16 nSamplesBufferUpdate; /* Number of samples to make 20ms */ + LVM_INT32 BufferUpdateSamplesCount; /* Counter used to know when to put a new value in the buffer */ + LVM_UINT16 nRelevantFilters; /* Number of relevent filters depending on sampling frequency and bands center frequency */ + LVM_UINT16 LocalSamplesCount; /* Counter used to update the SpectralDataBufferAudioTime */ + + LVM_UINT16 DownSamplingFactor; /* Down sampling factor depending on the sampling frequency */ + LVM_UINT16 DownSamplingCount; /* Counter used for the downsampling handling */ + + LVM_UINT16 SpectralDataBufferDuration; /* Length of the buffer in time (ms) defined by the application */ + LVM_UINT8 *pSpectralDataBufferStart; /* Starting address of the buffer */ + LVM_UINT8 *pSpectralDataBufferWritePointer; /* Current position of the writting pointer of the buffer */ + LVPSA_Time SpectralDataBufferAudioTime; /* AudioTime at which the last value save occured in the buffer */ + LVM_UINT32 SpectralDataBufferLength; /* Number of spectrum data value that the buffer can contain (per band) + = SpectralDataBufferDuration/20ms */ + + LVM_UINT8 *pPreviousPeaks; /* Points to a nBands elements array that contains the previous peak value of the level + detection. Those values are decremented after each call to the GetSpectrum function */ + +}LVPSA_InstancePr_t, *pLVPSA_InstancePr_t; + + + +/********************************************************************************** + FUNCTIONS PROTOTYPE +***********************************************************************************/ +/************************************************************************************/ +/* */ +/* FUNCTION: LVPSA_ApplyNewSettings */ +/* */ +/* DESCRIPTION: */ +/* Reinitialize some parameters and changes filters' coefficients if */ +/* some control parameters have changed. */ +/* */ +/* PARAMETERS: */ +/* pInst Pointer to the instance */ +/* */ +/* RETURNS: */ +/* LVPSA_OK Always succeeds */ +/* */ +/************************************************************************************/ +LVPSA_RETURN LVPSA_ApplyNewSettings (LVPSA_InstancePr_t *pInst); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _LVPSA_PRIVATE_H */ diff --git a/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Process.c b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Process.c new file mode 100755 index 0000000..d88a751 --- /dev/null +++ b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Process.c @@ -0,0 +1,260 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: PSA_01_ARMC_01 */ +/* $Author: beq07716 $*/ +/* $Revision: 1006 $*/ +/* $Date: 2010-06-28 14:01:47 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ +#include "LVPSA.h" +#include "LVPSA_Private.h" +#include "LVM_Macros.h" +#include "VectorArithmetic.h" + +#define LVM_MININT_32 0x80000000 + + +/************************************************************************************/ +/* */ +/* FUNCTION: LVPSA_Process */ +/* */ +/* DESCRIPTION: */ +/* The process applies band pass filters to the signal. Each output */ +/* feeds a quasi peak filter for level detection. */ +/* */ +/* PARAMETERS: */ +/* hInstance Pointer to the instance */ +/* pLVPSA_InputSamples Pointer to the input samples buffer */ +/* InputBlockSize Number of mono samples to process */ +/* AudioTime Playback time of the input samples */ +/* */ +/* */ +/* RETURNS: */ +/* LVPSA_OK Succeeds */ +/* otherwise Error due to bad parameters */ +/* */ +/************************************************************************************/ +LVPSA_RETURN LVPSA_Process ( pLVPSA_Handle_t hInstance, + LVM_INT16 *pLVPSA_InputSamples, + LVM_UINT16 InputBlockSize, + LVPSA_Time AudioTime ) + +{ + LVPSA_InstancePr_t *pLVPSA_Inst = (LVPSA_InstancePr_t*)hInstance; + LVM_INT16 *pScratch; + LVM_INT16 ii; + LVM_INT32 AudioTimeInc; + extern LVM_UINT32 LVPSA_SampleRateInvTab[]; + LVM_UINT8 *pWrite_Save; /* Position of the write pointer at the beginning of the process */ + + /****************************************************************************** + CHECK PARAMETERS + *******************************************************************************/ + if(hInstance == LVM_NULL || pLVPSA_InputSamples == LVM_NULL) + { + return(LVPSA_ERROR_NULLADDRESS); + } + if(InputBlockSize == 0 || InputBlockSize > pLVPSA_Inst->MaxInputBlockSize) + { + return(LVPSA_ERROR_INVALIDPARAM); + } + + pScratch = (LVM_INT16*)pLVPSA_Inst->MemoryTable.Region[LVPSA_MEMREGION_SCRATCH].pBaseAddress; + pWrite_Save = pLVPSA_Inst->pSpectralDataBufferWritePointer; + + /****************************************************************************** + APPLY NEW SETTINGS IF NEEDED + *******************************************************************************/ + if (pLVPSA_Inst->bControlPending == LVM_TRUE) + { + pLVPSA_Inst->bControlPending = 0; + LVPSA_ApplyNewSettings( pLVPSA_Inst); + } + + /****************************************************************************** + PROCESS SAMPLES + *******************************************************************************/ + /* Put samples in range [-0.5;0.5[ for BP filters (see Biquads documentation) */ + Copy_16( pLVPSA_InputSamples,pScratch,(LVM_INT16)InputBlockSize); + Shift_Sat_v16xv16(-1,pScratch,pScratch,(LVM_INT16)InputBlockSize); + + for (ii = 0; ii < pLVPSA_Inst->nRelevantFilters; ii++) + { + switch(pLVPSA_Inst->pBPFiltersPrecision[ii]) + { + case LVPSA_SimplePrecisionFilter: + BP_1I_D16F16C14_TRC_WRA_01 ( &pLVPSA_Inst->pBP_Instances[ii], + pScratch, + pScratch + InputBlockSize, + (LVM_INT16)InputBlockSize); + break; + + case LVPSA_DoublePrecisionFilter: + BP_1I_D16F32C30_TRC_WRA_01 ( &pLVPSA_Inst->pBP_Instances[ii], + pScratch, + pScratch + InputBlockSize, + (LVM_INT16)InputBlockSize); + break; + default: + break; + } + + + LVPSA_QPD_Process ( pLVPSA_Inst, + pScratch + InputBlockSize, + (LVM_INT16)InputBlockSize, + ii); + } + + /****************************************************************************** + UPDATE SpectralDataBufferAudioTime + *******************************************************************************/ + + if(pLVPSA_Inst->pSpectralDataBufferWritePointer != pWrite_Save) + { + MUL32x32INTO32((AudioTime + (LVM_INT32)((LVM_INT32)pLVPSA_Inst->LocalSamplesCount*1000)), + (LVM_INT32)LVPSA_SampleRateInvTab[pLVPSA_Inst->CurrentParams.Fs], + AudioTimeInc, + LVPSA_FsInvertShift) + pLVPSA_Inst->SpectralDataBufferAudioTime = AudioTime + AudioTimeInc; + } + + return(LVPSA_OK); +} + + +/************************************************************************************/ +/* */ +/* FUNCTION: LVPSA_GetSpectrum */ +/* */ +/* DESCRIPTION: */ +/* Gets the levels values at a certain point in time */ +/* */ +/* */ +/* PARAMETERS: */ +/* hInstance Pointer to the instance */ +/* GetSpectrumAudioTime Retrieve the values at this time */ +/* pCurrentValues Pointer to a buffer that will contain levels' values */ +/* pMaxValues Pointer to a buffer that will contain max levels' values */ +/* */ +/* */ +/* RETURNS: */ +/* LVPSA_OK Succeeds */ +/* otherwise Error due to bad parameters */ +/* */ +/************************************************************************************/ +LVPSA_RETURN LVPSA_GetSpectrum ( pLVPSA_Handle_t hInstance, + LVPSA_Time GetSpectrumAudioTime, + LVM_UINT8 *pCurrentValues, + LVM_UINT8 *pPeakValues ) + +{ + + LVPSA_InstancePr_t *pLVPSA_Inst = (LVPSA_InstancePr_t*)hInstance; + LVM_INT32 StatusDelta, ii; + LVM_UINT8 *pRead; + + if(hInstance == LVM_NULL || pCurrentValues == LVM_NULL || pPeakValues == LVM_NULL) + { + return(LVPSA_ERROR_NULLADDRESS); + } + + + /* First find the place where to look in the status buffer */ + if(GetSpectrumAudioTime <= pLVPSA_Inst->SpectralDataBufferAudioTime) + { + MUL32x32INTO32((pLVPSA_Inst->SpectralDataBufferAudioTime - GetSpectrumAudioTime),LVPSA_InternalRefreshTimeInv,StatusDelta,LVPSA_InternalRefreshTimeShift); + if((StatusDelta * LVPSA_InternalRefreshTime) != (pLVPSA_Inst->SpectralDataBufferAudioTime - GetSpectrumAudioTime)) + { + StatusDelta += 1; + } + } + else + { + /* This part handles the wrap around */ + MUL32x32INTO32(((pLVPSA_Inst->SpectralDataBufferAudioTime - (LVM_INT32)LVM_MININT_32) + ((LVM_INT32)LVM_MAXINT_32 - GetSpectrumAudioTime)),LVPSA_InternalRefreshTimeInv,StatusDelta,LVPSA_InternalRefreshTimeShift) + if(((LVM_INT32)(StatusDelta * LVPSA_InternalRefreshTime)) != ((LVM_INT32)((pLVPSA_Inst->SpectralDataBufferAudioTime - (LVM_INT32)LVM_MININT_32) + ((LVM_INT32)LVM_MAXINT_32 - GetSpectrumAudioTime)))) + { + StatusDelta += 1; + } + } + /* Check whether the desired level is not too "old" (see 2.10 in LVPSA_DesignNotes.doc)*/ + if( + ((GetSpectrumAudioTime < pLVPSA_Inst->SpectralDataBufferAudioTime)&& + ((GetSpectrumAudioTime<0)&&(pLVPSA_Inst->SpectralDataBufferAudioTime>0))&& + (((LVM_INT32)(-GetSpectrumAudioTime + pLVPSA_Inst->SpectralDataBufferAudioTime))>LVM_MAXINT_32))|| + + ((GetSpectrumAudioTime > pLVPSA_Inst->SpectralDataBufferAudioTime)&& + (((GetSpectrumAudioTime>=0)&&(pLVPSA_Inst->SpectralDataBufferAudioTime>=0))|| + ((GetSpectrumAudioTime<=0)&&(pLVPSA_Inst->SpectralDataBufferAudioTime<=0))|| + (((GetSpectrumAudioTime>=0)&&(pLVPSA_Inst->SpectralDataBufferAudioTime<=0))&& + (((LVM_INT32)(GetSpectrumAudioTime - pLVPSA_Inst->SpectralDataBufferAudioTime)) (LVM_INT32)pLVPSA_Inst->SpectralDataBufferLength) || + (!StatusDelta)) + { + for(ii = 0; ii < pLVPSA_Inst->nBands; ii++) + { + pCurrentValues[ii] = 0; + pPeakValues[ii] = 0; + } + return(LVPSA_OK); + } + /* Set the reading pointer */ + if((LVM_INT32)(StatusDelta * pLVPSA_Inst->nBands) > (pLVPSA_Inst->pSpectralDataBufferWritePointer - pLVPSA_Inst->pSpectralDataBufferStart)) + { + pRead = pLVPSA_Inst->pSpectralDataBufferWritePointer + (pLVPSA_Inst->SpectralDataBufferLength - (LVM_UINT32)StatusDelta) * pLVPSA_Inst->nBands; + } + else + { + pRead = pLVPSA_Inst->pSpectralDataBufferWritePointer - StatusDelta * pLVPSA_Inst->nBands; + } + + + /* Read the status buffer and fill the output buffers */ + for(ii = 0; ii < pLVPSA_Inst->nBands; ii++) + { + pCurrentValues[ii] = pRead[ii]; + if(pLVPSA_Inst->pPreviousPeaks[ii] <= pRead[ii]) + { + pLVPSA_Inst->pPreviousPeaks[ii] = pRead[ii]; + } + else if(pLVPSA_Inst->pPreviousPeaks[ii] != 0) + { + LVM_INT32 temp; + /*Re-compute max values for decay */ + temp = (LVM_INT32)(LVPSA_MAXUNSIGNEDCHAR - pLVPSA_Inst->pPreviousPeaks[ii]); + temp = ((temp * LVPSA_MAXLEVELDECAYFACTOR)>>LVPSA_MAXLEVELDECAYSHIFT); + /* If the gain has no effect, "help" the value to increase */ + if(temp == (LVPSA_MAXUNSIGNEDCHAR - pLVPSA_Inst->pPreviousPeaks[ii])) + { + temp += 1; + } + /* Saturate */ + temp = (temp > LVPSA_MAXUNSIGNEDCHAR) ? LVPSA_MAXUNSIGNEDCHAR : temp; + /* Store new max level */ + pLVPSA_Inst->pPreviousPeaks[ii] = (LVM_UINT8)(LVPSA_MAXUNSIGNEDCHAR - temp); + } + + pPeakValues[ii] = pLVPSA_Inst->pPreviousPeaks[ii]; + } + + return(LVPSA_OK); +} diff --git a/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_QPD.h b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_QPD.h new file mode 100755 index 0000000..641357e --- /dev/null +++ b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_QPD.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. + */ + +/************************************************************************/ +/* */ +/* Project:: PSA_01_ARMC_01 */ +/* $Author: beq07716 $*/ +/* $Revision: 1006 $*/ +/* $Date: 2010-06-28 14:01:47 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ +#ifndef _LVPSA_QPD_H_ +#define _LVPSA_QPD_H_ + +#include "LVM_Types.h" + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +typedef struct +{ + LVM_INT32 *pDelay; /* pointer to the delayed samples (data of 32 bits) */ + LVM_INT32 Coefs[2]; /* pointer to the filter coefficients */ +}QPD_State_t, *pQPD_State_t; + +typedef struct +{ + LVM_INT32 KP; /*should store a0*/ + LVM_INT32 KM; /*should store b2*/ + +} QPD_C32_Coefs, *PQPD_C32_Coefs; + +typedef struct +{ + LVM_INT32 Storage[1]; + +} QPD_Taps_t, *pQPD_Taps_t; + +/************************************************************************************/ +/* */ +/* FUNCTION: LVPSA_QPD_Process */ +/* */ +/* DESCRIPTION: */ +/* Apply downsampling, post gain, quasi peak filtering and write the levels values */ +/* in the buffer every 20 ms. */ +/* */ +/* PARAMETERS: */ +/* */ +/* RETURNS: void */ +/* */ +/************************************************************************************/ +void LVPSA_QPD_Process ( void *hInstance, + LVM_INT16 *pInSamps, + LVM_INT16 numSamples, + LVM_INT16 BandIndex); + +/************************************************************************************/ +/* */ +/* FUNCTION: LVPSA_QPD_Init */ +/* */ +/* DESCRIPTION: */ +/* Initialize a quasi peak filter instance. */ +/* */ +/* PARAMETERS: */ +/* pInstance Pointer to the instance */ +/* pTaps Pointer to the filter's taps */ +/* pCoef Pointer to the filter's coefficients */ +/* */ +/* RETURNS: void */ +/* */ +/************************************************************************************/ +void LVPSA_QPD_Init ( QPD_State_t *pInstance, + QPD_Taps_t *pTaps, + QPD_C32_Coefs *pCoef ); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif + diff --git a/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_QPD_Init.c b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_QPD_Init.c new file mode 100755 index 0000000..37abe40 --- /dev/null +++ b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_QPD_Init.c @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: PSA_01_ARMC_01 */ +/* $Author: beq07716 $*/ +/* $Revision: 1006 $*/ +/* $Date: 2010-06-28 14:01:47 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ +#include "LVPSA_QPD.h" + +/************************************************************************************/ +/* */ +/* FUNCTION: LVPSA_QPD_Init */ +/* */ +/* DESCRIPTION: */ +/* Initialize a quasi peak filter instance. */ +/* */ +/* PARAMETERS: */ +/* pQPD_State Pointer to the filter state */ +/* pTaps Pointer to the filter's taps */ +/* pCoef Pointer to the filter's coefficients */ +/* */ +/* RETURNS: void */ +/* */ +/************************************************************************************/ +void LVPSA_QPD_Init ( pQPD_State_t pQPD_State, + QPD_Taps_t *pTaps, + QPD_C32_Coefs *pCoef ) +{ + pQPD_State->pDelay = pTaps->Storage; + pQPD_State->Coefs[0] = pCoef->KP; + pQPD_State->Coefs[1] = pCoef->KM; +} diff --git a/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_QPD_Process.c b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_QPD_Process.c new file mode 100755 index 0000000..7087475 --- /dev/null +++ b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_QPD_Process.c @@ -0,0 +1,220 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: PSA_01_ARMC_01 */ +/* $Author: beq07716 $*/ +/* $Revision: 1006 $*/ +/* $Date: 2010-06-28 14:01:47 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ +#include "LVPSA_QPD.h" +#include "LVPSA_Private.h" + +/************************************************************************************/ +/* */ +/* FUNCTION: LVPSA_QPD_WritePeak */ +/* */ +/* DESCRIPTION: */ +/* Write a level value in the buffer in the corresponding band. */ +/* */ +/* PARAMETERS: */ +/* pInst Pointer to the LVPSA instance */ +/* ppWrite Pointer to pointer to the buffer */ +/* CallNumber Number of the band the value should be written in */ +/* Value Value to write in the buffer */ +/* */ +/* RETURNS: void */ +/* */ +/************************************************************************************/ +void LVPSA_QPD_WritePeak( pLVPSA_InstancePr_t pLVPSA_Inst, + LVM_UINT8 **ppWrite, + LVM_INT16 BandIndex, + LVM_INT16 Value ); + + + +/************************************************************************************/ +/* */ +/* FUNCTION: LVPSA_QPD_Process */ +/* */ +/* DESCRIPTION: */ +/* Apply downsampling, post gain, quasi peak filtering and write the levels values */ +/* in the buffer every 20 ms. */ +/* */ +/* PARAMETERS: */ +/* */ +/* RETURNS: void */ +/* */ +/************************************************************************************/ +void LVPSA_QPD_Process ( void *hInstance, + LVM_INT16 *pInSamps, + LVM_INT16 numSamples, + LVM_INT16 BandIndex) +{ + + /****************************************************************************** + PARAMETERS + *******************************************************************************/ + LVPSA_InstancePr_t *pLVPSA_Inst = (LVPSA_InstancePr_t*)hInstance; + QPD_State_t *pQPDState = (QPD_State_t*)&pLVPSA_Inst->pQPD_States[BandIndex]; + + /* Pointer to taps */ + LVM_INT32* pDelay = pQPDState->pDelay; + + /* Parameters needed during quasi peak calculations */ + LVM_INT32 X0; + LVM_INT32 temp,temp2; + LVM_INT32 accu; + LVM_INT16 Xg0; + LVM_INT16 D0; + LVM_INT16 V0 = (LVM_INT16)(*pDelay); + + /* Filter's coef */ + LVM_INT32 Kp = pQPDState->Coefs[0]; + LVM_INT32 Km = pQPDState->Coefs[1]; + + LVM_INT16 ii = numSamples; + + LVM_UINT8 *pWrite = pLVPSA_Inst->pSpectralDataBufferWritePointer; + LVM_INT32 BufferUpdateSamplesCount = pLVPSA_Inst->BufferUpdateSamplesCount; + LVM_UINT16 DownSamplingFactor = pLVPSA_Inst->DownSamplingFactor; + + /****************************************************************************** + INITIALIZATION + *******************************************************************************/ + /* Correct the pointer to take the first down sampled signal sample */ + pInSamps += pLVPSA_Inst->DownSamplingCount; + /* Correct also the number of samples */ + ii = (LVM_INT16)(ii - (LVM_INT16)pLVPSA_Inst->DownSamplingCount); + + while (ii > 0) + { + /* Apply post gain */ + X0 = ((*pInSamps) * pLVPSA_Inst->pPostGains[BandIndex]) >> (LVPSA_GAINSHIFT-1); /* - 1 to compensate scaling in process function*/ + pInSamps = pInSamps + DownSamplingFactor; + + /* Saturate and take absolute value */ + if(X0 < 0) + X0 = -X0; + if (X0 > 0x7FFF) + Xg0 = 0x7FFF; + else + Xg0 = (LVM_INT16)(X0); + + + /* Quasi peak filter calculation */ + D0 = (LVM_INT16)(Xg0 - V0); + + temp2 = (LVM_INT32)D0; + MUL32x32INTO32(temp2,Kp,accu,31); + + D0 = (LVM_INT16)(D0>>1); + if (D0 < 0){ + D0 = (LVM_INT16)(-D0); + } + + temp2 = (LVM_INT32)D0; + MUL32x32INTO32((LVM_INT32)D0,Km,temp,31); + accu +=temp + Xg0; + + if (accu > 0x7FFF) + accu = 0x7FFF; + else if(accu < 0) + accu = 0x0000; + + V0 = (LVM_INT16)accu; + + if(((pLVPSA_Inst->nSamplesBufferUpdate - BufferUpdateSamplesCount) < DownSamplingFactor)) + { + LVPSA_QPD_WritePeak( pLVPSA_Inst, + &pWrite, + BandIndex, + V0); + BufferUpdateSamplesCount -= pLVPSA_Inst->nSamplesBufferUpdate; + pLVPSA_Inst->LocalSamplesCount = (LVM_UINT16)(numSamples - ii); + } + BufferUpdateSamplesCount+=DownSamplingFactor; + + ii = (LVM_INT16)(ii-DownSamplingFactor); + + } + + /* Store last taps in memory */ + *pDelay = (LVM_INT32)(V0); + + /* If this is the last call to the function after last band processing, + update the parameters. */ + if(BandIndex == (pLVPSA_Inst->nRelevantFilters-1)) + { + pLVPSA_Inst->pSpectralDataBufferWritePointer = pWrite; + /* Adjustment for 11025Hz input, 220,5 is normally + the exact number of samples for 20ms.*/ + if((pLVPSA_Inst->pSpectralDataBufferWritePointer != pWrite)&&(pLVPSA_Inst->CurrentParams.Fs == LVM_FS_11025)) + { + if(pLVPSA_Inst->nSamplesBufferUpdate == 220) + { + pLVPSA_Inst->nSamplesBufferUpdate = 221; + } + else + { + pLVPSA_Inst->nSamplesBufferUpdate = 220; + } + } + pLVPSA_Inst->pSpectralDataBufferWritePointer = pWrite; + pLVPSA_Inst->BufferUpdateSamplesCount = BufferUpdateSamplesCount; + pLVPSA_Inst->DownSamplingCount = (LVM_UINT16)(-ii); + } +} + +/************************************************************************************/ +/* */ +/* FUNCTION: LVPSA_QPD_WritePeak */ +/* */ +/* DESCRIPTION: */ +/* Write a level value in the spectrum data buffer in the corresponding band. */ +/* */ +/* PARAMETERS: */ +/* pLVPSA_Inst Pointer to the LVPSA instance */ +/* ppWrite Pointer to pointer to the buffer */ +/* CallNumber Number of the band the value should be written in */ +/* Value Value to write in the spectrum data buffer */ +/* */ +/* RETURNS: void */ +/* */ +/************************************************************************************/ +void LVPSA_QPD_WritePeak( pLVPSA_InstancePr_t pLVPSA_Inst, + LVM_UINT8 **ppWrite, + LVM_INT16 BandIndex, + LVM_INT16 Value ) +{ + LVM_UINT8 *pWrite = *ppWrite; + + + /* Write the value and update the write pointer */ + *(pWrite + BandIndex) = (LVM_UINT8)(Value>>7); + pWrite += pLVPSA_Inst->nBands; + if (pWrite == (pLVPSA_Inst->pSpectralDataBufferStart + pLVPSA_Inst->nBands * pLVPSA_Inst->SpectralDataBufferLength)) + { + pWrite = pLVPSA_Inst->pSpectralDataBufferStart; + } + + *ppWrite = pWrite; + +} + diff --git a/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Tables.c b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Tables.c new file mode 100755 index 0000000..f4a35c5 --- /dev/null +++ b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Tables.c @@ -0,0 +1,250 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/************************************************************************/ +/* */ +/* Project:: PSA_01_ARMC_01 */ +/* $Author: beq07716 $*/ +/* $Revision: 1006 $*/ +/* $Date: 2010-06-28 14:01:47 +0200 (Mon, 28 Jun 2010) $*/ +/* */ +/************************************************************************/ + + +/************************************************************************************/ +/* */ +/* Includes */ +/* */ +/************************************************************************************/ + +#include "LVPSA.h" +#include "LVPSA_QPD.h" +/************************************************************************************/ +/* */ +/* Sample rate table */ +/* */ +/************************************************************************************/ + +/* + * Sample rate table for converting between the enumerated type and the actual + * frequency + */ +const LVM_UINT16 LVPSA_SampleRateTab[] = { 8000, /* 8kS/s */ + 11025, + 12000, + 16000, + 22050, + 24000, + 32000, + 44100, + 48000}; /* 48kS/s */ + +/************************************************************************************/ +/* */ +/* Sample rate inverse table */ +/* */ +/************************************************************************************/ + +/* + * Sample rate table for converting between the enumerated type and the actual + * frequency + */ +const LVM_UINT32 LVPSA_SampleRateInvTab[] = { 268435, /* 8kS/s */ + 194783, + 178957, + 134218, + 97391, + 89478, + 67109, + 48696, + 44739}; /* 48kS/s */ + + + +/************************************************************************************/ +/* */ +/* Number of samples in 20ms */ +/* */ +/************************************************************************************/ + +/* + * Table for converting between the enumerated type and the number of samples + * during 20ms + */ +const LVM_UINT16 LVPSA_nSamplesBufferUpdate[] = { 160, /* 8kS/s */ + 220, + 240, + 320, + 441, + 480, + 640, + 882, + 960}; /* 48kS/s */ +/************************************************************************************/ +/* */ +/* Down sampling factors */ +/* */ +/************************************************************************************/ + +/* + * Table for converting between the enumerated type and the down sampling factor + */ +const LVM_UINT16 LVPSA_DownSamplingFactor[] = { 5, /* 8000 S/s */ + 7, /* 11025 S/s */ + 8, /* 12000 S/s */ + 10, /* 16000 S/s */ + 15, /* 22050 S/s */ + 16, /* 24000 S/s */ + 21, /* 32000 S/s */ + 30, /* 44100 S/s */ + 32}; /* 48000 S/s */ + + +/************************************************************************************/ +/* */ +/* Coefficient calculation tables */ +/* */ +/************************************************************************************/ + +/* + * Table for 2 * Pi / Fs + */ +const LVM_INT16 LVPSA_TwoPiOnFsTable[] = { 26354, /* 8kS/s */ + 19123, + 17569, + 13177, + 9561, + 8785, + 6588, + 4781, + 4392}; /* 48kS/s */ + +/* + * Gain table + */ +const LVM_INT16 LVPSA_GainTable[] = { 364, /* -15dB gain */ + 408, + 458, + 514, + 577, + 647, + 726, + 815, + 914, + 1026, + 1151, + 1292, + 1449, + 1626, + 1825, + 2048, /* 0dB gain */ + 2297, + 2578, + 2892, + 3245, + 3641, + 4096, + 4584, + 5144, + 5772, + 6476, + 7266, + 8153, + 9148, + 10264, + 11576}; /* +15dB gain */ + +/************************************************************************************/ +/* */ +/* Cosone polynomial coefficients */ +/* */ +/************************************************************************************/ + +/* + * Coefficients for calculating the cosine with the equation: + * + * Cos(x) = (2^Shifts)*(a0 + a1*x + a2*x^2 + a3*x^3 + a4*x^4 + a5*x^5) + * + * These coefficients expect the input, x, to be in the range 0 to 32768 respresenting + * a range of 0 to Pi. The output is in the range 32767 to -32768 representing the range + * +1.0 to -1.0 + */ +const LVM_INT16 LVPSA_CosCoef[] = { 3, /* Shifts */ + 4096, /* a0 */ + -36, /* a1 */ + -19725, /* a2 */ + -2671, /* a3 */ + 23730, /* a4 */ + -9490}; /* a5 */ + +/* + * Coefficients for calculating the cosine error with the equation: + * + * CosErr(x) = (2^Shifts)*(a0 + a1*x + a2*x^2 + a3*x^3) + * + * These coefficients expect the input, x, to be in the range 0 to 32768 respresenting + * a range of 0 to Pi/25. The output is in the range 0 to 32767 representing the range + * 0.0 to 0.0078852986 + * + * This is used to give a double precision cosine over the range 0 to Pi/25 using the + * the equation: + * + * Cos(x) = 1.0 - CosErr(x) + */ +const LVM_INT16 LVPSA_DPCosCoef[] = { 1, /* Shifts */ + 0, /* a0 */ + -6, /* a1 */ + 16586, /* a2 */ + -44}; /* a3 */ + +/************************************************************************************/ +/* */ +/* Quasi peak filter coefficients table */ +/* */ +/************************************************************************************/ +const QPD_C32_Coefs LVPSA_QPD_Coefs[] = { + + {0x80CEFD2B,0x00CB9B17}, /* 8kS/s */ /* LVPSA_SPEED_LOW */ + {0x80D242E7,0x00CED11D}, + {0x80DCBAF5,0x00D91679}, + {0x80CEFD2B,0x00CB9B17}, + {0x80E13739,0x00DD7CD3}, + {0x80DCBAF5,0x00D91679}, + {0x80D94BAF,0x00D5B7E7}, + {0x80E13739,0x00DD7CD3}, + {0x80DCBAF5,0x00D91679}, /* 48kS/s */ + + {0x8587513D,0x055C22CF}, /* 8kS/s */ /* LVPSA_SPEED_MEDIUM */ + {0x859D2967,0x0570F007}, + {0x85E2EFAC,0x05B34D79}, + {0x8587513D,0x055C22CF}, + {0x8600C7B9,0x05CFA6CF}, + {0x85E2EFAC,0x05B34D79}, + {0x85CC1018,0x059D8F69}, + {0x8600C7B9,0x05CFA6CF},//{0x8600C7B9,0x05CFA6CF}, + {0x85E2EFAC,0x05B34D79}, /* 48kS/s */ + + {0xA115EA7A,0x1CDB3F5C}, /* 8kS/s */ /* LVPSA_SPEED_HIGH */ + {0xA18475F0,0x1D2C83A2}, + {0xA2E1E950,0x1E2A532E}, + {0xA115EA7A,0x1CDB3F5C}, + {0xA375B2C6,0x1E943BBC}, + {0xA2E1E950,0x1E2A532E}, + {0xA26FF6BD,0x1DD81530}, + {0xA375B2C6,0x1E943BBC}, + {0xA2E1E950,0x1E2A532E}}; /* 48kS/s */ + diff --git a/media/libeffects/lvm/lib/StereoWidening/lib/LVCS.h b/media/libeffects/lvm/lib/StereoWidening/lib/LVCS.h new file mode 100755 index 0000000..1ab45cc --- /dev/null +++ b/media/libeffects/lvm/lib/StereoWidening/lib/LVCS.h @@ -0,0 +1,396 @@ +/* + * 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 application layer interface of Concert Sound and Concert */ +/* Sound EX. */ +/* */ +/* This files includes all definitions, types, structures and function */ +/* prototypes required by the calling layer. All other types, structures and */ +/* functions are private. */ +/* */ +/****************************************************************************************/ +/* */ +/* Note: 1 */ +/* ======= */ +/* The algorithm can execute either with separate input and output buffers or with */ +/* a common buffer, i.e. the data is processed in-place. If the buffers are the */ +/* same then the MIPs will be slightly higher and an extra stereo scratch buffer is */ +/* required. */ +/* */ +/****************************************************************************************/ +/* */ +/* Note: 2 */ +/* ======= */ +/* Two data formats are support Stereo and Mono-In-Stereo. The data is interleaved as */ +/* follows: */ +/* Byte Offset Stereo Input Mono-In-Stereo Input */ +/* =========== ============ ==================== */ +/* 0 Left Sample #1 Mono Sample #1 */ +/* 2 Right Sample #1 Mono Sample #1 */ +/* 4 Left Sample #2 Mono Sample #2 */ +/* 6 Right Sample #2 Mono Sample #2 */ +/* . . . */ +/* . . . */ +/* */ +/* Mono format data is not supported, the calling routine must convert a Mono stream */ +/* in to Mono-In-Stereo format. */ +/* */ +/****************************************************************************************/ + +#ifndef LVCS_H +#define LVCS_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/****************************************************************************************/ +/* */ +/* Includes */ +/* */ +/****************************************************************************************/ + +#include "LVM_Types.h" +#include "LVM_Common.h" + + +/****************************************************************************************/ +/* */ +/* Definitions */ +/* */ +/****************************************************************************************/ + +/* Memory table */ +#define LVCS_MEMREGION_PERSISTENT_SLOW_DATA 0 /* Offset to the instance memory region */ +#define LVCS_MEMREGION_PERSISTENT_FAST_DATA 1 /* Offset to the persistent data memory region */ +#define LVCS_MEMREGION_PERSISTENT_FAST_COEF 2 /* Offset to the persistent coefficient memory region */ +#define LVCS_MEMREGION_TEMPORARY_FAST 3 /* Offset to temporary memory region */ +#define LVCS_NR_MEMORY_REGIONS 4 /* Number of memory regions */ + +/* Effect Level */ +#define LVCS_EFFECT_LOW 16384 /* Effect scaling 50% */ +#define LVCS_EFFECT_MEDIUM 24576 /* Effect scaling 75% */ +#define LVCS_EFFECT_HIGH 32767 /* Effect Scaling 100% */ + +/* Callback events */ +#define LVCS_EVENT_NONE 0x0000 /* Not a valid event */ +#define LVCS_EVENT_ALGOFF 0x0001 /* CS has completed switch off */ + + +/****************************************************************************************/ +/* */ +/* Types */ +/* */ +/****************************************************************************************/ + +/* Instance handle */ +typedef void *LVCS_Handle_t; + + +/* Operating modes */ +typedef enum +{ + LVCS_OFF = 0, + LVCS_ON = 15, + LVCS_MAX = LVM_MAXENUM +} LVCS_Modes_en; + + +/* Memory Types */ +typedef enum +{ + LVCS_SCRATCH = 0, + LVCS_DATA = 1, + LVCS_COEFFICIENT = 2, + LVCS_PERSISTENT = 3, + LVCS_MEMORYTYPE_MAX = LVM_MAXENUM +} LVCS_MemoryTypes_en; + + +/* Function return status */ +typedef enum +{ + LVCS_SUCCESS = 0, /* Successful return from a routine */ + LVCS_ALIGNMENTERROR = 1, /* Memory alignment error */ + LVCS_NULLADDRESS = 2, /* NULL allocation address */ + LVCS_TOOMANYSAMPLES = 3, /* Maximum block size exceeded */ + LVCS_INVALIDBUFFER = 4, /* Invalid buffer processing request */ + LVCS_STATUSMAX = LVM_MAXENUM +} LVCS_ReturnStatus_en; + + +/* + * Source data formats + */ +typedef enum +{ + LVCS_STEREO = 0, + LVCS_MONOINSTEREO = 1, + LVCS_SOURCEMAX = LVM_MAXENUM +} LVCS_SourceFormat_en; + + +/* + * Supported output devices + */ +typedef enum +{ + LVCS_HEADPHONES = 0, + LVCS_EX_HEADPHONES = 1, + LVCS_SPEAKERTYPE_MAX = LVM_MAXENUM +} LVCS_SpeakerType_en; + +/* + * Speaker Coefficients Table + */ +typedef struct +{ + void *pTable1; + void *pTable2; + void *pTable3; + void *pTable4; + void *pTable5; + void *pTable6; + void *pTable7; + void *pTable8; +} LVCS_CSMS_Coef_Tables_t; + + +/****************************************************************************************/ +/* */ +/* Structures */ +/* */ +/****************************************************************************************/ + +/* Memory region definition */ +typedef struct +{ + LVM_UINT32 Size; /* Region size in bytes */ + LVCS_MemoryTypes_en Type; /* Region type */ + void *pBaseAddress; /* Pointer to the region base address */ +} LVCS_MemoryRegion_t; + + +/* Memory table containing the region definitions */ +typedef struct +{ + LVCS_MemoryRegion_t Region[LVCS_NR_MEMORY_REGIONS]; /* One definition for each region */ +} LVCS_MemTab_t; + + +/* Concert Sound parameter structure */ +typedef struct +{ + LVCS_Modes_en OperatingMode; /* Algorithm mode */ + LVCS_SpeakerType_en SpeakerType; /* Output device type */ + LVCS_SourceFormat_en SourceFormat; /* Source data format */ + LVM_Mode_en CompressorMode; /* Non-Linear Compressor Mode */ + LVM_Fs_en SampleRate; /* Sampling rate */ + LVM_INT16 EffectLevel; /* Effect level */ + LVM_UINT16 ReverbLevel; /* Reverb level in % */ +} LVCS_Params_t; + + +/* Concert Sound Capability structure */ +typedef struct +{ + /* General parameters */ + LVM_UINT16 MaxBlockSize; /* Maximum block size in sample pairs */ + + /* Callback parameters */ + LVM_Callback CallBack; /* Bundle callback */ + void *pBundleInstance; /* Bundle instance handle */ + +} LVCS_Capabilities_t; + + +/****************************************************************************************/ +/* */ +/* Function Prototypes */ +/* */ +/****************************************************************************************/ + +/****************************************************************************************/ +/* */ +/* 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, of these only the buffer processing setting is */ +/* used. */ +/* */ +/* 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); + + +/****************************************************************************************/ +/* */ +/* 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 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 initialisation capabilities */ +/* */ +/* RETURNS: */ +/* LVCS_Success Initialisation succeeded */ +/* LVCS_AlignmentError Instance or scratch memory on incorrect alignment */ +/* LVCS_NullAddress Instance or scratch memory has a NULL pointer */ +/* */ +/* 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 */ +/* */ +/****************************************************************************************/ + +LVCS_ReturnStatus_en LVCS_Init(LVCS_Handle_t *phInstance, + LVCS_MemTab_t *pMemoryTable, + LVCS_Capabilities_t *pCapabilities); + + +/****************************************************************************************/ +/* */ +/* 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); + + +/****************************************************************************************/ +/* */ +/* 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); + + +/****************************************************************************************/ +/* */ +/* 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. */ +/* */ +/* 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); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* LVCS_H */ 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__ */ + -- cgit v1.1