Loading media/libeffects/lvm/lib/Eq/src/LVEQNB_Control.cpp +33 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,9 @@ /* */ /****************************************************************************************/ #ifdef BIQUAD_OPT #include <system/audio.h> #endif #include "LVEQNB.h" #include "LVEQNB_Private.h" #include "VectorArithmetic.h" Loading Loading @@ -179,6 +182,9 @@ void LVEQNB_SetCoefficients(LVEQNB_Instance_t* pInstance) { LVM_UINT16 i; /* Filter band index */ LVEQNB_BiquadType_en BiquadType; /* Filter biquad type */ #ifdef BIQUAD_OPT pInstance->gain.resize(pInstance->Params.NBands); #endif /* * Set the coefficients for each band by the init function */ Loading @@ -198,8 +204,19 @@ void LVEQNB_SetCoefficients(LVEQNB_Instance_t* pInstance) { /* * Set the coefficients */ #ifdef BIQUAD_OPT pInstance->gain[i] = Coefficients.G; std::array<LVM_FLOAT, android::audio_utils::kBiquadNumCoefs> coefs = { Coefficients.A0, 0.0, -(Coefficients.A0), -(Coefficients.B1), -(Coefficients.B2)}; pInstance->eqBiquad[i] .setCoefficients< std::array<LVM_FLOAT, android::audio_utils::kBiquadNumCoefs>>( coefs); #else PK_2I_D32F32CssGss_TRC_WRA_01_Init(&pInstance->pEQNB_FilterState_Float[i], &pInstance->pEQNB_Taps_Float[i], &Coefficients); #endif break; } default: Loading @@ -220,6 +237,11 @@ void LVEQNB_SetCoefficients(LVEQNB_Instance_t* pInstance) { /* */ /************************************************************************************/ void LVEQNB_ClearFilterHistory(LVEQNB_Instance_t* pInstance) { #ifdef BIQUAD_OPT for (size_t i = 0; i < pInstance->eqBiquad.size(); i++) { pInstance->eqBiquad[i].clear(); } #else LVM_FLOAT* pTapAddress; LVM_INT16 NumTaps; Loading @@ -233,6 +255,7 @@ void LVEQNB_ClearFilterHistory(LVEQNB_Instance_t* pInstance) { pTapAddress, /* Destination */ NumTaps); /* Number of words */ } #endif } /****************************************************************************************/ /* */ Loading Loading @@ -310,6 +333,16 @@ LVEQNB_ReturnStatus_en LVEQNB_Control(LVEQNB_Handle_t hInstance, LVEQNB_Params_t (OperatingModeSave == LVEQNB_ON && pInstance->bInOperatingModeTransition && LVC_Mixer_GetTarget(&pInstance->BypassMixer.MixerStream[0]) == 0); #ifdef BIQUAD_OPT /* * Create biquad instance */ pInstance->eqBiquad.resize( pParams->NBands, android::audio_utils::BiquadFilter<LVM_FLOAT>( (FCC_1 == pParams->NrChannels) ? FCC_2 : pParams->NrChannels)); LVEQNB_ClearFilterHistory(pInstance); #endif if (bChange || modeChange) { /* * If the sample rate has changed clear the history Loading media/libeffects/lvm/lib/Eq/src/LVEQNB_Init.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -62,6 +62,9 @@ LVEQNB_ReturnStatus_en LVEQNB_Init(LVEQNB_Handle_t* phInstance, pInstance->pScratch = pScratch; /* Equaliser Biquad Instance */ #ifdef BIQUAD_OPT LVM_UINT32 MemSize = pCapabilities->MaxBands * sizeof(*(pInstance->pBandDefinitions)); #else LVM_UINT32 MemSize = pCapabilities->MaxBands * sizeof(*(pInstance->pEQNB_FilterState_Float)); pInstance->pEQNB_FilterState_Float = (Biquad_FLOAT_Instance_t*)calloc(1, MemSize); if (pInstance->pEQNB_FilterState_Float == LVM_NULL) { Loading @@ -75,6 +78,7 @@ LVEQNB_ReturnStatus_en LVEQNB_Init(LVEQNB_Handle_t* phInstance, } MemSize = (pCapabilities->MaxBands * sizeof(*(pInstance->pBandDefinitions))); #endif pInstance->pBandDefinitions = (LVEQNB_BandDef_t*)calloc(1, MemSize); if (pInstance->pBandDefinitions == LVM_NULL) { return LVEQNB_NULLADDRESS; Loading Loading @@ -105,10 +109,11 @@ LVEQNB_ReturnStatus_en LVEQNB_Init(LVEQNB_Handle_t* phInstance, */ LVEQNB_SetFilters(pInstance, /* Set the filter types */ &pInstance->Params); #ifndef BIQUAD_OPT LVEQNB_SetCoefficients(pInstance); /* Set the filter coefficients */ LVEQNB_ClearFilterHistory(pInstance); /* Clear the filter history */ #endif /* * Initialise the bypass variables Loading Loading @@ -154,6 +159,7 @@ void LVEQNB_DeInit(LVEQNB_Handle_t* phInstance) { } pInstance = (LVEQNB_Instance_t*)*phInstance; #ifndef BIQUAD_OPT /* Equaliser Biquad Instance */ if (pInstance->pEQNB_FilterState_Float != LVM_NULL) { free(pInstance->pEQNB_FilterState_Float); Loading @@ -163,6 +169,7 @@ void LVEQNB_DeInit(LVEQNB_Handle_t* phInstance) { free(pInstance->pEQNB_Taps_Float); pInstance->pEQNB_Taps_Float = LVM_NULL; } #endif if (pInstance->pBandDefinitions != LVM_NULL) { free(pInstance->pBandDefinitions); pInstance->pBandDefinitions = LVM_NULL; Loading media/libeffects/lvm/lib/Eq/src/LVEQNB_Private.h +9 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,9 @@ /* */ /****************************************************************************************/ #ifdef BIQUAD_OPT #include <audio_utils/BiquadFilter.h> #endif #include "LVEQNB.h" /* Calling or Application layer definitions */ #include "BIQUAD.h" #include "LVC_Mixer.h" Loading Loading @@ -69,8 +72,14 @@ typedef struct { /* Aligned memory pointers */ LVM_FLOAT* pFastTemporary; /* Fast temporary data base address */ #ifdef BIQUAD_OPT std::vector<android::audio_utils::BiquadFilter<LVM_FLOAT>> eqBiquad; /* Biquad filter instances */ std::vector<LVM_FLOAT> gain; /* Gain values for all bands*/ #else Biquad_2I_Order2_FLOAT_Taps_t* pEQNB_Taps_Float; /* Equaliser Taps */ Biquad_FLOAT_Instance_t* pEQNB_FilterState_Float; /* State for each filter band */ #endif /* Filter definitions and call back */ LVM_UINT16 NBands; /* Number of bands */ Loading media/libeffects/lvm/lib/Eq/src/LVEQNB_Process.cpp +11 −0 Original line number Diff line number Diff line Loading @@ -104,19 +104,30 @@ LVEQNB_ReturnStatus_en LVEQNB_Process( * Check if band is non-zero dB gain */ if (pInstance->pBandDefinitions[i].Gain != 0) { #ifndef BIQUAD_OPT /* * Get the address of the biquad instance */ Biquad_FLOAT_Instance_t* pBiquad = &pInstance->pEQNB_FilterState_Float[i]; #endif /* * Select single or double precision as required */ switch (pInstance->pBiquadType[i]) { case LVEQNB_SinglePrecision_Float: { #ifdef BIQUAD_OPT LVM_FLOAT* pTemp = pScratch + NrSamples; pInstance->eqBiquad[i].process(pTemp, pScratch, NrFrames); const auto gain = pInstance->gain[i]; for (unsigned j = 0; j < NrSamples; ++j) { pScratch[j] += pTemp[j] * gain; } #else PK_Mc_D32F32C14G11_TRC_WRA_01(pBiquad, pScratch, pScratch, (LVM_INT16)NrFrames, (LVM_INT16)NrChannels); #endif break; } default: Loading Loading
media/libeffects/lvm/lib/Eq/src/LVEQNB_Control.cpp +33 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,9 @@ /* */ /****************************************************************************************/ #ifdef BIQUAD_OPT #include <system/audio.h> #endif #include "LVEQNB.h" #include "LVEQNB_Private.h" #include "VectorArithmetic.h" Loading Loading @@ -179,6 +182,9 @@ void LVEQNB_SetCoefficients(LVEQNB_Instance_t* pInstance) { LVM_UINT16 i; /* Filter band index */ LVEQNB_BiquadType_en BiquadType; /* Filter biquad type */ #ifdef BIQUAD_OPT pInstance->gain.resize(pInstance->Params.NBands); #endif /* * Set the coefficients for each band by the init function */ Loading @@ -198,8 +204,19 @@ void LVEQNB_SetCoefficients(LVEQNB_Instance_t* pInstance) { /* * Set the coefficients */ #ifdef BIQUAD_OPT pInstance->gain[i] = Coefficients.G; std::array<LVM_FLOAT, android::audio_utils::kBiquadNumCoefs> coefs = { Coefficients.A0, 0.0, -(Coefficients.A0), -(Coefficients.B1), -(Coefficients.B2)}; pInstance->eqBiquad[i] .setCoefficients< std::array<LVM_FLOAT, android::audio_utils::kBiquadNumCoefs>>( coefs); #else PK_2I_D32F32CssGss_TRC_WRA_01_Init(&pInstance->pEQNB_FilterState_Float[i], &pInstance->pEQNB_Taps_Float[i], &Coefficients); #endif break; } default: Loading @@ -220,6 +237,11 @@ void LVEQNB_SetCoefficients(LVEQNB_Instance_t* pInstance) { /* */ /************************************************************************************/ void LVEQNB_ClearFilterHistory(LVEQNB_Instance_t* pInstance) { #ifdef BIQUAD_OPT for (size_t i = 0; i < pInstance->eqBiquad.size(); i++) { pInstance->eqBiquad[i].clear(); } #else LVM_FLOAT* pTapAddress; LVM_INT16 NumTaps; Loading @@ -233,6 +255,7 @@ void LVEQNB_ClearFilterHistory(LVEQNB_Instance_t* pInstance) { pTapAddress, /* Destination */ NumTaps); /* Number of words */ } #endif } /****************************************************************************************/ /* */ Loading Loading @@ -310,6 +333,16 @@ LVEQNB_ReturnStatus_en LVEQNB_Control(LVEQNB_Handle_t hInstance, LVEQNB_Params_t (OperatingModeSave == LVEQNB_ON && pInstance->bInOperatingModeTransition && LVC_Mixer_GetTarget(&pInstance->BypassMixer.MixerStream[0]) == 0); #ifdef BIQUAD_OPT /* * Create biquad instance */ pInstance->eqBiquad.resize( pParams->NBands, android::audio_utils::BiquadFilter<LVM_FLOAT>( (FCC_1 == pParams->NrChannels) ? FCC_2 : pParams->NrChannels)); LVEQNB_ClearFilterHistory(pInstance); #endif if (bChange || modeChange) { /* * If the sample rate has changed clear the history Loading
media/libeffects/lvm/lib/Eq/src/LVEQNB_Init.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -62,6 +62,9 @@ LVEQNB_ReturnStatus_en LVEQNB_Init(LVEQNB_Handle_t* phInstance, pInstance->pScratch = pScratch; /* Equaliser Biquad Instance */ #ifdef BIQUAD_OPT LVM_UINT32 MemSize = pCapabilities->MaxBands * sizeof(*(pInstance->pBandDefinitions)); #else LVM_UINT32 MemSize = pCapabilities->MaxBands * sizeof(*(pInstance->pEQNB_FilterState_Float)); pInstance->pEQNB_FilterState_Float = (Biquad_FLOAT_Instance_t*)calloc(1, MemSize); if (pInstance->pEQNB_FilterState_Float == LVM_NULL) { Loading @@ -75,6 +78,7 @@ LVEQNB_ReturnStatus_en LVEQNB_Init(LVEQNB_Handle_t* phInstance, } MemSize = (pCapabilities->MaxBands * sizeof(*(pInstance->pBandDefinitions))); #endif pInstance->pBandDefinitions = (LVEQNB_BandDef_t*)calloc(1, MemSize); if (pInstance->pBandDefinitions == LVM_NULL) { return LVEQNB_NULLADDRESS; Loading Loading @@ -105,10 +109,11 @@ LVEQNB_ReturnStatus_en LVEQNB_Init(LVEQNB_Handle_t* phInstance, */ LVEQNB_SetFilters(pInstance, /* Set the filter types */ &pInstance->Params); #ifndef BIQUAD_OPT LVEQNB_SetCoefficients(pInstance); /* Set the filter coefficients */ LVEQNB_ClearFilterHistory(pInstance); /* Clear the filter history */ #endif /* * Initialise the bypass variables Loading Loading @@ -154,6 +159,7 @@ void LVEQNB_DeInit(LVEQNB_Handle_t* phInstance) { } pInstance = (LVEQNB_Instance_t*)*phInstance; #ifndef BIQUAD_OPT /* Equaliser Biquad Instance */ if (pInstance->pEQNB_FilterState_Float != LVM_NULL) { free(pInstance->pEQNB_FilterState_Float); Loading @@ -163,6 +169,7 @@ void LVEQNB_DeInit(LVEQNB_Handle_t* phInstance) { free(pInstance->pEQNB_Taps_Float); pInstance->pEQNB_Taps_Float = LVM_NULL; } #endif if (pInstance->pBandDefinitions != LVM_NULL) { free(pInstance->pBandDefinitions); pInstance->pBandDefinitions = LVM_NULL; Loading
media/libeffects/lvm/lib/Eq/src/LVEQNB_Private.h +9 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,9 @@ /* */ /****************************************************************************************/ #ifdef BIQUAD_OPT #include <audio_utils/BiquadFilter.h> #endif #include "LVEQNB.h" /* Calling or Application layer definitions */ #include "BIQUAD.h" #include "LVC_Mixer.h" Loading Loading @@ -69,8 +72,14 @@ typedef struct { /* Aligned memory pointers */ LVM_FLOAT* pFastTemporary; /* Fast temporary data base address */ #ifdef BIQUAD_OPT std::vector<android::audio_utils::BiquadFilter<LVM_FLOAT>> eqBiquad; /* Biquad filter instances */ std::vector<LVM_FLOAT> gain; /* Gain values for all bands*/ #else Biquad_2I_Order2_FLOAT_Taps_t* pEQNB_Taps_Float; /* Equaliser Taps */ Biquad_FLOAT_Instance_t* pEQNB_FilterState_Float; /* State for each filter band */ #endif /* Filter definitions and call back */ LVM_UINT16 NBands; /* Number of bands */ Loading
media/libeffects/lvm/lib/Eq/src/LVEQNB_Process.cpp +11 −0 Original line number Diff line number Diff line Loading @@ -104,19 +104,30 @@ LVEQNB_ReturnStatus_en LVEQNB_Process( * Check if band is non-zero dB gain */ if (pInstance->pBandDefinitions[i].Gain != 0) { #ifndef BIQUAD_OPT /* * Get the address of the biquad instance */ Biquad_FLOAT_Instance_t* pBiquad = &pInstance->pEQNB_FilterState_Float[i]; #endif /* * Select single or double precision as required */ switch (pInstance->pBiquadType[i]) { case LVEQNB_SinglePrecision_Float: { #ifdef BIQUAD_OPT LVM_FLOAT* pTemp = pScratch + NrSamples; pInstance->eqBiquad[i].process(pTemp, pScratch, NrFrames); const auto gain = pInstance->gain[i]; for (unsigned j = 0; j < NrSamples; ++j) { pScratch[j] += pTemp[j] * gain; } #else PK_Mc_D32F32C14G11_TRC_WRA_01(pBiquad, pScratch, pScratch, (LVM_INT16)NrFrames, (LVM_INT16)NrChannels); #endif break; } default: Loading