Loading media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Control.cpp +36 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,9 @@ * limitations under the License. */ #ifdef BIQUAD_OPT #include <system/audio.h> #endif #include "LVPSA.h" #include "LVPSA_Private.h" #include "VectorArithmetic.h" Loading Loading @@ -182,6 +185,13 @@ LVPSA_RETURN LVPSA_ApplyNewSettings(LVPSA_InstancePr_t* pInst) { break; } } #ifdef BIQUAD_OPT /* * Create biquad instance */ pInst->specBiquad.resize(pInst->nRelevantFilters, android::audio_utils::BiquadFilter<LVM_FLOAT>(FCC_1)); #endif LVPSA_SetBPFiltersType(pInst, &Params); LVPSA_SetBPFCoefficients(pInst, &Params); LVPSA_SetQPFCoefficients(pInst, &Params); Loading Loading @@ -302,8 +312,18 @@ LVPSA_RETURN LVPSA_SetBPFCoefficients(LVPSA_InstancePr_t* pInst, LVPSA_ControlPa /* * Set the coefficients */ #ifdef BIQUAD_OPT const std::array<LVM_FLOAT, android::audio_utils::kBiquadNumCoefs> coefs = { Coefficients.A0, 0.0, -(Coefficients.A0), -(Coefficients.B1), -(Coefficients.B2)}; pInst->specBiquad[ii] .setCoefficients< std::array<LVM_FLOAT, android::audio_utils::kBiquadNumCoefs>>( coefs); #else BP_1I_D16F32Cll_TRC_WRA_01_Init(&pInst->pBP_Instances[ii], &pInst->pBP_Taps[ii], &Coefficients); #endif break; } Loading @@ -319,8 +339,18 @@ LVPSA_RETURN LVPSA_SetBPFCoefficients(LVPSA_InstancePr_t* pInst, LVPSA_ControlPa /* * Set the coefficients */ #ifdef BIQUAD_OPT const std::array<LVM_FLOAT, android::audio_utils::kBiquadNumCoefs> coefs = { Coefficients.A0, 0.0, -(Coefficients.A0), -(Coefficients.B1), -(Coefficients.B2)}; pInst->specBiquad[ii] .setCoefficients< std::array<LVM_FLOAT, android::audio_utils::kBiquadNumCoefs>>( coefs); #else BP_1I_D16F16Css_TRC_WRA_01_Init(&pInst->pBP_Instances[ii], &pInst->pBP_Taps[ii], &Coefficients); #endif break; } } Loading Loading @@ -604,6 +634,11 @@ LVPSA_RETURN LVPSA_BPDoublePrecCoefs(LVM_UINT16 Fs, LVPSA_FilterParam_t* pFilter /* */ /************************************************************************************/ LVPSA_RETURN LVPSA_ClearFilterHistory(LVPSA_InstancePr_t* pInst) { #ifdef BIQUAD_OPT for (size_t i = 0; i < pInst->specBiquad.size(); i++) { pInst->specBiquad[i].clear(); } #else LVM_INT8* pTapAddress; LVM_UINT32 i; Loading @@ -617,6 +652,7 @@ LVPSA_RETURN LVPSA_ClearFilterHistory(LVPSA_InstancePr_t* pInst) { for (i = 0; i < pInst->nBands * sizeof(QPD_Taps_t); i++) { pTapAddress[i] = 0; } #endif return (LVPSA_OK); } media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Init.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -108,21 +108,25 @@ LVPSA_RETURN LVPSA_Init(pLVPSA_Handle_t* phInstance, LVPSA_InitParams_t* pInitPa if (pLVPSA_Inst->pBPFiltersPrecision == LVM_NULL) { return LVPSA_ERROR_NULLADDRESS; } #ifndef BIQUAD_OPT pLVPSA_Inst->pBP_Instances = (Biquad_FLOAT_Instance_t*)calloc( pInitParams->nBands, sizeof(*(pLVPSA_Inst->pBP_Instances))); if (pLVPSA_Inst->pBP_Instances == LVM_NULL) { return LVPSA_ERROR_NULLADDRESS; } #endif pLVPSA_Inst->pQPD_States = (QPD_FLOAT_State_t*)calloc(pInitParams->nBands, sizeof(*(pLVPSA_Inst->pQPD_States))); if (pLVPSA_Inst->pQPD_States == LVM_NULL) { return LVPSA_ERROR_NULLADDRESS; } #ifndef BIQUAD_OPT pLVPSA_Inst->pBP_Taps = (Biquad_1I_Order2_FLOAT_Taps_t*)calloc( pInitParams->nBands, sizeof(*(pLVPSA_Inst->pBP_Taps))); if (pLVPSA_Inst->pBP_Taps == LVM_NULL) { return LVPSA_ERROR_NULLADDRESS; } #endif pLVPSA_Inst->pQPD_Taps = (QPD_FLOAT_Taps_t*)calloc(pInitParams->nBands, sizeof(*(pLVPSA_Inst->pQPD_Taps))); if (pLVPSA_Inst->pQPD_Taps == LVM_NULL) { Loading Loading @@ -193,18 +197,22 @@ void LVPSA_DeInit(pLVPSA_Handle_t* phInstance) { free(pLVPSA_Inst->pBPFiltersPrecision); pLVPSA_Inst->pBPFiltersPrecision = LVM_NULL; } #ifndef BIQUAD_OPT if (pLVPSA_Inst->pBP_Instances != LVM_NULL) { free(pLVPSA_Inst->pBP_Instances); pLVPSA_Inst->pBP_Instances = LVM_NULL; } #endif if (pLVPSA_Inst->pQPD_States != LVM_NULL) { free(pLVPSA_Inst->pQPD_States); pLVPSA_Inst->pQPD_States = LVM_NULL; } #ifndef BIQUAD_OPT if (pLVPSA_Inst->pBP_Taps != LVM_NULL) { free(pLVPSA_Inst->pBP_Taps); pLVPSA_Inst->pBP_Taps = LVM_NULL; } #endif if (pLVPSA_Inst->pQPD_Taps != LVM_NULL) { free(pLVPSA_Inst->pQPD_Taps); pLVPSA_Inst->pQPD_Taps = LVM_NULL; Loading media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Private.h +8 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,9 @@ #ifndef _LVPSA_PRIVATE_H_ #define _LVPSA_PRIVATE_H_ #ifdef BIQUAD_OPT #include <audio_utils/BiquadFilter.h> #endif #include "LVPSA.h" #include "BIQUAD.h" #include "LVPSA_QPD.h" Loading Loading @@ -82,9 +85,14 @@ typedef struct { LVPSA_BPFilterPrecision_en* pBPFiltersPrecision; /* Points a nBands elements array that contains the filter precision for each band */ #ifdef BIQUAD_OPT std::vector<android::audio_utils::BiquadFilter<LVM_FLOAT>> specBiquad; /* Biquad filter instances */ #else Biquad_FLOAT_Instance_t* pBP_Instances; /* Points a nBands elements array that contains the band pass filter taps for each band */ Biquad_1I_Order2_FLOAT_Taps_t* pBP_Taps; #endif /* Points a nBands elements array that contains the QPD filter instance for each band */ QPD_FLOAT_State_t* pQPD_States; /* Points a nBands elements array that contains the QPD filter taps for each band */ Loading media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Process.cpp +10 −0 Original line number Diff line number Diff line Loading @@ -96,13 +96,23 @@ LVPSA_RETURN LVPSA_Process(pLVPSA_Handle_t hInstance, LVM_FLOAT* pLVPSA_InputSam for (ii = 0; ii < pLVPSA_Inst->nRelevantFilters; ii++) { switch (pLVPSA_Inst->pBPFiltersPrecision[ii]) { case LVPSA_SimplePrecisionFilter: #ifdef BIQUAD_OPT pLVPSA_Inst->specBiquad[ii].process(pScratch + InputBlockSize, pScratch, (LVM_INT16)InputBlockSize); #else BP_1I_D16F16C14_TRC_WRA_01(&pLVPSA_Inst->pBP_Instances[ii], pScratch, pScratch + InputBlockSize, (LVM_INT16)InputBlockSize); #endif break; case LVPSA_DoublePrecisionFilter: #ifdef BIQUAD_OPT pLVPSA_Inst->specBiquad[ii].process(pScratch + InputBlockSize, pScratch, (LVM_INT16)InputBlockSize); #else BP_1I_D16F32C30_TRC_WRA_01(&pLVPSA_Inst->pBP_Instances[ii], pScratch, pScratch + InputBlockSize, (LVM_INT16)InputBlockSize); #endif break; default: break; Loading Loading
media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Control.cpp +36 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,9 @@ * limitations under the License. */ #ifdef BIQUAD_OPT #include <system/audio.h> #endif #include "LVPSA.h" #include "LVPSA_Private.h" #include "VectorArithmetic.h" Loading Loading @@ -182,6 +185,13 @@ LVPSA_RETURN LVPSA_ApplyNewSettings(LVPSA_InstancePr_t* pInst) { break; } } #ifdef BIQUAD_OPT /* * Create biquad instance */ pInst->specBiquad.resize(pInst->nRelevantFilters, android::audio_utils::BiquadFilter<LVM_FLOAT>(FCC_1)); #endif LVPSA_SetBPFiltersType(pInst, &Params); LVPSA_SetBPFCoefficients(pInst, &Params); LVPSA_SetQPFCoefficients(pInst, &Params); Loading Loading @@ -302,8 +312,18 @@ LVPSA_RETURN LVPSA_SetBPFCoefficients(LVPSA_InstancePr_t* pInst, LVPSA_ControlPa /* * Set the coefficients */ #ifdef BIQUAD_OPT const std::array<LVM_FLOAT, android::audio_utils::kBiquadNumCoefs> coefs = { Coefficients.A0, 0.0, -(Coefficients.A0), -(Coefficients.B1), -(Coefficients.B2)}; pInst->specBiquad[ii] .setCoefficients< std::array<LVM_FLOAT, android::audio_utils::kBiquadNumCoefs>>( coefs); #else BP_1I_D16F32Cll_TRC_WRA_01_Init(&pInst->pBP_Instances[ii], &pInst->pBP_Taps[ii], &Coefficients); #endif break; } Loading @@ -319,8 +339,18 @@ LVPSA_RETURN LVPSA_SetBPFCoefficients(LVPSA_InstancePr_t* pInst, LVPSA_ControlPa /* * Set the coefficients */ #ifdef BIQUAD_OPT const std::array<LVM_FLOAT, android::audio_utils::kBiquadNumCoefs> coefs = { Coefficients.A0, 0.0, -(Coefficients.A0), -(Coefficients.B1), -(Coefficients.B2)}; pInst->specBiquad[ii] .setCoefficients< std::array<LVM_FLOAT, android::audio_utils::kBiquadNumCoefs>>( coefs); #else BP_1I_D16F16Css_TRC_WRA_01_Init(&pInst->pBP_Instances[ii], &pInst->pBP_Taps[ii], &Coefficients); #endif break; } } Loading Loading @@ -604,6 +634,11 @@ LVPSA_RETURN LVPSA_BPDoublePrecCoefs(LVM_UINT16 Fs, LVPSA_FilterParam_t* pFilter /* */ /************************************************************************************/ LVPSA_RETURN LVPSA_ClearFilterHistory(LVPSA_InstancePr_t* pInst) { #ifdef BIQUAD_OPT for (size_t i = 0; i < pInst->specBiquad.size(); i++) { pInst->specBiquad[i].clear(); } #else LVM_INT8* pTapAddress; LVM_UINT32 i; Loading @@ -617,6 +652,7 @@ LVPSA_RETURN LVPSA_ClearFilterHistory(LVPSA_InstancePr_t* pInst) { for (i = 0; i < pInst->nBands * sizeof(QPD_Taps_t); i++) { pTapAddress[i] = 0; } #endif return (LVPSA_OK); }
media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Init.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -108,21 +108,25 @@ LVPSA_RETURN LVPSA_Init(pLVPSA_Handle_t* phInstance, LVPSA_InitParams_t* pInitPa if (pLVPSA_Inst->pBPFiltersPrecision == LVM_NULL) { return LVPSA_ERROR_NULLADDRESS; } #ifndef BIQUAD_OPT pLVPSA_Inst->pBP_Instances = (Biquad_FLOAT_Instance_t*)calloc( pInitParams->nBands, sizeof(*(pLVPSA_Inst->pBP_Instances))); if (pLVPSA_Inst->pBP_Instances == LVM_NULL) { return LVPSA_ERROR_NULLADDRESS; } #endif pLVPSA_Inst->pQPD_States = (QPD_FLOAT_State_t*)calloc(pInitParams->nBands, sizeof(*(pLVPSA_Inst->pQPD_States))); if (pLVPSA_Inst->pQPD_States == LVM_NULL) { return LVPSA_ERROR_NULLADDRESS; } #ifndef BIQUAD_OPT pLVPSA_Inst->pBP_Taps = (Biquad_1I_Order2_FLOAT_Taps_t*)calloc( pInitParams->nBands, sizeof(*(pLVPSA_Inst->pBP_Taps))); if (pLVPSA_Inst->pBP_Taps == LVM_NULL) { return LVPSA_ERROR_NULLADDRESS; } #endif pLVPSA_Inst->pQPD_Taps = (QPD_FLOAT_Taps_t*)calloc(pInitParams->nBands, sizeof(*(pLVPSA_Inst->pQPD_Taps))); if (pLVPSA_Inst->pQPD_Taps == LVM_NULL) { Loading Loading @@ -193,18 +197,22 @@ void LVPSA_DeInit(pLVPSA_Handle_t* phInstance) { free(pLVPSA_Inst->pBPFiltersPrecision); pLVPSA_Inst->pBPFiltersPrecision = LVM_NULL; } #ifndef BIQUAD_OPT if (pLVPSA_Inst->pBP_Instances != LVM_NULL) { free(pLVPSA_Inst->pBP_Instances); pLVPSA_Inst->pBP_Instances = LVM_NULL; } #endif if (pLVPSA_Inst->pQPD_States != LVM_NULL) { free(pLVPSA_Inst->pQPD_States); pLVPSA_Inst->pQPD_States = LVM_NULL; } #ifndef BIQUAD_OPT if (pLVPSA_Inst->pBP_Taps != LVM_NULL) { free(pLVPSA_Inst->pBP_Taps); pLVPSA_Inst->pBP_Taps = LVM_NULL; } #endif if (pLVPSA_Inst->pQPD_Taps != LVM_NULL) { free(pLVPSA_Inst->pQPD_Taps); pLVPSA_Inst->pQPD_Taps = LVM_NULL; Loading
media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Private.h +8 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,9 @@ #ifndef _LVPSA_PRIVATE_H_ #define _LVPSA_PRIVATE_H_ #ifdef BIQUAD_OPT #include <audio_utils/BiquadFilter.h> #endif #include "LVPSA.h" #include "BIQUAD.h" #include "LVPSA_QPD.h" Loading Loading @@ -82,9 +85,14 @@ typedef struct { LVPSA_BPFilterPrecision_en* pBPFiltersPrecision; /* Points a nBands elements array that contains the filter precision for each band */ #ifdef BIQUAD_OPT std::vector<android::audio_utils::BiquadFilter<LVM_FLOAT>> specBiquad; /* Biquad filter instances */ #else Biquad_FLOAT_Instance_t* pBP_Instances; /* Points a nBands elements array that contains the band pass filter taps for each band */ Biquad_1I_Order2_FLOAT_Taps_t* pBP_Taps; #endif /* Points a nBands elements array that contains the QPD filter instance for each band */ QPD_FLOAT_State_t* pQPD_States; /* Points a nBands elements array that contains the QPD filter taps for each band */ Loading
media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Process.cpp +10 −0 Original line number Diff line number Diff line Loading @@ -96,13 +96,23 @@ LVPSA_RETURN LVPSA_Process(pLVPSA_Handle_t hInstance, LVM_FLOAT* pLVPSA_InputSam for (ii = 0; ii < pLVPSA_Inst->nRelevantFilters; ii++) { switch (pLVPSA_Inst->pBPFiltersPrecision[ii]) { case LVPSA_SimplePrecisionFilter: #ifdef BIQUAD_OPT pLVPSA_Inst->specBiquad[ii].process(pScratch + InputBlockSize, pScratch, (LVM_INT16)InputBlockSize); #else BP_1I_D16F16C14_TRC_WRA_01(&pLVPSA_Inst->pBP_Instances[ii], pScratch, pScratch + InputBlockSize, (LVM_INT16)InputBlockSize); #endif break; case LVPSA_DoublePrecisionFilter: #ifdef BIQUAD_OPT pLVPSA_Inst->specBiquad[ii].process(pScratch + InputBlockSize, pScratch, (LVM_INT16)InputBlockSize); #else BP_1I_D16F32C30_TRC_WRA_01(&pLVPSA_Inst->pBP_Instances[ii], pScratch, pScratch + InputBlockSize, (LVM_INT16)InputBlockSize); #endif break; default: break; Loading