Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 11824f03 authored by Andy Hung's avatar Andy Hung Committed by Gerrit Code Review
Browse files

Merge "lvm: Remove code under #ifndef BIQUAD_OPT"

parents fcd7a562 824611ee
Loading
Loading
Loading
Loading
+0 −31
Original line number Diff line number Diff line
@@ -42,33 +42,6 @@ cc_library_static {
        "Common/src/InstAlloc.cpp",
        "Common/src/DC_2I_D16_TRC_WRA_01.cpp",
        "Common/src/DC_2I_D16_TRC_WRA_01_Init.cpp",
        "Common/src/FO_2I_D16F32C15_LShx_TRC_WRA_01.cpp",
        "Common/src/FO_2I_D16F32Css_LShx_TRC_WRA_01_Init.cpp",
        "Common/src/FO_1I_D16F16C15_TRC_WRA_01.cpp",
        "Common/src/FO_1I_D16F16Css_TRC_WRA_01_Init.cpp",
        "Common/src/BP_1I_D16F32C30_TRC_WRA_01.cpp",
        "Common/src/BP_1I_D16F16C14_TRC_WRA_01.cpp",
        "Common/src/BP_1I_D32F32C30_TRC_WRA_02.cpp",
        "Common/src/BP_1I_D16F16Css_TRC_WRA_01_Init.cpp",
        "Common/src/BP_1I_D16F32Cll_TRC_WRA_01_Init.cpp",
        "Common/src/BP_1I_D32F32Cll_TRC_WRA_02_Init.cpp",
        "Common/src/BQ_2I_D32F32Cll_TRC_WRA_01_Init.cpp",
        "Common/src/BQ_2I_D32F32C30_TRC_WRA_01.cpp",
        "Common/src/BQ_2I_D16F32C15_TRC_WRA_01.cpp",
        "Common/src/BQ_2I_D16F32C14_TRC_WRA_01.cpp",
        "Common/src/BQ_2I_D16F32C13_TRC_WRA_01.cpp",
        "Common/src/BQ_2I_D16F32Css_TRC_WRA_01_init.cpp",
        "Common/src/BQ_2I_D16F16C15_TRC_WRA_01.cpp",
        "Common/src/BQ_2I_D16F16C14_TRC_WRA_01.cpp",
        "Common/src/BQ_2I_D16F16Css_TRC_WRA_01_Init.cpp",
        "Common/src/BQ_1I_D16F16C15_TRC_WRA_01.cpp",
        "Common/src/BQ_1I_D16F16Css_TRC_WRA_01_Init.cpp",
        "Common/src/BQ_1I_D16F32C14_TRC_WRA_01.cpp",
        "Common/src/BQ_1I_D16F32Css_TRC_WRA_01_init.cpp",
        "Common/src/PK_2I_D32F32C30G11_TRC_WRA_01.cpp",
        "Common/src/PK_2I_D32F32C14G11_TRC_WRA_01.cpp",
        "Common/src/PK_2I_D32F32CssGss_TRC_WRA_01_Init.cpp",
        "Common/src/PK_2I_D32F32CllGss_TRC_WRA_01_Init.cpp",
        "Common/src/Copy_16.cpp",
        "Common/src/MonoTo2I_32.cpp",
        "Common/src/LoadConst_32.cpp",
@@ -129,7 +102,6 @@ cc_library_static {
        "libhardware_headers",
    ],
    cppflags: [
        "-DBIQUAD_OPT",
        "-fvisibility=hidden",
        "-Wall",
        "-Werror",
@@ -161,8 +133,6 @@ cc_library_static {
        "Common/src/LoadConst_32.cpp",
        "Common/src/From2iToMono_32.cpp",
        "Common/src/Mult3s_32x16.cpp",
        "Common/src/FO_1I_D32F32C31_TRC_WRA_01.cpp",
        "Common/src/FO_1I_D32F32Cll_TRC_WRA_01_Init.cpp",
        "Common/src/Copy_16.cpp",
        "Common/src/Mac3s_Sat_32x16.cpp",
        "Common/src/Shift_Sat_v32xv32.cpp",
@@ -195,7 +165,6 @@ cc_library_static {
        "libaudioutils",
    ],
    cppflags: [
        "-DBIQUAD_OPT",
        "-fvisibility=hidden",
        "-Wall",
        "-Werror",
+0 −22
Original line number Diff line number Diff line
@@ -21,10 +21,8 @@
/*                                                                                      */
/****************************************************************************************/

#ifdef BIQUAD_OPT
#include <audio_utils/BiquadFilter.h>
#include <system/audio.h>
#endif
#include "LVDBE.h"
#include "LVDBE_Private.h"
#include "VectorArithmetic.h"
@@ -111,37 +109,19 @@ void LVDBE_SetFilters(LVDBE_Instance_t* pInstance, LVDBE_Params_t* pParams) {
    /*
     * Setup the high pass filter
     */
#ifdef BIQUAD_OPT
    std::array<LVM_FLOAT, android::audio_utils::kBiquadNumCoefs> coefs = {
            LVDBE_HPF_Table[Offset].A0, LVDBE_HPF_Table[Offset].A1, LVDBE_HPF_Table[Offset].A2,
            -(LVDBE_HPF_Table[Offset].B1), -(LVDBE_HPF_Table[Offset].B2)};
    pInstance->pHPFBiquad
            ->setCoefficients<std::array<LVM_FLOAT, android::audio_utils::kBiquadNumCoefs>>(coefs);
#else
    LoadConst_Float(0,                                      /* Clear the history, value 0 */
                    (LVM_FLOAT*)&pInstance->pData->HPFTaps, /* Destination */
                    sizeof(pInstance->pData->HPFTaps) / sizeof(LVM_FLOAT)); /* Number of words */
    BQ_2I_D32F32Cll_TRC_WRA_01_Init(&pInstance->pCoef->HPFInstance, /* Initialise the filter */
                                    &pInstance->pData->HPFTaps,
                                    (BQ_FLOAT_Coefs_t*)&LVDBE_HPF_Table[Offset]);
#endif

    /*
     * Setup the band pass filter
     */
#ifdef BIQUAD_OPT
    coefs = {LVDBE_BPF_Table[Offset].A0, 0.0, -(LVDBE_BPF_Table[Offset].A0),
             -(LVDBE_BPF_Table[Offset].B1), -(LVDBE_BPF_Table[Offset].B2)};
    pInstance->pBPFBiquad
            ->setCoefficients<std::array<LVM_FLOAT, android::audio_utils::kBiquadNumCoefs>>(coefs);
#else
    LoadConst_Float(0,                                      /* Clear the history, value 0 */
                    (LVM_FLOAT*)&pInstance->pData->BPFTaps, /* Destination */
                    sizeof(pInstance->pData->BPFTaps) / sizeof(LVM_FLOAT)); /* Number of words */
    BP_1I_D32F32Cll_TRC_WRA_02_Init(&pInstance->pCoef->BPFInstance, /* Initialise the filter */
                                    &pInstance->pData->BPFTaps,
                                    (BP_FLOAT_Coefs_t*)&LVDBE_BPF_Table[Offset]);
#endif
}

/************************************************************************************/
@@ -294,13 +274,11 @@ LVDBE_ReturnStatus_en LVDBE_Control(LVDBE_Handle_t hInstance, LVDBE_Params_t* pP
    LVDBE_Instance_t* pInstance = (LVDBE_Instance_t*)hInstance;
    LVMixer3_2St_FLOAT_st* pBypassMixer_Instance = &pInstance->pData->BypassMixer;

#ifdef BIQUAD_OPT
    /*
     * Create biquad instance
     */
    pInstance->pHPFBiquad.reset(new android::audio_utils::BiquadFilter<LVM_FLOAT>(
            (FCC_1 == pParams->NrChannels) ? FCC_2 : pParams->NrChannels));
#endif

    /*
     * Update the filters
+0 −15
Original line number Diff line number Diff line
@@ -21,9 +21,7 @@
/*                                                                                      */
/****************************************************************************************/

#ifdef BIQUAD_OPT
#include <system/audio.h>
#endif
#include <stdlib.h>
#include "LVDBE.h"
#include "LVDBE_Private.h"
@@ -92,19 +90,12 @@ LVDBE_ReturnStatus_en LVDBE_Init(LVDBE_Handle_t* phInstance, LVDBE_Capabilities_
    if (pInstance->pData == NULL) {
        return LVDBE_NULLADDRESS;
    }
#ifdef BIQUAD_OPT
    /*
     * Create biquad instance
     */
    pInstance->pHPFBiquad.reset(
            new android::audio_utils::BiquadFilter<LVM_FLOAT>(LVM_MAX_CHANNELS));
    pInstance->pBPFBiquad.reset(new android::audio_utils::BiquadFilter<LVM_FLOAT>(FCC_1));
#else
    pInstance->pCoef = (LVDBE_Coef_FLOAT_t*)calloc(1, sizeof(*(pInstance->pCoef)));
    if (pInstance->pCoef == NULL) {
        return LVDBE_NULLADDRESS;
    }
#endif

    /*
     * Initialise the filters
@@ -194,12 +185,6 @@ void LVDBE_DeInit(LVDBE_Handle_t* phInstance) {
        free(pInstance->pData);
        pInstance->pData = LVM_NULL;
    }
#ifndef BIQUAD_OPT
    if (pInstance->pCoef != LVM_NULL) {
        free(pInstance->pCoef);
        pInstance->pCoef = LVM_NULL;
    }
#endif
    free(pInstance);
    *phInstance = LVM_NULL;
}
+0 −19
Original line number Diff line number Diff line
@@ -33,9 +33,7 @@
/*                                                                                      */
/****************************************************************************************/

#ifdef BIQUAD_OPT
#include <audio_utils/BiquadFilter.h>
#endif
#include "LVDBE.h" /* Calling or Application layer definitions */
#include "BIQUAD.h"
#include "LVC_Mixer.h"
@@ -66,23 +64,11 @@ typedef struct {
    AGC_MIX_VOL_2St1Mon_FLOAT_t AGCInstance; /* AGC instance parameters */

    /* Process variables */
#ifndef BIQUAD_OPT
    Biquad_2I_Order2_FLOAT_Taps_t HPFTaps; /* High pass filter taps */
    Biquad_1I_Order2_FLOAT_Taps_t BPFTaps; /* Band pass filter taps */
#endif
    LVMixer3_1St_FLOAT_st BypassVolume;    /* Bypass volume scaler */
    LVMixer3_2St_FLOAT_st BypassMixer;     /* Bypass Mixer for Click Removal */

} LVDBE_Data_FLOAT_t;

#ifndef BIQUAD_OPT
/* Coefs structure */
typedef struct {
    /* Process variables */
    Biquad_FLOAT_Instance_t HPFInstance; /* High pass filter instance */
    Biquad_FLOAT_Instance_t BPFInstance; /* Band pass filter instance */
} LVDBE_Coef_FLOAT_t;
#endif

/* Instance structure */
typedef struct {
@@ -92,16 +78,11 @@ typedef struct {

    /* Data and coefficient pointers */
    LVDBE_Data_FLOAT_t* pData; /* Instance data */
#ifndef BIQUAD_OPT
    LVDBE_Coef_FLOAT_t* pCoef; /* Instance coefficients */
#endif
    void* pScratch;            /* scratch pointer */
#ifdef BIQUAD_OPT
    std::unique_ptr<android::audio_utils::BiquadFilter<LVM_FLOAT>>
            pHPFBiquad; /* Biquad filter instance for HPF */
    std::unique_ptr<android::audio_utils::BiquadFilter<LVM_FLOAT>>
            pBPFBiquad; /* Biquad filter instance for BPF */
#endif
} LVDBE_Instance_t;

/****************************************************************************************/
+0 −16
Original line number Diff line number Diff line
@@ -20,9 +20,7 @@
/*    Includes                                                                          */
/*                                                                                      */
/****************************************************************************************/
#ifdef BIQUAD_OPT
#include <audio_utils/BiquadFilter.h>
#endif

#include <string.h>  // memset
#include "LVDBE.h"
@@ -128,14 +126,7 @@ LVDBE_ReturnStatus_en LVDBE_Process(
         * Apply the high pass filter if selected
         */
        if (pInstance->Params.HPFSelect == LVDBE_HPF_ON) {
#ifdef BIQUAD_OPT
            pInstance->pHPFBiquad->process(pScratch, pScratch, NrFrames);
#else
            BQ_MC_D32F32C30_TRC_WRA_01(&pInstance->pCoef->HPFInstance, /* Filter instance      */
                                       pScratch,                       /* Source               */
                                       pScratch,                       /* Destination          */
                                       (LVM_INT16)NrFrames, (LVM_INT16)NrChannels);
#endif
        }

        /*
@@ -149,14 +140,7 @@ LVDBE_ReturnStatus_en LVDBE_Process(
        /*
         * Apply the band pass filter
         */
#ifdef BIQUAD_OPT
        pInstance->pBPFBiquad->process(pMono, pMono, NrFrames);
#else
        BP_1I_D32F32C30_TRC_WRA_02(&pInstance->pCoef->BPFInstance, /* Filter instance       */
                                   pMono,                          /* Source                */
                                   pMono,                          /* Destination           */
                                   (LVM_INT16)NrFrames);
#endif

        /*
         * Apply the AGC and mix
Loading