Home | History | Annotate | Download | only in lib
      1 /*
      2  * Copyright (C) 2004-2010 NXP Software
      3  * Copyright (C) 2010 The Android Open Source Project
      4  *
      5  * Licensed under the Apache License, Version 2.0 (the "License");
      6  * you may not use this file except in compliance with the License.
      7  * You may obtain a copy of the License at
      8  *
      9  *      http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  * Unless required by applicable law or agreed to in writing, software
     12  * distributed under the License is distributed on an "AS IS" BASIS,
     13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  * See the License for the specific language governing permissions and
     15  * limitations under the License.
     16  */
     17 
     18 #ifndef _BIQUAD_H_
     19 #define _BIQUAD_H_
     20 
     21 
     22 #ifdef __cplusplus
     23 extern "C" {
     24 #endif /* __cplusplus */
     25 
     26 #include "LVM_Types.h"
     27 /**********************************************************************************
     28    INSTANCE MEMORY TYPE DEFINITION
     29 ***********************************************************************************/
     30 
     31 typedef struct
     32 {
     33     LVM_INT32 Storage[6];
     34 
     35 } Biquad_Instance_t;
     36 
     37 
     38 /**********************************************************************************
     39    COEFFICIENT TYPE DEFINITIONS
     40 ***********************************************************************************/
     41 
     42 /*** Biquad coefficients **********************************************************/
     43 typedef struct
     44 {
     45     LVM_INT16 A2;   /*  a2  */
     46     LVM_INT16 A1;   /*  a1  */
     47     LVM_INT16 A0;   /*  a0  */
     48     LVM_INT16 B2;   /* -b2! */
     49     LVM_INT16 B1;   /* -b1! */
     50 } BQ_C16_Coefs_t;
     51 
     52 typedef struct
     53 {
     54     LVM_INT32  A2;   /*  a2  */
     55     LVM_INT32  A1;   /*  a1  */
     56     LVM_INT32  A0;   /*  a0  */
     57     LVM_INT32  B2;   /* -b2! */
     58     LVM_INT32  B1;   /* -b1! */
     59 } BQ_C32_Coefs_t;
     60 
     61 /*** First order coefficients *****************************************************/
     62 typedef struct
     63 {
     64     LVM_INT16 A1;   /*  a1  */
     65     LVM_INT16 A0;   /*  a0  */
     66     LVM_INT16 B1;   /* -b1! */
     67 } FO_C16_Coefs_t;
     68 
     69 typedef struct
     70 {
     71     LVM_INT32  A1;   /*  a1  */
     72     LVM_INT32  A0;   /*  a0  */
     73     LVM_INT32  B1;   /* -b1! */
     74 } FO_C32_Coefs_t;
     75 
     76 /*** First order coefficients with Shift*****************************************************/
     77 typedef struct
     78 {
     79     LVM_INT16 A1;    /*  a1  */
     80     LVM_INT16 A0;    /*  a0  */
     81     LVM_INT16 B1;    /* -b1! */
     82     LVM_INT16 Shift; /* Shift */
     83 } FO_C16_LShx_Coefs_t;
     84 
     85 /*** Band pass coefficients *******************************************************/
     86 typedef struct
     87 {
     88     LVM_INT16 A0;   /*  a0  */
     89     LVM_INT16 B2;   /* -b2! */
     90     LVM_INT16 B1;   /* -b1! */
     91 } BP_C16_Coefs_t;
     92 
     93 typedef struct
     94 {
     95     LVM_INT32  A0;   /*  a0  */
     96     LVM_INT32  B2;   /* -b2! */
     97     LVM_INT32  B1;   /* -b1! */
     98 } BP_C32_Coefs_t;
     99 
    100 /*** Peaking coefficients *********************************************************/
    101 typedef struct
    102 {
    103     LVM_INT16 A0;   /*  a0  */
    104     LVM_INT16 B2;   /* -b2! */
    105     LVM_INT16 B1;   /* -b1! */
    106     LVM_INT16  G;   /* Gain */
    107 } PK_C16_Coefs_t;
    108 
    109 typedef struct
    110 {
    111     LVM_INT32  A0;   /*  a0  */
    112     LVM_INT32  B2;   /* -b2! */
    113     LVM_INT32  B1;   /* -b1! */
    114     LVM_INT16  G;   /* Gain */
    115 } PK_C32_Coefs_t;
    116 
    117 
    118 /**********************************************************************************
    119    TAPS TYPE DEFINITIONS
    120 ***********************************************************************************/
    121 
    122 /*** Types used for first order and shelving filter *******************************/
    123 
    124 typedef struct
    125 {
    126     LVM_INT32 Storage[ (1*2) ];  /* One channel, two taps of size LVM_INT32 */
    127 } Biquad_1I_Order1_Taps_t;
    128 
    129 typedef struct
    130 {
    131     LVM_INT32 Storage[ (2*2) ];  /* Two channels, two taps of size LVM_INT32 */
    132 } Biquad_2I_Order1_Taps_t;
    133 
    134 
    135 /*** Types used for biquad, band pass and peaking filter **************************/
    136 
    137 typedef struct
    138 {
    139     LVM_INT32 Storage[ (1*4) ];  /* One channel, four taps of size LVM_INT32 */
    140 } Biquad_1I_Order2_Taps_t;
    141 
    142 typedef struct
    143 {
    144     LVM_INT32 Storage[ (2*4) ];  /* Two channels, four taps of size LVM_INT32 */
    145 } Biquad_2I_Order2_Taps_t;
    146 
    147 /* The names of the functions are changed to satisfy QAC rules: Name should be Unique withing 16 characters*/
    148 #define BQ_2I_D32F32Cll_TRC_WRA_01_Init  Init_BQ_2I_D32F32Cll_TRC_WRA_01
    149 #define BP_1I_D32F32C30_TRC_WRA_02       TWO_BP_1I_D32F32C30_TRC_WRA_02
    150 
    151 /**********************************************************************************
    152    FUNCTION PROTOTYPES: BIQUAD FILTERS
    153 ***********************************************************************************/
    154 
    155 /*** 16 bit data path *************************************************************/
    156 
    157 void BQ_2I_D16F32Css_TRC_WRA_01_Init (      Biquad_Instance_t       *pInstance,
    158                                             Biquad_2I_Order2_Taps_t *pTaps,
    159                                             BQ_C16_Coefs_t          *pCoef);
    160 
    161 void BQ_2I_D16F32C15_TRC_WRA_01 (           Biquad_Instance_t       *pInstance,
    162                                             LVM_INT16                    *pDataIn,
    163                                             LVM_INT16                    *pDataOut,
    164                                             LVM_INT16                    NrSamples);
    165 
    166 void BQ_2I_D16F32C14_TRC_WRA_01 (           Biquad_Instance_t       *pInstance,
    167                                             LVM_INT16                    *pDataIn,
    168                                             LVM_INT16                    *pDataOut,
    169                                             LVM_INT16                    NrSamples);
    170 
    171 void BQ_2I_D16F32C13_TRC_WRA_01 (           Biquad_Instance_t       *pInstance,
    172                                             LVM_INT16                    *pDataIn,
    173                                             LVM_INT16                    *pDataOut,
    174                                             LVM_INT16                    NrSamples);
    175 
    176 void BQ_2I_D16F16Css_TRC_WRA_01_Init (      Biquad_Instance_t       *pInstance,
    177                                             Biquad_2I_Order2_Taps_t *pTaps,
    178                                             BQ_C16_Coefs_t          *pCoef);
    179 
    180 void BQ_2I_D16F16C15_TRC_WRA_01(            Biquad_Instance_t       *pInstance,
    181                                             LVM_INT16                   *pDataIn,
    182                                             LVM_INT16                   *pDataOut,
    183                                             LVM_INT16                   NrSamples);
    184 
    185 void BQ_2I_D16F16C14_TRC_WRA_01(            Biquad_Instance_t       *pInstance,
    186                                             LVM_INT16                   *pDataIn,
    187                                             LVM_INT16                   *pDataOut,
    188                                             LVM_INT16                   NrSamples);
    189 
    190 void BQ_1I_D16F16Css_TRC_WRA_01_Init (      Biquad_Instance_t       *pInstance,
    191                                             Biquad_1I_Order2_Taps_t *pTaps,
    192                                             BQ_C16_Coefs_t          *pCoef);
    193 
    194 void BQ_1I_D16F16C15_TRC_WRA_01(            Biquad_Instance_t       *pInstance,
    195                                             LVM_INT16                   *pDataIn,
    196                                             LVM_INT16                   *pDataOut,
    197                                             LVM_INT16                   NrSamples);
    198 
    199 void BQ_1I_D16F32Css_TRC_WRA_01_Init (      Biquad_Instance_t       *pInstance,
    200                                             Biquad_1I_Order2_Taps_t *pTaps,
    201                                             BQ_C16_Coefs_t          *pCoef);
    202 
    203 void BQ_1I_D16F32C14_TRC_WRA_01 (           Biquad_Instance_t       *pInstance,
    204                                             LVM_INT16                    *pDataIn,
    205                                             LVM_INT16                    *pDataOut,
    206                                             LVM_INT16                    NrSamples);
    207 
    208 /*** 32 bit data path *************************************************************/
    209 
    210 void BQ_2I_D32F32Cll_TRC_WRA_01_Init (      Biquad_Instance_t       *pInstance,
    211                                             Biquad_2I_Order2_Taps_t *pTaps,
    212                                             BQ_C32_Coefs_t          *pCoef);
    213 
    214 void BQ_2I_D32F32C30_TRC_WRA_01 (           Biquad_Instance_t       *pInstance,
    215                                             LVM_INT32                    *pDataIn,
    216                                             LVM_INT32                    *pDataOut,
    217                                             LVM_INT16                    NrSamples);
    218 
    219 /**********************************************************************************
    220    FUNCTION PROTOTYPES: FIRST ORDER FILTERS
    221 ***********************************************************************************/
    222 
    223 /*** 16 bit data path *************************************************************/
    224 
    225 void FO_1I_D16F16Css_TRC_WRA_01_Init(       Biquad_Instance_t       *pInstance,
    226                                             Biquad_1I_Order1_Taps_t *pTaps,
    227                                             FO_C16_Coefs_t          *pCoef);
    228 
    229 void FO_1I_D16F16C15_TRC_WRA_01(            Biquad_Instance_t       *pInstance,
    230                                             LVM_INT16                   *pDataIn,
    231                                             LVM_INT16                   *pDataOut,
    232                                             LVM_INT16                   NrSamples);
    233 
    234 void FO_2I_D16F32Css_LShx_TRC_WRA_01_Init(Biquad_Instance_t       *pInstance,
    235                                           Biquad_2I_Order1_Taps_t *pTaps,
    236                                           FO_C16_LShx_Coefs_t     *pCoef);
    237 
    238 void FO_2I_D16F32C15_LShx_TRC_WRA_01(Biquad_Instance_t       *pInstance,
    239                                      LVM_INT16               *pDataIn,
    240                                      LVM_INT16               *pDataOut,
    241                                      LVM_INT16               NrSamples);
    242 
    243 /*** 32 bit data path *************************************************************/
    244 
    245 void FO_1I_D32F32Cll_TRC_WRA_01_Init(       Biquad_Instance_t       *pInstance,
    246                                             Biquad_1I_Order1_Taps_t *pTaps,
    247                                             FO_C32_Coefs_t          *pCoef);
    248 
    249 void FO_1I_D32F32C31_TRC_WRA_01(            Biquad_Instance_t       *pInstance,
    250                                             LVM_INT32               *pDataIn,
    251                                             LVM_INT32               *pDataOut,
    252                                             LVM_INT16               NrSamples);
    253 
    254 /**********************************************************************************
    255    FUNCTION PROTOTYPES: BAND PASS FILTERS
    256 ***********************************************************************************/
    257 
    258 /*** 16 bit data path *************************************************************/
    259 
    260 void BP_1I_D16F16Css_TRC_WRA_01_Init (      Biquad_Instance_t       *pInstance,
    261                                             Biquad_1I_Order2_Taps_t *pTaps,
    262                                             BP_C16_Coefs_t          *pCoef);
    263 
    264 void BP_1I_D16F16C14_TRC_WRA_01 (           Biquad_Instance_t       *pInstance,
    265                                             LVM_INT16                    *pDataIn,
    266                                             LVM_INT16                    *pDataOut,
    267                                             LVM_INT16                    NrSamples);
    268 
    269 void BP_1I_D16F32Cll_TRC_WRA_01_Init (      Biquad_Instance_t       *pInstance,
    270                                             Biquad_1I_Order2_Taps_t *pTaps,
    271                                             BP_C32_Coefs_t          *pCoef);
    272 
    273 void BP_1I_D16F32C30_TRC_WRA_01 (           Biquad_Instance_t       *pInstance,
    274                                             LVM_INT16                    *pDataIn,
    275                                             LVM_INT16                    *pDataOut,
    276                                             LVM_INT16                    NrSamples);
    277 
    278 
    279 /*** 32 bit data path *************************************************************/
    280 
    281 void BP_1I_D32F32Cll_TRC_WRA_02_Init (      Biquad_Instance_t       *pInstance,
    282                                             Biquad_1I_Order2_Taps_t *pTaps,
    283                                             BP_C32_Coefs_t          *pCoef);
    284 
    285 void BP_1I_D32F32C30_TRC_WRA_02(            Biquad_Instance_t       *pInstance,
    286                                             LVM_INT32                    *pDataIn,
    287                                             LVM_INT32                    *pDataOut,
    288                                             LVM_INT16                    NrSamples);
    289 
    290 
    291 /*** 32 bit data path STEREO ******************************************************/
    292 
    293 void PK_2I_D32F32CllGss_TRC_WRA_01_Init (   Biquad_Instance_t       *pInstance,
    294                                             Biquad_2I_Order2_Taps_t *pTaps,
    295                                             PK_C32_Coefs_t          *pCoef);
    296 
    297 void PK_2I_D32F32C30G11_TRC_WRA_01 (        Biquad_Instance_t       *pInstance,
    298                                             LVM_INT32                    *pDataIn,
    299                                             LVM_INT32                    *pDataOut,
    300                                             LVM_INT16                    NrSamples);
    301 
    302 void PK_2I_D32F32CssGss_TRC_WRA_01_Init (   Biquad_Instance_t       *pInstance,
    303                                             Biquad_2I_Order2_Taps_t *pTaps,
    304                                             PK_C16_Coefs_t          *pCoef);
    305 
    306 void PK_2I_D32F32C14G11_TRC_WRA_01 (        Biquad_Instance_t       *pInstance,
    307                                             LVM_INT32                    *pDataIn,
    308                                             LVM_INT32                    *pDataOut,
    309                                             LVM_INT16                    NrSamples);
    310 
    311 
    312 /**********************************************************************************
    313    FUNCTION PROTOTYPES: DC REMOVAL FILTERS
    314 ***********************************************************************************/
    315 
    316 /*** 16 bit data path STEREO ******************************************************/
    317 
    318 void DC_2I_D16_TRC_WRA_01_Init     (        Biquad_Instance_t       *pInstance);
    319 
    320 void DC_2I_D16_TRC_WRA_01          (        Biquad_Instance_t       *pInstance,
    321                                             LVM_INT16               *pDataIn,
    322                                             LVM_INT16               *pDataOut,
    323                                             LVM_INT16               NrSamples);
    324 
    325 #ifdef __cplusplus
    326 }
    327 #endif /* __cplusplus */
    328 
    329 
    330 /**********************************************************************************/
    331 
    332 #endif  /** _BIQUAD_H_ **/
    333 
    334