LCOV - code coverage report
Current view: top level - lib_com - prot.h (source / functions) Hit Total Coverage
Test: Coverage on main -- short test vectors @ 6c9ddc4024a9c0e1ecb8f643f114a84a0e26ec6b Lines: 3 3 100.0 %
Date: 2025-05-23 08:37:30 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /******************************************************************************************************
       2             : 
       3             :    (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
       4             :    Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
       5             :    Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
       6             :    Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
       7             :    contributors to this repository. All Rights Reserved.
       8             : 
       9             :    This software is protected by copyright law and by international treaties.
      10             :    The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
      11             :    Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
      12             :    Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
      13             :    Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
      14             :    contributors to this repository retain full ownership rights in their respective contributions in
      15             :    the software. This notice grants no license of any kind, including but not limited to patent
      16             :    license, nor is any license granted by implication, estoppel or otherwise.
      17             : 
      18             :    Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
      19             :    contributions.
      20             : 
      21             :    This software is provided "AS IS", without any express or implied warranties. The software is in the
      22             :    development stage. It is intended exclusively for experts who have experience with such software and
      23             :    solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
      24             :    and fitness for a particular purpose are hereby disclaimed and excluded.
      25             : 
      26             :    Any dispute, controversy or claim arising under or in relation to providing this software shall be
      27             :    submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
      28             :    accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
      29             :    the United Nations Convention on Contracts on the International Sales of Goods.
      30             : 
      31             : *******************************************************************************************************/
      32             : 
      33             : /*====================================================================================
      34             :     EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
      35             :   ====================================================================================*/
      36             : 
      37             : #ifndef PROT_H
      38             : #define PROT_H
      39             : 
      40             : #include <stdio.h>
      41             : #include <stdlib.h>
      42             : #include <stdint.h>
      43             : #include "options.h"
      44             : #ifdef DEBUGGING
      45             : #include "debug.h"
      46             : #endif
      47             : #include "typedef.h"
      48             : #include "stat_enc.h"
      49             : #include "stat_dec.h"
      50             : #include "stat_com.h"
      51             : #include "ivas_stat_com.h"
      52             : #include "ivas_stat_enc.h"
      53             : #include "ivas_stat_dec.h"
      54             : #include "cnst.h"
      55             : #include "stl.h"
      56             : #include "ivas_error_utils.h"
      57             : 
      58             : 
      59             : /*----------------------------------------------------------------------------------*
      60             :  * Prototypes of global macros
      61             :  *----------------------------------------------------------------------------------*/
      62             : 
      63             : #ifndef min
      64             : #define min( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) )
      65             : #endif
      66             : 
      67             : #ifndef max
      68             : #define max( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) )
      69             : #endif
      70             : 
      71             : #ifndef TRUNC
      72             : #define TRUNC( x ) ( (int16_t) ( ( ( x ) >= 32767. ? 32767 : ( ( x ) <= -32768. ? -32768 : ( x ) ) ) + 0.5 ) )
      73             : #endif
      74             : 
      75             : #define log_base_2( x ) ( (double) log( (double) ( x ) ) * 1.4426950408889634074f )
      76             : #define round_f( x )    ( ( ( x ) > 0 ) ? (int32_t) ( ( x ) + 0.5f ) : ( -(int32_t) ( ( -x ) + 0.5f ) ) )
      77             : 
      78             : #ifndef ABSVAL
      79             : #define ABSVAL( a ) ( ( a ) >= 0 ? ( a ) : ( -( a ) ) )
      80             : #endif
      81             : 
      82             : #ifndef SQR
      83             : #define SQR( a ) ( ( a ) * ( a ) )
      84             : #endif
      85             : 
      86             : #ifndef SWAP
      87             : #define SWAP( a, b )   \
      88             :     {                  \
      89             :         tempr = ( a ); \
      90             :         ( a ) = ( b ); \
      91             :         ( b ) = tempr; \
      92             :     }
      93             : #endif
      94             : 
      95             : #ifndef swap
      96             : #define swap( x, y, type ) \
      97             :     {                      \
      98             :         type u__p;         \
      99             :         u__p = x;          \
     100             :         x = y;             \
     101             :         y = u__p;          \
     102             :     }
     103             : #endif
     104             : 
     105             : #define set_max( a, b )   \
     106             :     {                     \
     107             :         if ( ( b ) > *a ) \
     108             :         {                 \
     109             :             *a = ( b );   \
     110             :         }                 \
     111             :     } /* If the first argument is already the highes or lowest, nothing is done. */
     112             : #define set_min( a, b )   \
     113             :     {                     \
     114             :         if ( ( b ) < *a ) \
     115             :         {                 \
     116             :             *a = ( b );   \
     117             :         }                 \
     118             :     } /* Otherwise, the 2nd arg is stored at the address of the first arg. */
     119             : 
     120      686520 : static __inline Word16 L_Extract_lc( const Word32 L_32, Word16 *p_hi )
     121             : {
     122      686520 :     *p_hi = extract_h( L_32 );
     123      686520 :     return lshr( extract_l( L_32 ), 1 );
     124             : }
     125             : 
     126             : /*----------------------------------------------------------------------------------*
     127             :  * MODE1 prototypes
     128             :  *----------------------------------------------------------------------------------*/
     129             : 
     130             : /*! r: inverse square root of input value */
     131             : float inv_sqrt(
     132             :     const float x /* i  : input value                                     */
     133             : );
     134             : 
     135             : /*! r: inverse square root of input value (float) */
     136             : float inv_sqrtf(
     137             :     const float x /* i  : input value                                     */
     138             : );
     139             : 
     140             : /*! r: output random value */
     141             : int16_t own_random(
     142             :     int16_t *seed /* i/o: random seed                                     */
     143             : );
     144             : 
     145             : /*! r: sign of x (+1/-1) */
     146             : float sign(
     147             :     const float x /* i  : input value of x                                */
     148             : );
     149             : 
     150             : /*! r: logarithm2 of x */
     151             : float log2_f(
     152             :     const float x /* i  : input value of x                                */
     153             : );
     154             : 
     155             : int16_t norm_ul(
     156             :     uint32_t UL_var1 );
     157             : 
     158             : /*! r: sum of all vector elements */
     159             : int16_t sum_s(
     160             :     const int16_t *vec, /* i  : input vector                                    */
     161             :     const int16_t lvec  /* i  : length of input vector                          */
     162             : );
     163             : 
     164             : #ifdef DEBUGGING
     165             : /*! r: sum of all vector elements */
     166             : int32_t sum_l(
     167             :     const int32_t *vec, /* i  : input vector                                    */
     168             :     const int16_t lvec  /* i  : length of input vector                          */
     169             : );
     170             : 
     171             : #endif
     172             : /*! r: sum of all vector elements */
     173             : float sum_f(
     174             :     const float *vec,  /* i  : input vector                                    */
     175             :     const int16_t lvec /* i  : length of input vector                          */
     176             : );
     177             : 
     178             : /*! r: sum of all squared vector elements */
     179             : float sum2_f(
     180             :     const float *vec,  /* i  : input vector                                    */
     181             :     const int16_t lvec /* i  : length of input vector                          */
     182             : );
     183             : 
     184             : void set_c(
     185             :     int8_t y[],     /* i/o: Vector to set                                   */
     186             :     const int8_t a, /* i  : Value to set the vector to                      */
     187             :     const int32_t N /* i  : Length of the vector                */
     188             : );
     189             : 
     190             : void set_s(
     191             :     int16_t y[],     /* i/o: Vector to set                                   */
     192             :     const int16_t a, /* i  : Value to set the vector to                      */
     193             :     const int16_t N  /* i  : Lenght of the vector                            */
     194             : );
     195             : 
     196             : void set_l(
     197             :     int32_t y[],     /* i/o: Vector to set                                   */
     198             :     const int32_t a, /* i  : Value to set the vector to                      */
     199             :     const int16_t N  /* i  : Length of the vector                            */
     200             : );
     201             : 
     202             : void set_f(
     203             :     float y[],      /* i/o: Vector to set                                   */
     204             :     const float a,  /* i  : Value to set the vector to                      */
     205             :     const int16_t N /* i  : Lenght of the vector                            */
     206             : );
     207             : 
     208             : void set_zero(
     209             :     float *vec,        /* o  : input vector                                    */
     210             :     const int16_t lvec /* i  : length of the vector                            */
     211             : );
     212             : 
     213             : void mvr2r(
     214             :     const float x[], /* i  : input vector                                    */
     215             :     float y[],       /* o  : output vector                                   */
     216             :     const int16_t n  /* i  : vector size                                     */
     217             : );
     218             : 
     219             : void mvs2s(
     220             :     const int16_t x[], /* i  : input vector                                    */
     221             :     int16_t y[],       /* o  : output vector                                   */
     222             :     const int16_t n    /* i  : vector size                                     */
     223             : );
     224             : 
     225             : #ifdef DEBUGGING
     226             : /*! r: number of overload samples */
     227             : uint32_t check_clipping(
     228             :     const float x[],    /* i  : input vector                                   */
     229             :     const int16_t n,    /* i  : vector size                                    */
     230             :     float *maxOverload, /* i/o: max overload value                             */
     231             :     float *minOverload  /* i/o: max overload value                             */
     232             : );
     233             : 
     234             : #endif
     235             : /*! r: number of clipped samples */
     236             : uint32_t mvr2s(
     237             :     const float x[], /* i  : input vector                                    */
     238             :     int16_t y[],     /* o  : output vector                                   */
     239             :     const int16_t n  /* i  : vector size                                     */
     240             : );
     241             : 
     242             : void mvs2r(
     243             :     const int16_t x[], /* i  : input vector                                    */
     244             :     float y[],         /* o  : output vector                                   */
     245             :     const int16_t n    /* i  : vector size                                     */
     246             : );
     247             : 
     248             : void mvl2l(
     249             :     const int32_t x[], /* i  : input vector                                    */
     250             :     int32_t y[],       /* o  : output vector                                   */
     251             :     const int16_t n    /* i  : vector size                                     */
     252             : );
     253             : 
     254             : void AGC_dec(
     255             :     float x[],      /* i/o: input/output vector                             */
     256             :     float mem[],    /* i/o: mem[2] should be init to [0,0]                  */
     257             :     const int16_t n /* i  : vector size                                     */
     258             : );
     259             : 
     260             : /*! r: index of the maximum value in the input vector */
     261             : int16_t maximum(
     262             :     const float *vec,   /* i  : input vector                                    */
     263             :     const int16_t lvec, /* i  : length of input vector                          */
     264             :     float *max_val      /* o  : maximum value in the input vector               */
     265             : );
     266             : 
     267             : /*! r: index of the maximum value in the input vector */
     268             : int16_t maximum_s(
     269             :     const int16_t *vec, /* i  : input vector                                   */
     270             :     const int16_t lvec, /* i  : length of input vector                         */
     271             :     int16_t *max        /* o  : maximum value in the input vector              */
     272             : );
     273             : 
     274             : /*! r: index of the maximum value in the input vector */
     275             : int16_t maximumAbs(
     276             :     const float *vec,   /* i  : input vector                                    */
     277             :     const int16_t lvec, /* i  : length of input vector                          */
     278             :     float *max_val      /* o  : maximum value in the input vector               */
     279             : );
     280             : 
     281             : /*! r: index of the minimum value in the input vector */
     282             : int16_t minimum(
     283             :     const float *vec,   /* i  : input vector                                    */
     284             :     const int16_t lvec, /* i  : length of input vector                          */
     285             :     float *min_val      /* o  : minimum value in the input vector               */
     286             : );
     287             : 
     288             : /*! r: index of the minimum value in the input vector */
     289             : int16_t minimum_s(
     290             :     const int16_t *vec, /* i  : Input vector                                    */
     291             :     const int16_t lvec, /* i  : Vector length                                   */
     292             :     int16_t *min_val    /* o  : minimum value in the input vector               */
     293             : );
     294             : 
     295             : /*! r: return index with max energy value in vector */
     296             : int16_t emaximum(
     297             :     const float *vec,   /* i  : input vector                                    */
     298             :     const int16_t lvec, /* i  : length of input vector                          */
     299             :     float *ener_max     /* o  : maximum energy value                            */
     300             : );
     301             : 
     302             : /*! r: vector mean */
     303             : float mean(
     304             :     const float *vec,  /* i  : input vector                                    */
     305             :     const int16_t lvec /* i  : length of input vector                          */
     306             : );
     307             : 
     308             : /*! r: dot product of x[] and y[] */
     309             : float dotp(
     310             :     const float x[], /* i  : vector x[]                                      */
     311             :     const float y[], /* i  : vector y[]                                      */
     312             :     const int16_t n  /* i  : vector length                                   */
     313             : );
     314             : 
     315             : void conv(
     316             :     const float x[], /* i  : input vector                                    */
     317             :     const float h[], /* i  : impulse response (or second input vector)       */
     318             :     float y[],       /* o  : output vetor (result of convolution)            */
     319             :     const int16_t L  /* i  : vector size                                     */
     320             : );
     321             : 
     322             : void fir(
     323             :     const float x[],  /* i  : input vector                                    */
     324             :     const float h[],  /* i  : impulse response of the FIR filter              */
     325             :     float y[],        /* o  : output vector (result of filtering)             */
     326             :     float mem[],      /* i/o: memory of the input signal (M samples)          */
     327             :     const int16_t L,  /* i  : input vector size                               */
     328             :     const int16_t K,  /* i  : order of the FIR filter (M+1 coefs.)            */
     329             :     const int16_t upd /* i  : 1 = update the memory, 0 = not                  */
     330             : );
     331             : 
     332             : void v_add(
     333             :     const float x1[], /* i  : Input vector 1                                  */
     334             :     const float x2[], /* i  : Input vector 2                                  */
     335             :     float y[],        /* o  : Output vector that contains vector 1 + vector 2 */
     336             :     const int16_t N   /* i  : Vector length                                   */
     337             : );
     338             : 
     339             : void v_sub(
     340             :     const float x1[], /* i  : Input vector 1                                  */
     341             :     const float x2[], /* i  : Input vector 2                                  */
     342             :     float y[],        /* o  : Output vector that contains vector 1 - vector 2 */
     343             :     const int16_t N   /* i  : Vector length                                   */
     344             : );
     345             : 
     346             : void v_mult(
     347             :     const float x1[], /* i  : Input vector 1                                  */
     348             :     const float x2[], /* i  : Input vector 2                                  */
     349             :     float y[],        /* o  : Output vector that contains vector 1 .* vector 2*/
     350             :     const int16_t N   /* i  : Vector length                                   */
     351             : );
     352             : 
     353             : void v_multc(
     354             :     const float x[], /* i  : Input vector                                     */
     355             :     const float c,   /* i  : Constant                                         */
     356             :     float y[],       /* o  : Output vector that contains c*x                  */
     357             :     const int16_t N  /* i  : Vector length                                    */
     358             : );
     359             : 
     360             : void v_sub_s(
     361             :     const int16_t x1[], /* i  : Input vector 1                                  */
     362             :     const int16_t x2[], /* i  : Input vector 2                                  */
     363             :     int16_t y[],        /* o  : Output vector that contains vector 1 - vector 2 */
     364             :     const int16_t N     /* i  : Vector length                                   */
     365             : );
     366             : 
     367             : /*! r: index of the winning codeword */
     368             : int16_t squant(
     369             :     const float x,       /* i  : scalar value to quantize                       */
     370             :     float *xq,           /* o  : quantized value                                */
     371             :     const float cb[],    /* i  : codebook                                       */
     372             :     const int16_t cbsize /* i  : codebook size                                  */
     373             : );
     374             : 
     375             : int16_t squant_int(
     376             :     uint8_t x,           /* i  : scalar value to quantize                       */
     377             :     uint8_t *xq,         /* o  : quantized value                                */
     378             :     const uint8_t *cb,   /* i  : codebook                                       */
     379             :     const int16_t cbsize /* i  : codebook size                                  */
     380             : );
     381             : 
     382             : /*! r: index of the winning codevector */
     383             : int16_t vquant(
     384             :     float x[],            /* i  : vector to quantize                              */
     385             :     const float x_mean[], /* i  : vector mean to subtract (0 if none)             */
     386             :     float xq[],           /* o  : quantized vector                                */
     387             :     const float cb[],     /* i  : codebook                                        */
     388             :     const int16_t dim,    /* i  : dimension of codebook vectors                   */
     389             :     const int16_t cbsize  /* i  : codebook size                                   */
     390             : );
     391             : 
     392             : /*! r: index of the winning codevector */
     393             : int16_t w_vquant(
     394             :     float x[],               /* i  : vector to quantize                              */
     395             :     const float x_mean[],    /* i  : vector mean to subtract (0 if none)             */
     396             :     const int16_t weights[], /* i  : error weights                                   */
     397             :     float xq[],              /* o  : quantized vector                                */
     398             :     const float cb[],        /* i  : codebook                                        */
     399             :     const int16_t dim,       /* i  : dimension of codebook vectors                   */
     400             :     const int16_t cbsize,    /* i  : codebook size                                   */
     401             :     const int16_t reverse    /* i  : reverse codebook vectors                        */
     402             : );
     403             : 
     404             : /*! r: index of the winning codeword */
     405             : int16_t usquant(
     406             :     const float x,       /* i  : scalar value to quantize                        */
     407             :     float *xq,           /* o  : quantized value                                 */
     408             :     const float qlow,    /* i  : lowest codebook entry (index 0)                 */
     409             :     const float delta,   /* i  : quantization step                               */
     410             :     const int16_t cbsize /* i  : codebook size                                   */
     411             : );
     412             : 
     413             : /*! r: dequanzited gain */
     414             : float usdequant(
     415             :     const int16_t idx, /* i  : quantizer index                                 */
     416             :     const float qlow,  /* i  : lowest codebook entry (index 0)                 */
     417             :     const float delta  /* i  : quantization step                               */
     418             : );
     419             : 
     420             : void v_sort(
     421             :     float *r,         /* i/o: Vector to be sorted in place                    */
     422             :     const int16_t lo, /* i  : Low limit of sorting range                      */
     423             :     const int16_t up  /* i  : High limit of sorting range                     */
     424             : );
     425             : 
     426             : void sort(
     427             :     uint16_t *x, /* i/o: Vector to be sorted                             */
     428             :     uint16_t len /* i/o: vector length                                   */
     429             : );
     430             : 
     431             : /*! r: variance of vector */
     432             : float var(
     433             :     const float *x,   /* i  : input vector                                    */
     434             :     const int16_t len /* i  : length of inputvector                           */
     435             : );
     436             : 
     437             : /*! r: standard deviation */
     438             : float std_dev(
     439             :     const float *x,   /* i  : input vector                                    */
     440             :     const int16_t len /* i  : length of the input vector                      */
     441             : );
     442             : 
     443             : /*! r: the dot product x'*A*x */
     444             : float dot_product_mat(
     445             :     const float *x, /* i  : vector x                                        */
     446             :     const float *A, /* i  : matrix A                                        */
     447             :     const int16_t m /* i  : vector length                                   */
     448             : );
     449             : 
     450             : float root_a(
     451             :     float a );
     452             : 
     453             : float root_a_over_b(
     454             :     float a,
     455             :     float b );
     456             : 
     457             : void polezero_filter(
     458             :     const float *in,     /* i  : input vector                              */
     459             :     float *out,          /* o  : output vector                             */
     460             :     const int16_t N,     /* i  : input vector size                         */
     461             :     const float *b,      /* i  : numerator coefficients                    */
     462             :     const float *a,      /* i  : denominator coefficients                  */
     463             :     const int16_t order, /* i  : filter order                              */
     464             :     float *mem           /* i/o: filter memory                             */
     465             : );
     466             : 
     467             : double rint_new(
     468             :     double x /* i/o: Round to the nearest integer with mid point exception */
     469             : );
     470             : 
     471             : double anint(
     472             :     double x /* i/o: Round to the nearest integer               */
     473             : );
     474             : 
     475             : /*! r: Output either 1 if Numeric, 0 if NaN or Inf */
     476             : int16_t is_numeric_float(
     477             :     float x /* i  : Input value which is checked if numeric or not */
     478             : );
     479             : 
     480             : void delay_signal(
     481             :     float x[],          /* i/o: signal to be delayed                    */
     482             :     const int16_t len,  /* i  : length of the input signal              */
     483             :     float mem[],        /* i/o: synchronization memory                  */
     484             :     const int16_t delay /* i  : delay in samples                        */
     485             : );
     486             : 
     487             : #ifdef DEBUG_BS_READ_WRITE
     488             : #define push_indice( ... ) push_indice_( __VA_ARGS__, __LINE__, __func__ )
     489             : ivas_error push_indice_(
     490             : #else
     491             : ivas_error push_indice(
     492             : #endif
     493             :     BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle                    */
     494             :     int16_t id,            /* i  : ID of the indice                            */
     495             :     uint16_t value,        /* i  : value of the quantized indice               */
     496             :     int16_t nb_bits        /* i  : number of bits used to quantize the indice  */
     497             : #ifdef DEBUG_BS_READ_WRITE
     498             :     ,
     499             :     int16_t line,
     500             :     const char *func
     501             : #endif
     502             : );
     503             : 
     504             : #ifdef DEBUG_BS_READ_WRITE
     505             : #define push_next_indice( ... ) push_next_indice_( __VA_ARGS__, __LINE__, __func__ )
     506             : ivas_error push_next_indice_(
     507             : #else
     508             : ivas_error push_next_indice(
     509             : #endif
     510             :     BSTR_ENC_HANDLE hBstr,
     511             :     uint16_t value, /* i  : value of the quantized indice          */
     512             :     int16_t nb_bits /* i  : number of bits used to quantize the indice */
     513             : #ifdef DEBUG_BS_READ_WRITE
     514             :     ,
     515             :     int16_t line,
     516             :     const char *func
     517             : #endif
     518             : );
     519             : 
     520             : #ifdef DEBUG_BS_READ_WRITE
     521             : #define push_next_bits( ... ) push_next_bits_( __VA_ARGS__, __LINE__, __func__ )
     522             : ivas_error push_next_bits_(
     523             : #else
     524             : ivas_error push_next_bits(
     525             : #endif
     526             :     BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle               */
     527             :     const uint16_t bits[], /* i  : bit buffer to pack, sequence of single bits */
     528             :     const int16_t nb_bits  /* i  : number of bits to pack                 */
     529             : #ifdef DEBUG_BS_READ_WRITE
     530             :     ,
     531             :     int16_t line,
     532             :     const char *func
     533             : #endif
     534             : );
     535             : 
     536             : /*! r: maximum number of indices */
     537             : int16_t get_ivas_max_num_indices(
     538             :     const IVAS_FORMAT ivas_format, /* i  : IVAS format               */
     539             :     const int32_t ivas_total_brate /* i  : IVAS total bitrate           */
     540             : );
     541             : 
     542             : /*! r: maximum number of indices */
     543             : int16_t get_BWE_max_num_indices(
     544             :     const int32_t extl_brate /* i  : extensiona layer bitrate  */
     545             : );
     546             : 
     547             : /*! r: maximum number of indices */
     548             : int16_t get_ivas_max_num_indices_metadata(
     549             :     const IVAS_FORMAT ivas_format, /* i  : IVAS format               */
     550             :     const int32_t ivas_total_brate /* i  : IVAS total bitrate       */
     551             : );
     552             : 
     553             : ivas_error ind_list_realloc(
     554             :     INDICE_HANDLE old_ind_list,    /* i  : pointer to the beginning of the old buffer of indices */
     555             :     const int16_t max_num_indices, /* i  : new maximum number of allowed indices in the list */
     556             :     Encoder_Struct *st_ivas        /* i  : IVAS encoder structure                  */
     557             : );
     558             : 
     559             : ivas_error check_ind_list_limits(
     560             :     BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle                    */
     561             : );
     562             : 
     563             : void move_indices(
     564             :     INDICE_HANDLE old_ind_list, /* i/o: old location of indices */
     565             :     INDICE_HANDLE new_ind_list, /* i/o: new location of indices */
     566             :     const int16_t nb_indices    /* i  : number of moved indices */
     567             : );
     568             : 
     569             : /*! r: index of the indice in the list, -1 if not found */
     570             : int16_t find_indice(
     571             :     BSTR_ENC_HANDLE hBstr, /* i  : encoder bitstream handle                    */
     572             :     const int16_t id,      /* i  : ID of the indice                            */
     573             :     uint16_t *value,       /* o  : value of the quantized indice               */
     574             :     int16_t *nb_bits       /* o  : number of bits used to quantize the indice  */
     575             : );
     576             : 
     577             : /*! r: number of deleted indices                   */
     578             : uint16_t delete_indice(
     579             :     BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle                    */
     580             :     const int16_t id       /* i  : ID of the indice                            */
     581             : );
     582             : 
     583             : /*! r: value of the indice */
     584             : #ifdef DEBUG_BS_READ_WRITE
     585             : #define get_next_indice( ... ) get_next_indice_( __VA_ARGS__, __LINE__, __func__ )
     586             : uint16_t get_next_indice_(
     587             : #else
     588             : uint16_t get_next_indice(
     589             : #endif
     590             :     Decoder_State *st, /* i/o: decoder state structure                */
     591             :     int16_t nb_bits    /* i  : number of bits that were used to quantize the indice */
     592             : #ifdef DEBUG_BS_READ_WRITE
     593             :     ,
     594             :     int16_t line,
     595             :     const char *func
     596             : #endif
     597             : );
     598             : 
     599             : /*! r: value of the indice */
     600             : uint16_t get_next_indice_1(
     601             :     Decoder_State *st /* i/o: decoder state structure                */
     602             : );
     603             : 
     604             : void get_next_indice_tmp(
     605             :     Decoder_State *st, /* o  : decoder state structure                */
     606             :     int16_t nb_bits    /* i  : number of bits that were used to quantize the indice */
     607             : );
     608             : 
     609             : /*! r: value of the indice */
     610             : #ifdef DEBUG_BS_READ_WRITE
     611             : #define get_indice( ... ) get_indice_( __VA_ARGS__, __LINE__, __func__ )
     612             : uint16_t get_indice_(
     613             : #else
     614             : uint16_t get_indice(
     615             : #endif
     616             :     Decoder_State *st, /* i/o: decoder state structure                */
     617             :     int16_t pos,       /* i  : absolute position in the bitstream     */
     618             :     int16_t nb_bits    /* i  : number of bits that were used to quantize the indice */
     619             : #ifdef DEBUG_BS_READ_WRITE
     620             :     ,
     621             :     int16_t line,
     622             :     const char *func
     623             : #endif
     624             : );
     625             : 
     626             : /*! r: value of the indice */
     627             : uint16_t get_indice_1(
     628             :     Decoder_State *st, /* i/o: decoder state structure                */
     629             :     int16_t pos        /* i  : absolute position in the bitstream     */
     630             : );
     631             : 
     632             : void reset_indices_enc(
     633             :     BSTR_ENC_HANDLE hBstr,        /* i/o: encoder bitstream handle               */
     634             :     const int16_t max_num_indices /* i  : max number of indices                  */
     635             : );
     636             : 
     637             : void reset_indices_dec(
     638             :     Decoder_State *st /* i/o: decoder state structure                */
     639             : );
     640             : 
     641             : ivas_error write_indices_ivas(
     642             :     Encoder_Struct *st_ivas, /* i/o: encoder state structure                                       */
     643             :     uint16_t *bit_stream,    /* i/o: output bitstream                                              */
     644             :     uint16_t *num_bits       /* i/o: number of bits written to output                              */
     645             : );
     646             : 
     647             : Word16 rate2EVSmode(
     648             :     const Word32 brate, /* i  : bitrate                                                    */
     649             :     int16_t *is_amr_wb  /* o  : (flag) does the bitrate belong to AMR-WB? Can be NULL      */
     650             : );
     651             : 
     652             : 
     653             : /*! r: 1 = OK, 0 = something wrong */
     654             : ivas_error read_indices(
     655             :     Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure                 */
     656             :     uint16_t bit_stream[],   /* i  : bitstream buffer                       */
     657             :     UWord16 num_bits,        /* i  : number of bits in bitstream            */
     658             :     int16_t *prev_ft_speech,
     659             :     int16_t *CNG,
     660             :     int16_t bfi /* i  : bad frame indicator                    */
     661             : );
     662             : 
     663             : #ifdef DEBUGGING
     664             : /*! r: 1 = reading OK, 0 = problem */
     665             : ivas_error preview_indices(
     666             :     Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure                 */
     667             :     uint16_t bit_stream[],   /* i  : bitstream buffer                       */
     668             :     UWord16 num_bits         /* i  : number of bits in bitstream            */
     669             : );
     670             : #endif
     671             : 
     672             : void ivas_set_bitstream_pointers(
     673             :     Decoder_Struct *st_ivas /* i/o: IVAS decoder structure    */
     674             : );
     675             : 
     676             : Decoder_State **reset_elements(
     677             :     Decoder_Struct *st_ivas /* i/o: IVAS decoder structure      */
     678             : );
     679             : 
     680             : 
     681             : void convertSerialToBytestream(
     682             :     const uint16_t *const serial, /* i  : input serial bitstream with values 0 and 1  */
     683             :     const uint16_t num_bits,      /* i  : number of bits in the input bitstream       */
     684             :     uint8_t *const bytestream     /* o  : output compact bitstream (bytestream)       */
     685             : );
     686             : 
     687             : void convertBytestreamToSerial(
     688             :     const uint8_t *const bytestream, /* i  : input compact bitstream (bytestream)        */
     689             :     const uint16_t num_bits,         /* i  : number of bits in the input bitstream       */
     690             :     uint16_t *const serial           /* o  : output serial bitstream with values 0 and 1 */
     691             : );
     692             : 
     693             : void mdct_switching_dec(
     694             :     Decoder_State *st /* i/o: decoder state structure                 */
     695             : );
     696             : 
     697             : void evs_dec_previewFrame(
     698             :     uint8_t *bitstream,            /* i  : bitstream pointer                       */
     699             :     int16_t bitstreamSize,         /* i  : bitstream size                          */
     700             :     int16_t *partialCopyFrameType, /* o  : frame type of the partial copy          */
     701             :     int16_t *partialCopyOffset     /* o  : offset of the partial copy relative to the primary copy */
     702             : );
     703             : 
     704             : 
     705             : void getPartialCopyInfo(
     706             :     Decoder_State *st, /* i  : decoder state structure                 */
     707             :     int16_t *sharpFlag );
     708             : 
     709             : void get_NextCoderType(
     710             :     uint8_t *bitstream,      /* i  : bitstream                               */
     711             :     int16_t *next_coder_type /* o  : next coder type                         */
     712             : );
     713             : 
     714             : int16_t print_disclaimer(
     715             :     FILE *fPtr );
     716             : 
     717             : void autocorr(
     718             :     const float *x,         /* i  : input signal                            */
     719             :     float *r,               /* o  : autocorrelations vector                 */
     720             :     const int16_t m,        /* i  : order of LP filter                      */
     721             :     const int16_t len,      /* i  : window size                             */
     722             :     const float *wind,      /* i  : window                                  */
     723             :     const int16_t rev_flag, /* i  : flag to reverse window                  */
     724             :     const int16_t sym_flag, /* i  : symmetric window flag                   */
     725             :     const int16_t no_thr    /* i  : flag to avoid thresholding              */
     726             : );
     727             : 
     728             : /*! r: energy of prediction error */
     729             : int16_t lev_dur(
     730             :     float *a,        /* o  :   LP coefficients (a[0] = 1.0)          */
     731             :     const float *r,  /* i  :   vector of autocorrelations            */
     732             :     const int16_t m, /* i  :   order of LP filter                    */
     733             :     float epsP[]     /* o  :   prediction error energy               */
     734             : );
     735             : 
     736             : /*! r: delay value in ns */
     737             : int32_t get_delay(
     738             :     const int16_t enc_dec,                  /* i  : encoder/decoder flag                  */
     739             :     const int32_t io_fs,                    /* i  : input/output sampling frequency       */
     740             :     const IVAS_FORMAT ivas_format,          /* i  : IVAS format                           */
     741             :     HANDLE_CLDFB_FILTER_BANK hCldfb,        /* i  : Handle of Cldfb analysis              */
     742             :     const int16_t flag_binaural_split_coded /* i  : split rendering on/off flag         */
     743             : );
     744             : 
     745             : void decision_matrix_enc(
     746             :     Encoder_State *st,    /* i/o: encoder state structure                   */
     747             :     int16_t *hq_core_type /* o  : HQ core type                              */
     748             : );
     749             : 
     750             : void signaling_enc(
     751             :     Encoder_State *st /* i  : encoder state structure                   */
     752             : );
     753             : 
     754             : int16_t signaling_mode1_tcx20_enc(
     755             :     Encoder_State *st, /* i/o: encoder state structure                   */
     756             :     const int16_t push /* i  : flag to push indice                       */
     757             : );
     758             : 
     759             : void decision_matrix_dec(
     760             :     Decoder_State *st,           /* i/o: decoder state structure                   */
     761             :     int16_t *sharpFlag,          /* o  : formant sharpening flag                   */
     762             :     int16_t *hq_core_type,       /* o  : HQ core type                              */
     763             :     int16_t *core_switching_flag /* o  : ACELP->HQ switching frame flag            */
     764             : );
     765             : 
     766             : /*! r: LP filter stability */
     767             : float lsf_stab(
     768             :     const float *lsf,         /* i  : LSF vector                                  */
     769             :     const float *lsfold,      /* i  : old LSF vector                              */
     770             :     const int16_t Opt_AMR_WB, /* i  : flag indicating AMR-WB IO mode              */
     771             :     const int16_t L_frame     /* i  : frame length                                */
     772             : );
     773             : 
     774             : void amr_wb_dec_init(
     775             :     AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle                            */
     776             : );
     777             : 
     778             : void hf_synth_amr_wb_init(
     779             :     AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle                            */
     780             : );
     781             : 
     782             : void hf_synth_amr_wb_reset(
     783             :     AMRWB_IO_DEC_HANDLE hAmrwb_IO, /* i/o: AMR-WB IO data handle                            */
     784             :     ZERO_BWE_DEC_HANDLE hBWE_zero  /* o  : zero BWE decoder handle                          */
     785             : );
     786             : 
     787             : void hf_synth_amr_wb(
     788             :     AMRWB_IO_DEC_HANDLE hAmrwb_IO, /* i/o: AMR-WB IO data handle                             */
     789             :     ZERO_BWE_DEC_HANDLE hBWE_zero, /* o  : zero BWE decoder handle                           */
     790             :     const int32_t core_brate,      /* i  : core bitrate                                      */
     791             :     const int16_t output_frame,    /* i  : output frame length                               */
     792             :     const float *Aq,               /* i  : quantized Az                                      */
     793             :     const float *exc,              /* i  : excitation at 12.8 kHz                            */
     794             :     float *synth,                  /* i/o: synthesis signal at 12.8 kHz                      */
     795             :     int16_t *amr_io_class,         /* i  : signal class (determined by FEC algorithm)        */
     796             :     float *synth_out,              /* i/o: synthesis signal at output Fs                     */
     797             :     float fmerit,                  /* i  : classify parameter from FEC                       */
     798             :     const int16_t *hf_gain,        /* i  : decoded HF gain                                   */
     799             :     const float *voice_factors,    /* i  : voicing factors                                   */
     800             :     const float pitch_buf[],       /* i  : pitch buffer                                      */
     801             :     const float ng_ener_ST,        /* i  : Noise gate - short-term energy                    */
     802             :     const float *lsf_new           /* i  : ISF vector                                        */
     803             : );
     804             : 
     805             : void hf_cod_init(
     806             :     float *mem_hp400_enc,  /* o  : memory of hp 400 Hz filter   */
     807             :     float *mem_hf1_enc,    /* o  : HF band-pass filter memory   */
     808             :     float *mem_syn_hf_enc, /* o  : HF synthesis memory          */
     809             :     float *mem_hf2_enc,    /* o  : HF band-pass filter memory   */
     810             :     float *gain_alpha      /* o  : smoothing gain for transitions between active and inactive frames */
     811             : );
     812             : 
     813             : void hf_cod(
     814             :     const int32_t core_brate, /* i  : core bitrate                 */
     815             :     const float *speech16k,   /* i  : original speech at 16 kHz    */
     816             :     const float Aq[],         /* i  : quantized Aq                 */
     817             :     const float exc[],        /* i  : excitation at 12.8 kHz       */
     818             :     float synth[],            /* i  : 12.8kHz synthesis signal     */
     819             :     int16_t *seed2_enc,       /* i/o: random seed for HF noise gen */
     820             :     float *mem_hp400_enc,     /* i/o: memory of hp 400 Hz filter   */
     821             :     float *mem_syn_hf_enc,    /* i/o: HF synthesis memory          */
     822             :     float *mem_hf1_enc,       /* i/o: HF band-pass filter memory   */
     823             :     float *mem_hf2_enc,       /* i/o: HF band-pass filter memory   */
     824             :     const int16_t *dtxHangoverCount,
     825             :     float *gain_alpha, /* i/o: smoothing gain for transitions between active and inactive frames */
     826             :     int16_t *hf_gain   /* o  :  HF gain to be transmitted to decoder */
     827             : );
     828             : 
     829             : void hf_synth_init(
     830             :     ZERO_BWE_DEC_HANDLE hBWE_zero /* o  : zero BWE decoder handle     */
     831             : );
     832             : 
     833             : void hf_synth_reset(
     834             :     ZERO_BWE_DEC_HANDLE hBWE_zero /* o  : zero BWE decoder handle     */
     835             : );
     836             : 
     837             : void hf_synth(
     838             :     ZERO_BWE_DEC_HANDLE hBWE_zero, /* o  : zero BWE decoder handle     */
     839             :     const int32_t core_brate,      /* i  : core bitrate                */
     840             :     const int16_t output_frame,    /* i  : output frame length         */
     841             :     const float *Aq,               /* i  : quantized Az                */
     842             :     const float *exc,              /* i  : excitation at 12.8 kHz      */
     843             :     float *synth,                  /* i/o: 12.8kHz synthesis signal    */
     844             :     float *synth16k                /* i/o: 16kHz synthesis signal      */
     845             : );
     846             : 
     847             : int16_t lsp_convert_poly(
     848             :     float w[],              /* i/o: LSP or ISP parameters          */
     849             :     const int16_t L_frame,  /* i  : flag for up or down conversion */
     850             :     const int16_t Opt_AMRWB /* i  : flag for the AMR-WB IO mode    */
     851             : );
     852             : 
     853             : /*! r: pulse position */
     854             : int16_t findpulse(
     855             :     const int16_t L_frame, /* i  : length of the frame   */
     856             :     const float res[],     /* i  : residual signal       */
     857             :     const int16_t T0,      /* i  : integer pitch         */
     858             :     const int16_t enc_dec, /* i  : flag enc/dec, 0 - enc, 1 - dec */
     859             :     int16_t *sign          /* i/o: sign of the maximum   */
     860             : );
     861             : 
     862             : void fft_rel(
     863             :     float x[],       /* i/o: input/output vector    */
     864             :     const int16_t n, /* i  : vector length          */
     865             :     const int16_t m  /* i  : log2 of vector length  */
     866             : );
     867             : 
     868             : void ifft_rel(
     869             :     float io[],      /* i/o: input/output vector   */
     870             :     const int16_t n, /* i  : vector length         */
     871             :     const int16_t m  /* i  : log2 of vector length */
     872             : );
     873             : 
     874             : void preemph(
     875             :     float *signal,   /* i/o: signal             */
     876             :     const float mu,  /* i  : preemphasis factor */
     877             :     const int16_t L, /* i  : vector size        */
     878             :     float *mem       /* i/o: memory (x[-1])     */
     879             : );
     880             : 
     881             : void cb_shape(
     882             :     const int16_t preemphFlag,     /* i  : flag for pre-emphasis                       */
     883             :     const int16_t pitchFlag,       /* i  : flag for pitch sharpening                   */
     884             :     const int16_t scramblingFlag,  /* i  : flag for phase scrambling                   */
     885             :     const int16_t formantFlag,     /* i  : flag for formant sharpening                 */
     886             :     const int16_t formantTiltFlag, /* i  : flag for formant tilt                       */
     887             :     const float g1,                /* i  : formant sharpening numerator weighting      */
     888             :     const float g2,                /* i  : formant sharpening denominator weighting    */
     889             :     const float *p_Aq,             /* i  : LP filter coefficients                      */
     890             :     float *code,                   /* i/o: signal to shape                             */
     891             :     const float tilt_code,         /* i  : tilt of code                                */
     892             :     const float pt_pitch,          /* i  : pointer to current subframe fractional pitch*/
     893             :     const int16_t L_subfr          /* i  : subfframe length                            */
     894             : );
     895             : 
     896             : void isp2a(
     897             :     const float *isp, /* i  : ISP vector (in the cosine domain)       */
     898             :     float *a,         /* o  : LP filter coefficients                  */
     899             :     const int16_t m   /* i  : order of LP analysis                    */
     900             : );
     901             : 
     902             : void isp2isf(
     903             :     const float isp[], /* i  : isp[m] (range: -1<=val<1)               */
     904             :     float isf[],       /* o  : isf[m] normalized (range: 0<=val<=fs/2) */
     905             :     const int16_t m,   /* i  : LPC order                               */
     906             :     const int32_t Fs   /* i  : sampling frequency                      */
     907             : );
     908             : 
     909             : void isf2isp(
     910             :     const float isf[], /* i  : isf[m] normalized (range: 0<=val<=fs/2) */
     911             :     float isp[],       /* o  : isp[m] (range: -1<=val<1)               */
     912             :     const int16_t m,   /* i  : LPC order                               */
     913             :     const int32_t Fs   /* i  : sampling frequency                      */
     914             : );
     915             : 
     916             : void reorder_isf(
     917             :     float *isf,           /* i/o: vector of isfs in the frequency domain (0..0.5)*/
     918             :     const float min_dist, /* i  : minimum required distance               */
     919             :     const int16_t n,      /* i  : LPC order                               */
     920             :     const float Fs        /* i  : sampling frequency                      */
     921             : );
     922             : 
     923             : void lsp2lsf(
     924             :     const float lsp[], /* i  : isp[m] (range: -1<=val<1)               */
     925             :     float lsf[],       /* o  : isf[m] normalized (range: 0<=val<=fs/2) */
     926             :     const int16_t m,   /* i  : LPC order                               */
     927             :     const int32_t Fs   /* i  : sampling frequency                      */
     928             : );
     929             : 
     930             : void lsf2lsp(
     931             :     const float lsf[], /* i  : isf[m] normalized (range: 0<=val<=fs/2) */
     932             :     float lsp[],       /* o  : isp[m] (range: -1<=val<1)               */
     933             :     const int16_t m,   /* i  : LPC order                               */
     934             :     const int32_t Fs   /* i  : sampling frequency                      */
     935             : );
     936             : 
     937             : void lsp2isp(
     938             :     const float *lsp,  /* i  : LSP vector                              */
     939             :     float *isp,        /* o  : ISP filter coefficients                 */
     940             :     float *stable_isp, /* i/o: ISP filter coefficients                 */
     941             :     const int16_t m    /* i  : order of LP analysis                    */
     942             : );
     943             : 
     944             : void isp2lsp(
     945             :     const float *isp,  /* i  : LSP vector                              */
     946             :     float *lsp,        /* o  : ISP filter coefficients                 */
     947             :     float *stable_lsp, /* i/o: stable LSP filter coefficients          */
     948             :     const int16_t m    /* i  : order of LP analysis                    */
     949             : );
     950             : 
     951             : void reorder_lsf(
     952             :     float *lsf,           /* i/o: vector of lsfs in the frequency domain (0..0.5)*/
     953             :     const float min_dist, /* i  : minimum required distance               */
     954             :     const int16_t n,      /* i  : LPC order                               */
     955             :     const int32_t Fs      /* i  : sampling frequency                      */
     956             : );
     957             : 
     958             : void CNG_exc(
     959             :     const int32_t core_brate,      /* i  : core bitrate                            */
     960             :     const int16_t L_frame,         /* i  : length of the frame                     */
     961             :     float *Enew,                   /* i/o: decoded SID energy                      */
     962             :     int16_t *seed,                 /* i/o: random generator seed                   */
     963             :     float exc[],                   /* o  : current non-enhanced excitation         */
     964             :     float exc2[],                  /* o  : current enhanced excitation             */
     965             :     float *lp_ener,                /* i/o: LP filtered E                           */
     966             :     const int32_t last_core_brate, /* i  : previous frame core bitrate             */
     967             :     int16_t *first_CNG,            /* i/o: first CNG frame flag for energy init.   */
     968             :     int16_t *cng_ener_seed,        /* i/o: random generator seed for CNG energy    */
     969             :     float bwe_exc[],               /* o  : excitation for SWB TBE                  */
     970             :     const int16_t allow_cn_step,   /* i  : allow CN step                           */
     971             :     int16_t *last_allow_cn_step,   /* i/o: last CN_step                            */
     972             :     const int16_t num_ho,          /* i  : number of selected hangover frames      */
     973             :     float q_env[],
     974             :     float *lp_env,
     975             :     float *old_env,
     976             :     float *exc_mem,
     977             :     float *exc_mem1,
     978             :     int16_t *sid_bw,
     979             :     int16_t *cng_ener_seed1,
     980             :     float exc3[],
     981             :     const int16_t Opt_AMR_WB,  /* i  : AMR-WB interop flag                     */
     982             :     const int16_t element_mode /* i  : IVAS Element mode                       */
     983             : );
     984             : 
     985             : void cng_params_upd(
     986             :     const float lsp_new[],           /* i  : LSP aprameters                                      */
     987             :     const float exc2[],              /* i  : current enhanced excitation                         */
     988             :     const int16_t L_frame,           /* i  : frame length                                        */
     989             :     int16_t *ho_circ_ptr,            /* i/o: pointer for CNG averaging buffers                   */
     990             :     float ho_ener_circ[],            /* o  : energy buffer for CNG averaging                     */
     991             :     int16_t *ho_circ_size,           /* i/o: size of DTX hangover history buffer for averaging   */
     992             :     float ho_lsp_circ[],             /* o  : old LSP buffer for CNG averaging                    */
     993             :     const int16_t enc_dec_flag,      /* i  : Flag indicating encoder or decoder (ENC,DEC)        */
     994             :     float ho_env_circ[],             /* i/o: Envelope buffer                                     */
     995             :     int16_t *cng_buf_cnt,            /* i/o: Counter of postponed FFT-processing instances       */
     996             :     float cng_exc2_buf[],            /* i/o: Excitation buffer                                   */
     997             :     int32_t cng_brate_buf[],         /* i/o: last_active_brate buffer                            */
     998             :     const int32_t last_active_brate, /* i  : Last active bitrate                                 */
     999             :     const int16_t element_mode,      /* i  : Element mode                                        */
    1000             :     const int16_t bwidth             /* i  : audio bandwidth                                     */
    1001             : );
    1002             : 
    1003             : void cng_params_postupd(
    1004             :     const int16_t ho_circ_ptr,    /* i  : pointer for CNG averaging buffers                   */
    1005             :     int16_t *cng_buf_cnt,         /* i/o: counter for CNG store buffers                       */
    1006             :     const float *cng_exc2_buf,    /* i  : Excitation buffer                                   */
    1007             :     const int32_t *cng_brate_buf, /* i  : bitrate buffer                                      */
    1008             :     float ho_env_circ[],          /* i/o: Envelope buffer                                     */
    1009             :     const int16_t element_mode,   /* i  : Element mode                                        */
    1010             :     const int16_t bwidth          /* i  : audio bandwidth                                     */
    1011             : );
    1012             : 
    1013             : void calculate_hangover_attenuation_gain(
    1014             :     Encoder_State *st,           /* i  : encoder state structure                               */
    1015             :     float *att,                  /* o  : attenuation factor                                    */
    1016             :     const int16_t vad_hover_flag /* i  : VAD hangover flag                          */
    1017             : );
    1018             : 
    1019             : int16_t get_cng_mode(
    1020             :     const int32_t last_active_brate /* i  : last active bitrate                                 */
    1021             : );
    1022             : 
    1023             : void disf_ns_28b(
    1024             :     int16_t *indice, /* i  : quantized indices, use indice[0] = -1 in the decoder*/
    1025             :     float *isf_q     /* o  : ISF in the frequency domain (0..6400)               */
    1026             : );
    1027             : 
    1028             : void limit_T0(
    1029             :     const int16_t L_frame,    /* i  : length of the frame                                  */
    1030             :     const int16_t delta,      /* i  : Half the close-loop searched interval                */
    1031             :     const int16_t pit_flag,   /* i  : selecting absolute(0) or delta(1) pitch quantization */
    1032             :     const int16_t limit_flag, /* i  : flag for limits (0=restrained, 1=extended)           */
    1033             :     const int16_t T0,         /* i  : rough pitch estimate around which the search is done */
    1034             :     const int16_t T0_frac,    /* i  : pitch estimate fractional part                       */
    1035             :     int16_t *T0_min,          /* o  : lower pitch limit                                    */
    1036             :     int16_t *T0_max           /* o  : higher pitch limit                                   */
    1037             : );
    1038             : 
    1039             : /*! r: interpolated value */
    1040             : float interpolation(
    1041             :     const float *x,        /* i  : input vector                                */
    1042             :     const float *win,      /* i  : interpolation window                        */
    1043             :     const int16_t frac,    /* i  : fraction                                    */
    1044             :     const int16_t up_samp, /* i  : upsampling factor                           */
    1045             :     const int16_t nb_coef  /* i  : nb of filter coef                           */
    1046             : );
    1047             : 
    1048             : void deemph(
    1049             :     float *signal,   /* i/o: signal                                      */
    1050             :     const float mu,  /* i  : deemphasis factor                           */
    1051             :     const int16_t L, /* i  : vector size                                 */
    1052             :     float *mem       /* i/o: memory (y[-1])                              */
    1053             : );
    1054             : 
    1055             : /*! r: tilt of the code */
    1056             : float est_tilt(
    1057             :     const float *adpt_exc,  /* i  : adaptive excitation vector                  */
    1058             :     const float gain_pit,   /* i  : adaptive gain                               */
    1059             :     const float *fixe_exc,  /* i  : algebraic exctitation vector                */
    1060             :     const float gain_code,  /* i  : algebraic code gain                         */
    1061             :     float *voice_fac,       /* o  : voicing factor                              */
    1062             :     const int16_t L_subfr,  /* i  : subframe size                               */
    1063             :     const int16_t flag_tilt /* i  : flag for special tilt                       */
    1064             : );
    1065             : 
    1066             : void weight_a(
    1067             :     const float *a,    /* i  : LP filter coefficients                      */
    1068             :     float *ap,         /* o  : weighted LP filter coefficients             */
    1069             :     const float gamma, /* i  : weighting factor                            */
    1070             :     const int16_t m    /* i  : order of LP filter                          */
    1071             : );
    1072             : 
    1073             : void weight_a_subfr(
    1074             :     const int16_t nb_subfr, /* i  : number of subframes                         */
    1075             :     const float *a,         /* i  : LP filter coefficients                      */
    1076             :     float *ap,              /* o  : weighted LP filter coefficients             */
    1077             :     const float gamma,      /* i  : weighting factor                            */
    1078             :     const int16_t m         /* i  : order of LP filter                          */
    1079             : );
    1080             : 
    1081             : void syn_12k8(
    1082             :     const int16_t L_frame, /* i  : length of the frame                         */
    1083             :     const float *Aq,       /* i  : LP filter coefficients                      */
    1084             :     const float *exc,      /* i  : input signal                                */
    1085             :     float *synth,          /* o  : output signal                               */
    1086             :     float *mem,            /* i/o: initial filter states                       */
    1087             :     const int16_t update_m /* i  : update memory flag: 0 --> no memory update  */
    1088             : );                         /*                          1 --> update of memory  */
    1089             : 
    1090             : void syn_filt(
    1091             :     const float a[],       /* i  : LP filter coefficients                      */
    1092             :     const int16_t m,       /* i  : order of LP filter                          */
    1093             :     const float x[],       /* i  : input signal                                */
    1094             :     float y[],             /* o  : output signal                               */
    1095             :     const int16_t l,       /* i  : size of filtering                           */
    1096             :     float mem[],           /* i/o: initial filter states                       */
    1097             :     const int16_t update_m /* i  : update memory flag: 0 --> no memory update  */
    1098             : );                         /*                          1 --> update of memory  */
    1099             : 
    1100             : void synth_mem_updt2(
    1101             :     const int16_t L_frame,      /* i  : frame length                                */
    1102             :     const int16_t last_L_frame, /* i  : frame length                                */
    1103             :     float old_exc[],            /* i/o: excitation buffer                           */
    1104             :     float mem_syn_r[],          /* i/o: synthesis filter memory                     */
    1105             :     float mem_syn2[],           /* o  : synthesis filter memory for find_target     */
    1106             :     float mem_syn[],            /* o  : synthesis filter memory for find_target     */
    1107             :     const int16_t dec           /* i  : flag for decoder indication                 */
    1108             : );
    1109             : 
    1110             : void int_lsp(
    1111             :     const int16_t L_frame,   /* i  : length of the frame                         */
    1112             :     const float lsp_old[],   /* i  : LSPs from past frame                        */
    1113             :     const float lsp_new[],   /* i  : LSPs from present frame                     */
    1114             :     float *Aq,               /* o  : LP coefficients in both subframes           */
    1115             :     const int16_t m,         /* i  : order of LP filter                          */
    1116             :     const float *int_coeffs, /* i  : interpolation coefficients                  */
    1117             :     const int16_t Opt_AMR_WB /* i  : flag indicating AMR-WB IO mode              */
    1118             : );
    1119             : 
    1120             : void int_lsp4(
    1121             :     const int16_t L_frame,        /* i  : length of the frame                         */
    1122             :     const float lsp_old[],        /* i  : previous end-frame LSPs                     */
    1123             :     const float lsp_mid[],        /* i  : current mid-frame LSPs                      */
    1124             :     const float lsp_new[],        /* i  : current end-frame LSPs                      */
    1125             :     float *Aq,                    /* o  : LP coefficients in both subframes           */
    1126             :     const int16_t m,              /* i  : order of LP filter                          */
    1127             :     int16_t relax_prev_lsf_interp /* i  : relax prev frame lsf interp after erasure   */
    1128             : );
    1129             : 
    1130             : /*! r: length of output */
    1131             : int16_t modify_Fs(
    1132             :     const float sigIn[], /* i  : signal to decimate                          */
    1133             :     const int16_t lg,    /* i  : length of input                             */
    1134             :     const int32_t fin,   /* i  : frequency of input                          */
    1135             :     float sigOut[],      /* o  : decimated signal                            */
    1136             :     const int32_t fout,  /* i  : frequency of output                         */
    1137             :     float mem[],         /* i/o: filter memory                               */
    1138             :     const int16_t nblp   /* i  : flag indicating if NB low-pass is applied   */
    1139             : );
    1140             : 
    1141             : void pred_lt4(
    1142             :     const float excI[],     /* i  : input excitation buffer                     */
    1143             :     float excO[],           /* o  : output excitation buffer                    */
    1144             :     const int16_t T0,       /* i  : integer pitch lag                           */
    1145             :     int16_t frac,           /* i  : fraction of lag                             */
    1146             :     const int16_t L_subfr,  /* i  : subframe size                               */
    1147             :     const float *win,       /* i  : interpolation window                        */
    1148             :     const int16_t nb_coef,  /* i  : nb of filter coef                           */
    1149             :     const int16_t up_sample /* i  : up_sample                                   */
    1150             : );
    1151             : 
    1152             : void pred_lt4_tc(
    1153             :     float exc[],           /* i  : excitation buffer                           */
    1154             :     const int16_t T0,      /* i  : integer pitch lag                           */
    1155             :     int16_t frac,          /* i  : fraction of lag                             */
    1156             :     const float *win,      /* i  : interpolation window                        */
    1157             :     const int16_t imp_pos, /* i  : glottal impulse position                    */
    1158             :     const int16_t i_subfr  /* i  : subframe index                              */
    1159             : );
    1160             : 
    1161             : void residu(
    1162             :     const float *a,  /* i  : LP filter coefficients                      */
    1163             :     const int16_t m, /* i  : order of LP filter                          */
    1164             :     const float *x,  /* i  : input signal (usually speech)               */
    1165             :     float *y,        /* o  : output signal (usually residual)            */
    1166             :     const int16_t l  /* i  : size of filtering                           */
    1167             : );
    1168             : 
    1169             : void calc_residu(
    1170             :     const float *speech,  /* i  : weighted speech signal                      */
    1171             :     float *res,           /* o  : residual signal                             */
    1172             :     const float *p_Aq,    /* i  : quantized LP filter coefficients            */
    1173             :     const int16_t L_frame /* i  : size of frame                               */
    1174             : );
    1175             : 
    1176             : /*! r: impulse response energy */
    1177             : float enr_1_Az(
    1178             :     const float Aq[], /* i  : LP filter coefs                             */
    1179             :     const int16_t len /* i  : impulse response length                     */
    1180             : );
    1181             : 
    1182             : void Es_pred_enc(
    1183             :     float *Es_pred,          /* o  : predicited scaled innovation energy         */
    1184             :     int16_t *Es_pred_indice, /* o  : indice corresponding to above parameter     */
    1185             :     const int16_t L_frame,   /* i  : length of the frame                         */
    1186             :     const int16_t L_subfr,   /* i  : length of the subframe                      */
    1187             :     const float *res,        /* i  : residual signal                             */
    1188             :     const float *voicing,    /* i  : normal. correlattion in three 1/2frames     */
    1189             :     const int16_t nb_bits,   /* i  : allocated number of bits                    */
    1190             :     const int16_t no_ltp     /* i  : no_ltp flag                                 */
    1191             : );
    1192             : 
    1193             : void create_offset(
    1194             :     UWord32 *offset_scale1,
    1195             :     UWord32 *offset_scale2,
    1196             :     const int16_t mode,
    1197             :     const int16_t prediction_flag );
    1198             : 
    1199             : float mslvq(
    1200             :     float *pTmp,            /* i  : M-dimensional input vector                  */
    1201             :     float *quant,           /* o  : quantized vector                            */
    1202             :     float *cv_out,          /* o  : corresponding 8-dim lattice codevectors (without the scaling) */
    1203             :     int16_t *idx_lead,      /* o  : leader index for each 8-dim subvector       */
    1204             :     int16_t *idx_scale,     /* o  : scale index for each subvector              */
    1205             :     const float *w,         /* i  : weights for LSF quantization                */
    1206             :     const int16_t mode,     /* i  : number indicating the coding mode           */
    1207             :     const int16_t mode_glb, /* i  : LVQ coding mode                             */
    1208             :     const int16_t pred_flag /* i  : prediction flag (0: safety net, 1 - predictive )*/
    1209             : );
    1210             : 
    1211             : void permute(
    1212             :     float *pTmp1,       /* i/o: vector whose components are to be permuted  */
    1213             :     const int16_t *perm /* i  : permutation info (indexes that should be interchanged), max two perms */
    1214             : );
    1215             : 
    1216             : void sort_desc_ind(
    1217             :     float *s,
    1218             :     const int16_t len,
    1219             :     int16_t *ind );
    1220             : 
    1221             : float mslvq_cng(
    1222             :     int16_t idx_cv,     /* i  : index of cv from previous stage             */
    1223             :     float *pTmp,        /* i  : 16 dimensional input vector                 */
    1224             :     float *quant,       /* o  : quantized vector                            */
    1225             :     float *cv_out,      /* o  : corresponding 8-dim lattice codevectors (without the scaling) */
    1226             :     int16_t *idx_lead,  /* o  : leader index for each 8-dim subvector       */
    1227             :     int16_t *idx_scale, /* o  : scale index for each subvector              */
    1228             :     const float *w      /* i  : weights for LSF quantization                */
    1229             : );
    1230             : 
    1231             : int16_t deindex_lvq_cng(
    1232             :     int16_t *index,       /* i  : index to be decoded, as an array of 3 short */
    1233             :     float *x_lvq,         /* o  : decoded codevector                          */
    1234             :     const int16_t idx_cv, /* i  : relative mode_lvq, wrt START_CNG            */
    1235             :     const int16_t no_bits /* i  : number of bits for lattice                  */
    1236             : );
    1237             : 
    1238             : void multiply32_32_64(
    1239             :     UWord32 x,   /* i  : operand 1                                   */
    1240             :     UWord32 y,   /* i  : operand 2                                   */
    1241             :     UWord32 *res /* o  : result as array of two uint32               */
    1242             : );
    1243             : 
    1244             : int16_t deindex_lvq(
    1245             :     int16_t *index,        /* i  : index to be decoded, as an array of 3 short */
    1246             :     float *x_lvq,          /* o  : decoded codevector                          */
    1247             :     const int16_t mode,    /* i  : LVQ  coding mode (select scales & no_lead ), or idx_cv */
    1248             :     const int16_t sf_flag, /* i  : safety net flag                             */
    1249             :     const int16_t no_bits  /* i  : number of bits for lattice                  */
    1250             : );
    1251             : 
    1252             : int16_t vq_dec_lvq(
    1253             :     int16_t sf_flag,      /* i  : safety net flag                             */
    1254             :     float x[],            /* o  : Decoded vector                              */
    1255             :     int16_t indices[],    /* i  : Indices                                     */
    1256             :     const int16_t stages, /* i  : Number of stages                            */
    1257             :     const int16_t N,      /* i  : Vector dimension                            */
    1258             :     const int16_t mode,   /* i  : lvq coding type                             */
    1259             :     const int16_t no_bits /* i  : no. bits for lattice                        */
    1260             : );
    1261             : 
    1262             : void index_lvq(
    1263             :     float *quant,                 /* i  : codevector to be indexed (2 8-dim subvectors)                     */
    1264             :     int16_t *idx_lead,            /* i  : leader class index for each subvector                             */
    1265             :     int16_t *idx_scale,           /* i  : scale index for each subvector                                    */
    1266             :     const int16_t mode,           /* i  : integer signaling the quantizer structure for the current bitrate */
    1267             :     int16_t *index,               /* o  : encoded index (represented on 3 short each with 15 bits )         */
    1268             :     const int16_t prediction_flag /* i  : predictive mode or not                                            */
    1269             : );
    1270             : 
    1271             : int16_t qlsf_ARSN_tcvq_Dec_16k(
    1272             :     float *y,           /* o  : Quantized LSF vector                        */
    1273             :     int16_t *indice,    /* i  : Indices                                     */
    1274             :     const int16_t nBits /* i  : number of bits                              */
    1275             : );
    1276             : 
    1277             : int16_t lsf_bctcvq_encprm(
    1278             :     BSTR_ENC_HANDLE hBstr,
    1279             :     const int16_t *param_lpc,
    1280             :     const int16_t *bits_param_lpc,
    1281             :     const int16_t no_indices );
    1282             : 
    1283             : int16_t lsf_bctcvq_decprm(
    1284             :     Decoder_State *st,
    1285             :     int16_t *param_lpc );
    1286             : 
    1287             : ivas_error lsf_allocate(
    1288             :     const int16_t nBits,       /* i  : Number of bits to use for quantization      */
    1289             :     const int16_t framemode,   /* i  : ISF quantizer mode                          */
    1290             :     const int16_t framemode_p, /* i  : ISF quantizer mode                          */
    1291             :     int16_t *stages0,          /* o  : Number of stages for safety-net quantizer   */
    1292             :     int16_t *stages1,          /* o  : Number of stages for predictive quantizer   */
    1293             :     int16_t levels0[],         /* o  : Number of vectors for each stage for SFNET  */
    1294             :     int16_t levels1[],         /* o  : Number of vectors for each stage for pred   */
    1295             :     int16_t bits0[],           /* o  : Number of bits for each stage safety net    */
    1296             :     int16_t bits1[]            /* o  : Number of bits for each stage predictive    */
    1297             : );
    1298             : 
    1299             : void disf_2s_36b(
    1300             :     int16_t *indice, /* i  : quantized indices (use indice[0] = -1 in the decoder) */
    1301             :     float *isf_q,    /* o  : quantized ISFs in the cosine domain         */
    1302             :     float *mem_AR,   /* i/o: quantizer memory for AR model               */
    1303             :     float *mem_MA    /* i/o: quantizer memory for MA model               */
    1304             : );
    1305             : 
    1306             : void disf_2s_46b(
    1307             :     int16_t *indice, /* i  : quantized indices (use indice[0] = -1 in the decoder) */
    1308             :     float *isf_q,    /* o  : quantized ISFs in the cosine domain         */
    1309             :     float *mem_AR,   /* o  : quantizer memory for AR model               */
    1310             :     float *mem_MA    /* i/o: quantizer memory for MA model               */
    1311             : );
    1312             : 
    1313             : void re8_k2y(
    1314             :     const int16_t *k, /* i  : Voronoi index k[0..7]                                   */
    1315             :     const int16_t m,  /* i  : Voronoi modulo (m = 2^r = 1<<r, where r is integer >=2) */
    1316             :     int16_t *y        /* o  : 8-dimensional point y[0..7] in RE8                      */
    1317             : );
    1318             : 
    1319             : void re8_PPV(
    1320             :     const float x[], /* i  : point in R^8                                */
    1321             :     int16_t y[]      /* o  : point in RE8 (8-dimensional integer vector) */
    1322             : );
    1323             : 
    1324             : void enhancer(
    1325             :     const int16_t codec_mode,   /* i  : flag indicating Codec Mode              */
    1326             :     const int32_t core_brate,   /* i  : core bitrate                            */
    1327             :     const int16_t cbk_index,    /* i  :                                         */
    1328             :     const int16_t Opt_AMR_WB,   /* i  : flag indicating AMR-WB IO mode          */
    1329             :     const int16_t coder_type,   /* i  : coding type                             */
    1330             :     const int16_t L_frame,      /* i  : frame size                              */
    1331             :     const float voice_fac,      /* i  : subframe voicing estimation             */
    1332             :     const float stab_fac,       /* i  : LP filter stablility measure            */
    1333             :     const float norm_gain_code, /* i  : normalized innovative cb. gain          */
    1334             :     const float gain_inov,      /* i  : gain of the unscaled innovation         */
    1335             :     float *gc_threshold,        /* i/o: code threshold                          */
    1336             :     float *code,                /* i/o: innovation                              */
    1337             :     float *exc2,                /* i/o: adapt. excitation/total exc.            */
    1338             :     const float gain_pit,       /* i  : Quantized pitch gain                    */
    1339             :     float *dispMem              /* i/o: Phase dispersion algorithm memory       */
    1340             : );
    1341             : 
    1342             : void phase_dispersion(
    1343             :     const float gain_code, /* i  : gain of code                            */
    1344             :     const float gain_pit,  /* i  : gain of pitch                           */
    1345             :     float code[],          /* i/o: code vector                             */
    1346             :     const int16_t mode,    /* i  : level, 0=hi, 1=lo, 2=off                */
    1347             :     float disp_mem[]       /* i/o: static memory (size = 8)                */
    1348             : );
    1349             : 
    1350             : void re8_vor(
    1351             :     int16_t y[], /* i  : point in RE8 (8-dimensional integer vector)      */
    1352             :     int16_t *n,  /* o  : codebook number n=0,2,3,4,... (scalar integer)   */
    1353             :     int16_t k[], /* o  : Voronoi index (integer vector of dimension 8) used only if n>4 */
    1354             :     int16_t c[], /* o  : codevector in Q0, Q2, Q3, or Q4 if n<=4, y=c     */
    1355             :     int16_t *ka  /* o  : identifier of absolute leader (needed to index c)*/
    1356             : );
    1357             : 
    1358             : void edct(
    1359             :     const float *x,            /* i  : input signal        */
    1360             :     float *y,                  /* o  : output transform    */
    1361             :     const int16_t length,      /* i  : length              */
    1362             :     const int16_t element_mode /* i  : IVAS element mode   */
    1363             : );
    1364             : 
    1365             : void edst(
    1366             :     const float *x,            /* i  : input signal        */
    1367             :     float *y,                  /* o  : output transform    */
    1368             :     const int16_t length,      /* i  : length              */
    1369             :     const int16_t element_mode /* i  : IVAS element mode   */
    1370             : );
    1371             : 
    1372             : void edxt(
    1373             :     const float *x,            /* i  : input signal        */
    1374             :     float *y,                  /* o  : output transform    */
    1375             :     const int16_t length,      /* i  : length              */
    1376             :     const uint16_t kernelType, /* i  : kernel type (0 - 3) */
    1377             :     const uint16_t synthesis   /* i  : nonzero for inverse */
    1378             : );
    1379             : 
    1380             : void iedct_short(
    1381             :     const float *in,              /* i  : input vector        */
    1382             :     float *out,                   /* o  : output vector       */
    1383             :     const int16_t segment_length, /* i  : length              */
    1384             :     const int16_t element_mode    /* i  : IVAS element mode   */
    1385             : );
    1386             : 
    1387             : void DoRTFT480(
    1388             :     float *x, /* i/o: real part of input and output data       */
    1389             :     float *y  /* i/o: imaginary part of input and output data  */
    1390             : );
    1391             : 
    1392             : void DoRTFT320(
    1393             :     float *x, /* i/o: real part of input and output data       */
    1394             :     float *y  /* i/o: imaginary part of input and output data  */
    1395             : );
    1396             : 
    1397             : void DoRTFT160(
    1398             :     float *x, /* i/o: real part of input and output data       */
    1399             :     float *y  /* i/o: imaginary part of input and output data  */
    1400             : );
    1401             : 
    1402             : void DoRTFT128(
    1403             :     float *x, /* i/o: real part of input and output data       */
    1404             :     float *y  /* i/o: imaginary part of input and output data  */
    1405             : );
    1406             : 
    1407             : void DoRTFT120(
    1408             :     float *x, /* i/o: real part of input and output data       */
    1409             :     float *y  /* i/o: imaginary part of input and output data  */
    1410             : );
    1411             : 
    1412             : void DoRTFT80(
    1413             :     float *x, /* i/o: real part of input and output data       */
    1414             :     float *y  /* i/o: imaginary part of input and output data  */
    1415             : );
    1416             : 
    1417             : void DoRTFT20(
    1418             :     float *x, /* i/o: real part of input and output data       */
    1419             :     float *y  /* i/o: imaginary part of input and output data  */
    1420             : );
    1421             : 
    1422             : void DoRTFT40(
    1423             :     float *x, /* i/o: real part of input and output data       */
    1424             :     float *y  /* i/o: imaginary part of input and output data  */
    1425             : );
    1426             : 
    1427             : void DoRTFTn(
    1428             :     float *x,       /* i/o: real part of input and output data       */
    1429             :     float *y,       /* i/o: imaginary part of input and output data  */
    1430             :     const int16_t n /* i  : size of the FFT n=(2^k) up to 1024       */
    1431             : );
    1432             : 
    1433             : void BASOP_cfft(
    1434             :     Word32 *re,   /* i/o: real part                                 */
    1435             :     Word32 *im,   /* i/o: imag part                                 */
    1436             :     Word16 s,     /* i  : stride real and imag part                 */
    1437             :     Word16 *scale /* i  : scalefactor                               */
    1438             : );
    1439             : 
    1440             : void fft(
    1441             :     float *re,            /* i/o: real part                         */
    1442             :     float *im,            /* i/o: imag part                         */
    1443             :     const int16_t length, /* i  : length of fft                     */
    1444             :     const int16_t s       /* i  : sign                              */
    1445             : );
    1446             : 
    1447             : void rfft(
    1448             :     float *x,             /* i/o: values                            */
    1449             :     const float *w,       /* i  : window                            */
    1450             :     const int16_t length, /* i  : length of fft                     */
    1451             :     const int16_t isign   /* i  : sign                              */
    1452             : );
    1453             : 
    1454             : void sinq(
    1455             :     const float tmp, /* i  : sinus factor cos(tmp*i+phi)  */
    1456             :     const float phi, /* i  : sinus phase cos(tmp*i+phi)   */
    1457             :     const int16_t N, /* i  : size of output               */
    1458             :     float x[]        /* o  : output vector                */
    1459             : );
    1460             : 
    1461             : void edct2(
    1462             :     const int16_t n,
    1463             :     const int16_t isgn,
    1464             :     float *in,
    1465             :     float *a,
    1466             :     const int16_t *ip,
    1467             :     const float *w );
    1468             : 
    1469             : void stat_noise_uv_mod(
    1470             :     const int16_t coder_type,   /* i  : coder type                           */
    1471             :     float noisiness,            /* i  : noisiness parameter                  */
    1472             :     const float *const lsp_old, /* i  : old LSP vector at 4th sfr            */
    1473             :     const float *const lsp_new, /* i  : LSP vector at 4th sfr                */
    1474             :     const float *const lsp_mid, /* i  : LSP vector at 2nd sfr                */
    1475             :     float *Aq,                  /* o  : A(z) quantized for the 4 subframes   */
    1476             :     float *exc2,                /* o  : excitation buffer                    */
    1477             :     const int16_t bfi,          /* i  : bad frame indicator                  */
    1478             :     float *ge_sm,               /* i/o: smoothed excitation gain             */
    1479             :     int16_t *uv_count,          /* i/o: unvoiced counter                     */
    1480             :     int16_t *act_count,         /* i/o: activation counter                   */
    1481             :     float lspold_s[],           /* i/o: old LSP                              */
    1482             :     int16_t *noimix_seed,       /* i/o: mixture seed                         */
    1483             :     float *st_min_alpha,        /* i/o: minimum alpha                        */
    1484             :     float *exc_pe,              /* i/o: memory of the preemphasis filter     */
    1485             :     const int32_t bitrate,      /* i  : core bitrate                         */
    1486             :     const int16_t bwidth        /* i  : audio bandwidth                      */
    1487             : );
    1488             : 
    1489             : void pre_echo_att(
    1490             :     float *Last_frame_ener,        /* i/o: Energy of the last frame                */
    1491             :     float *exc,                    /* i/o: Excitation of the current frame         */
    1492             :     const int16_t attack_flag,     /* i  : attack flag (GSC or TC)                 */
    1493             :     const int16_t last_coder_type, /* i  : Last coder type                         */
    1494             :     const int16_t L_frame          /* i  : frame length                            */
    1495             : );
    1496             : 
    1497             : void limit_band_noise_level_calc(
    1498             :     const int16_t *wnorm,     /* i  : reordered norm of sub-vectors           */
    1499             :     int16_t *limit,           /* o  : highest band of bit allocation          */
    1500             :     const int32_t core_brate, /* i  : core bitrate                            */
    1501             :     float *noise_level        /* o  : noise level                             */
    1502             : );
    1503             : 
    1504             : /*! r: hqswb_clas */
    1505             : int16_t peak_avrg_ratio(
    1506             :     const int32_t total_brate, /* i  : total bitrate              */
    1507             :     const float *input_hi,     /* i  : input signal               */
    1508             :     const int16_t N,           /* i  : number of coefficients     */
    1509             :     int16_t *mode_count,       /* i/o: HQ_HARMONIC mode count     */
    1510             :     int16_t *mode_count1       /* i/o: HQ_NORMAL mode count       */
    1511             : );
    1512             : 
    1513             : /*! r: Number of coefficients in nf codebook */
    1514             : int16_t build_nf_codebook(
    1515             :     const int16_t flag_32K_env_ho, /* i  : Envelope attenuation hangover flag */
    1516             :     const float *coeff,            /* i  : Coded spectral coefficients        */
    1517             :     const int16_t *sfm_start,      /* i  : Subband start indices              */
    1518             :     const int16_t *sfmsize,        /* i  : Subband widths                     */
    1519             :     const int16_t *sfm_end,        /* i  : Subband end indices                */
    1520             :     const int16_t nb_sfm,          /* i  : Last coded band                    */
    1521             :     const int16_t *R,              /* i  : Per-band bit allocation            */
    1522             :     float *CodeBook,               /* o  : Noise-fill codebook                */
    1523             :     float *CodeBook_mod            /* o  : Densified noise-fill codebook      */
    1524             : );
    1525             : 
    1526             : void apply_noisefill_HQ(
    1527             :     const int16_t *R,              /* i  : bit allocation                   */
    1528             :     const int16_t length,          /* i  : input frame length               */
    1529             :     const int16_t flag_32K_env_ho, /* i  : envelope stability hangover flag */
    1530             :     const int32_t core_brate,      /* i  : core bitrate                     */
    1531             :     const int16_t last_sfm,        /* i  : last coded subband               */
    1532             :     const float *CodeBook,         /* i  : Noise-fill codebook              */
    1533             :     const float *CodeBook_mod,     /* i  : Densified noise-fill codebook    */
    1534             :     const int16_t cb_size,         /* i  : Codebook length                  */
    1535             :     const int16_t *sfm_start,      /* i  : Subband start coefficient        */
    1536             :     const int16_t *sfm_end,        /* i  : Subband end coefficient          */
    1537             :     const int16_t *sfmsize,        /* i  : Subband band width               */
    1538             :     float *coeff                   /* i/o: coded/noisefilled spectrum       */
    1539             : );
    1540             : 
    1541             : void harm_bwe_fine(
    1542             :     const int16_t *R,         /* i  : bit allocation                          */
    1543             :     const int16_t last_sfm,   /* i  : last coded subband                      */
    1544             :     const int16_t high_sfm,   /* i  : higher transition band to BWE           */
    1545             :     const int16_t num_sfm,    /* i  : total number of bands                   */
    1546             :     const int16_t *norm,      /* i  : quantization indices for norms          */
    1547             :     const int16_t *sfm_start, /* i  : Subband start coefficient               */
    1548             :     const int16_t *sfm_end,   /* i  : Subband end coefficient                 */
    1549             :     int16_t *prev_L_swb_norm, /* i/o: last normalize length                   */
    1550             :     float *coeff,             /* i/o: coded/noisefilled normalized spectrum   */
    1551             :     float *coeff_out,         /* o  : coded/noisefilled spectrum              */
    1552             :     float *coeff_fine         /* o  : BWE fine structure                      */
    1553             : );
    1554             : 
    1555             : void hvq_bwe_fine(
    1556             :     const int16_t last_sfm,   /* i  : last coded subband                      */
    1557             :     const int16_t num_sfm,    /* i  : total number of bands                   */
    1558             :     const int16_t *sfm_end,   /* i  : Subband end coefficient                 */
    1559             :     const int16_t *peak_idx,  /* i  : Peak index                              */
    1560             :     const int16_t Npeaks,     /* i  : Number of peaks                         */
    1561             :     int16_t *peak_pos,        /* i/o: Peak positions                          */
    1562             :     int16_t *prev_L_swb_norm, /* i/o: last normalize length                   */
    1563             :     float *coeff,             /* i/o: coded/noisefilled normalized spectrum   */
    1564             :     int16_t *bwe_peaks,       /* o  : Positions of peaks in BWE               */
    1565             :     float *coeff_fine         /* o  : HVQ BWE fine structure                  */
    1566             : );
    1567             : 
    1568             : void hq_fold_bwe(
    1569             :     const int16_t last_sfm, /* i  : last coded subband                      */
    1570             :     const int16_t *sfm_end, /* i  : Subband end coefficient                 */
    1571             :     const int16_t num_sfm,  /* i  : Number of subbands                      */
    1572             :     float *coeff            /* i/o: coded/noisefilled normalized spectrum   */
    1573             : );
    1574             : 
    1575             : void apply_nf_gain(
    1576             :     const int16_t nf_idx,     /* i  : noise fill gain index                   */
    1577             :     const int16_t last_sfm,   /* i  : last coded subband                      */
    1578             :     const int16_t *R,         /* i  : bit allocation                          */
    1579             :     const int16_t *sfm_start, /* i  : Subband start coefficient               */
    1580             :     const int16_t *sfm_end,   /* i  : Subband end coefficient                 */
    1581             :     float *coeff              /* i/o: coded/noisefilled normalized spectrum   */
    1582             : 
    1583             : );
    1584             : 
    1585             : void hq_generic_fine(
    1586             :     float *coeff,             /* i  : coded/noisefilled normalized spectrum   */
    1587             :     const int16_t last_sfm,   /* i  : Last coded band                         */
    1588             :     const int16_t *sfm_start, /* i  : Subband start coefficient               */
    1589             :     const int16_t *sfm_end,   /* i  : Subband end coefficient                 */
    1590             :     int16_t *bwe_seed,        /* i/o: random seed for generating BWE input    */
    1591             :     float *coeff_out1         /* o  : HQ GENERIC input                        */
    1592             : );
    1593             : 
    1594             : void harm_bwe(
    1595             :     const float *coeff_fine,    /* i  : fine structure for BWE                  */
    1596             :     const float *coeff,         /* i  : coded/noisefilled normalized spectrum   */
    1597             :     const int16_t num_sfm,      /* i  : Number of subbands                      */
    1598             :     const int16_t *sfm_start,   /* i  : Subband start coefficient               */
    1599             :     const int16_t *sfm_end,     /* i  : Subband end coefficient                 */
    1600             :     const int16_t last_sfm,     /* i  : last coded subband                      */
    1601             :     const int16_t high_sfm,     /* i  : higher transition band to BWE           */
    1602             :     const int16_t *R,           /* i  : bit allocation                          */
    1603             :     const int16_t prev_hq_mode, /* i  : previous hq mode                        */
    1604             :     int16_t *norm,              /* i/o: quantization indices for norms          */
    1605             :     float *noise_level,         /* i/o: noise levels for harmonic modes         */
    1606             :     float *prev_noise_level,    /* i/o: noise factor in previous frame          */
    1607             :     int16_t *bwe_seed,          /* i/o: random seed for generating BWE input    */
    1608             :     float *coeff_out,           /* o  : coded/noisefilled spectrum              */
    1609             :     const int16_t element_mode  /* i  : element mode                            */
    1610             : );
    1611             : 
    1612             : void hvq_bwe(
    1613             :     const float *coeff,         /* i  : coded/noisefilled spectrum              */
    1614             :     const float *coeff_fine,    /* i  : BWE fine structure                      */
    1615             :     const int16_t *sfm_start,   /* i  : Subband start coefficient               */
    1616             :     const int16_t *sfm_end,     /* i  : Subband end coefficient                 */
    1617             :     const int16_t *sfm_len,     /* i  : Subband length                          */
    1618             :     const int16_t last_sfm,     /* i  : last coded subband                      */
    1619             :     const int16_t prev_hq_mode, /* i  : previous hq mode                        */
    1620             :     const int16_t *bwe_peaks,   /* i  : HVQ bwe peaks                           */
    1621             :     const int16_t bin_th,       /* i  : HVQ transition bin                      */
    1622             :     const int16_t num_sfm,      /* i  : Number of bands                         */
    1623             :     const int32_t core_brate,   /* i  : Core bitrate                            */
    1624             :     const int16_t *R,           /* i  : Bit allocation                          */
    1625             :     int16_t *norm,              /* i/o: quantization indices for norms          */
    1626             :     float *noise_level,         /* i/o: noise levels for harmonic modes         */
    1627             :     float *prev_noise_level,    /* i/o: noise factor in previous frame          */
    1628             :     int16_t *bwe_seed,          /* i/o: random seed for generating BWE input    */
    1629             :     float *coeff_out            /* o  : coded/noisefilled spectrum              */
    1630             : );
    1631             : 
    1632             : void hvq_concat_bands(
    1633             :     const int16_t pvq_bands,  /* i  : Number of bands in concatenated PVQ target  */
    1634             :     const int16_t *sel_bnds,  /* i  : Array of selected high bands                */
    1635             :     const int16_t n_sel_bnds, /* i  : Number of selected high bands               */
    1636             :     int16_t *hvq_band_start,  /* o  : Band start indices                          */
    1637             :     int16_t *hvq_band_width,  /* o  : Band widths                                 */
    1638             :     int16_t *hvq_band_end     /* o  : Band end indices                            */
    1639             : );
    1640             : 
    1641             : void hq_generic_bwe(
    1642             :     const int16_t HQ_mode,             /* i  : HQ mode                                     */
    1643             :     float *coeff_out1,                 /* i/o: BWE input & temporary buffer                */
    1644             :     const float *hq_generic_fenv,      /* i  : SWB frequency envelopes                     */
    1645             :     float *coeff_out,                  /* o  : SWB signal in MDCT domain                   */
    1646             :     const int16_t hq_generic_offset,   /* i  : frequency offset for representing hq generic*/
    1647             :     int16_t *prev_L_swb_norm,          /* i/o: last normalize length                       */
    1648             :     const int16_t hq_generic_exc_clas, /* i  : hq generic hf excitation class              */
    1649             :     const int16_t *sfm_end,            /* i  : End of bands                                */
    1650             :     const int16_t num_sfm,             /* i  : Number of bands                             */
    1651             :     const int16_t num_env_bands,       /* i  : Number of coded envelope bands              */
    1652             :     const int16_t *R                   /* i  : Bit allocation                              */
    1653             : );
    1654             : 
    1655             : void logqnorm_2(
    1656             :     const float *env_fl,      /* o  : index                   */
    1657             :     const int16_t L,          /* i  : codebook length         */
    1658             :     const int16_t n_env_band, /* i  : sub-vector size         */
    1659             :     const int16_t nb_sfm,     /* i  : sub-vector size         */
    1660             :     int16_t *ynrm,            /* o  : norm indices            */
    1661             :     int16_t *normqlg2,        /* o  : quantized norm values   */
    1662             :     const float *thren        /* i  : quantization thresholds */
    1663             : );
    1664             : 
    1665             : void map_hq_generic_fenv_norm(
    1666             :     const int16_t hqswb_clas,       /* i  : signal classification flag      */
    1667             :     const float *hq_generic_fenv,   /* i  : HQ GENERIC envelope             */
    1668             :     int16_t *ynrm,                  /* o  : high band norm indices          */
    1669             :     int16_t *normqlg2,              /* o  : high band norm values           */
    1670             :     const int16_t num_env_bands,    /* i  : Number coded envelope bands     */
    1671             :     const int16_t nb_sfm,           /* i  : Number of envelope bands        */
    1672             :     const int16_t hq_generic_offset /* i  : Freq offset for HQ GENERIC      */
    1673             : );
    1674             : 
    1675             : /*! r: Number of bits consumed for the delta coding */
    1676             : int16_t calc_nor_delta_hf(
    1677             :     BSTR_ENC_HANDLE hBstr,       /* i/o: encoder bitstream handle       */
    1678             :     const float *t_audio,        /* i  : transform-domain coefficients  */
    1679             :     int16_t *ynrm,               /* i/o: norm indices                   */
    1680             :     int16_t *Rsubband,           /* i/o: sub-band bit allocation        */
    1681             :     const int16_t num_env_bands, /* i  : Number coded envelope bands    */
    1682             :     const int16_t nb_sfm,        /* i  : Number of envelope bands       */
    1683             :     const int16_t *sfmsize,      /* i  : band length                    */
    1684             :     const int16_t *sfm_start,    /* i  : Start index of bands           */
    1685             :     const int16_t core_sfm       /* i  : index of the end band for core */
    1686             : );
    1687             : 
    1688             : /*! r: Number of bits consumed for the delta coding */
    1689             : int16_t get_nor_delta_hf(
    1690             :     Decoder_State *st,           /* i/o: Decoder state                  */
    1691             :     int16_t *ynrm,               /* i/o: norm indices                   */
    1692             :     int16_t *Rsubband,           /* i/o: sub-band bit allocation        */
    1693             :     const int16_t num_env_bands, /* i  : Number coded envelope bands    */
    1694             :     const int16_t nb_sfm,        /* i  : Number of envelope bands       */
    1695             :     const int16_t core_sfm );    /* i  : index of the end band for core */
    1696             : 
    1697             : void hq_wb_nf_bwe(
    1698             :     const float *coeff,              /* i  : coded/noisefilled normal. spectrum      */
    1699             :     const int16_t is_transient,      /* i  : is transient flag                       */
    1700             :     const int16_t prev_bfi,          /* i  : previous bad frame indicator            */
    1701             :     const float *normq_v,            /* i  : norms                                   */
    1702             :     const int16_t num_sfm,           /* i  : Number of subbands                      */
    1703             :     const int16_t *sfm_start,        /* i  : Subband start coefficient               */
    1704             :     const int16_t *sfm_end,          /* i  : Subband end coefficient                 */
    1705             :     const int16_t *sfmsize,          /* i  : Subband band width                      */
    1706             :     const int16_t last_sfm,          /* i  : last coded subband                      */
    1707             :     const int16_t *R,                /* i  : bit allocation                          */
    1708             :     const int16_t prev_is_transient, /* i  : previous transient flag                 */
    1709             :     float *prev_normq,               /* i/o: previous norms                          */
    1710             :     float *prev_env,                 /* i/o: previous noise envelopes                */
    1711             :     int16_t *bwe_seed,               /* i/o: random seed for generating BWE input    */
    1712             :     float *prev_coeff_out,           /* i/o: decoded spectrum in previous frame      */
    1713             :     int16_t *prev_R,                 /* i/o: previous frame bit allocation info.     */
    1714             :     float *coeff_out                 /* o  : coded/noisefilled spectrum              */
    1715             : );
    1716             : 
    1717             : /*! r: Number of bits */
    1718             : int16_t encode_envelope_indices(
    1719             :     BSTR_ENC_HANDLE hBstr,     /* i/o: encoder bitstream handle                */
    1720             :     const int16_t num_sfm,     /* i  : Number of subbands                      */
    1721             :     const int16_t numnrmibits, /* i  : Bitrate of fall-back coding mode        */
    1722             :     int16_t *difidx,           /* i/o: Diff indices/encoded diff indices       */
    1723             :     int16_t *LCmode,           /* o  : Coding mode                             */
    1724             :     const int16_t flag_pack,   /* i  : indicator of packing or estimating bits */
    1725             :     const int16_t flag_HQ2,    /* i  : indicator of HQ2 core                   */
    1726             :     const int16_t is_transient /* i  : transient flag                          */
    1727             : );
    1728             : 
    1729             : void diff_envelope_coding(
    1730             :     const int16_t is_transient,  /* i  : transient indicator                     */
    1731             :     const int16_t num_env_bands, /* i  : number of envelope bands to code        */
    1732             :     const int16_t start_norm,    /* i  : start of envelope coding                */
    1733             :     int16_t *ynrm,               /* i/o: quantization indices for norms          */
    1734             :     int16_t *normqlg2,           /* i/o: quantized norms                         */
    1735             :     int16_t *difidx              /* o  : differential code                       */
    1736             : );
    1737             : 
    1738             : /*! r: Number of bits */
    1739             : int16_t decode_envelope_indices(
    1740             :     Decoder_State *st,         /* i/o: decoder state structure                 */
    1741             :     const int16_t start_norm,  /* i  : First SDE encoded norm                  */
    1742             :     const int16_t num_sfm,     /* i  : Number of norms                         */
    1743             :     const int16_t numnrmibits, /* i  : Bitrate of fall-back coding mode        */
    1744             :     int16_t *ynrm,             /* o  : Decoded norm indices                    */
    1745             :     const int16_t flag_HQ2,    /* i  : indicator of HQ2 core                   */
    1746             :     const int16_t is_transient /* i  : transient flag                          */
    1747             : );
    1748             : 
    1749             : /*! r: Number of bits */
    1750             : void dequantize_norms(
    1751             :     Decoder_State *st,          /* i/o: decoder state structure                 */
    1752             :     const int16_t start_norm,   /* i  : First SDE encoded norm                  */
    1753             :     const int16_t num_sfm,      /* i  : Number of norms                         */
    1754             :     const int16_t is_transient, /* i  : Transient flag                          */
    1755             :     int16_t *ynrm,              /* o  : Decoded norm indices                    */
    1756             :     int16_t *normqlg2           /* o  : Log2 of decoded norms                   */
    1757             : );
    1758             : 
    1759             : void hq_configure(
    1760             :     const int16_t length,       /* i  : Frame length                              */
    1761             :     const int16_t hqswb_clas,   /* i  : HQ SWB class                              */
    1762             :     const int32_t core_brate,   /* i  : core bitrate                              */
    1763             :     int16_t *num_sfm,           /* o  : Total number of subbands                  */
    1764             :     int16_t *nb_sfm,            /* o  : Total number of coded bands               */
    1765             :     int16_t *start_norm,        /* o  : First norm to be SDE encoded              */
    1766             :     int16_t *num_sde_norm,      /* o  : Number of norms for SDE encoding          */
    1767             :     int16_t *numnrmibits,       /* o  : Number of bits in fall-back norm encoding */
    1768             :     int16_t *hq_generic_offset, /* o  : Freq offset for HQ GENERIC                */
    1769             :     int16_t *sfmsize,           /* o  : Subband bandwidths                        */
    1770             :     int16_t *sfm_start,         /* o  : Subband start coefficients                */
    1771             :     int16_t *sfm_end            /* o  : Subband end coefficients                  */
    1772             : );
    1773             : 
    1774             : /*! r: Consumed bits */
    1775             : int16_t hvq_enc(
    1776             :     BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle                */
    1777             :     const int16_t bwidth,  /* i  : audio bandwidth                         */
    1778             : #ifdef DEBUGGING
    1779             :     const int16_t idchan, /* i  : channel ID                              */
    1780             : #endif
    1781             :     const int32_t core_brate, /* i  : core bitrate                            */
    1782             :     const int16_t hvq_bits,   /* i  : HVQ bit budget                          */
    1783             :     const int16_t Npeaks,     /* i  : Number of peaks                         */
    1784             :     const int16_t *ynrm,      /* i  : Envelope coefficients                   */
    1785             :     int16_t *R,               /* i/o: Bit allocation/updated bit allocation   */
    1786             :     int16_t *peaks,           /* i/o: Peak pos. / Encoded peak pos.           */
    1787             :     float *nf_gains,          /* i/o: Noise fill gains / Quant. nf gains      */
    1788             :     float *noise_level,       /* o  : Quantized noise level                   */
    1789             :     const float *pe_gains,    /* i  : Peak gains                              */
    1790             :     const float *coefs,       /* i  : spectrum coefficients                   */
    1791             :     float *coefs_out          /* o  : encoded spectrum coefficients           */
    1792             : );
    1793             : 
    1794             : /*! r: Consumed bits */
    1795             : int16_t hq_classifier_enc(
    1796             :     Encoder_State *st,          /* i/o: encoder state structure                 */
    1797             :     const int16_t length,       /* i  : Frame length                            */
    1798             :     const float *coefs,         /* i  : Spectral coefficients                   */
    1799             :     const int16_t is_transient, /* i  : Transient flag                          */
    1800             :     int16_t *Npeaks,            /* o  : Number of identified peaks              */
    1801             :     int16_t *peaks,             /* o  : Peak indices                            */
    1802             :     float *pe_gains,            /* o  : Peak gains                              */
    1803             :     float *nf_gains,            /* o  : Noise-fill gains                        */
    1804             :     int16_t *hqswb_clas         /* o  : HQ class                                */
    1805             : );
    1806             : 
    1807             : /*! r: Consumed bits */
    1808             : int16_t hq_classifier_dec(
    1809             :     Decoder_State *st,        /* i/o: decoder state structure                 */
    1810             :     const int32_t core_brate, /* i  : Core bitrate                            */
    1811             :     const int16_t length,     /* i  : Frame length                            */
    1812             :     int16_t *is_transient,    /* o  : Transient flag                          */
    1813             :     int16_t *hqswb_clas       /* o  : HQ class                                */
    1814             : );
    1815             : 
    1816             : void hq_bit_allocation(
    1817             :     const int32_t core_brate,   /* i  : Core bitrate                                   */
    1818             :     const int16_t length,       /* i  : Frame length                                   */
    1819             :     const int16_t hqswb_clas,   /* i  : HQ class                                       */
    1820             :     int16_t *num_bits,          /* i/o: Remaining bit budget                           */
    1821             :     const int16_t *normqlg2,    /* i  : Quantized norms                                */
    1822             :     const int16_t nb_sfm,       /* i  : Number sub bands to be encoded                 */
    1823             :     const int16_t *sfmsize,     /* i  : Sub band bandwidths                            */
    1824             :     float *noise_level,         /* o  : HVQ noise level                                */
    1825             :     int16_t *R,                 /* o  : Bit allocation per sub band                    */
    1826             :     int16_t *Rsubband,          /* o  : Fractional bit allocation (Q3)                 */
    1827             :     int16_t *sum,               /* o  : Sum of allocated shape bits                    */
    1828             :     int16_t *core_sfm,          /* o  : Last coded band in core                        */
    1829             :     const int16_t num_env_bands /* i  : Number sub bands to be encoded for HQ_SWB_BWE  */
    1830             : );
    1831             : 
    1832             : void enforce_zero_for_min_envelope(
    1833             :     const int16_t hqswb_clas, /* i  : HQ coding class                         */
    1834             :     const int16_t *ynrm,      /* i  : Envelope indices                        */
    1835             :     float *coefsq,            /* i/o: Quantized spectrum/zeroed spectrum      */
    1836             :     int16_t nb_sfm,           /* i  : Number of coded sub bands               */
    1837             :     const int16_t *sfm_start, /* i  : Sub band start indices                  */
    1838             :     const int16_t *sfm_end    /* i  : Sub band end indices                    */
    1839             : );
    1840             : 
    1841             : /*! r: Number of assigned gain bits */
    1842             : int16_t assign_gain_bits(
    1843             :     const int16_t core,        /* i  : HQ core                                 */
    1844             :     const int16_t BANDS,       /* i  : Number of bands                         */
    1845             :     const int16_t *band_width, /* i  : Sub band bandwidth                      */
    1846             :     int16_t *Rk,               /* i/o: Bit allocation/Adjusted bit alloc. (Q3) */
    1847             :     int16_t *gain_bits_array,  /* o  : Assigned gain bits                      */
    1848             :     int16_t *Rcalc             /* o  : Bit budget for shape quantizer (Q3)     */
    1849             : );
    1850             : 
    1851             : void apply_envelope(
    1852             :     const float *coeff,       /* i/o: Coded/noisefilled normalized spectrum   */
    1853             :     const int16_t *norm,      /* i  : Envelope                                */
    1854             :     const float *norm_adj,    /* i  : Envelope adjustment                     */
    1855             :     const int16_t num_sfm,    /* i  : Total number of bands                   */
    1856             :     const int16_t last_sfm,   /* i  : Last coded band                         */
    1857             :     const int16_t HQ_mode,    /* i  : HQ mode                                 */
    1858             :     const int16_t length,     /* i  : Frame length                            */
    1859             :     const int16_t *sfm_start, /* i  : Sub band start indices                  */
    1860             :     const int16_t *sfm_end,   /* i  : Sub band end indices                    */
    1861             :     float *normq_v,           /* o  : Envelope with adjustment                */
    1862             :     float *coeff_out,         /* o  : coded/noisefilled spectrum              */
    1863             :     float *coeff_out1         /* o  : noisefilled spectrum for HQ SWB BWE     */
    1864             : );
    1865             : 
    1866             : void apply_envelope_enc(
    1867             :     float *coeff,             /* i/o: Normalized/scaled normalized spectrum   */
    1868             :     const int16_t *norm,      /* i  : Envelope                                */
    1869             :     const int16_t num_sfm,    /* i  : Total number of bands                   */
    1870             :     const int16_t *sfm_start, /* i  : Sub band start indices                  */
    1871             :     const int16_t *sfm_end    /* i  : Sub band end indices                    */
    1872             : );
    1873             : 
    1874             : /*! r: Leading_sign_index, index, size, k_val */
    1875             : PvqEntry mpvq_encode_vec(
    1876             :     const int16_t *vec_in, /* i  : Signed pulse train                       */
    1877             :     const int16_t dim_in,  /* i  : Dimension                                */
    1878             :     int16_t k_val_local    /* i/o: Num unit pulses                          */
    1879             : );
    1880             : 
    1881             : /*! r: Size, dim, k_val */
    1882             : PvqEntry get_size_mpvq_calc_offset(
    1883             :     const int16_t dim_in,   /* i  : Dimension                                */
    1884             :     const int16_t k_val_in, /* i  : Num unit pulses                          */
    1885             :     uint32_t *h_mem         /* o  : Offsets                                  */
    1886             : );
    1887             : 
    1888             : void mpvq_decode_vec(
    1889             :     const PvqEntry *entry, /* i  :  Sign_ind, index, dim, k_val             */
    1890             :     uint32_t *h_mem,       /* i  :  A/U offsets                             */
    1891             :     int16_t *vec_out       /* o  :  Pulse train                             */
    1892             : );
    1893             : 
    1894             : /*! r: Multiplication result */
    1895             : uint32_t UMult_32_32(
    1896             :     const uint32_t UL_var1, /* i  : factor 1 */
    1897             :     const uint32_t UL_var2  /* i  : factor 2 */
    1898             : );
    1899             : 
    1900             : /*! r: inverse */
    1901             : uint32_t UL_inverse(
    1902             :     const uint32_t UL_val, /* i  : input value Q_exp      */
    1903             :     int16_t *exp           /* i/o: input exp / result exp */
    1904             : );
    1905             : 
    1906             : /*! r: ratio */
    1907             : Word16 ratio(
    1908             :     const Word32 numer, /* i  : numerator              */
    1909             :     const Word32 denom, /* i  : denominator            */
    1910             :     Word16 *expo        /* i/o: input exp / result exp */
    1911             : );
    1912             : 
    1913             : /*! r: Angle between 0 and EVS_PI/2 radian (Q14) */
    1914             : Word16 atan2_fx(
    1915             :     const Word32 y, /* i  : near side (Argument must be positive) (Q15) */
    1916             :     const Word32 x  /* i  : opposite side (Q15)                         */
    1917             : );
    1918             : 
    1919             : void pvq_encode_frame(
    1920             :     BSTR_ENC_HANDLE hBstr,    /* i/o: encoder bitstream handle                    */
    1921             :     const float *coefs_norm,  /* i  : normalized coefficients to encode           */
    1922             :     float *coefs_quant,       /* o  : quantized coefficients                      */
    1923             :     float *gopt,              /* o  : optimal shape gains                         */
    1924             :     int16_t *npulses,         /* o  : number of pulses per band                   */
    1925             :     int16_t *pulse_vector,    /* o  : non-normalized pulse shapes                 */
    1926             :     const int16_t *sfm_start, /* i  : indices of first coefficients in the bands  */
    1927             :     const int16_t *sfm_end,   /* i  : indices of last coefficients in the bands   */
    1928             :     const int16_t *sfmsize,   /* i  : band sizes                                  */
    1929             :     const int16_t nb_sfm,     /* i  : total number of bands                       */
    1930             :     const int16_t *R,         /* i  : bitallocation per band (Q3)                 */
    1931             :     const int16_t pvq_bits,   /* i  : number of bits avaiable                     */
    1932             :     const int16_t core        /* i  : core                                        */
    1933             : );
    1934             : 
    1935             : void pvq_decode_frame(
    1936             :     Decoder_State *st,        /* i/o: Decoder state                        */
    1937             :     float *coefs_quant,       /* o  : quantized coefficients               */
    1938             :     int16_t *npulses,         /* o  : number of pulses per band            */
    1939             :     int16_t *pulse_vector,    /* o  : non-normalized pulse shapes          */
    1940             :     const int16_t *sfm_start, /* i  : indices of first coeffs in the bands */
    1941             :     const int16_t *sfm_end,   /* i  : indices of last coeffs in the bands  */
    1942             :     const int16_t *sfmsize,   /* i  : band sizes                           */
    1943             :     const int16_t nb_sfm,     /* i  : total number of bands                */
    1944             :     const int16_t *R,         /* i  : bitallocation per band (Q3)          */
    1945             :     const int16_t pvq_bits,   /* i  : number of bits avaiable              */
    1946             :     const int16_t core        /* i  : core                                 */
    1947             : );
    1948             : 
    1949             : void srt_vec_ind(
    1950             :     const int16_t *linear, /* linear input                                     */
    1951             :     int16_t *srt,          /* sorted output                                    */
    1952             :     int16_t *I,            /* index for sorted output                          */
    1953             :     const int16_t length );
    1954             : 
    1955             : void srt_vec_ind_f(
    1956             :     const float *linear, /* linear input                                     */
    1957             :     float *srt,          /* sorted output                                    */
    1958             :     int16_t *I,          /* index for sorted output                          */
    1959             :     const int16_t length /* length of vector                                 */
    1960             : );
    1961             : 
    1962             : /*! r: floor(sqrt(input)) */
    1963             : uint32_t floor_sqrt_exact(
    1964             :     const uint32_t input /* i  : unsigned input  [0.. UINT_MAX/4]     */
    1965             : );
    1966             : 
    1967             : void fine_gain_quant(
    1968             :     BSTR_ENC_HANDLE hBstr,    /* i/o: encoder bitstream handle                    */
    1969             :     const int16_t *ord,       /* i  : Indices for energy order                    */
    1970             :     const int16_t num_sfm,    /* i  : Number of bands                             */
    1971             :     const int16_t *gain_bits, /* i  : Gain adjustment bits per sub band           */
    1972             :     float *fg_pred,           /* i/o: Predicted gains / Corrected gains           */
    1973             :     const float *gopt         /* i  : Optimal gains                               */
    1974             : );
    1975             : 
    1976             : void apply_gain(
    1977             :     const int16_t *ord,        /* i  : Indices for energy order                    */
    1978             :     const int16_t *band_start, /* i  : Sub band start indices                      */
    1979             :     const int16_t *band_end,   /* i  : Sub band end indices                        */
    1980             :     const int16_t num_sfm,     /* i  : Number of bands                             */
    1981             :     const float *gains,        /* i  : Band gain vector                            */
    1982             :     float *xq                  /* i/o: float synthesis / gain adjusted synth       */
    1983             : );
    1984             : 
    1985             : void fine_gain_pred(
    1986             :     const int16_t *sfm_start, /* i  : Sub band start indices                      */
    1987             :     const int16_t *sfm_end,   /* i  : Sub band end indices                        */
    1988             :     const int16_t *sfm_size,  /* i  : Sub band bandwidths                         */
    1989             :     const int16_t *i_sort,    /* i  : Energy sorting indices                      */
    1990             :     const int16_t *K,         /* i  : Number of pulses per band                   */
    1991             :     const int16_t *maxpulse,  /* i  : Maximum pulse per band                      */
    1992             :     const int16_t *R,         /* i  : Bits per sub band (Q3)                      */
    1993             :     const int16_t num_sfm,    /* i  : Number of sub bands                         */
    1994             :     float *xq,                /* i/o: Quantized vector /quantized vector with finegain adj */
    1995             :     int16_t *y,               /* i/o: Quantized vector                            */
    1996             :     float *fg_pred,           /* o  : Predicted fine gains                        */
    1997             :     const int16_t core        /* i  : Core                                        */
    1998             : );
    1999             : 
    2000             : void fine_gain_dec(
    2001             :     Decoder_State *st,        /* i/o: Decoder state struct                        */
    2002             :     const int16_t *ord,       /* i  : Indices for energy order                    */
    2003             :     const int16_t num_sfm,    /* i  : Number of bands                             */
    2004             :     const int16_t *gain_bits, /* i  : Gain adjustment bits per sub band           */
    2005             :     float *fg_pred            /* i/o: Predicted gains / Corrected gains           */
    2006             : );
    2007             : 
    2008             : void get_max_pulses(
    2009             :     const int16_t *band_start, /* i  : Sub band start indices                      */
    2010             :     const int16_t *band_end,   /* i  : Sub band end indices                        */
    2011             :     const int16_t *k_sort,     /* i  : Indices for sorting by energy               */
    2012             :     const int16_t *npulses,    /* i  : Pulses per sub band                         */
    2013             :     const int16_t BANDS,       /* i  : Number of bands                             */
    2014             :     int16_t *inp_vector,       /* i/o: Encoded shape vectors                       */
    2015             :     int16_t *maxpulse          /* o  : Maximum pulse height per band               */
    2016             : );
    2017             : 
    2018             : Word32 ar_div(
    2019             :     Word32 num,
    2020             :     Word32 denum );
    2021             : 
    2022             : void ar_encoder_start(
    2023             :     PARCODEC arInst,
    2024             :     TCQ_PBITSTREAM bsInst,
    2025             :     int16_t max_bits );
    2026             : 
    2027             : void ar_decoder_start(
    2028             :     PARCODEC arInst,
    2029             :     TCQ_PBITSTREAM bsInst );
    2030             : 
    2031             : void ar_encoder_done(
    2032             :     PARCODEC arInst );
    2033             : 
    2034             : void ar_decoder_done(
    2035             :     PARCODEC arInst );
    2036             : 
    2037             : float GetISCScale(
    2038             :     float *quants,
    2039             :     int16_t size,
    2040             :     Word32 bits_fx,
    2041             :     float *magn,
    2042             :     float *qscale,
    2043             :     Word32 *surplus_fx,
    2044             :     float *pulses,
    2045             :     int32_t *savedstates,
    2046             :     int16_t noTCQ,
    2047             :     int32_t *nzpout,
    2048             :     int16_t *bcount,
    2049             :     float *abuffer,
    2050             :     float *mbuffer,
    2051             :     float *sbuffer );
    2052             : 
    2053             : Word32 Mult_32_16(
    2054             :     Word32 a,
    2055             :     Word16 b );
    2056             : 
    2057             : Word32 Mult_32_32(
    2058             :     Word32 a,
    2059             :     Word32 b );
    2060             : 
    2061             : void decode_position_ari_fx(
    2062             :     PARCODEC pardec,
    2063             :     Word16 size,
    2064             :     Word16 npulses,
    2065             :     Word16 *nz,
    2066             :     Word32 *position );
    2067             : 
    2068             : void decode_magnitude_usq_fx(
    2069             :     ARCODEC *pardec,
    2070             :     Word16 size,
    2071             :     Word16 npulses,
    2072             :     Word16 nzpos,
    2073             :     Word32 *positions,
    2074             :     Word32 *out );
    2075             : 
    2076             : void decode_mangitude_tcq_fx(
    2077             :     ARCODEC *pardec,
    2078             :     Word16 size,
    2079             :     Word16 npulses,
    2080             :     Word16 nzpos,
    2081             :     Word32 *positions,
    2082             :     Word32 *out,
    2083             :     Word32 *surplus_fx );
    2084             : 
    2085             : void decode_signs_fx(
    2086             :     ARCODEC *pardec,
    2087             :     Word16 size,
    2088             :     Word32 *out );
    2089             : 
    2090             : void srt_vec_ind_fx(
    2091             :     const Word32 *linear,
    2092             :     Word32 *srt,
    2093             :     Word16 *I,
    2094             :     Word16 length );
    2095             : 
    2096             : Word16 GetScale_fx(
    2097             :     Word16 blen,
    2098             :     Word32 bits_fx /*Q16*/,
    2099             :     Word32 *surplus_fx /*Q16*/
    2100             : );
    2101             : 
    2102             : void bit_allocation_second_fx(
    2103             :     Word32 *Rk,
    2104             :     Word32 *Rk_sort,
    2105             :     Word16 BANDS,
    2106             :     const Word16 *band_width,
    2107             :     Word16 *k_sort,
    2108             :     Word16 *k_num,
    2109             :     const Word16 *p2a_flags,
    2110             :     const Word16 p2a_bands,
    2111             :     const Word16 *last_bitalloc,
    2112             :     const Word16 input_frame );
    2113             : 
    2114             : Word32 encode_position_ari_fx(
    2115             :     PARCODEC parenc,
    2116             :     float *quants,
    2117             :     Word16 size,
    2118             :     Word32 *est_bits_frame_fx );
    2119             : 
    2120             : Word32 encode_magnitude_tcq_fx(
    2121             :     ARCODEC *parenc,
    2122             :     float *magn_fx,
    2123             :     Word16 size,
    2124             :     Word16 npulses,
    2125             :     Word16 nzpos,
    2126             :     Word32 *savedstates,
    2127             :     Word32 *est_frame_bits_fx );
    2128             : 
    2129             : Word32 encode_signs_fx(
    2130             :     ARCODEC *parenc,
    2131             :     float *magn,
    2132             :     Word16 size,
    2133             :     Word16 npos,
    2134             :     Word32 *est_frame_bits_fx );
    2135             : 
    2136             : Word32 encode_magnitude_usq_fx(
    2137             :     ARCODEC *parenc,
    2138             :     float *magn_fx,
    2139             :     Word16 size,
    2140             :     Word16 npulses,
    2141             :     Word16 nzpos,
    2142             :     Word32 *est_frame_bits_fx );
    2143             : 
    2144             : ivas_error tcq_core_LR_enc(
    2145             :     BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle                    */
    2146             : #ifdef DEBUGGING
    2147             :     const int16_t idchan,
    2148             : #endif
    2149             :     int32_t inp_vector[],
    2150             :     const float coefs_norm[],
    2151             :     float coefs_quant[],
    2152             :     const int16_t bit_budget, /* number of bits */
    2153             :     const int16_t nb_sfm,
    2154             :     const int16_t *sfm_start,
    2155             :     const int16_t *sfm_end,
    2156             :     const int16_t *sfmsize,
    2157             :     Word32 *Rk_fx,
    2158             :     int16_t *npulses,
    2159             :     int16_t *k_sort,
    2160             :     const int16_t *p2a_flags,
    2161             :     const int16_t p2a_bands,
    2162             :     const int16_t *last_bitalloc,
    2163             :     const int16_t input_frame,
    2164             :     const int16_t adjustFlag,
    2165             :     const int16_t is_transient );
    2166             : 
    2167             : void tcq_core_LR_dec(
    2168             :     Decoder_State *st,
    2169             :     int32_t *inp_vector,
    2170             :     const int16_t bit_budget,
    2171             :     const int16_t bands,
    2172             :     const int16_t *band_start,
    2173             :     const int16_t *band_width,
    2174             :     Word32 *Rk_fx,
    2175             :     int16_t npulses[],
    2176             :     int16_t *k_sort,
    2177             :     const int16_t *p2a_flags,
    2178             :     const int16_t p2a_bands,
    2179             :     const int16_t *last_bitalloc,
    2180             :     const int16_t input_frame,
    2181             :     const int16_t adjustFlag,
    2182             :     const int16_t *is_transient );
    2183             : 
    2184             : void InitLSBTCQ(
    2185             :     int16_t *bcount );
    2186             : 
    2187             : void TCQLSB(
    2188             :     int16_t bcount,
    2189             :     float *abuffer,
    2190             :     float *mbuffer,
    2191             :     float *sbuffer,
    2192             :     int16_t *dpath );
    2193             : 
    2194             : void RestoreTCQ(
    2195             :     float *magn,
    2196             :     int16_t size,
    2197             :     int16_t *bcount,
    2198             :     float *mbuffer );
    2199             : 
    2200             : void SaveTCQdata(
    2201             :     PARCODEC arInst,
    2202             :     int16_t *dpath,
    2203             :     int16_t bcount );
    2204             : 
    2205             : void LoadTCQdata(
    2206             :     PARCODEC arInst,
    2207             :     int16_t *dpath,
    2208             :     int16_t bcount );
    2209             : 
    2210             : void RestoreTCQdec(
    2211             :     int32_t *magn,
    2212             :     int16_t size,
    2213             :     int16_t *bcount,
    2214             :     float *mbuffer );
    2215             : 
    2216             : void TCQLSBdec(
    2217             :     int16_t *dpath,
    2218             :     float *mbuffer,
    2219             :     int16_t bcount );
    2220             : 
    2221             : void bit_allocation_second_fx(
    2222             :     Word32 *Rk,
    2223             :     Word32 *Rk_sort,
    2224             :     Word16 BANDS,
    2225             :     const Word16 *band_width,
    2226             :     Word16 *k_sort,
    2227             :     Word16 *k_num,
    2228             :     const Word16 *p2a_flags,
    2229             :     const Word16 p2a_bands,
    2230             :     const Word16 *last_bitalloc,
    2231             :     const Word16 input_frame );
    2232             : 
    2233             : void io_ini_enc(
    2234             :     const int32_t argc, /* i  : command line arguments number           */
    2235             :     char *argv[],       /* i  : command line arguments                  */
    2236             :     FILE **f_input,     /* o  : input signal file                       */
    2237             :     FILE **f_stream,    /* o  : output bitstream file                   */
    2238             :     FILE **f_rate,      /* o  : bitrate switching profile (0 if N/A)    */
    2239             :     FILE **f_bwidth,    /* o  : bandwidth switching profile (0 if N/A)  */
    2240             :     FILE **f_metadata,  /* o  : metadata files (NULL if N/A)            */
    2241             : #ifdef DEBUGGING
    2242             :     FILE **f_force, /* o  : force switching profile (0 if N/A)      */
    2243             : #endif
    2244             :     FILE **f_rf,         /* o  : channel aware configuration file        */
    2245             :     int16_t *quietMode,  /* o  : limit printouts                         */
    2246             :     int16_t *noDelayCmp, /* o  : turn off delay compensation             */
    2247             :     Encoder_Struct *st   /* o  : IVAS encoder structure                  */
    2248             : );
    2249             : 
    2250             : void read_next_rfparam(
    2251             :     int16_t *rf_fec_offset,    /* o  : RF offset                               */
    2252             :     int16_t *rf_fec_indicator, /* o  : RF FEC indicator                        */
    2253             :     FILE *f_rf                 /* i  : file pointer to read parameters         */
    2254             : );
    2255             : 
    2256             : void read_next_brate(
    2257             :     int32_t *total_brate,           /* i/o: total bitrate                           */
    2258             :     const int32_t last_total_brate, /* i  : last total bitrate                      */
    2259             :     FILE *f_rate,                   /* i  : bitrate switching profile (0 if N/A)    */
    2260             :     const int16_t element_mode,     /* i  : IVAS element mode                       */
    2261             :     int32_t input_Fs,               /* i  : input sampling frequency                */
    2262             :     int16_t *Opt_AMR_WB,            /* i  : flag indicating AMR-WB IO mode          */
    2263             :     int16_t *Opt_SC_VBR,            /* i/o: SC-VBR flag                             */
    2264             :     int16_t *codec_mode             /* i/o: Mode 1 or 2                             */
    2265             : );
    2266             : 
    2267             : void read_next_bwidth(
    2268             :     int16_t *max_bwidth,         /* i/o: maximum encoded bandwidth               */
    2269             :     FILE *f_bwidth,              /* i  : bandwidth switching profile (0 if N/A)  */
    2270             :     int32_t *bwidth_profile_cnt, /* i/o: counter of frames for bandwidth switching profile file */
    2271             :     int32_t input_Fs             /* i  : input sampling rate                     */
    2272             : );
    2273             : 
    2274             : #ifdef DEBUGGING
    2275             : void read_next_force(
    2276             :     int16_t *force,            /* i/o: force value (0/1, 0 = speech, 1 = music)*/
    2277             :     FILE *f_force,             /* i  : force switching profile (0 if N/A)      */
    2278             :     int32_t *force_profile_cnt /* i/o: counter of frames for force switching profile file */
    2279             : );
    2280             : #endif
    2281             : 
    2282             : ivas_error init_encoder(
    2283             :     Encoder_State *st,               /* i/o: state structure                        */
    2284             :     Encoder_Struct *st_ivas,         /* i/o: encoder state structure                */
    2285             :     const int16_t idchan,            /* i  : channel ID                             */
    2286             :     const int16_t var_SID_rate_flag, /* i  : flag for variable SID update rate      */
    2287             :     const int16_t interval_SID,      /* i  : interval for SID update                */
    2288             :     const int16_t vad_only_flag,     /* i  : flag to indicate front-VAD structure   */
    2289             :     const ISM_MODE ism_mode,         /* i  : ISM mode                               */
    2290             :     const int32_t element_brate      /* element bitrate                             */
    2291             : );
    2292             : 
    2293             : void LPDmem_enc_init(
    2294             :     LPD_state_HANDLE hLPDmem /* i/o: LP memories                             */
    2295             : );
    2296             : 
    2297             : void destroy_cldfb_encoder(
    2298             :     Encoder_State *st /* i/o: state structure                         */
    2299             : );
    2300             : ivas_error evs_enc(
    2301             :     Encoder_State *st,      /* i/o: state structure                         */
    2302             :     const int16_t *data,    /* i  : input signal                            */
    2303             :     float *mem_hp20_in,     /* i/o: hp20 filter memory                      */
    2304             :     const int16_t n_samples /* i  : number of input samples                 */
    2305             : );
    2306             : void amr_wb_enc(
    2307             :     Encoder_State *st,      /* i/o: encoder state structure                 */
    2308             :     const int16_t *data,    /* i  : input signal                            */
    2309             :     float *mem_hp20_in,     /* i/o: hp20 filter memory                      */
    2310             :     const int16_t n_samples /* i  : number of input samples                 */
    2311             : );
    2312             : 
    2313             : void sc_vbr_enc_init(
    2314             :     SC_VBR_ENC_HANDLE hSC_VBR /* i/o: SC-VBR encoder handle                   */
    2315             : );
    2316             : 
    2317             : void amr_wb_enc_init(
    2318             :     AMRWB_IO_ENC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO encoder handle                */
    2319             : );
    2320             : 
    2321             : void pre_proc(
    2322             :     Encoder_State *st,            /* i/o: encoder state structure                 */
    2323             :     const int16_t input_frame,    /* i  : frame length                            */
    2324             :     float old_inp_12k8[],         /* i/o: buffer of old input signal              */
    2325             :     float old_inp_16k[],          /* i/o: buffer of old input signal @ 16kHz      */
    2326             :     float **inp,                  /* o  : ptr. to inp. signal in the current frame*/
    2327             :     float fr_bands[2 * NB_BANDS], /* i  : energy in frequency bands               */
    2328             :     float *ener,                  /* o  : residual energy from Levinson-Durbin    */
    2329             : #ifndef FIX_I4_OL_PITCH
    2330             :     int16_t pitch_orig[3], /* o  : open-loop pitch values for quantization */
    2331             : #endif
    2332             :     float A[NB_SUBFR16k * ( M + 1 )],                          /* i/o: A(z) unquantized for the 4 subframes    */
    2333             :     float Aw[NB_SUBFR16k * ( M + 1 )],                         /* i/o: weighted A(z) unquantized for subframes */
    2334             :     float epsP[M + 1],                                         /* i/o: LP prediction errors                    */
    2335             :     float lsp_new[M],                                          /* i/o: LSPs at the end of the frame            */
    2336             :     float lsp_mid[M],                                          /* i/o: LSPs in the middle of the frame         */
    2337             :     int16_t *vad_hover_flag,                                   /* i  : VAD hangover flag                       */
    2338             :     int16_t *attack_flag,                                      /* o  : attack flag                             */
    2339             :     float *new_inp_resamp16k,                                  /* o  : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */
    2340             :     int16_t *Voicing_flag,                                     /* o  : voicing flag for HQ FEC                 */
    2341             :     float realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer                             */
    2342             :     float imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer                             */
    2343             :     int16_t *hq_core_type                                      /* o  : HQ core type                            */
    2344             : );
    2345             : #endif
    2346             : 
    2347             : /*! r: HQ_CORE/TCX_20_CORE decision */
    2348             : int16_t mdct_classifier(
    2349             :     Encoder_State *st,        /* i/o: Encoder state variable                  */
    2350             :     const float *fft_buff,    /* i  : FFT spectrum from fft_rel               */
    2351             :     const float enerBuffer[], /* i  : energy buffer                           */
    2352             :     const int32_t brate       /* i  : current brate, IVAS: nominal bitrate, EVS: st->total_brate */
    2353             : );
    2354             : 
    2355             : void MDCT_selector(
    2356             :     Encoder_State *st,       /* i/o: Encoder State                           */
    2357             :     const float sp_floor,    /* i  : Noise floor estimate                    */
    2358             :     const float Etot,        /* i  : Total energy                            */
    2359             :     const float cor_map_sum, /* i  : sum of correlation map                  */
    2360             :     const float enerBuffer[] /* i  : energy buffer                           */
    2361             : );
    2362             : 
    2363             : void MDCT_selector_reset(
    2364             :     TCX_ENC_HANDLE hTcxEnc /* i/o: TCX Encoder Handle                      */
    2365             : );
    2366             : 
    2367             : void MDCT_classifier_reset(
    2368             :     TCX_ENC_HANDLE hTcxEnc /* i/o: TCX Encoder Handle                      */
    2369             : );
    2370             : 
    2371             : ivas_error acelp_core_enc(
    2372             :     Encoder_State *st,                   /* i/o: encoder state structure                 */
    2373             :     const float inp[],                   /* i  : input signal of the current frame       */
    2374             :     const float ener,                    /* i  : residual energy from Levinson-Durbin    */
    2375             :     float A[NB_SUBFR16k * ( M + 1 )],    /* i  : A(z) unquantized for the 4 subframes    */
    2376             :     float Aw[NB_SUBFR16k * ( M + 1 )],   /* i  : weighted A(z) unquant. for subframes    */
    2377             :     const float epsP[M + 1],             /* i  : LP prediction errors                    */
    2378             :     float lsp_new[M],                    /* i  : LSPs at the end of the frame            */
    2379             :     float lsp_mid[M],                    /* i  : LSPs in the middle of the frame         */
    2380             :     const int16_t vad_hover_flag,        /* i  : VAD hangover flag                       */
    2381             :     const int16_t attack_flag,           /* i  : attack flag (GSC or TC)                 */
    2382             :     float bwe_exc_extended[],            /* i/o: bandwidth extended excitation           */
    2383             :     float *voice_factors,                /* o  : voicing factors                         */
    2384             :     float old_syn_12k8_16k[],            /* o  : ACELP core synthesis at 12.8kHz or 16kHz to be used by SWB BWE */
    2385             :     float pitch_buf[NB_SUBFR16k],        /* o  : floating pitch for each subframe        */
    2386             :     int16_t *unbits,                     /* o  : number of unused bits                   */
    2387             :     STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle                */
    2388             :     const float tdm_lsfQ_PCh[M]          /* i  : Q LSFs for primary channel              */
    2389             : );
    2390             : 
    2391             : ivas_error acelp_core_switch_dec_bfi(
    2392             :     Decoder_State *st /* i/o: decoder state structure                 */
    2393             : );
    2394             : 
    2395             : void acelp_core_switch_enc(
    2396             :     Encoder_State *st,                     /* i/o: encoder state structure                 */
    2397             :     const float inp12k8[],                 /* i  : input signal @12.8 kHz                  */
    2398             :     const float inp16k[],                  /* i  : input signal @16 kHz                    */
    2399             :     const float A[NB_SUBFR16k * ( M + 1 )] /* i  : A(z) unquantized for the 4 subframes    */
    2400             : );
    2401             : 
    2402             : /*! r: length of output */
    2403             : int16_t modify_Fs_intcub3m_sup(
    2404             :     const float sigIn[], /* i  : signal to decimate with memory of 2 samples (indexes -2 & -1) */
    2405             :     const int16_t lg,    /* i  : length of input                         */
    2406             :     const int32_t fin,   /* i  : frequency of input                      */
    2407             :     float sigOut[],      /* o  : decimated signal                        */
    2408             :     const int32_t fout,  /* i  : frequency of output                     */
    2409             :     int16_t *delayout    /* o  : delay of output                         */
    2410             : );
    2411             : 
    2412             : void core_switching_OLA(
    2413             :     const float *mem_over_hp,     /* i  : upsampling filter memory                */
    2414             :     const int16_t last_L_frame,   /* i  : last L_frame lengthture                 */
    2415             :     const int32_t output_Fs,      /* i  : output sampling rate                    */
    2416             :     float *synth,                 /* i/o: synthesized signal from HQ core         */
    2417             :     const float *synth_subfr_out, /* i  : synthesized signal from ACELP core      */
    2418             :     float *synth_subfr_bwe,       /* i  : synthesized BWE from ACELP core         */
    2419             :     const int16_t output_frame,   /* i  : output frame length                     */
    2420             :     const int16_t bwidth          /* i  : output bandwidth                        */
    2421             : );
    2422             : 
    2423             : void retro_interp4_5(
    2424             :     const float *syn,
    2425             :     float *pst_old_syn );
    2426             : 
    2427             : void retro_interp5_4(
    2428             :     float *pst_old_syn );
    2429             : 
    2430             : void core_switching_hq_prepare_enc(
    2431             :     Encoder_State *st,         /* i/o: encoder state structure                 */
    2432             :     int16_t *num_bits,         /* i/o: bit budget update                       */
    2433             :     const int16_t input_frame, /* i  : input frame length                      */
    2434             :     float *wtda_audio,
    2435             :     const float *audio );
    2436             : 
    2437             : void core_switching_hq_prepare_dec(
    2438             :     Decoder_State *st,        /* i/o: decoder state structure                 */
    2439             :     int16_t *num_bits,        /* i/o: bit budget update                       */
    2440             :     const int16_t input_frame /* i  : input frame length                      */
    2441             : );
    2442             : 
    2443             : ivas_error acelp_core_switch_dec(
    2444             :     Decoder_State *st,                 /* i/o: decoder structure              */
    2445             :     float *synth_subfr_out,            /* o  : synthesized ACELP subframe     */
    2446             :     float *tmp_synth_bwe,              /* o  : synthesized ACELP subframe BWE */
    2447             :     const int16_t output_frame,        /* i  : input frame length             */
    2448             :     const int16_t core_switching_flag, /* i  : core switching flag            */
    2449             :     float *mem_synth,                  /* o  : synthesis to overlap           */
    2450             :     const int16_t nchan_out            /* i  : number of output channels      */
    2451             : );
    2452             : 
    2453             : void space_lsfs(
    2454             :     float *lsfs,
    2455             :     const int16_t order );
    2456             : 
    2457             : void lsp2a(
    2458             :     float *pc_in,
    2459             :     float *freq,
    2460             :     const int16_t order );
    2461             : 
    2462             : void lsp_weights(
    2463             :     const float *lsps,
    2464             :     float *weight,
    2465             :     const int16_t order );
    2466             : 
    2467             : void a2lsp_stab(
    2468             :     const float *a,      /* i  : LP filter coefficients              */
    2469             :     float *lsp,          /* o  : Line spectral pairs                 */
    2470             :     const float *old_lsp /* i  : LSP vector from past frame          */
    2471             : );
    2472             : 
    2473             : void lsp2a_stab(
    2474             :     const float *lsp, /* i  : LSF vector (in the cosine domain)   */
    2475             :     float *a,         /* o  : LP filter coefficients              */
    2476             :     const int16_t m   /* i  : order of LP analysis                */
    2477             : );
    2478             : 
    2479             : void isf2lsf(
    2480             :     const float *isf,  /* i  : ISF vector                          */
    2481             :     float *lsf,        /* o  : LSF vector                          */
    2482             :     float *stable_lsp, /* i/o: LSF vector                          */
    2483             :     const int16_t m,   /* i  : order of LP analysis                */
    2484             :     const int32_t Fs );
    2485             : 
    2486             : void lsf2isf(
    2487             :     const float *lsf,  /* i  : LSF vector                          */
    2488             :     float *isf,        /* o  : ISF vector                          */
    2489             :     float *stable_isp, /* i/o: ISP vector                          */
    2490             :     const int16_t m,   /* i  : order of LP analysis                */
    2491             :     const int32_t Fs );
    2492             : 
    2493             : int16_t a2lsp(
    2494             :     float *freq,        /* o  : LSP vector                              */
    2495             :     const float *a,     /* i  : predictor coefficients                  */
    2496             :     const int16_t order /* i  : order of LP analysis                    */
    2497             : );
    2498             : 
    2499             : void ResetSHBbuffer_Enc(
    2500             :     TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle                      */
    2501             : );
    2502             : 
    2503             : void ResetSHBbuffer_Dec(
    2504             :     TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle                      */
    2505             :     const int16_t extl         /* i  : BWE extension layer                     */
    2506             : );
    2507             : 
    2508             : void calc_st_filt(
    2509             :     const float *apond2,   /* i  : coefficients of numerator               */
    2510             :     const float *apond1,   /* i  : coefficients of denominator             */
    2511             :     float *parcor0,        /* o  : 1st parcor calcul. on composed filter   */
    2512             :     float *sig_ltp_ptr,    /* i/o: input of 1/A(gamma1) : scaled by 1/g0   */
    2513             :     float *mem_zero,       /* i/o: All zero memory                         */
    2514             :     const int16_t L_subfr, /* i  : the length of subframe                  */
    2515             :     const int16_t extl     /* i  : extension layer info                    */
    2516             : );
    2517             : 
    2518             : void scale_st(
    2519             :     const float *sig_in,   /* i  : postfilter input signal                 */
    2520             :     float *sig_out,        /* i/o: postfilter output signal                */
    2521             :     float *gain_prec,      /* i/o: last value of gain for subframe         */
    2522             :     const int16_t L_subfr, /* i  : the length of subframe                  */
    2523             :     const int16_t extl     /* i  : extension layer info                    */
    2524             : );
    2525             : 
    2526             : void filt_mu(
    2527             :     const float *sig_in,   /* i  : signal (beginning at sample -1)         */
    2528             :     float *sig_out,        /* o  : output signal                           */
    2529             :     const float parcor0,   /* i  : parcor0 (mu = parcor0 * gamma3)         */
    2530             :     const int16_t L_subfr, /* i  : the length of subframe                  */
    2531             :     const int16_t extl     /* i  : extension layer info                    */
    2532             : );
    2533             : 
    2534             : void PostShortTerm(
    2535             :     float *sig_in,          /* i  : input signal (ptr. to current subframe  */
    2536             :     float *lpccoeff,        /* i  : LPC coefficients for current subframe   */
    2537             :     float *sig_out,         /* o  : postfiltered output                     */
    2538             :     float *mem_stp,         /* i/o: postfilter memory                       */
    2539             :     float *ptr_mem_stp,     /* i/o: pointer to postfilter memory            */
    2540             :     float *ptr_gain_prec,   /* i/o: for gain adjustment                     */
    2541             :     float *mem_zero,        /* i/o: null memory to compute h_st             */
    2542             :     const float formant_fac /* i  : Strength of post-filter [0,1]           */
    2543             : );
    2544             : 
    2545             : /*! r: Formant filter strength [0,1] */
    2546             : float swb_formant_fac(
    2547             :     const float lpc_shb2, /* i  : 2nd HB LPC coefficient                  */
    2548             :     float *tilt_mem       /* i/o: Tilt smoothing memory                   */
    2549             : );
    2550             : 
    2551             : void GenShapedSHBExcitation(
    2552             :     float *excSHB,                      /* o  : synthesized shaped shb exctiation       */
    2553             :     const float *lpc_shb,               /* i  : lpc coefficients                        */
    2554             :     float *exc16kWhtnd,                 /* o  : whitened synthesized shb excitation     */
    2555             :     float *mem_csfilt,                  /* i/o: memory                                  */
    2556             :     float *mem_genSHBexc_filt_down_shb, /* i/o: memory                                  */
    2557             :     float *state_lpc_syn,               /* i/o: memory                                  */
    2558             :     const int16_t coder_type,           /* i  : coding type                             */
    2559             :     const float *bwe_exc_extended,      /* i  : bandwidth extended excitation           */
    2560             :     int16_t bwe_seed[],                 /* i/o: random number generator seed            */
    2561             :     float voice_factors[],              /* i  : voicing factor                          */
    2562             :     const int16_t extl,                 /* i  : extension layer                         */
    2563             :     float *tbe_demph,                   /* i/o: de-emphasis memory                      */
    2564             :     float *tbe_premph,                  /* i/o: pre-emphasis memory                     */
    2565             :     float *lpc_shb_sf,                  /* i  : LP coefficients                         */
    2566             :     float *shb_ener_sf,                 /* i  : SHB subframe energies                   */
    2567             :     float *shb_res_gshape,              /* i  : SHB LP residual gain shape              */
    2568             :     float *shb_res,                     /* i  : SHB residual used in encoder only       */
    2569             :     int16_t *vf_ind,                    /* i/o: Mixing factor index                     */
    2570             :     const float formant_fac,            /* i  : Formant sharpening factor [0..1]        */
    2571             :     float fb_state_lpc_syn[],           /* i/o: memory                                  */
    2572             :     float *fb_tbe_demph,                /* i/o: fb de-emphasis memory                   */
    2573             :     const int32_t total_brate,          /* i  : overall bitrate                         */
    2574             :     const int16_t prev_bfi,             /* i  : previous frame was lost flag            */
    2575             :     const int16_t element_mode,         /* i  : element mode                            */
    2576             :     const int16_t flag_ACELP16k,        /* i  : ACELP@16kHz flag                        */
    2577             :     float *nlExc16k,                    /* i/o: NL exc for IC-BWE                       */
    2578             :     float *mixExc16k,                   /* i/o: exc spreading for IC-BWE                */
    2579             :     const int32_t extl_brate,           /* i  : TD BWE bitrate                          */
    2580             :     const int16_t MSFlag,               /* i  : Multi-source flag                       */
    2581             :     float EnvSHBres_4k[],               /* i/o: TD envelope of the SHB residual signal  */
    2582             :     float *prev_pow_exc16kWhtnd,        /* i/o: power of the LB excitation signal in the previous frame */
    2583             :     float *prev_mix_factor,             /* i/o: mixing factor in the previous frame     */
    2584             :     float *Env_error,                   /* o  : error in SHB residual envelope modelling*/
    2585             :     float Env_error_part[]              /* o  : per-segment error in SHB residual envelope modelling */
    2586             : );
    2587             : 
    2588             : void GenSHBSynth(
    2589             :     const float *shb_target_speech,    /* i  : input synthesized speech                */
    2590             :     float *shb_syn_speech_32k,         /* o  : output highband component               */
    2591             :     float Hilbert_Mem[],               /* i/o: memory                                  */
    2592             :     float state_lsyn_filt_shb_local[], /* i/o: memory                                  */
    2593             :     const int16_t L_frame,             /* i  : ACELP Frame length                      */
    2594             :     int16_t *syn_dm_phase );
    2595             : 
    2596             : void ScaleShapedSHB(
    2597             :     const int16_t length,   /* i  : SHB overlap length                      */
    2598             :     float *synSHB,          /* i/o: synthesized shb signal                  */
    2599             :     float *overlap,         /* i/o: buffer for overlap-add                  */
    2600             :     const float *subgain,   /* i  : subframe gain                           */
    2601             :     const float frame_gain, /* i  : frame gain                              */
    2602             :     const float *win,       /* i  : window                                  */
    2603             :     const float *subwin     /* i  : subframes window                        */
    2604             : );
    2605             : 
    2606             : void Interpolate_allpass_steep(
    2607             :     const float *in, /* i  : input array of size N                   */
    2608             :     float *mem,      /* i/o: memory                                  */
    2609             :     const int16_t N, /* i  : number of input samples                 */
    2610             :     float *out       /* o  : output array of size 2*N                */
    2611             : );
    2612             : 
    2613             : void Decimate_allpass_steep(
    2614             :     const float *in, /* i  : input array of size N                   */
    2615             :     float *mem,      /* i/o: memory                                  */
    2616             :     const int16_t N, /* i  : number of input samples                 */
    2617             :     float *out       /* o  : output array of size N/2                */
    2618             : );
    2619             : 
    2620             : void interpolate_3_over_2_allpass(
    2621             :     const float *input, /* i  : input signal                            */
    2622             :     const int16_t len,  /* i  : number of input samples                 */
    2623             :     float *out,         /* o  : output signal                           */
    2624             :     float *mem          /* i/o: memory                                  */
    2625             : );
    2626             : 
    2627             : void decimate_2_over_3_allpass(
    2628             :     const float *input, /* i  : input signal                            */
    2629             :     const int16_t len,  /* i  : number of input samples                 */
    2630             :     float *out,         /* o  : output signal                           */
    2631             :     float *mem,         /* i/o: memory                                  */
    2632             :     float *lp_mem );
    2633             : 
    2634             : void interpolate_3_over_1_allpass(
    2635             :     const float *input, /* i  : input signal                            */
    2636             :     const int16_t len,  /* i  : number of input samples                 */
    2637             :     float *out,         /* o  : output signal                           */
    2638             :     float *mem          /* i/o: memory                                  */
    2639             : );
    2640             : 
    2641             : void InitSWBencBuffer(
    2642             :     TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle                      */
    2643             : );
    2644             : 
    2645             : void InitSWBencBufferStates(
    2646             :     TD_BWE_ENC_HANDLE hBWE_TD, /* i/o: TD BWE data handle                   */
    2647             :     float *shb_speech          /* o  : SHB target signal (6-14kHz) at 16kHz */
    2648             : );
    2649             : 
    2650             : void swb_tbe_enc(
    2651             :     Encoder_State *st,                    /* i/o: encoder state structure                 */
    2652             :     STEREO_ICBWE_ENC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure                  */
    2653             :     const float *new_speech,              /* i  : original input signal                   */
    2654             :     const float *bwe_exc_extended,        /* i  : bandwidth extended exciatation          */
    2655             :     const float voice_factors[],          /* i  : voicing factors                         */
    2656             :     float *White_exc16k,                  /* o  : shaped white excitation for the FB TBE  */
    2657             :     const float pitch_buf[]               /* i  : pitch for each subframe                 */
    2658             : );
    2659             : 
    2660             : void swb_tbe_dec(
    2661             :     Decoder_State *st,                    /* i/o: decoder state structure                 */
    2662             :     STEREO_ICBWE_DEC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure                  */
    2663             :     const float *bwe_exc_extended,        /* i  : bandwidth extended exciatation          */
    2664             :     const float voice_factors[],          /* i  : voicing factors                         */
    2665             :     const float old_syn_12k8_16k[],       /* i  : low band synthesis at 12.8kHz or 16kHz  */
    2666             :     float *White_exc16k,                  /* o  : shaped white excitation for the FB TBE  */
    2667             :     float *synth,                         /* i/o: ACELP core synthesis/final synthesis    */
    2668             :     float *pitch_buf );
    2669             : 
    2670             : void flip_and_downmix_generic(
    2671             :     float input[],                      /* i  : input spectrum                          */
    2672             :     float output[],                     /* o  : output  spectrum                        */
    2673             :     const int16_t length,               /* i  : length of spectra                       */
    2674             :     float mem1_ext[HILBERT_ORDER1],     /* i/o: Hilbert filter memory                   */
    2675             :     float mem2_ext[2 * HILBERT_ORDER2], /* i/o: memory                                  */
    2676             :     float mem3_ext[2 * HILBERT_ORDER2], /* i/o: memory                                  */
    2677             :     int16_t *phase_state                /* i/o: Phase state in case frequency isn't multiple of 50 Hz */
    2678             : );
    2679             : 
    2680             : void non_linearity(
    2681             :     const float input[],          /* i  : input signal                            */
    2682             :     float output[],               /* i  : output signal                           */
    2683             :     float old_bwe_exc_extended[], /* i/o: memory bugffer                          */
    2684             :     const int16_t length,         /* i  : input length                            */
    2685             :     float *prev_scale,            /* i/o: memory                                  */
    2686             :     const int16_t coder_type,     /* i  : Coder Type                              */
    2687             :     const float *voice_factors,   /* i  : Voice Factors                           */
    2688             :     const int16_t L_frame         /* i  : ACELP frame length                      */
    2689             : );
    2690             : 
    2691             : void interp_code_5over2(
    2692             :     const float inp_code[],  /* i  :  input vector                           */
    2693             :     float interp_code[],     /* o  :  output vector                          */
    2694             :     const int16_t inp_length /* i  :  length of the input vector             */
    2695             : );
    2696             : 
    2697             : void interp_code_4over2(
    2698             :     const float inp_code[],  /* i  :  input vector                           */
    2699             :     float interp_code[],     /* o  :  output vector                          */
    2700             :     const int16_t inp_length /* i  :  length of the input vector             */
    2701             : );
    2702             : 
    2703             : void flip_spectrum_and_decimby4(
    2704             :     const float input[],    /* i  : input spectrum                          */
    2705             :     float output[],         /* o  : output  spectrum                        */
    2706             :     const int16_t length,   /* i  : vector length                           */
    2707             :     float mem1[],           /* i/o: memory                                  */
    2708             :     float mem2[],           /* i/o: memory                                  */
    2709             :     const int16_t ramp_flag /* i  : flag to trigger slow ramp-up of output  */
    2710             : );
    2711             : 
    2712             : void GenShapedWBExcitation(
    2713             :     float *excSHB,                   /* o  : synthesized shaped shb exctiation      */
    2714             :     const float *lpc_shb,            /* i  : lpc coefficients                       */
    2715             :     float *exc4kWhtnd,               /* o  : whitened synthesized shb excitation    */
    2716             :     float *mem_csfilt,               /* i/o: memory                                 */
    2717             :     float *mem_genSHBexc_filt_down1, /* i/o: memory                                 */
    2718             :     float *mem_genSHBexc_filt_down2, /* i/o: memory                                 */
    2719             :     float *mem_genSHBexc_filt_down3, /* i/o: memory                                 */
    2720             :     float *state_lpc_syn,            /* i/o: memory                                 */
    2721             :     const int16_t coder_type,        /* i  : coding type                            */
    2722             :     const float *bwe_exc_extended,   /* i  : bandwidth extended exciatation         */
    2723             :     int16_t bwe_seed[],              /* i/o: random number generator seed           */
    2724             :     const float voice_factors[],     /* i  : voicing factor                         */
    2725             :     const int16_t uv_flag,           /* i  : unvoiced flag                          */
    2726             :     const int16_t igf_flag );
    2727             : 
    2728             : void GenWBSynth(
    2729             :     const float *input_synspeech, /* i  : input synthesized speech                */
    2730             :     float *shb_syn_speech_16k,    /* o  : output highband compnent                */
    2731             :     float *state_lsyn_filt_shb1,  /* i/o: memory                                  */
    2732             :     float *state_lsyn_filt_shb2   /* i/o: memory                                  */
    2733             : );
    2734             : 
    2735             : void wb_tbe_enc(
    2736             :     Encoder_State *st,             /* i/o: encoder state structure                */
    2737             :     const float *hb_speech,        /* i  : HB target signal (6-8kHz) at 16kHz     */
    2738             :     const float *bwe_exc_extended, /* i  : bandwidth extended exciatation         */
    2739             :     const float pitch_buf[],       /* i  : pitch for each subframe                */
    2740             :     const float voicing[]          /* o  : OL maximum normalized correlation      */
    2741             : );
    2742             : 
    2743             : void wb_tbe_dec(
    2744             :     Decoder_State *st,             /* i/o: decoder state structure                 */
    2745             :     const float *bwe_exc_extended, /* i  : bandwidth extended exciatation          */
    2746             :     const float voice_factors[],   /* i  : voicing factors                         */
    2747             :     float *synth                   /* i/o: ACELP core synthesis/final synthesis    */
    2748             : );
    2749             : 
    2750             : void tbe_write_bitstream(
    2751             :     Encoder_State *st /* i/o: encoder state structure                 */
    2752             : );
    2753             : 
    2754             : void tbe_read_bitstream(
    2755             :     Decoder_State *st /* i/o: decoder state structure                 */
    2756             : );
    2757             : 
    2758             : void GenTransition(
    2759             :     TD_BWE_DEC_HANDLE hBWE_TD,  /* i/o: TD BWE data handle                      */
    2760             :     float *outputHB,            /* o  : synthesized HB transitions signal       */
    2761             :     const int32_t output_Fs,    /* i  : output sampling rate                    */
    2762             :     const int16_t element_mode, /* i  : element mode                            */
    2763             :     const int16_t L_frame,      /* i  : ACELP frame length                      */
    2764             :     const int16_t rf_flag,      /* i  : RF flag                                 */
    2765             :     const int32_t total_brate   /* i  : total bitrate                           */
    2766             : );
    2767             : 
    2768             : void GenTransition_WB(
    2769             :     TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle                      */
    2770             :     float *outputHB,           /* o  : synthesized HB transitions signal       */
    2771             :     const int32_t output_Fs    /* i  : output sampling rate                    */
    2772             : );
    2773             : 
    2774             : void td_bwe_dec_init(
    2775             :     TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle                      */
    2776             :     const int16_t extl,        /* i  : BWE extension layer                     */
    2777             :     const int32_t output_Fs    /* i  : output sampling rate                    */
    2778             : );
    2779             : 
    2780             : void TBEreset_enc(
    2781             :     TD_BWE_ENC_HANDLE hBWE_TD, /* i/o: TD BWE data handle                      */
    2782             :     const int16_t last_core,   /* i  : last core                               */
    2783             :     const int16_t bwidth       /* i  : audio bandwidth                         */
    2784             : );
    2785             : 
    2786             : void TBEreset_dec(
    2787             :     Decoder_State *st /* i/o: decoder state structure                 */
    2788             : );
    2789             : 
    2790             : /*! r: TBE bit consumption per frame */
    2791             : int16_t get_tbe_bits(
    2792             :     const int32_t total_brate, /* i  : overall bitrate                         */
    2793             :     const int16_t bwidth,      /* i  : audio bandwidth                         */
    2794             :     const int16_t rf_mode      /* i  : channel aware mode                      */
    2795             : );
    2796             : 
    2797             : void fb_tbe_enc(
    2798             :     Encoder_State *st,       /* i/o: encoder state structure                 */
    2799             :     const float new_input[], /* i  : input speech at 48 kHz sample rate      */
    2800             :     const float fb_exc[]     /* i  : FB excitation from the SWB part         */
    2801             : );
    2802             : 
    2803             : void fb_tbe_dec(
    2804             :     Decoder_State *st,         /* i/o: decoder state structure                 */
    2805             :     const float fb_exc[],      /* i  : FB excitation from the SWB part         */
    2806             :     float *hb_synth,           /* i/o: high-band synthesis                     */
    2807             :     float *fb_synth_ref,       /* o  : high-band synthesis 16-20 kHz           */
    2808             :     const int16_t output_frame /* i  : output frame length                     */
    2809             : );
    2810             : 
    2811             : void calc_tilt_bwe(
    2812             :     const float *sp, /* i  : input signal                            */
    2813             :     float *tilt,     /* o  : signal tilt                             */
    2814             :     const int16_t N  /* i  : signal length                           */
    2815             : );
    2816             : 
    2817             : void fd_bwe_enc_init(
    2818             :     FD_BWE_ENC_HANDLE hBWE_FD /* i/o: FD BWE data handle                      */
    2819             : );
    2820             : 
    2821             : void swb_pre_proc(
    2822             :     Encoder_State *st,                                         /* i/o: encoder state structure                 */
    2823             :     float *new_swb_speech,                                     /* o  : original input signal at 32kHz          */
    2824             :     float *shb_speech,                                         /* o  : SHB target signal (6-14kHz) at 16kHz    */
    2825             :     float realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i  : real buffer                             */
    2826             :     float imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i  : imag buffer                             */
    2827             :     CPE_ENC_HANDLE hCPE                                        /* i/o: CPE encoder structure                   */
    2828             : );
    2829             : 
    2830             : void wb_pre_proc(
    2831             :     Encoder_State *st,               /* i/o: encoder state structure                 */
    2832             :     const int16_t last_element_mode, /* i  : last element mode                       */
    2833             :     const float *new_inp_resamp16k,  /* i  : original input signal                   */
    2834             :     float *hb_speech                 /* o  : HB target signal (6-8kHz) at 16kHz      */
    2835             : );
    2836             : 
    2837             : void wb_bwe_enc(
    2838             :     Encoder_State *st,         /* i/o: encoder state structure                 */
    2839             :     const float *new_wb_speech /* i  : original input signal at 16kHz          */
    2840             : );
    2841             : 
    2842             : void wb_bwe_dec(
    2843             :     Decoder_State *st,               /* i/o: decoder state structure                 */
    2844             :     const float output[],            /* i  : synthesis @internal Fs                  */
    2845             :     float *synth,                    /* i/o: ACELP core synthesis/final synthesis    */
    2846             :     float *hb_synth,                 /* o  : SHB synthesis/final synthesis           */
    2847             :     const int16_t use_cldfb_for_dft, /* i  : flag to use of CLDFB for DFT Stereo     */
    2848             :     const int16_t output_frame,      /* i  : frame length                            */
    2849             :     const float voice_factors[],     /* i  : voicing factors                         */
    2850             :     const float pitch_buf[]          /* i  : pitch buffer                            */
    2851             : );
    2852             : 
    2853             : void swb_bwe_enc(
    2854             :     Encoder_State *st,               /* i/o: encoder state structure                 */
    2855             :     const int16_t last_element_mode, /* i  : last element mode                       */
    2856             :     const float *old_input_12k8,     /* i  : input signal @12.8kHz for SWB BWE       */
    2857             :     const float *old_input_16k,      /* i  : input signal @16kHz for SWB BWE         */
    2858             :     const float *old_syn_12k8_16k,   /* i  : ACELP core synthesis at 12.8kHz or 16kHz*/
    2859             :     const float *new_swb_speech,     /* i  : original input signal at 32kHz          */
    2860             :     const float *shb_speech          /* i  : SHB target signal (6-14kHz) at 16kHz    */
    2861             : );
    2862             : 
    2863             : void swb_bwe_enc_hr(
    2864             :     Encoder_State *st,         /* i/o: encoder state structure                 */
    2865             :     const float *new_input,    /* i  : input signal                            */
    2866             :     const int16_t input_frame, /* i  : frame length                            */
    2867             :     const int16_t unbits       /* i  : number of core unused bits              */
    2868             : );
    2869             : 
    2870             : void fd_bwe_dec_init(
    2871             :     FD_BWE_DEC_HANDLE hBWE_FD /* i/o: FD BWE data handle                      */
    2872             : );
    2873             : 
    2874             : void swb_bwe_dec(
    2875             :     Decoder_State *st,               /* i/o: decoder state structure                 */
    2876             :     const float output[],            /* i  : synthesis @internal Fs                  */
    2877             :     const float *synth,              /* i  : ACELP core synthesis/final synthesis    */
    2878             :     float *hb_synth,                 /* o  : SHB synthesis/final synthesis           */
    2879             :     const int16_t use_cldfb_for_dft, /* i  : flag to use of CLDFB for DFT Stereo     */
    2880             :     const int16_t output_frame       /* i  : frame length                            */
    2881             : );
    2882             : 
    2883             : void hr_bwe_dec_init(
    2884             :     HR_BWE_DEC_HANDLE hBWE_FD_HR /* i/o: HR BWE data handle                      */
    2885             : );
    2886             : 
    2887             : void swb_bwe_dec_hr(
    2888             :     Decoder_State *st,          /* i/o: decoder state structure                 */
    2889             :     const float *syn_12k8_16k,  /* i  : ACELP core synthesis @16kHz             */
    2890             :     float *hb_synth,            /* o  : SHB synthesis                           */
    2891             :     const int16_t output_frame, /* i  : frame length                            */
    2892             :     const int16_t unbits,       /* i  : number of core unused bits              */
    2893             :     const float pitch_buf[]     /* i  : pitch buffer                            */
    2894             : );
    2895             : 
    2896             : void swb_hr_noise_fill(
    2897             :     const int16_t is_transient, /* i  : transient flag                          */
    2898             :     const int16_t spect_start,  /* i  : spectrum start point                    */
    2899             :     const int16_t spect_end,    /* i  : spectrum end point                      */
    2900             :     const float tilt_wb,        /* i  : tilt of wideband signal                 */
    2901             :     const float pitch,          /* i  : pitch value                             */
    2902             :     const int16_t nq[],         /* i  : AVQ nq index                            */
    2903             :     int16_t Nsv,                /* i  : number of subband                       */
    2904             :     int16_t *bwe_highrate_seed, /* i/o: seed of random noise                    */
    2905             :     float *t_audio              /* i/o: mdct spectrum                           */
    2906             : );
    2907             : 
    2908             : /*! r: gain */
    2909             : float td_postprocess(
    2910             :     float hb_synth[],          /* i/o: high-band synthesis                     */
    2911             :     const int16_t input_frame, /* i  : frame length                            */
    2912             :     const int16_t last_extl    /* i  : last extension layer                    */
    2913             : );
    2914             : 
    2915             : void calc_normal_length(
    2916             :     const int16_t core,      /* i  : core                                    */
    2917             :     const float *sp,         /* i  : input signal                            */
    2918             :     const int16_t mode,      /* i  : input mode                              */
    2919             :     const int16_t extl,      /* i  : extension layer                         */
    2920             :     int16_t *L_swb_norm,     /* o  : normalize length                        */
    2921             :     int16_t *prev_L_swb_norm /* i/o: last normalize length                   */
    2922             : );
    2923             : 
    2924             : void calc_norm_envelop(
    2925             :     const float SWB_signal[],  /* i  : SWB spectrum                            */
    2926             :     float *envelope,           /* o  : normalized envelope                     */
    2927             :     const int16_t L_swb_norm,  /* i  : length of envelope                      */
    2928             :     const int16_t SWB_flength, /* i  : Length of input/output                  */
    2929             :     const int16_t st_offset    /* i  : offset                                  */
    2930             : );
    2931             : 
    2932             : void time_envelop_shaping(
    2933             :     float werr[],     /* i/o: SHB synthesis                           */
    2934             :     float SWB_tenv[], /* i/o: frequency envelope                      */
    2935             :     const int16_t L   /* i  : frame length                            */
    2936             : );
    2937             : 
    2938             : void time_reduce_pre_echo(
    2939             :     const float *synth,   /* i  : ACELP core synthesis                    */
    2940             :     float *error,         /* o  : SHB BWE synthesis                       */
    2941             :     float prev_td_energy, /* o  : last td energy                          */
    2942             :     const int16_t L       /* i  : subframe length                         */
    2943             : );
    2944             : 
    2945             : int16_t WB_BWE_gain_pred(
    2946             :     float *WB_fenv,                /* o  : WB frequency envelopes                  */
    2947             :     const float *core_dec_freq,    /* i  : Frequency domain core decoded signal    */
    2948             :     const int16_t coder_type,      /* i  : coding type                             */
    2949             :     const int16_t prev_code_type,  /* i  : coding type of last frame               */
    2950             :     const float prev_WB_fenv,      /* i  : envelope for last frame                 */
    2951             :     const float voice_factors[],   /* i  : voicing factors                         */
    2952             :     const float pitch_buf[],       /* i  : pitch buffer                            */
    2953             :     const int32_t last_core_brate, /* i  : previous frame core bitrate             */
    2954             :     const float last_wb_bwe_ener,  /* i  : previous frame wb bwe signal energy     */
    2955             :     const int16_t last_extl,       /* i  : extl. layer for last frame              */
    2956             :     const float tilt );
    2957             : 
    2958             : void WB_BWE_decoding(
    2959             :     const float *core_dec_freq, /* i  : Frequency domain core decoded signal    */
    2960             :     float *WB_fenv,             /* i  : WB frequency envelopes                  */
    2961             :     float *WB_signal,           /* o  : WB signal in MDCT domain                */
    2962             :     const int16_t WB_flength,   /* i  : Length of input/output                  */
    2963             :     const int16_t mode,         /* i  : classification for WB signal            */
    2964             :     const int16_t last_extl,    /* i  : extl. layer for last frame              */
    2965             :     float *prev_Energy,         /* i/o: energy for last frame                   */
    2966             :     float *prev_WB_fenv,        /* i/o: envelope for last frame                 */
    2967             :     int16_t *prev_L_wb_norm,    /* i/o: length for last frame wb norm           */
    2968             :     const int16_t extl,         /* i  : extension layer                         */
    2969             :     const int16_t coder_type,   /* i  : coding type                             */
    2970             :     const int32_t total_brate,  /* i  : core layer bitrate                      */
    2971             :     int16_t *Seed,              /* i/o: random generator seed                   */
    2972             :     int16_t *prev_flag,         /* i/o: attenu flag of last frame               */
    2973             :     int16_t prev_coder_type     /* i  : coding type of last frame               */
    2974             : );
    2975             : 
    2976             : void SWB_BWE_decoding(
    2977             :     const float *core_dec_freq, /* i  : Frequency domain core decoded signal    */
    2978             :     float *SWB_fenv,            /* i/o: SWB frequency envelopes                 */
    2979             :     float *SWB_signal,          /* o  : SWB signal in MDCT domain               */
    2980             :     const int16_t SWB_flength,  /* i  : Length of input/output                  */
    2981             :     const int16_t mode,         /* i  : classification for SWB signal           */
    2982             :     int16_t *frica_flag,        /* o  : fricative signal flag                   */
    2983             :     float *prev_Energy,         /* i/o: energy for last frame                   */
    2984             :     float *prev_SWB_fenv,       /* i/o: envelope for last frame                 */
    2985             :     int16_t *prev_L_swb_norm,   /* i/o: length for last frame wb norm           */
    2986             :     const float tilt_nb,        /* i  : tilt of synthesis wb signal             */
    2987             :     int16_t *Seed,              /* i/o: random generator seed                   */
    2988             :     const int16_t st_offset,    /* i  : offset value due to different core      */
    2989             :     float *prev_weight,         /* i/o: excitation weight value of last frame   */
    2990             :     const int16_t extl,         /* i  : extension layer                         */
    2991             :     const int16_t last_extl     /* i  : extension layer of last frame           */
    2992             : );
    2993             : 
    2994             : void CNG_reset_enc(
    2995             :     Encoder_State *st,    /* i/o: encoder state structure                 */
    2996             :     float *pitch_buf,     /* o  : floating pitch for each subframe        */
    2997             :     float *voice_factors, /* o  : voicing factors                         */
    2998             :     int16_t VBR_cng_reset_flag );
    2999             : 
    3000             : void a2isp(
    3001             :     const float *a,      /* i  : LP filter coefficients                  */
    3002             :     float *isp,          /* o  : Immittance spectral pairs               */
    3003             :     const float *old_isp /* i  : ISP vector from past frame              */
    3004             : );
    3005             : 
    3006             : void a2isf(
    3007             :     float *a,
    3008             :     float *isf,
    3009             :     const float *old_isf,
    3010             :     const int16_t lpcOrder );
    3011             : 
    3012             : /*! r: stability flag */
    3013             : uint16_t a2rc(
    3014             :     const float *a,        /* i  : LPC coefficients                                */
    3015             :     float *refl,           /* o  : Reflection co-efficients                        */
    3016             :     const int16_t lpcorder /* i  : LPC order                                       */
    3017             : );
    3018             : 
    3019             : int16_t lp_filt_exc_enc(
    3020             :     const int16_t codec_mode, /* i  : codec mode                                      */
    3021             :     const int16_t coder_type, /* i  : coding type                                     */
    3022             :     const int16_t i_subfr,    /* i  : subframe index                                  */
    3023             :     float *exc,               /* i/o: pointer to excitation signal frame              */
    3024             :     const float *h1,          /* i  : weighted filter input response                  */
    3025             :     const float *xn,          /* i  : target vector                                   */
    3026             :     float *y1,                /* o  : zero-memory filtered adaptive excitation        */
    3027             :     float *xn2,               /* o  : target vector for innovation search             */
    3028             :     const int16_t L_subfr,    /* i  : length of vectors for gain quantization         */
    3029             :     const int16_t L_frame,    /* i  : frame size                                      */
    3030             :     float *g_corr,            /* o  : ACELP correlation values                        */
    3031             :     const int16_t clip_gain,  /* i  : adaptive gain clipping flag                     */
    3032             :     float *gain_pit,          /* o  : adaptive excitation gain                        */
    3033             :     int16_t *lp_flag          /* i/o: mode selection                                  */
    3034             : );
    3035             : 
    3036             : void updt_tar(
    3037             :     const float *x,   /* i  : old target (for pitch search)                   */
    3038             :     float *x2,        /* o  : new target (for codebook search)                */
    3039             :     const float *y,   /* i  : filtered adaptive codebook vector               */
    3040             :     const float gain, /* i  : adaptive codebook gain                          */
    3041             :     const int16_t L   /* i  : subframe size                                   */
    3042             : );
    3043             : 
    3044             : void analy_sp(
    3045             :     const int16_t element_mode, /* i  : element mode                                     */
    3046             :     CPE_ENC_HANDLE hCPE,        /* i/o: CPE encoder structure                            */
    3047             :     const int32_t input_Fs,     /* i  : input sampling rate                              */
    3048             :     float *speech,              /* i  : speech buffer                                    */
    3049             :     float *Bin_E,               /* o  : per bin log energy spectrum                      */
    3050             :     float *Bin_E_old,           /* o  : per bin log energy spectrum for mid-frame        */
    3051             :     float *fr_bands,            /* o  : per band energy spectrum (2 analyses)            */
    3052             :     float lf_E[],               /* o  : per bin E for first VOIC_BINS bins (without DC)  */
    3053             :     float *Etot,                /* o  : total input energy                               */
    3054             :     const int16_t min_band,     /* i  : minimum critical band                            */
    3055             :     const int16_t max_band,     /* i  : maximum critical band                            */
    3056             :     float *band_ener,           /* o  : energy in critical frequency bands without minimum noise floor E_MIN */
    3057             :     float *PS,                  /* o  : Per bin energy spectrum                          */
    3058             :     float *fft_buff             /* o  : FFT coefficients                                 */
    3059             : );
    3060             : 
    3061             : void CNG_enc(
    3062             :     Encoder_State *st,      /* i/o: State structure                                     */
    3063             :     float Aq[],             /* o  : LP coefficients                                     */
    3064             :     const float *speech,    /* i  : pointer to current frame input speech buffer        */
    3065             :     float enr,              /* i  : frame energy output from Levinson recursion         */
    3066             :     const float *lsp_mid,   /* i  : mid frame LSPs                                      */
    3067             :     float *lsp_new,         /* i/o: current frame LSPs                                  */
    3068             :     float *lsf_new,         /* i/o: current frame LSFs                                  */
    3069             :     int16_t *allow_cn_step, /* o  : allow CN step                                       */
    3070             :     float *q_env,
    3071             :     int16_t *sid_bw );
    3072             : 
    3073             : void swb_CNG_enc(
    3074             :     Encoder_State *st,        /* i/o: State structure                                     */
    3075             :     const float *shb_speech,  /* i  : SHB target signal (6-14kHz) at 16kHz                */
    3076             :     const float *syn_12k8_16k /* i  : ACELP core synthesis at 12.8kHz or 16kHz            */
    3077             : );
    3078             : 
    3079             : void lsf_enc(
    3080             :     Encoder_State *st,               /* i/o: state structure                            */
    3081             :     float *lsf_new,                  /* o  : quantized LSF vector                       */
    3082             :     float *lsp_new,                  /* i/o: LSP vector to quantize/quantized           */
    3083             :     float *lsp_mid,                  /* i  : mid-frame LSP vector                       */
    3084             :     float *Aq,                       /* o  : quantized A(z) for 4 subframes             */
    3085             :     const int16_t tdm_low_rate_mode, /* i  : secondary channel low rate mode flag       */
    3086             :     const int16_t GSC_IVAS_mode,     /* i  : GSC IVAS mode                              */
    3087             :     const float tdm_lsfQ_PCh[M]      /* i  : Q LSFs for primary channel                 */
    3088             : );
    3089             : 
    3090             : void isf_enc_amr_wb(
    3091             :     Encoder_State *st, /* i/o: state structure                                     */
    3092             :     float *isf_new,    /* o  : quantized ISF vector                                */
    3093             :     float *isp_new,    /* i/o: ISP vector to quantize/quantized                    */
    3094             :     float *Aq          /* o  : quantized A(z) for 4 subframes                      */
    3095             : );
    3096             : 
    3097             : void find_targets(
    3098             :     const float *speech,   /* i  : pointer to the speech frame                         */
    3099             :     const float *mem_syn,  /* i  : memory of the synthesis filter                      */
    3100             :     const int16_t i_subfr, /* i  : subframe index                                      */
    3101             :     float *mem_w0,         /* i/o: weighting filter denominator memory                 */
    3102             :     const float *p_Aq,     /* i  : interpolated quantized A(z) filter                  */
    3103             :     const float *res,      /* i  : residual signal                                     */
    3104             :     const int16_t L_subfr, /* i  : length of vectors for gain quantization             */
    3105             :     const float *Ap,       /* i  : unquantized A(z) filter with bandwidth expansion    */
    3106             :     const float tilt_fac,  /* i  : tilt factor                                         */
    3107             :     float *xn,             /* o  : Close-loop Pitch search target vector               */
    3108             :     float *cn,             /* o  : target vector in residual domain                    */
    3109             :     float *h1              /* o  : impulse response of weighted synthesis filter       */
    3110             : );
    3111             : 
    3112             : void inov_encode(
    3113             :     Encoder_State *st,          /* i/o: encoder state structure                             */
    3114             :     const int32_t core_brate,   /* i  : core bitrate                                        */
    3115             :     const int16_t Opt_AMR_WB,   /* i  : flag indicating AMR-WB IO mode                      */
    3116             :     const int16_t L_frame,      /* i  : length of the frame                                 */
    3117             :     const int16_t last_L_frame, /* i  : length of the last frame                            */
    3118             :     const int16_t coder_type,   /* i  : coding type                                         */
    3119             :     const int16_t bwidth,       /* i  : input signal bandwidth                              */
    3120             :     const int16_t sharpFlag,    /* i  : formant sharpening flag                             */
    3121             :     const int16_t i_subfr,      /* i  : subframe index                                      */
    3122             :     const int16_t tc_subfr,     /* i  : TC subframe index                                   */
    3123             :     const float *p_Aq,          /* i  : LP filter coefficients                              */
    3124             :     const float gain_pit,       /* i  : adaptive excitation gain                            */
    3125             :     float *cn,                  /* i/o: target vector in residual domain                    */
    3126             :     const float *exc,           /* i  : pointer to excitation signal frame                  */
    3127             :     float *h1,                  /* i/o: weighted filter input response                      */
    3128             :     const float tilt_code,      /* i  : tilt of of the excitation of previous subframe      */
    3129             :     const float pt_pitch,       /* i  : pointer to current subframe fractional pitch        */
    3130             :     const float *xn2,           /* i  : target vector for innovation search                 */
    3131             :     float *code,                /* o  : algebraic excitation                                */
    3132             :     float *y2,                  /* o  : zero-memory filtered algebraic excitation           */
    3133             :     int16_t *unbits,            /* o  : number of unused bits for  EVS_PI                   */
    3134             :     const int16_t L_subfr       /* i  : subframe length                                     */
    3135             : );
    3136             : 
    3137             : void acelp_1t64(
    3138             :     BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle                            */
    3139             :     const float dn[],      /* i  : corr. between target and h[].                       */
    3140             :     const float h[],       /* i  : impulse response of weighted synthesis filter       */
    3141             :     float code[],          /* o  : algebraic (fixed) codebook excitation               */
    3142             :     float y[],             /* o  : filtered fixed codebook excitation                  */
    3143             :     const int16_t L_subfr  /* i  : subframe length                                     */
    3144             : );
    3145             : 
    3146             : void acelp_2t32(
    3147             :     BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle                            */
    3148             :     const float dn[],      /* i  : corr. between target and h[].                       */
    3149             :     const float h[],       /* i  : impulse response of weighted synthesis filter       */
    3150             :     float code[],          /* o  : algebraic (fixed) codebook excitation               */
    3151             :     float y[]              /* o  : filtered fixed codebook excitation                  */
    3152             : );
    3153             : 
    3154             : int16_t acelp_4t64(
    3155             :     BSTR_ENC_HANDLE hBstr,    /* i/o: encoder bitstream handle                            */
    3156             :     float dn[],               /* i  : corr. between target and h[].                       */
    3157             :     const float cn[],         /* i  : residual after long term prediction                 */
    3158             :     const float H[],          /* i  : impulse response of weighted synthesis filter       */
    3159             :     float R[],                /* i  : autocorrelation values                              */
    3160             :     const int16_t acelpautoc, /* i  : autocorrealtion flag                                */
    3161             :     float code[],             /* o  : algebraic (fixed) codebook excitation               */
    3162             :     float y[],                /* o  : filtered fixed codebook excitation                  */
    3163             :     int16_t nbbits,           /* i  : number of bits per codebook                         */
    3164             :     const int16_t cmpl_flag,  /* i  : coomplexity reduction flag                          */
    3165             :     const int16_t Opt_AMR_WB  /* i  : flag indicating AMR-WB IO mode                      */
    3166             : );
    3167             : 
    3168             : /*! r: return (2*N)+1 bits */
    3169             : int16_t quant_2p_2N1(
    3170             :     const int16_t pos1, /* i  : position of the pulse 1                             */
    3171             :     const int16_t pos2, /* i  : position of the pulse 2                             */
    3172             :     const int16_t N     /* i  : number of bits for position                         */
    3173             : );
    3174             : 
    3175             : void corr_xh(
    3176             :     const float *x,       /* i  : target signal                                       */
    3177             :     float *y,             /* o  : correlation between x[] and h[]                     */
    3178             :     const float *h,       /* i  : impulse response of weighted synthesis filter       */
    3179             :     const int16_t L_subfr /* i  : length of the subframe                              */
    3180             : );
    3181             : 
    3182             : void find_tilt(
    3183             :     const float fr_bands[],   /* i  : energy in frequency bands                           */
    3184             :     const float bckr[],       /* i  : per band background noise energy estimate           */
    3185             :     float ee[2],              /* o  : lf/hf E ration for present frame                    */
    3186             :     const int16_t pitch[3],   /* i  : open loop pitch values for 3 half-frames            */
    3187             :     const float voicing[3],   /* i  : normalized correlation for 3 half-frames            */
    3188             :     const float *lf_E,        /* i  : per bin energy  for low frequencies                 */
    3189             :     const float corr_shift,   /* i  : normalized correlation correction                   */
    3190             :     const int16_t bwidth,     /* i  : input signal bandwidth                              */
    3191             :     const int16_t max_band,   /* i  : maximum critical band                               */
    3192             :     float hp_E[],             /* o  : energy in HF                                        */
    3193             :     const int16_t codec_mode, /* i  : Mode 1 or 2                                         */
    3194             :     float *bckr_tilt_lt,      /* i/o: lf/hf E ratio of background noise                   */
    3195             :     int16_t Opt_vbr_mode );
    3196             : 
    3197             : void init_gp_clip(
    3198             :     float mem[] /* o  : memory of gain of pitch clipping algorithm          */
    3199             : );
    3200             : 
    3201             : int16_t gp_clip(
    3202             :     const int16_t element_mode, /* i  : element mode                                        */
    3203             :     const int32_t core_brate,   /* i  : core bitrate                                        */
    3204             :     const float *voicing,       /* i  : normalized correlations (from OL pitch)             */
    3205             :     const int16_t i_subfr,      /* i  : subframe index                                      */
    3206             :     const int16_t coder_type,   /* i  : coding type                                         */
    3207             :     const float xn[],           /* i  : target vector                                       */
    3208             :     float mem[]                 /* i/o: memory of gain of pitch clipping algorithm          */
    3209             : );
    3210             : 
    3211             : void gp_clip_test_lsf(
    3212             :     const int16_t element_mode, /* i  : element mode                                        */
    3213             :     const int32_t core_brate,   /* i  : core bitrate                                        */
    3214             :     const float lsf[],          /* i  : LSF vector                                          */
    3215             :     float mem[],                /* i/o: memory of gain of pitch clipping algorithm          */
    3216             :     const int16_t Opt_AMR_WB    /* i  : flag indicating AMR-WB IO mode                      */
    3217             : );
    3218             : 
    3219             : void gp_clip_test_gain_pit(
    3220             :     const int16_t element_mode, /* i  : element mode                                        */
    3221             :     const int32_t core_brate,   /* i  : core bitrate                                        */
    3222             :     const float gain_pit,       /* i  :   gain of quantized pitch                           */
    3223             :     float mem[]                 /* i/o: memory of gain of pitch clipping algorithm          */
    3224             : );
    3225             : 
    3226             : void analy_lp(
    3227             :     const float speech[],           /* i  : pointer to the denoised speech frame                */
    3228             :     const int16_t L_frame,          /* i  : length of the frame                                 */
    3229             :     const int16_t L_look,           /* i  : look-ahead length                                   */
    3230             :     float *ener,                    /* o  : residual signal energy                              */
    3231             :     float A[],                      /* o  : A(z) filter coefficients                            */
    3232             :     float epsP[],                   /* o  : LP analysis residual energies for each iteration    */
    3233             :     float lsp_new[],                /* o  : current frame ISPs                                  */
    3234             :     float lsp_mid[],                /* o  : current mid-frame ISPs                              */
    3235             :     float lsp_old[],                /* i/o: previous frame unquantized ISPs                     */
    3236             :     const int16_t Top[2],           /* i  : open loop pitch lag                                 */
    3237             :     const float Tnc[2],             /* i  : open loop pitch gain                                */
    3238             :     const int32_t sr_core,          /* i  : internal sampling rate                              */
    3239             :     const int16_t sec_chan_low_rate /* i  : TD secondary channel flag                           */
    3240             : );
    3241             : 
    3242             : void analy_lp_AMR_WB(
    3243             :     const float speech[], /* i  : pointer to the speech frame                         */
    3244             :     float *ener,          /* o  : residual energy from Levinson-Durbin                */
    3245             :     float A[],            /* o  : A(z) filter coefficients                            */
    3246             :     float epsP[],         /* o  : LP analysis residual energies for each iteration    */
    3247             :     float isp_new[],      /* o  : current frame ISPs                                  */
    3248             :     float isp_old[],      /* i/o: previous frame unquantized ISPs                     */
    3249             :     float isf_new[],      /* o  : current frame ISFs                                  */
    3250             :     const int16_t Top,    /* i  : open loop pitch lag                                 */
    3251             :     const float Tnc       /* i  : open loop pitch gain                                */
    3252             : );
    3253             : 
    3254             : void noise_est_init(
    3255             :     NOISE_EST_HANDLE hNoiseEst /* i/o: Noise estimation handle                             */
    3256             : );
    3257             : 
    3258             : void speech_music_clas_init(
    3259             :     SP_MUS_CLAS_HANDLE hSpMusClas /* i/o: speech/music classifier handle                      */
    3260             : );
    3261             : 
    3262             : void long_enr(
    3263             :     Encoder_State *st,                  /* i/o: encoder state structure                  */
    3264             :     const float Etot,                   /* i  : total channel energy                     */
    3265             :     const int16_t localVAD_HE_SAD,      /* i  : HE-SAD flag without hangover             */
    3266             :     const int16_t high_lpn_flag,        /* i  : sp/mus LPN flag                          */
    3267             :     FRONT_VAD_ENC_HANDLE hFrontVad[],   /* i/o: front-VAD handles                        */
    3268             :     const int16_t n_chan,               /* i  : number of channels                       */
    3269             :     const int16_t localVAD_HE_SAD_LR[], /* i  : HE-SAD flag without hangover LR channels */
    3270             :     const float Etot_LR[]               /* i  : total channel energy LR channels         */
    3271             : );
    3272             : 
    3273             : void noise_est_pre(
    3274             :     const float Etot,               /* i  : Energy of current frame                             */
    3275             :     const int16_t ini_frame,        /* i  : Frame number (init)                                 */
    3276             :     NOISE_EST_HANDLE hNoiseEst,     /* i/o: Noise estimation data handle                        */
    3277             :     const int16_t idchan,           /* i  : channel ID                                          */
    3278             :     const int16_t element_mode,     /* i  : element mode                                        */
    3279             :     const int16_t last_element_mode /* i  : last element mode                                   */
    3280             : );
    3281             : 
    3282             : void noise_est_down(
    3283             :     const float fr_bands[], /* i  : per band input energy (contains 2 vectors)          */
    3284             :     float bckr[],           /* i/o: per band background noise energy estimate           */
    3285             :     float tmpN[],           /* o  : temporary noise update                              */
    3286             :     float enr[],            /* o  : averaged energy over both subframes                 */
    3287             :     const int16_t min_band, /* i  : minimum critical band                               */
    3288             :     const int16_t max_band, /* i  : maximum critical band                               */
    3289             :     float *totalNoise,      /* o  : noise estimate over all critical bands              */
    3290             :     const float Etot,       /* i  : Energy of current frame                             */
    3291             :     float *Etot_last,       /* i/o: Energy of last frame                                */
    3292             :     float *Etot_v_h2        /* i/o: Energy variaions of noise frames                    */
    3293             : );
    3294             : 
    3295             : void noise_est(
    3296             :     Encoder_State *st,                    /* i/o: encoder state structure                             */
    3297             :     const int16_t old_pitch1,             /* i  : previous frame OL pitch[1]                          */
    3298             :     const float tmpN[],                   /* i  : temporary noise update                              */
    3299             :     const float *epsP,                    /* i  : LP prediction error energies                        */
    3300             :     const float Etot,                     /* i  : total channel E                                     */
    3301             :     const float relE,                     /* i  : relative frame energy                               */
    3302             :     const float corr_shift,               /* i  : normalized correlation correction                   */
    3303             :     const float enr[],                    /* i  : averaged energy over both subframes                 */
    3304             :     float fr_bands[],                     /* i  : spectrum per critical bands of the current frame    */
    3305             :     float *cor_map_sum,                   /* o  : sum of correlation map from mult-harm analysis      */
    3306             :     float *ncharX,                        /* o  : noise character for sp/mus classifier               */
    3307             :     float *sp_div,                        /* o  : soectral diversity feature                          */
    3308             :     float *non_staX,                      /* o  : non-stationarity for sp/mus classifier              */
    3309             :     int16_t *loc_harm,                    /* o  : multi-harmonicity flag for UV classifier            */
    3310             :     const float *lf_E,                    /* i  : per bin energy  for low frequencies                 */
    3311             :     int16_t *st_harm_cor_cnt,             /* i  : 1st harm correlation timer                          */
    3312             :     const float Etot_l_lp,                /* i  : Smoothed low energy                                 */
    3313             :     float *sp_floor,                      /* o  : noise floor estimate                                */
    3314             :     float S_map[],                        /* o  : short-term correlation map                          */
    3315             :     STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure                         */
    3316             :     FRONT_VAD_ENC_HANDLE hFrontVad,       /* i/o: front-VAD handle                                    */
    3317             :     const int16_t ini_frame               /* i  : Frame number (init)                                 */
    3318             : );
    3319             : 
    3320             : void vad_param_updt(
    3321             :     Encoder_State *st,                /* i/o: encoder state structure                             */
    3322             :     const float corr_shift,           /* i  : correlation shift                                   */
    3323             :     const float corr_shiftR,          /* i  : correlation shift right channel                     */
    3324             :     const float A[],                  /* i  : A(z) unquantized for the 4 subframes                */
    3325             :     const int16_t old_pitch1,         /* i  : previous frame OL pitch[1]                          */
    3326             :     FRONT_VAD_ENC_HANDLE hFrontVad[], /* i/o: front-VAD handles                                   */
    3327             :     const int16_t n_channels          /* i  : number of channels                                  */
    3328             : );
    3329             : 
    3330             : /*! r: frame multi-harmonicity (1-harmonic, 0-not) */
    3331             : int16_t multi_harm(
    3332             :     const float Bin_E[],       /* i  : log energy spectrum of the current frame        */
    3333             :     float old_S[],             /* i/o: prev. log-energy spectrum w. subtracted floor   */
    3334             :     float cor_map_LT[],        /* i/o: LT correlation map                              */
    3335             :     float *multi_harm_limit,   /* i/o: multi harminic threshold                        */
    3336             :     const int32_t total_brate, /* i  : total bitrate                                   */
    3337             :     const int16_t bwidth,      /* i  : input signal bandwidth                          */
    3338             :     int16_t *cor_strong_limit, /* i/o: HF correlation indicator                        */
    3339             :     float *st_mean_avr_dyn,    /* i/o: long term average dynamic                       */
    3340             :     float *st_last_sw_dyn,     /* i/o: last dynamic                                    */
    3341             :     float *cor_map_sum,        /* i  : sum of correlation map                          */
    3342             :     float *sp_floor,           /* o  : noise floor estimate                            */
    3343             :     float S_map[]              /* o  : short-term correlation map                      */
    3344             : );
    3345             : 
    3346             : void lp_gain_updt(
    3347             :     const int16_t i_subfr,      /* i  :  subframe number                                */
    3348             :     const float gain_pit,       /* i  : Decoded gain pitch                              */
    3349             :     const float norm_gain_code, /* i  : Normalised gain code                            */
    3350             :     float *lp_gainp,            /* i/o: LP-filtered pitch gain(FEC)                     */
    3351             :     float *lp_gainc,            /* i/o: LP-filtered code gain (FEC)                     */
    3352             :     const int16_t L_frame       /* i  : length of the frame                             */
    3353             : );
    3354             : 
    3355             : void enc_pit_exc(
    3356             :     Encoder_State *st,                  /* i/o: state structure                                 */
    3357             :     const float *speech,                /* i  : Input speech                                    */
    3358             :     const float Aw[],                   /* i  : weighted A(z) unquantized for subframes         */
    3359             :     const float *Aq,                    /* i  : 12k8 Lp coefficient                             */
    3360             :     const float Es_pred,                /* i  : predicted scaled innov. energy                  */
    3361             :     const float *res,                   /* i  : residual signal                                 */
    3362             :     float *synth,                       /* i/o: core synthesis                                  */
    3363             :     float *exc,                         /* i/o: current non-enhanced excitation                 */
    3364             :     int16_t *T0,                        /* i/o: close loop integer pitch                        */
    3365             :     int16_t *T0_frac,                   /* i/o: close-loop pitch period - fractional part       */
    3366             :     float *pitch_buf,                   /* i/o: Fractionnal per subframe pitch                  */
    3367             :     const int16_t nb_subfr,             /* i  : Number of subframe considered                   */
    3368             :     float *gpit,                        /* o  : pitch gain per subframe                         */
    3369             :     const int16_t tdm_Pitch_reuse_flag, /* i  : primary channel pitch reuse flag                */
    3370             :     const float tdm_Pri_pitch_buf[]     /* i  : primary channel pitch buffer                    */
    3371             : );
    3372             : 
    3373             : void GSC_enc_init(
    3374             :     GSC_ENC_HANDLE hGSCEnc /* i/o: GSC data handle                                  */
    3375             : );
    3376             : 
    3377             : void encod_audio(
    3378             :     Encoder_State *st,                  /* i/o: state structure                                  */
    3379             :     const float speech[],               /* i  : input speech                                     */
    3380             :     const float Aw[],                   /* i  : weighted A(z) unquantized for subframes          */
    3381             :     const float Aq[],                   /* i  : 12k8 Lp coefficient                              */
    3382             :     const float *res,                   /* i  : residual signal                                  */
    3383             :     float *synth,                       /* i/o: core synthesis                                   */
    3384             :     float *exc,                         /* i/o: current non-enhanced excitation                  */
    3385             :     float *pitch_buf,                   /* i/o: floating pitch values for each subframe          */
    3386             :     float *voice_factors,               /* o  : voicing factors                                  */
    3387             :     float *bwe_exc,                     /* o  : excitation for SWB TBE                           */
    3388             :     const int16_t attack_flag,          /* i  : attack flag (GSC or TC)                          */
    3389             :     float *lsf_new,                     /* i  : current frame ISF vector                         */
    3390             :     float *tmp_noise,                   /* o  : long-term noise energy                           */
    3391             :     const int16_t tdm_Pitch_reuse_flag, /* i  : primary channel pitch reuse flag                 */
    3392             :     const float tdm_Pri_pitch_buf[]     /* i  : primary channel pitch buffer                     */
    3393             : );
    3394             : 
    3395             : /*! r: index of the last band where pitch contribution is significant */
    3396             : int16_t Pit_exc_contribution_len(
    3397             :     Encoder_State *st,    /* i/o: state structure                                 */
    3398             :     const float *dct_res, /* i  : DCT of residual                                 */
    3399             :     float *dct_pitex,     /* i/o: DCT of pitch contribution                       */
    3400             :     float *pitch_buf,     /* i/o: Pitch per subframe                              */
    3401             :     int16_t *hangover     /* i  : Hangover for the time contribution switching    */
    3402             : );
    3403             : 
    3404             : int16_t stab_est(
    3405             :     float etot,               /* i  : Total energy of the current frame                   */
    3406             :     float *lt_diff_etot,      /* i/o: Long term total energy variation                    */
    3407             :     float *mem_etot,          /* i/o: Total energy memory                                 */
    3408             :     int16_t *nb_thr_3,        /* i/o: Number of consecutives frames of level 3            */
    3409             :     int16_t *nb_thr_1,        /* i/o: Number of consecutives frames of level 1            */
    3410             :     float *thresh,            /* i/o: Detection thresold                                  */
    3411             :     int16_t *last_music_flag, /* i/o: Previous music detection ouptut                     */
    3412             :     const int16_t vad_flag    /* i  : VAD flag                                            */
    3413             : );
    3414             : 
    3415             : float gsc_gainQ(
    3416             :     BSTR_ENC_HANDLE hBstr,       /* i/o: encoder bitstream handle                            */
    3417             :     const int16_t element_mode,  /* i  : element mode                                        */
    3418             :     const int16_t idchan,        /* i  : channel ID                                          */
    3419             :     const float y_gain4[],       /* i  : gain per band                                       */
    3420             :     float y_gainQ[],             /* o  : quantized gain per band                             */
    3421             :     const int32_t core_brate,    /* i  : Core rate                                           */
    3422             :     const int16_t coder_type,    /* i  : coding type                                         */
    3423             :     const int16_t bwidth,        /* i  : input signal bandwidth                              */
    3424             :     const int16_t L_frame,       /* i  : frame length                                        */
    3425             :     const int16_t tdm_LRTD_flag, /* i  : LRTD stereo mode flag                               */
    3426             :     const int32_t core_brate_inp /* i  : true core brate                                     */
    3427             : );
    3428             : 
    3429             : void Ener_per_band_comp(
    3430             :     const float exc_diff[], /* i  : gain per band                                       */
    3431             :     float y_gain4[],        /* o  : gain per band to quantize                           */
    3432             :     const int16_t Mband,    /* i  : Max band                                            */
    3433             :     const int16_t Eflag,    /* i  : flag of highest band                                */
    3434             :     const int16_t L_frame   /* i  : frame length                                        */
    3435             : );
    3436             : 
    3437             : void Comp_and_apply_gain(
    3438             :     float exc_diffQ[],      /* i/o: gain per band                                       */
    3439             :     float Ener_per_bd_iQ[], /* o  : Quant Ener per band                                 */
    3440             :     float Ener_per_bd_yQ[], /* o  : Ener per band for quantize y                        */
    3441             :     int16_t Mbands_gn,      /* i  : number of bands                                     */
    3442             :     const int16_t ReUseGain /* i  : Reuse the gain in Ener_per_bd_yQ                    */
    3443             : );
    3444             : 
    3445             : void bands_and_bit_alloc(
    3446             :     const int16_t cor_strong_limit, /* i  : HF correlation                                        */
    3447             :     const int16_t noise_lev,        /* i  : dwn scaling factor                                    */
    3448             :     const int32_t core_brate,       /* i  : core bitrate                                          */
    3449             :     const int16_t Diff_len,         /* i  : Lenght of the difference signal (before pure spectral)*/
    3450             :     const int16_t bits_used,        /* i  : Number of bit used before frequency Q                 */
    3451             :     int16_t *bit,                   /* i/o: Number of bit allowed for frequency quantization      */
    3452             :     float *ener_vec,                /* i/o: Quantized energy vector                               */
    3453             :     int16_t *max_ener_band,         /* o  : Sorted order                                          */
    3454             :     int16_t *bits_per_bands_s,      /* i/o: Number of bit allowed per allowed subband (Q3)        */
    3455             :     int16_t *nb_subbands,           /* o  : Number of subband allowed                             */
    3456             :     const float *exc_diff,          /* i  : Difference signal to quantize (encoder side only)     */
    3457             :     float *concat_in,               /* o  : Concatened PVQ's input vector (encoder side only)     */
    3458             :     int16_t *pvq_len,               /* o  : Number of bin covered with the PVQ                    */
    3459             :     const int16_t coder_type,       /* i  : coding type                                           */
    3460             :     const int16_t bwidth,           /* i  : input signal bandwidth                                */
    3461             :     const int16_t GSC_noisy_speech, /* i  : GSC noisy speech flag                                 */
    3462             :     const int16_t L_frame,          /* i  : frame length                                          */
    3463             :     const int16_t element_mode,     /* i  : element mode                                          */
    3464             :     const int16_t GSC_IVAS_mode     /* i  : GSC IVAS mode                                         */
    3465             : );
    3466             : 
    3467             : /*! r: average frequency gain */
    3468             : float gsc_gaindec(
    3469             :     Decoder_State *st,        /* i/o: decoder state structure                 */
    3470             :     float y_gainQ[],          /* o  : quantized gain per band                 */
    3471             :     const int32_t core_brate, /* i  : core used                               */
    3472             :     float old_y_gain[],       /* i/o: AR gain quantizer for low rate          */
    3473             :     const int16_t coder_type, /* i  : coding type                             */
    3474             :     const int16_t bwidth      /* i  : input signal bandwidth                  */
    3475             : );
    3476             : 
    3477             : void freq_dnw_scaling(
    3478             :     const int16_t cor_strong_limit, /* i  : HF correlation                          */
    3479             :     const int16_t coder_type,       /* i  : coder type                              */
    3480             :     const int16_t noise_lev,        /* i  : Noise level                             */
    3481             :     const int32_t core_brate,       /* i  : Core bitrate                            */
    3482             :     float fy_norm[],                /* i/o: Frequency quantized parameter           */
    3483             :     const int16_t L_frame           /* i  : frame length                            */
    3484             : );
    3485             : 
    3486             : void GSC_dec_init(
    3487             :     GSC_DEC_HANDLE hGSCDec /* i/o: GSC data handle                         */
    3488             : );
    3489             : 
    3490             : void decod_audio(
    3491             :     Decoder_State *st,                  /* i/o: decoder static memory                     */
    3492             :     float dct_epit[],                   /* o  : GSC excitation in DCT domain              */
    3493             :     const float *Aq,                    /* i  : LP filter coefficient                     */
    3494             :     float *tmp_noise,                   /* o  : long term temporary noise energy          */
    3495             :     float *pitch_buf,                   /* o  : floating pitch values for each subframe   */
    3496             :     float *voice_factors,               /* o  : voicing factors                           */
    3497             :     float *exc_dct_in,                  /* i/o: adapt. excitation exc                     */
    3498             :     float *exc2,                        /* i/o: adapt. excitation/total exc               */
    3499             :     float *bwe_exc,                     /* o  : excitation for SWB TBE                    */
    3500             :     float *lsf_new,                     /* i  : current frame ISF vector                  */
    3501             :     float *gain_buf,                    /* o  : floating pitch gain for each subframe     */
    3502             :     const int16_t tdm_lp_reuse_flag,    /* i  : LPC reuse flag                            */
    3503             :     const int16_t tdm_low_rate_mode,    /* i  : secondary channel low rate mode flag      */
    3504             :     const int16_t tdm_Pitch_reuse_flag, /* i  : primary channel pitch reuse flag          */
    3505             :     const float tdm_Pri_pitch_buf[]     /* i  : primary channel pitch buffer              */
    3506             : );
    3507             : 
    3508             : void gsc_dec(
    3509             :     Decoder_State *st,          /* i/o: State structure                           */
    3510             :     float exc_dct_in[],         /* i/o: dct of pitch-only/total excitation        */
    3511             :     const int16_t pit_band_idx, /* i  : pitch band index                          */
    3512             :     const int16_t Diff_len,     /* i  :  */
    3513             :     const int16_t bits_used,    /* i  : total number of bits used                 */
    3514             :     const int16_t nb_subfr,     /* i  : Number of subframe considered             */
    3515             :     const int16_t coder_type,   /* i  : coding type                               */
    3516             :     int16_t *last_bin,          /* i  : last bin of bit allocation                */
    3517             :     const float *lsf_new,       /* i  : ISFs at the end of the frame              */
    3518             :     float *exc_wo_nf,           /* o  : excitation (in f domain) without noisefill*/
    3519             :     float *tmp_noise            /* o  : long-term noise energy                    */
    3520             : );
    3521             : 
    3522             : void dec_pit_exc(
    3523             :     Decoder_State *st,                  /* i/o: decoder static memory                     */
    3524             :     const int16_t L_frame,              /* i  : length of the frame                       */
    3525             :     const float *Aq,                    /* i  : LP filter coefficient                     */
    3526             :     const float Es_pred,                /* i  : predicted scaled innov. energy            */
    3527             :     float *pitch_buf,                   /* o  : floating pitch values for each subframe   */
    3528             :     float *code,                        /* o  : innovation                                */
    3529             :     float *exc,                         /* i/o: adapt. excitation exc                     */
    3530             :     const int16_t nb_subfr,             /* i  : Number of subframe considered             */
    3531             :     float *gain_buf,                    /* o  : floating pitch gain for each subframe     */
    3532             :     const int16_t tdm_Pitch_reuse_flag, /* i  : primary channel pitch reuse flag          */
    3533             :     const float tdm_Pri_pitch_buf[]     /* i  : primary channel pitch buffer              */
    3534             : );
    3535             : 
    3536             : void highband_exc_dct_in(
    3537             :     const int32_t core_brate,         /* i  : core bitrate                                    */
    3538             :     const int16_t *mfreq_bindiv_loc,  /* i  : bin per bands tables                            */
    3539             :     int16_t last_bin,                 /* i  : last bin of bit allocation                      */
    3540             :     int16_t Diff_len,                 /* i  : number of bin before cut-off frequency          */
    3541             :     int16_t noise_lev,                /* i  : pulses dynamic                                  */
    3542             :     int16_t pit_band_idx,             /* i  : bin position of the cut-off frequency           */
    3543             :     float *exc_diffQ,                 /* i  : frequency coefficients of per band              */
    3544             :     int16_t *seed_tcx,                /* i  : Seed for noise                                  */
    3545             :     float *Ener_per_bd_iQ,            /* i  : Quantized energy of targeted vector             */
    3546             :     int16_t nb_subfr,                 /* i  : Number of subframe considered                   */
    3547             :     float *exc_dct_in,                /* o  : dct of residual signal                          */
    3548             :     int16_t last_coder_type,          /* i  : coding type of last frame                       */
    3549             :     int16_t *bitallocation_band,      /* i  : bit allocation flag of each band                */
    3550             :     const float *lsf_new,             /* i  : ISFs at the end of the frame                    */
    3551             :     float *last_exc_dct_in,           /* i  : dct of residual signal of last frame            */
    3552             :     float *last_ener,                 /* i  : frequency energy  of last frame                 */
    3553             :     int16_t *last_bitallocation_band, /* i  : bit allocation flag of each band  of last frame */
    3554             :     int16_t *bitallocation_exc,       /* i  : flag of decoded coefficients                    */
    3555             :     const int16_t bfi,                /* i  : bad frame indicator                             */
    3556             :     const int16_t coder_type,         /* i  : coder type                                      */
    3557             :     const int16_t bwidth,             /* i  : audio bandwidth                                 */
    3558             :     float *exc_wo_nf,                 /* o  : excitation (in f domain) without noisefill      */
    3559             :     const int16_t GSC_noisy_speech,   /* i  : GSC noisy speech flag                           */
    3560             :     float *lt_ener_per_band_fx,       /* i/o: Average per band energy                         */
    3561             :     const int16_t L_frame,            /* i  : frame length                                    */
    3562             :     const int16_t element_mode,       /* i  : IVAS element moden                              */
    3563             :     const int16_t GSC_IVAS_mode       /* i  : GSC IVAS mode                                   */
    3564             : );
    3565             : 
    3566             : void inact_switch_ematch(
    3567             :     float exc2[],                           /* i/o: CELP/GSC excitation buffer                  */
    3568             :     float dct_exc_tmp[],                    /* i  : GSC excitation in DCT domain                */
    3569             :     float lt_ener_per_band[],               /* i/o: long-term energy per band                   */
    3570             :     const int16_t coder_type,               /* i  : coder type                                  */
    3571             :     const int16_t inactive_coder_type_flag, /* i  : AVQ (0) or GSC (1) IC flag                  */
    3572             :     const int16_t L_frame,                  /* i  : frame length                                */
    3573             :     const int16_t bfi,                      /* i  : frame lost indicator                        */
    3574             :     const int16_t last_core,                /* i  : Last core used                              */
    3575             :     const int16_t last_codec_mode,          /* i  : Last codec mode                             */
    3576             :     const int16_t tdm_low_rate_mode,        /* i  : secondary channel low rate mode flag        */
    3577             :     const int16_t element_mode              /* i  : element mode                                */
    3578             : );
    3579             : 
    3580             : void music_postfilt_init(
    3581             :     MUSIC_POSTFILT_HANDLE hMusicPF /* i/o: LD music postfilter handle                  */
    3582             : );
    3583             : 
    3584             : void LD_music_post_filter(
    3585             :     MUSIC_POSTFILT_HANDLE hMusicPF, /* i/o: LD music postfilter handle                  */
    3586             :     const float dtc_in[],           /* i  : input synthesis                             */
    3587             :     float dtc_out[],                /* o  : output synthesis                            */
    3588             :     const int32_t core_brate,       /* i  : core bitrate                                */
    3589             :     const int16_t coder_type,       /* i  : Coder type : -1 in case of IO               */
    3590             :     const int16_t Last_coder_type   /* i  : last Coder type                             */
    3591             : );
    3592             : 
    3593             : void Post_music_postP(
    3594             :     float dct_buffer_in[],  /* i/o: excitation buffer                           */
    3595             :     float exc_buffer_out[], /* o  : DCT output buffer                           */
    3596             :     float *exc2,            /* i/o: Current excitation to be overwriten         */
    3597             :     const float *mem_tmp,   /* i  : previous frame synthesis memory             */
    3598             :     float *st_mem_syn2,     /* i/o: current frame synthesis memory              */
    3599             :     const float *Aq,        /* i  : LPC filter coefficients                     */
    3600             :     float *syn              /* i/o: 12k8 synthesis                              */
    3601             : );
    3602             : 
    3603             : void Prep_music_postP(
    3604             :     float exc_buffer_in[],   /* i/o: excitation buffer                           */
    3605             :     float dct_buffer_out[],  /* o  : DCT output buffer                           */
    3606             :     float filt_lfE[],        /* i/o: long term spectrum energy                   */
    3607             :     const int16_t last_core, /* i  : last core                                   */
    3608             :     const float *pitch_buf,  /* i  : current frame pitch information             */
    3609             :     float *LDm_enh_lp_gbin   /* o  : smoothed suppression gain, per bin FFT      */
    3610             : );
    3611             : 
    3612             : void speech_music_classif(
    3613             :     Encoder_State *st,             /* i/o: encoder state structure                         */
    3614             :     const float *new_inp,          /* i  : new input signal                                */
    3615             :     const float *inp,              /* i  : input signal to locate attach position          */
    3616             :     const int16_t localVAD_HE_SAD, /* i  : HE-SAD flag without hangover                    */
    3617             :     const float lsp_new[M],        /* i  : LSPs in current frame                           */
    3618             :     const float cor_map_sum,       /* i  : correlation map sum (from multi-harmonic anal.) */
    3619             :     const float epsP[M + 1],       /* i  : LP prediciton error                             */
    3620             :     const float PS[],              /* i  : energy spectrum                                 */
    3621             :     const float Etot,              /* i  : total frame energy                              */
    3622             :     const float old_cor,           /* i  : max correlation from previous frame             */
    3623             :     int16_t *attack_flag,          /* o  : attack flag (GSC or TC)                         */
    3624             :     const float non_staX,          /* i  : unbound non-stationarity for sp/mus classifier  */
    3625             :     const float relE,              /* i  : relative frame energy                           */
    3626             :     int16_t *high_lpn_flag,        /* o  : sp/mus LPN flag                                 */
    3627             :     const int16_t flag_spitch      /* i  : flag to indicate very short stable pitch        */
    3628             : );
    3629             : 
    3630             : void find_wsp(
    3631             :     const int16_t L_frame,  /* i  : length of the frame                         */
    3632             :     const int16_t L_subfr,  /* i  : length of subframe                          */
    3633             :     const int16_t nb_subfr, /* i  : number of subframes                         */
    3634             :     const float *A,         /* i  : A(z) filter coefficients                    */
    3635             :     float *Aw,              /* o  : weighted A(z) filter coefficients           */
    3636             :     const float *speech,    /* i  : pointer to the denoised speech frame        */
    3637             :     const float tilt_fact,  /* i  : tilt factor                                 */
    3638             :     float *wsp,             /* o  : poitnter to the weighted speech frame       */
    3639             :     float *mem_wsp,         /* i/o: W(Z) denominator memory                     */
    3640             :     const float gamma,      /* i  : weighting factor                            */
    3641             :     const int16_t L_look    /* i  : look-ahead                                  */
    3642             : );
    3643             : 
    3644             : void pitch_ol_init(
    3645             :     float *old_thres,   /* o  : threshold for reinforcement of past pitch influence */
    3646             :     int16_t *old_pitch, /* o  : pitch  of the 2nd half-frame of previous frame      */
    3647             :     int16_t *delta_pit, /* o  : pitch evolution extrapolation                       */
    3648             :     float *old_corr     /* o  : correlation                                         */
    3649             : );
    3650             : 
    3651             : void pitch_ol(
    3652             :     int16_t pitch[3],         /* o  : open loop pitch lag for each half-frame                        */
    3653             :     float voicing[3],         /* o  : maximum normalized correlation for each half-frame             */
    3654             :     int16_t *old_pitch,       /* i/o: OL pitch of the 2nd half-frame of the last frame               */
    3655             :     float *old_corr,          /* i/o: correlation                                                    */
    3656             :     float corr_shift,         /* i  : normalized correlation correction                              */
    3657             :     float *old_thres,         /* i/o: maximum correlation weighting with respect to past frame pitch */
    3658             :     int16_t *delta_pit,       /* i/o: old pitch extrapolation correction (added to old pitch)        */
    3659             :     float *st_old_wsp2,       /* i/o: weighted speech memory                                         */
    3660             :     const float *wsp,         /* i  : weighted speech for current frame and look-ahead               */
    3661             :     float mem_decim2[3],      /* i/o: wsp decimation filter memory                                   */
    3662             :     const float relE,         /* i  : relative frame energy                                          */
    3663             :     const int16_t L_look,     /* i  : look-ahead length                                              */
    3664             :     const int16_t last_class, /* i  : frame classification of last frame                             */
    3665             :     const int16_t bwidth,     /* i  : audio bandwidth                                                */
    3666             :     const int16_t Opt_SC_VBR  /* i  : SC-VBR flag                                                    */
    3667             : );
    3668             : 
    3669             : void pitch_ol2(
    3670             :     const int16_t pit_min,  /* i  : pit_min value                                                   */
    3671             :     const int16_t pitch_ol, /* i  : pitch to be improved                                            */
    3672             :     float *pitch_fr,        /* o  : adjusted 1/4 fractional pitch                                   */
    3673             :     float *voicing_fr,      /* o  : adjusted 1/4 fractional voicing                                 */
    3674             :     const int16_t pos,      /* i  : position in frame where to calculate the improv.                */
    3675             :     const float *wsp,       /* i  : weighted speech for current frame and look-ahead                */
    3676             :     const int16_t delta     /* i  : delta for pitch search                                          */
    3677             : );
    3678             : 
    3679             : void StableHighPitchDetect(
    3680             :     int16_t *flag_spitch,      /* o  : flag to indicate very short stable pitch                        */
    3681             :     int16_t pitch[],           /* i/o: OL pitch buffer                                                 */
    3682             :     const float voicing[],     /* i  : OL pitch gains                                                  */
    3683             :     const float Bin_E[],       /* i  : per bin log energy spectrum                                     */
    3684             :     const float wsp[],         /* i  : weighted speech                                                 */
    3685             :     const int16_t localVAD,    /* i  : local VAD flag                                                  */
    3686             :     float *voicing_sm,         /* i/o: smoothed open-loop pitch gains                                  */
    3687             :     float *voicing0_sm,        /* i/o: smoothed high pitch gains                                       */
    3688             :     float *LF_EnergyRatio_sm,  /* i/o: smoothed [0, 300Hz] relative peak energy                        */
    3689             :     int16_t *predecision_flag, /* i/o: predecision flag                                                */
    3690             :     float *diff_sm,            /* i/o: smoothed pitch frequency difference                             */
    3691             :     float *energy_sm           /* i/o: smoothed energy around pitch frequency                          */
    3692             : );
    3693             : 
    3694             : void pitchDoubling_det(
    3695             :     const float *wspeech,
    3696             :     int16_t *pitch_ol,
    3697             :     float *pitch_fr,
    3698             :     float *voicing_fr );
    3699             : 
    3700             : void gain_enc_amr_wb(
    3701             :     BSTR_ENC_HANDLE hBstr,    /* i/o: encoder bitstream handle                                        */
    3702             :     const float *xn,          /* i  : target vector                                                   */
    3703             :     const float *y1,          /* i  : zero-memory filtered adaptive excitation                        */
    3704             :     const float *y2,          /* i  : zero-memory filtered algebraic codebook excitation              */
    3705             :     const float *code,        /* i  : algebraic excitation                                            */
    3706             :     const int32_t core_brate, /* i  : core bitrate                                                    */
    3707             :     float *gain_pit,          /* i/o: Pitch gain / Quantized pitch gain                               */
    3708             :     float *gain_code,         /* o  : Quantized codebook gain                                         */
    3709             :     float *gain_inov,         /* o  : innovation gain                                                 */
    3710             :     float *norm_gain_code,    /* o  : norm. gain of the codebook excitation                           */
    3711             :     float *coeff,             /* i/o: correlations <y1,y1>, -2<xn,y1>,<y2,y2>, -2<xn,y2> and 2<y1,y2> */
    3712             :     const int16_t clip_gain,  /* i  : gain pitch clipping flag (1 = clipping)                         */
    3713             :     float *past_qua_en        /* i/o: gain quantization memory (4 words)                              */
    3714             : );
    3715             : 
    3716             : void gain_enc_lbr(
    3717             :     BSTR_ENC_HANDLE hBstr,      /* i/o: encoder bitstream handle                                        */
    3718             :     const int16_t gains_mode[], /* i  : gain bits                                                       */
    3719             :     const int16_t coder_type,   /* i  : coding type                                                     */
    3720             :     const int16_t i_subfr,      /* i  : subframe index                                                  */
    3721             :     const float *xn,            /* i  : target vector                                                   */
    3722             :     const float *y1,            /* i  : zero-memory filtered adaptive excitation                        */
    3723             :     const float *y2,            /* i  : zero-memory filtered algebraic codebook excitation              */
    3724             :     const float *code,          /* i  : algebraic excitation                                            */
    3725             :     float *gain_pit,            /* o  : quantized pitch gain                                            */
    3726             :     float *gain_code,           /* o  : quantized codebook gain                                         */
    3727             :     float *gain_inov,           /* o  : gain of the innovation (used for normalization)                 */
    3728             :     float *norm_gain_code,      /* o  : norm. gain of the codebook excitation                           */
    3729             :     float *g_corr,              /* i/o: correlations <y1,y1>, -2<xn,y1>,<y2,y2>, -2<xn,y2> and 2<y1,y2> */
    3730             :     float gains_mem[],          /* i/o: pitch gain and code gain from previous subframes                */
    3731             :     const int16_t clip_gain,    /* i  : gain pitch clipping flag (1 = clipping)                         */
    3732             :     const int16_t L_subfr       /* i  : subfr Lenght                                                    */
    3733             : );
    3734             : 
    3735             : void gain_enc_mless(
    3736             :     BSTR_ENC_HANDLE hBstr,      /* i/o: encoder bitstream handle                                        */
    3737             :     const int16_t gains_mode[], /* i  : gain bits                                                       */
    3738             :     const int16_t element_mode, /* i  : element mode                                                    */
    3739             :     const int16_t L_frame,      /* i  : length of the frame                                             */
    3740             :     const int16_t i_subfr,      /* i  : subframe index                                                  */
    3741             :     const int16_t tc_subfr,     /* i  : TC subframe index                                               */
    3742             :     const float *xn,            /* i  : target vector                                                   */
    3743             :     const float *y1,            /* i  : zero-memory filtered adaptive excitation                        */
    3744             :     const float *y2,            /* i  : zero-memory filtered algebraic codebook excitation              */
    3745             :     const float *code,          /* i  : algebraic excitation                                            */
    3746             :     const float Es_pred,        /* i  : predicted scaled innovation energy                              */
    3747             :     float *gain_pit,            /* o  : quantized pitch gain                                            */
    3748             :     float *gain_code,           /* o  : quantized codebook gain                                         */
    3749             :     float *gain_inov,           /* o  : innovation gain                                                 */
    3750             :     float *norm_gain_code,      /* o  : norm. gain of the codebook excitation                           */
    3751             :     float *coeff,               /* i/o: correlations <y1,y1>, -2<xn,y1>,<y2,y2>, -2<xn,y2> and 2<y1,y2> */
    3752             :     const int16_t clip_gain     /* i  : gain pitch clipping flag (1 = clipping)                         */
    3753             : );
    3754             : 
    3755             : void gain_enc_SQ(
    3756             :     BSTR_ENC_HANDLE hBstr,      /* i/o: encoder bitstream handle                                        */
    3757             :     const int16_t gains_mode[], /* i  : gain bits                                                       */
    3758             :     const int16_t i_subfr,      /* i  : subframe index                                                  */
    3759             :     const float *xn,            /* i  : target vector                                                   */
    3760             :     const float *yy1,           /* i  : zero-memory filtered adaptive excitation                        */
    3761             :     const float *y2,            /* i  : zero-memory filtered algebraic codebook excitation              */
    3762             :     const float *code,          /* i  : algebraic excitation                                            */
    3763             :     const float Es_pred,        /* i  : predicted scaled innovation energy                              */
    3764             :     float *gain_pit,            /* o  : quantized pitch gain                                            */
    3765             :     float *gain_code,           /* o  : quantized codebook gain                                         */
    3766             :     float *gain_inov,           /* o  : gain of the innovation (used for normalization)                 */
    3767             :     float *norm_gain_code,      /* o  : norm. gain of the codebook excitation                           */
    3768             :     float *g_corr,              /* i/o: correlations <y1,y1>, -2<xn,y1>,<y2,y2>, -2<xn,y2> and 2<y1,y2> */
    3769             :     const int16_t clip_gain     /* i  : gain pitch clipping flag (1 = clipping)                         */
    3770             : );
    3771             : 
    3772             : /*! r: Return index of quantization */
    3773             : int16_t gain_enc_gaus(
    3774             :     float *gain,          /* i/o: Code gain to quantize                       */
    3775             :     const int16_t bits,   /* i  : number of bits to quantize                  */
    3776             :     const float lowBound, /* i  : lower bound of quantizer (dB)               */
    3777             :     const float topBound  /* i  : upper bound of quantizer (dB)               */
    3778             : );
    3779             : 
    3780             : void E_corr_xy2(
    3781             :     const float xn[],     /* i  : target vector                               */
    3782             :     const float y1[],     /* i  : filtered excitation components 1            */
    3783             :     const float y2[],     /* i  : filtered excitation components 2            */
    3784             :     float g_corr[],       /* o  : correlations between x, y1, y2, y3, y4      */
    3785             :     const int16_t L_subfr /* i  : subframe size                               */
    3786             : );
    3787             : 
    3788             : /*! r: Floating pitch for each subframe */
    3789             : float pit_encode(
    3790             :     BSTR_ENC_HANDLE hBstr,              /* i/o: encoder bitstream handle                    */
    3791             :     const int16_t pitch_bits[],         /* i  : pitch bits                                  */
    3792             :     const int32_t core_brate,           /* i  : core bitrate                                */
    3793             :     const int16_t Opt_AMR_WB,           /* i  : flag indicating AMR-WB IO mode              */
    3794             :     const int16_t L_frame,              /* i  : length of the frame                         */
    3795             :     const int16_t coder_type,           /* i  : coding type                                 */
    3796             :     int16_t *limit_flag,                /* i/o: restrained(0) or extended(1) Q limits       */
    3797             :     const int16_t i_subfr,              /* i  : subframe index                              */
    3798             :     float *exc,                         /* i/o: pointer to excitation signal frame          */
    3799             :     const int16_t L_subfr,              /* i  : subframe length                             */
    3800             :     const int16_t *pitch,               /* i  : open loop pitch estimates in current frame  */
    3801             :     int16_t *T0_min,                    /* i/o: lower limit for close-loop search           */
    3802             :     int16_t *T0_max,                    /* i/o: higher limit for close-loop search          */
    3803             :     int16_t *T0,                        /* i/o: close loop integer pitch                    */
    3804             :     int16_t *T0_frac,                   /* i/o: close loop fractional part of the pitch     */
    3805             :     const float *h1,                    /* i  : weighted filter input response              */
    3806             :     const float *xn,                    /* i  : target vector                               */
    3807             :     const int16_t tdm_Pitch_reuse_flag, /* i  : primary channel pitch reuse flag            */
    3808             :     const float tdm_Pri_pitch_buf[]     /* i  : primary channel pitch buffer                */
    3809             : );
    3810             : 
    3811             : /*! r: coding type */
    3812             : int16_t find_uv(
    3813             :     Encoder_State *st,               /* i/o: encoder state structure                       */
    3814             :     const float *pitch_fr,           /* i  : pointer to adjusted fractional pitch (4 val.) */
    3815             :     const float *voicing_fr,         /* i  : refined correlation for each subframes        */
    3816             :     const float *speech,             /* i  : pointer to speech signal for E computation    */
    3817             :     const float *ee,                 /* i  : lf/hf Energy ratio for present frame          */
    3818             :     float *dE1X,                     /* o  : sudden energy increase for S/M classifier     */
    3819             :     const float corr_shift,          /* i  : normalized correlation correction in noise    */
    3820             :     const float relE,                /* i  : relative frame energy                         */
    3821             :     const float Etot,                /* i  : total energy                                  */
    3822             :     const float hp_E[],              /* i  : energy in HF                                  */
    3823             :     int16_t *flag_spitch,            /* i/o: flag to indicate very short stable pitch and high correlation */
    3824             :     const int16_t last_core_orig,    /* i  : original last core                            */
    3825             :     STEREO_CLASSIF_HANDLE hStereoClf /* i/o: stereo classifier structure                   */
    3826             : );
    3827             : 
    3828             : /*! r: classification for current frames */
    3829             : int16_t signal_clas(
    3830             :     Encoder_State *st,    /* i/o: encoder state structure                           */
    3831             :     const float *speech,  /* i  : pointer to speech signal for E computation        */
    3832             :     const float *ee,      /* i  : lf/hf E ration for 2 half-frames                  */
    3833             :     const float relE,     /* i  : frame relative E to the long term average         */
    3834             :     const int16_t L_look, /* i  : look-ahead                                        */
    3835             :     int16_t *clas_mod     /* o  : class flag for NOOP detection                     */
    3836             : );
    3837             : 
    3838             : void select_TC(
    3839             :     const int16_t codec_mode, /* i  : codec mode                                        */
    3840             :     const int16_t tc_cnt,     /* i  : TC frame counter                                  */
    3841             :     int16_t *coder_type,      /* i/o: coder type                                        */
    3842             :     const int16_t localVAD    /* i  : VAD without hangover                              */
    3843             : );
    3844             : 
    3845             : void coder_type_modif(
    3846             :     Encoder_State *st, /* i/o: encoder state structure                           */
    3847             :     const float relE   /* i  : frame relative E to the long term average         */
    3848             : );
    3849             : 
    3850             : void wb_vad_init(
    3851             :     VAD_HANDLE hVAD /* i/o: VAD data handle                            */
    3852             : );
    3853             : 
    3854             : int16_t dtx_hangover_addition(
    3855             :     Encoder_State *st,               /* i/o: encoder state structure                    */
    3856             :     const int16_t vad_flag,          /* i  : VAD flag                                   */
    3857             :     const float snr,                 /* i  : input single SNR estimate                  */
    3858             :     const int16_t cldfb_subtraction, /* i  :                                            */
    3859             :     int16_t *vad_hover_flag,         /* o  : VAD hangover flag                          */
    3860             :     VAD_HANDLE hVAD,                 /* i/o: VAD handle for L or R channel              */
    3861             :     NOISE_EST_HANDLE hNoiseEst,      /* i  : Noise estimation handle                    */
    3862             :     int16_t *rem_dtx_ho              /* o  : Expected remaining hangover frames         */
    3863             : );
    3864             : 
    3865             : int16_t wb_vad(
    3866             :     Encoder_State *st,              /* i/o: encoder state structure                    */
    3867             :     const float fr_bands[],         /* i  : per band input energy (contains 2 vectors) */
    3868             :     int16_t *noisy_speech_HO,       /* o  : SC-VBR noisy speech HO flag                */
    3869             :     int16_t *clean_speech_HO,       /* o  : SC-VBR clean speech HO flag                */
    3870             :     int16_t *NB_speech_HO,          /* o  : SC-VBR NB speech HO flag                   */
    3871             :     float *snr_sum_he,              /* i  : voicing metric from SAD                    */
    3872             :     int16_t *localVAD_HE_SAD,       /* o  : HE_SAD decision without hangovers          */
    3873             :     int16_t *flag_noisy_speech_snr, /* o  :                                            */
    3874             :     VAD_HANDLE hVAD,                /* i/o: VAD handle                                 */
    3875             :     NOISE_EST_HANDLE hNoiseEst,     /* i/o: Noise estimation handle                    */
    3876             :     float lp_speech,                /* i  : long term active speech energy average     */
    3877             :     float lp_noise                  /* i  : long term noise energy                     */
    3878             : );
    3879             : 
    3880             : void bw_detect(
    3881             :     Encoder_State *st,             /* i/o: Encoder State                               */
    3882             :     const float signal_in[],       /* i  : input signal                                */
    3883             :     float *spectrum,               /* i  : MDCT spectrum                               */
    3884             :     const float *enerBuffer,       /* i  : energy buffer                               */
    3885             :     const IVAS_FORMAT ivas_format, /* i  : IVAS format                                 */
    3886             :     const int16_t mct_on           /* i  : flag MCT mode                               */
    3887             : );
    3888             : 
    3889             : void set_bw(
    3890             :     const int16_t element_mode,  /* i  : element mode                                */
    3891             :     const int32_t element_brate, /* i  : element bitrate                             */
    3892             :     Encoder_State *st,           /* i/o: Encoder State                               */
    3893             :     const int16_t codec_mode     /* i  : codec mode                                  */
    3894             : );
    3895             : 
    3896             : float gaus_encode(
    3897             :     Encoder_State *st,     /* i/o: encoder state structure                     */
    3898             :     const int16_t i_subfr, /* i  : subframe index                              */
    3899             :     const float *h1,       /* i  : weighted filter input response              */
    3900             :     const float *xn,       /* i  : target vector                               */
    3901             :     float *exc,            /* o  : pointer to excitation signal frame          */
    3902             :     float *mem_w0,         /* o  : weighting filter denominator memory         */
    3903             :     float *gp_clip_mem,    /* o  : memory of gain of pitch clipping algorithm  */
    3904             :     float *tilt_code,      /* o  : synthesis excitation spectrum tilt          */
    3905             :     float *code,           /* o  : algebraic excitation                        */
    3906             :     float *gain_code,      /* o  : Code gain.                                  */
    3907             :     float *y2,             /* o  : zero-memory filtered adaptive excitation    */
    3908             :     float *gain_inov,      /* o  : innovation gain                             */
    3909             :     float *voice_fac,      /* o  : voicing factor                              */
    3910             :     float *gain_pit,       /* o  : adaptive excitation gain                    */
    3911             :     float *norm_gain_code  /* o  : normalized innovative cb. gain              */
    3912             : );
    3913             : 
    3914             : void td_cng_enc_init(
    3915             :     TD_CNG_ENC_HANDLE hTdCngEnc, /* i/o: DTX/TD CNG data handle                      */
    3916             :     const int16_t Opt_DTX_ON,    /* i  : flag indicating DTX operation               */
    3917             :     const int16_t max_bwidth     /* i  : maximum encoded bandwidth                   */
    3918             : );
    3919             : 
    3920             : void dtx(
    3921             :     Encoder_State *st,                   /* i/o: encoder state structure                     */
    3922             :     const int32_t last_ivas_total_brate, /* i  : last IVAS total bitrate                */
    3923             :     const int32_t ivas_total_brate,      /* i  : IVAS total bitrate                          */
    3924             :     const int16_t vad,                   /* i  : VAD flag for DTX                            */
    3925             :     const float speech[]                 /* i  : Pointer to the speech frame                 */
    3926             : );
    3927             : 
    3928             : void dtx_hangover_control(
    3929             :     Encoder_State *st,     /* i/o: encoder state structure                     */
    3930             :     const float lsp_new[M] /* i  : current frame LSPs                          */
    3931             : );
    3932             : 
    3933             : void updt_enc(
    3934             :     Encoder_State *st,       /* i/o: state structure                             */
    3935             :     const float *old_exc,    /* i  : buffer of excitation                        */
    3936             :     const float *pitch_buf,  /* i  : Floating pitch   for each subframe          */
    3937             :     const float Es_pred,     /* i  : predicited scaled innovation energy         */
    3938             :     const float *Aq,         /* i  : A(z) quantized for all subframes            */
    3939             :     const float *lsf_new,    /* i  : current frame LSF vector                    */
    3940             :     const float *lsp_new,    /* i  : current frame LSP vector                    */
    3941             :     const float *old_bwe_exc /* o  : buffer of excitation for SWB TBE            */
    3942             : );
    3943             : 
    3944             : void updt_enc_common(
    3945             :     Encoder_State *st /* i/o: encoder state structure                     */
    3946             : );
    3947             : 
    3948             : void updt_IO_switch_enc(
    3949             :     Encoder_State *st,        /* i/o: state structure                             */
    3950             :     const int16_t input_frame /* i  : input frame length                          */
    3951             : );
    3952             : 
    3953             : void transition_enc(
    3954             :     Encoder_State *st,     /* i/o: encoder state structure                     */
    3955             :     const int16_t i_subfr, /* i  : subframe index                              */
    3956             :     int16_t *tc_subfr,     /* i/o: TC subframe index                           */
    3957             :     int16_t *Jopt_flag,    /* i  : joint optimization flag                     */
    3958             :     int16_t *position,     /* i/o: maximum of residual signal index            */
    3959             :     int16_t *T0,           /* i/o: close loop integer pitch                    */
    3960             :     int16_t *T0_frac,      /* i/o: close loop fractional part of the pitch     */
    3961             :     int16_t *T0_min,       /* i/o: lower limit for close-loop search           */
    3962             :     int16_t *T0_max,       /* i/o: higher limit for close-loop search          */
    3963             :     float *exc,            /* i/o: pointer to excitation signal frame          */
    3964             :     float *y1,             /* o  : zero-memory filtered adaptive excitation    */
    3965             :     const float *h1,       /* i  : weighted filter input response              */
    3966             :     const float *xn,       /* i  : target vector                               */
    3967             :     float *xn2,            /* o  : target vector for innovation search         */
    3968             :     float *gp_cl,          /* i/o: memory of gain of pitch clipping algorithm  */
    3969             :     float *gain_pit,       /* o  : adaptive excitation gain                    */
    3970             :     float *g_corr,         /* o  : ACELP correlation values                    */
    3971             :     int16_t *clip_gain,    /* i/o: adaptive gain clipping flag                 */
    3972             :     float **pt_pitch,      /* o  : floating pitch values                       */
    3973             :     float *bwe_exc,        /* i/o: excitation for SWB TBE                      */
    3974             :     int16_t *unbits        /* i/o: unused bits                                 */
    3975             : );
    3976             : 
    3977             : void tc_classif_enc(
    3978             :     const int16_t L_frame,     /* i  : length of the frame                           */
    3979             :     int16_t *tc_subfr,         /* i/o: TC subframe index                             */
    3980             :     int16_t *position,         /* i/o: maximum of residual signal index              */
    3981             :     const int16_t attack_flag, /* i  : attack flag                                   */
    3982             :     const int16_t pitch,       /* i  : open loop pitch estimates for first halfframe */
    3983             :     const float *res           /* i  : pointer to the LP residual signal frame       */
    3984             : );
    3985             : 
    3986             : void set_impulse(
    3987             :     const float xn[],     /* i  : target signal                                   */
    3988             :     const float h_orig[], /* i  : impulse response of weighted synthesis filter   */
    3989             :     float exc[],          /* o  : adaptive codebook excitation                    */
    3990             :     float y1[],           /* o  : filtered adaptive codebook excitation           */
    3991             :     int16_t *imp_shape,   /* o  : adaptive codebook index                         */
    3992             :     int16_t *imp_pos,     /* o  : position of the glottal impulse center index    */
    3993             :     float *gain_trans     /* o  : transition gain                                 */
    3994             : );
    3995             : 
    3996             : void gain_enc_tc(
    3997             :     BSTR_ENC_HANDLE hBstr,      /* i/o: encoder bitstream handle                                */
    3998             :     const int16_t gains_mode[], /* i  : gain bits                                               */
    3999             :     const int16_t i_subfr,      /* i  : subframe index                                          */
    4000             :     const float xn[],           /* i  : target vector                                           */
    4001             :     const float y2[],           /* i  : zero-memory filtered algebraic codebook excitation      */
    4002             :     const float code[],         /* i  : algebraic excitation                                    */
    4003             :     const float Es_pred,        /* i  : predicted scaled innovation energy                      */
    4004             :     float *gain_pit,            /* o  : pitch gain / Quantized pitch gain                       */
    4005             :     float *gain_code,           /* o  : quantized codebook gain                                 */
    4006             :     float *gain_inov,           /* o  : innovation gain                                         */
    4007             :     float *norm_gain_code       /* o  : norm. gain of the codebook excitation                   */
    4008             : );
    4009             : 
    4010             : /*! r: pitch gain  (0..GAIN_PIT_MAX) */
    4011             : float corr_xy1(
    4012             :     const float xn[],       /* i  : target signal                               */
    4013             :     const float y1[],       /* i  : filtered adaptive codebook excitation       */
    4014             :     float g_corr[],         /* o  : correlations <y1,y1>  and -2<xn,y1>         */
    4015             :     const int16_t L_subfr,  /* i  : subframe length                             */
    4016             :     const int16_t norm_flag /* i  : flag for constraining pitch contribution    */
    4017             : );
    4018             : 
    4019             : void norm_corr(
    4020             :     const float exc[],    /* i  : excitation buffer                          */
    4021             :     const float xn[],     /* i  : target signal                              */
    4022             :     const float h[],      /* i  : weighted synthesis filter impulse response */
    4023             :     const int16_t t_min,  /* i  : minimum value of searched range            */
    4024             :     const int16_t t_max,  /* i  : maximum value of searched range            */
    4025             :     float corr_norm[],    /* o  : normalized correlation                     */
    4026             :     const int16_t L_subfr /* i  : subframe size                              */
    4027             : );
    4028             : 
    4029             : /*! r: chosen integer pitch lag */
    4030             : int16_t pitch_fr4(
    4031             :     const float exc[],        /* i  : excitation buffer                          */
    4032             :     const float xn[],         /* i  : target signal                              */
    4033             :     const float h[],          /* i  : weighted synthesis filter impulse response */
    4034             :     const int16_t t0_min,     /* i  : minimum value in the searched range.       */
    4035             :     const int16_t t0_max,     /* i  : maximum value in the searched range.       */
    4036             :     int16_t *pit_frac,        /* o  : chosen fraction (0, 1, 2 or 3)             */
    4037             :     const int16_t i_subfr,    /* i  : flag to first subframe                     */
    4038             :     const int16_t limit_flag, /* i  : flag for limits (0=restrained, 1=extended) */
    4039             :     const int16_t t0_fr2,     /* i  : minimum value for resolution 1/2           */
    4040             :     const int16_t t0_fr1,     /* i  : minimum value for resolution 1             */
    4041             :     const int16_t L_frame,    /* i  : length of the frame                        */
    4042             :     const int16_t L_subfr     /* i  : size of subframe                           */
    4043             : );
    4044             : 
    4045             : void pit_Q_enc(
    4046             :     BSTR_ENC_HANDLE hBstr,    /* i/o: encoder bitstream handle                */
    4047             :     const int16_t Opt_AMR_WB, /* i  : flag indicating AMR-WB IO mode          */
    4048             :     const int16_t nBits,      /* i  : # of Q bits                             */
    4049             :     const int16_t delta,      /* i  : Half the CL searched interval           */
    4050             :     const int16_t pit_flag,   /* i  : absolute(0) or delta(1) pitch Q         */
    4051             :     const int16_t limit_flag, /* i  : restrained(0) or extended(1) Q limits   */
    4052             :     const int16_t T0,         /* i  : integer pitch lag                       */
    4053             :     const int16_t T0_frac,    /* i  : pitch fraction                          */
    4054             :     int16_t *T0_min,          /* i/o: delta search min                        */
    4055             :     int16_t *T0_max           /* o  : delta search max                        */
    4056             : );
    4057             : 
    4058             : void pit16k_Q_enc(
    4059             :     BSTR_ENC_HANDLE hBstr,    /* i/o: encoder bitstream handle                */
    4060             :     const int16_t nBits,      /* i  : # of Q bits                             */
    4061             :     const int16_t limit_flag, /* i  : restrained(0) or extended(1) Q limits   */
    4062             :     const int16_t T0,         /* i  : integer pitch lag                       */
    4063             :     const int16_t T0_frac,    /* i  : pitch fraction                          */
    4064             :     int16_t *T0_min,          /* i/o: delta search min                        */
    4065             :     int16_t *T0_max           /* o  : delta search max                        */
    4066             : );
    4067             : 
    4068             : /*! r: pitch index */
    4069             : int16_t abs_pit_enc(
    4070             :     const int16_t fr_steps,   /* i  : fractional resolution step              */
    4071             :     const int16_t limit_flag, /* i  : restrained(0) or extended(1) limits     */
    4072             :     const int16_t T0,         /* i  : integer pitch lag                       */
    4073             :     const int16_t T0_frac     /* i  : pitch fraction                          */
    4074             : );
    4075             : 
    4076             : /*! r: pitch index */
    4077             : int16_t delta_pit_enc(
    4078             :     const int16_t fr_steps, /* i  : fractional resolution steps (2 or 4)    */
    4079             :     const int16_t T0,       /* i  : integer pitch lag                       */
    4080             :     const int16_t T0_frac,  /* i  : pitch fraction                          */
    4081             :     const int16_t T0_min    /* i  : delta search min                        */
    4082             : );
    4083             : 
    4084             : /*! r: comfort noise gain factor */
    4085             : float AVQ_cod(
    4086             :     const float xri[],     /* i  : vector to quantize                      */
    4087             :     int16_t xriq[],        /* o  : quantized normalized vector (assuming the bit budget is enough) */
    4088             :     const int16_t nb_bits, /* i  : number of allocated bits                */
    4089             :     const int16_t Nsv      /* i  : number of subvectors (lg=Nsv*8)         */
    4090             : );
    4091             : 
    4092             : void AVQ_encmux(
    4093             :     BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle                        */
    4094             :     const int16_t extl,    /* i  : extension layer                                 */
    4095             :     int16_t xriq[],        /* i/o: rounded subvectors [0..8*Nsv-1] followed by rounded bit allocations [8*Nsv..8*Nsv+Nsv-1] */
    4096             :     int16_t *nb_bits,      /* i/o: number of allocated bits                        */
    4097             :     const int16_t Nsv,     /* i  : number of subvectors                            */
    4098             :     int16_t nq[],          /* o  : AVQ nq index                                    */
    4099             :     int16_t avq_bit_sFlag, /* i  : flag indicating AVQ bit savings                 */
    4100             :     int16_t trgtSvPos      /* i  : target SV for AVQ bit savings                   */
    4101             : );
    4102             : 
    4103             : void ordr_esti(
    4104             :     const int16_t k,   /* i  : sub-vector index                         */
    4105             :     int16_t *Mpos,     /* i/o: dominant sub-vector position from ACV    */
    4106             :     int16_t svOrder[], /* i/o: AVQ sub-vector order                     */
    4107             :     const int16_t Nsv  /* i  : total sub-vectors in a sub-frames        */
    4108             : );
    4109             : 
    4110             : void re8_cod(
    4111             :     int16_t x[], /* i  : point in RE8 (8-dimensional integer vector)                         */
    4112             :     int16_t *n,  /* i  : codebook number (*n is an integer defined in {0,2,3,4,..,n_max})    */
    4113             :     uint16_t *I, /* o  : index of c (pointer to unsigned 16-bit word)                        */
    4114             :     int16_t k[]  /* o  : index of v (8-dimensional vector of binary indices) = Voronoi index */
    4115             : );
    4116             : 
    4117             : void pre_exc(
    4118             :     const int16_t Opt_AMR_WB, /* i  : flag indicating AMR-WB IO mode                       */
    4119             :     const int16_t L_frame,    /* i  : frame length                                         */
    4120             :     const float *speech,      /* i  : input speech                                         */
    4121             :     const float *p_Aq,        /* i  : 12k8 Lp coefficient                                  */
    4122             :     const float *p_A,         /* i  : unquantized A(q) filter with bandwidth expansion     */
    4123             :     const int16_t coder_type, /* i  : coding type                                          */
    4124             :     const int16_t i_subfr,    /* i  : current sub frame indicator                          */
    4125             :     float *Ap,                /* o  : weighted LP filter coefficients                      */
    4126             :     const float *res,         /* i  : residual signal                                      */
    4127             :     float *h1,                /* o  : impulse response of weighted synthesis filter        */
    4128             :     float *xn,                /* o  : close-loop Pitch search target vector                */
    4129             :     float *cn,                /* o  : target vector in residual domain                     */
    4130             :     float *mem_syn,           /* i/o: memory of the synthesis filter                       */
    4131             :     float *mem_w0,            /* i/o: weighting filter denominator memory                  */
    4132             :     const int16_t L_subfr     /* i  : subframe length                                      */
    4133             : );
    4134             : 
    4135             : void encod_unvoiced(
    4136             :     Encoder_State *st,               /* i/o: state structure                                 */
    4137             :     const float *speech,             /* i  : input speech                                    */
    4138             :     const float Aw[],                /* i  : weighted A(z) unquantized for subframes         */
    4139             :     const float *Aq,                 /* i  : LP coefficients                                 */
    4140             :     const float Es_pred,             /* i  : predicted scaled innov. energy                  */
    4141             :     const int16_t uc_two_stage_flag, /* i  : flag indicating two-stage UC                    */
    4142             :     const float *res,                /* i  : residual signal                                 */
    4143             :     float *syn,                      /* o  : core synthesis                                  */
    4144             :     float *tmp_noise,                /* o  : long-term noise energy                          */
    4145             :     float *exc,                      /* i/o: current non-enhanced excitation                 */
    4146             :     float *pitch_buf,                /* o  : floating pitch values for each subframe         */
    4147             :     float *voice_factors,            /* o  : voicing factors                                 */
    4148             :     float *bwe_exc                   /* i/o: excitation for SWB TBE                          */
    4149             : );
    4150             : 
    4151             : void encod_gen_voic(
    4152             :     Encoder_State *st,                  /* i/o: state structure                                 */
    4153             :     const float speech[],               /* i  : input speech                                    */
    4154             :     const float Aw[],                   /* i  : weighted A(z) unquantized for subframes         */
    4155             :     const float Aq[],                   /* i  : LP coefficients                                 */
    4156             :     const float Es_pred,                /* i  : predicted scaled innov. energy                  */
    4157             :     const float *res,                   /* i  : residual signal                                 */
    4158             :     float *syn,                         /* o  : core synthesis                                  */
    4159             :     float *exc,                         /* i/o: current non-enhanced excitation                 */
    4160             :     float *exc2,                        /* i/o: current enhanced excitation                     */
    4161             :     float *pitch_buf,                   /* o  : floating pitch values for each subframe         */
    4162             :     float *voice_factors,               /* o  : voicing factors                                 */
    4163             :     float *bwe_exc,                     /* i/o: excitation for SWB TBE                          */
    4164             :     int16_t *unbits,                    /* i/o: number of unused bits                           */
    4165             :     const int16_t tdm_Pitch_reuse_flag, /* i  : primary channel pitch reuse flag                */
    4166             :     const float tdm_Pri_pitch_buf[]     /* i  : primary channel pitch buffer                    */
    4167             : );
    4168             : 
    4169             : int16_t encod_tran(
    4170             :     Encoder_State *st,    /* i/o: state structure                                 */
    4171             :     const float speech[], /* i  : input speech                                    */
    4172             :     const float Aw[],     /* i  : weighted A(z) unquantized for subframes         */
    4173             :     const float Aq[],     /* i  : LP coefficients                                 */
    4174             :     const float Es_pred,  /* i  : predicted scaled innov. energy                  */
    4175             :     const float *res,     /* i  : residual signal                                 */
    4176             :     float *syn,           /* o  : synthesis                                       */
    4177             :     float *exc,           /* i/o: current non-enhanced excitation                 */
    4178             :     float *exc2,          /* i/o: current enhanced excitation                     */
    4179             :     float *pitch_buf,     /* o  : floating pitch values for each subframe         */
    4180             :     float *voice_factors, /* o  : voicing factors                                 */
    4181             :     float *bwe_exc,       /* i/o: excitation for SWB TBE                          */
    4182             :     int16_t tc_subfr,     /* i/o: TC subframe classification                      */
    4183             :     int16_t position,     /* i  : maximum of residual signal index                */
    4184             :     int16_t *unbits       /* i/o: number of unused bits                           */
    4185             : );
    4186             : 
    4187             : void encod_amr_wb(
    4188             :     Encoder_State *st,         /* i/o: state structure                                 */
    4189             :     const float speech[],      /* i  : input speech                                    */
    4190             :     const float Aw[],          /* i  : weighted A(z) unquantized for subframes         */
    4191             :     const float Aq[],          /* i  : 12k8 Lp coefficient                             */
    4192             :     const float *res,          /* i  : residual signal                                 */
    4193             :     float *syn,                /* i/o: core synthesis                                  */
    4194             :     float *exc,                /* i/o: current non-enhanced excitation                 */
    4195             :     float *exc2,               /* i/o: current enhanced excitation                     */
    4196             :     float *pitch_buf,          /* i/o: floating pitch values for each subframe         */
    4197             :     int16_t hf_gain[NB_SUBFR], /* o  : decoded HF gain                                 */
    4198             :     const float *speech16k     /* i  : input speech @16kHz                             */
    4199             : );
    4200             : 
    4201             : void stat_noise_uv_enc(
    4202             :     Encoder_State *st,              /* i/o: state structure                      */
    4203             :     const float *epsP,              /* i  : LP prediction errors                 */
    4204             :     const float *isp_new,           /* i  : immittance spectral pairs at 4th sfr */
    4205             :     const float *isp_mid,           /* i  : immittance spectral pairs at 2nd sfr */
    4206             :     float *Aq,                      /* i/o: A(z) quantized for the 4 subframes   */
    4207             :     float *exc2,                    /* i/o: excitation buffer                    */
    4208             :     const int16_t uc_two_stage_flag /* o  : flag undicating two-stage UC         */
    4209             : );
    4210             : 
    4211             : void re8_compute_base_index(
    4212             :     const int16_t *x, /* i  : Elemen of Q2, Q3 or Q4                          */
    4213             :     const int16_t ka, /* i  : Identifier of the absolute leader related to x  */
    4214             :     uint16_t *I       /* o  : index                                           */
    4215             : );
    4216             : 
    4217             : void transf_cdbk_enc(
    4218             :     Encoder_State *st,             /* i/o: encoder state structure                     */
    4219             :     const int16_t harm_flag_acelp, /* i  : harmonic flag for higher rates ACELP        */
    4220             :     const int16_t i_subfr,         /* i  : subframe index                              */
    4221             :     float cn[],                    /* i/o: target vector in residual domain            */
    4222             :     float exc[],                   /* i/o: pointer to excitation signal frame          */
    4223             :     const float *p_Aq,             /* i  : 12k8 Lp coefficient                         */
    4224             :     const float Ap[],              /* i  : weighted LP filter coefficients             */
    4225             :     const float h1[],              /* i  : weighted filter input response              */
    4226             :     float xn[],                    /* i/o: target vector                               */
    4227             :     float xn2[],                   /* i/o: target vector for innovation search         */
    4228             :     float y1[],                    /* i/o: zero-memory filtered adaptive excitation    */
    4229             :     const float y2[],              /* i  : zero-memory filtered innovative excitation  */
    4230             :     const float Es_pred,           /* i  : predicited scaled innovation energy         */
    4231             :     float *gain_pit,               /* i/o: adaptive excitation gain                    */
    4232             :     const float gain_code,         /* i  : innovative excitation gain                  */
    4233             :     float g_corr[],                /* o  : ACELP correlation values                    */
    4234             :     const int16_t clip_gain,       /* i  : adaptive gain clipping flag                 */
    4235             :     float *gain_preQ,              /* o  : prequantizer excitation gain                */
    4236             :     float code_preQ[],             /* o  : prequantizer excitation                     */
    4237             :     int16_t *unbits                /* i/o: number of AVQ unused bits                   */
    4238             : );
    4239             : 
    4240             : /*! r: quantization index */
    4241             : int16_t gain_quant(
    4242             :     float *gain,         /* i/o: quantized gain                              */
    4243             :     const float min_val, /* i  : value of lower limit                        */
    4244             :     const float max_val, /* i  : value of upper limit                        */
    4245             :     const int16_t bits   /* i  : number of bits to quantize                  */
    4246             : );
    4247             : 
    4248             : void deemph_lpc(
    4249             :     float *p_Aq_cuerr,  /* i  : LP coefficients current frame               */
    4250             :     float *p_Aq_old,    /* i  : LP coefficients previous frame              */
    4251             :     float *LPC_de_curr, /* o  : De-emphasized LP coefficients current frame */
    4252             :     float *LPC_de_old,  /* o  : De-emphasized LP coefficients previous frame*/
    4253             :     const int16_t deemph_old );
    4254             : 
    4255             : void Interpol_delay(
    4256             :     float *out,       /* o  : pitch interpolation output                  */
    4257             :     float *last,      /* i  : last frame pitch lag                        */
    4258             :     float *current,   /* i  : current frame pitch lag                     */
    4259             :     int16_t SubNum,   /* i  : subframe number                             */
    4260             :     const float *frac /* i  : interpolation constant                      */
    4261             : );
    4262             : 
    4263             : void dequantize_uvg(
    4264             :     int16_t iG1,         /* i  : gain 1 index                                */
    4265             :     int16_t *iG2,        /* i  : gain 2 index                                */
    4266             :     float *G,            /* o  : quantized gain                              */
    4267             :     const int16_t bwidth /* i  : audio bandwidth                             */
    4268             : );
    4269             : 
    4270             : void generate_nelp_excitation(
    4271             :     int16_t *seed, /* i/o: random number seed                          */
    4272             :     float *Gains,  /* i  : excitation gains                            */
    4273             :     float *output, /* o  : excitation output                           */
    4274             :     float gain_fac /* i  : gain factor                                 */
    4275             : );
    4276             : 
    4277             : void nelp_encoder(
    4278             :     Encoder_State *st, /* i/o: encoder state                               */
    4279             :     float *in,         /* i  : residual signal                             */
    4280             :     float *exc,        /* o  : NELP quantized excitation signal            */
    4281             :     const int16_t reduce_gains );
    4282             : 
    4283             : void encod_nelp(
    4284             :     Encoder_State *st,    /* i/o: state structure                             */
    4285             :     const float *speech,  /* i  : input speech                                */
    4286             :     const float Aw[],     /* i  : weighted A(z) unquantized for subframes     */
    4287             :     const float *Aq,      /* i  : 12k8 Lp coefficient                         */
    4288             :     float *res,           /* o  : residual signal                             */
    4289             :     float *synth,         /* o  : core synthesis                              */
    4290             :     float *tmp_noise,     /* o  : long-term noise energy                      */
    4291             :     float *exc,           /* i/o: current non-enhanced excitation             */
    4292             :     float *exc2,          /* i/o: current enhanced excitation                 */
    4293             :     float *pitch_buf,     /* o  : floating pitch values for each subframe     */
    4294             :     float *voice_factors, /* o  : voicing factors                             */
    4295             :     float *bwe_exc        /* o  : excitation for SWB TBE                      */
    4296             : );
    4297             : 
    4298             : void realft(
    4299             :     float *data,  /* i/o: data array                                  */
    4300             :     int16_t n,    /* i  : length of data array                        */
    4301             :     int16_t isign /* i  : sign +1 or -1                               */
    4302             : );
    4303             : 
    4304             : ivas_error DTFS_new(
    4305             :     DTFS_STRUCTURE **dtfs_out );
    4306             : 
    4307             : void DTFS_copy(
    4308             :     DTFS_STRUCTURE *Xout, /* o  : DTFS                                        */
    4309             :     DTFS_STRUCTURE Xinp   /* i  : DTFS                                        */
    4310             : );
    4311             : 
    4312             : void DTFS_sub(
    4313             :     DTFS_STRUCTURE *tmp, /* o  : output DFTS                                 */
    4314             :     DTFS_STRUCTURE X1,   /* i  : DTFS input 1                                */
    4315             :     DTFS_STRUCTURE X2    /* i  : DTFS input 2                                */
    4316             : );
    4317             : 
    4318             : void DTFS_to_fs(
    4319             :     const float *x,    /* i  : Time domain signal                          */
    4320             :     const int16_t N,   /* i  : Length of input vector                      */
    4321             :     DTFS_STRUCTURE *X, /* o  : DTFS structure with a, b, lag               */
    4322             :     const int32_t sampling_rate,
    4323             :     const int16_t FR_flag /* i  : FR flag                                     */
    4324             : );
    4325             : 
    4326             : void DTFS_fs_inv(
    4327             :     DTFS_STRUCTURE *X, /* i  : DTFS                                         */
    4328             :     float *x,          /* o  : time domain sig                              */
    4329             :     const int16_t N,   /* i  : Output length                                */
    4330             :     float ph0          /* i  : Input phase                                  */
    4331             : );
    4332             : 
    4333             : void DTFS_car2pol(
    4334             :     DTFS_STRUCTURE *X /* i/o: DTFS structure a, b, lag                    */
    4335             :                       /* input in Cartesion, output in Polar              */
    4336             : );
    4337             : 
    4338             : void DTFS_pol2car(
    4339             :     DTFS_STRUCTURE *X /* i/o: DTFS structure a, b, lag                   */
    4340             :                       /* input in Polar, output in Cartesian             */
    4341             : );
    4342             : 
    4343             : /*! r: Return Input RMS between f1/f2 b4 scaling */
    4344             : float DTFS_setEngyHarm(
    4345             :     float f1,         /* i  : lower band freq of input to control energy  */
    4346             :     float f2,         /* i  : upper band freq of input to control energy  */
    4347             :     float g1,         /* i  : lower band freq of output to control energy */
    4348             :     float g2,         /* i  : upper band freq of output to control energy */
    4349             :     float en2,        /* i  : Target Energy to set the DTFS to            */
    4350             :     DTFS_STRUCTURE *X /* i/o: DTFS to adjust the energy of                */
    4351             : );
    4352             : 
    4353             : void DTFS_to_erb(
    4354             :     DTFS_STRUCTURE X, /* i  : DTFS input                             */
    4355             :     float *out        /* o  : ERB output                             */
    4356             : );
    4357             : 
    4358             : void DTFS_zeroPadd(
    4359             :     const int16_t N,  /* i  : Target lag                            */
    4360             :     DTFS_STRUCTURE *X /* i/o: DTFS                                  */
    4361             : );
    4362             : 
    4363             : /*! r: Energy */
    4364             : float DTFS_getEngy(
    4365             :     DTFS_STRUCTURE X /* i  : DTFS to compute energy of              */
    4366             : );
    4367             : 
    4368             : void DTFS_adjustLag(
    4369             :     DTFS_STRUCTURE *X_DTFS, /* i/o: DTFS to adjust lag for                */
    4370             :     const int16_t N         /* i  : Target lag                            */
    4371             : );
    4372             : 
    4373             : void DTFS_poleFilter(
    4374             :     DTFS_STRUCTURE *X, /* i/o: DTFS to poleFilter inplace            */
    4375             :     const float *LPC,  /* i  : LPCs                                  */
    4376             :     const int16_t N    /* i  : LPCORDER                              */
    4377             : );
    4378             : 
    4379             : void DTFS_zeroFilter(
    4380             :     DTFS_STRUCTURE *X, /* i/o: DTFS to zeroFilter inplace            */
    4381             :     const float *LPC,  /* i  : LPCs                                  */
    4382             :     const int16_t N    /* i  : LPCORDER                              */
    4383             : );
    4384             : 
    4385             : float DTFS_alignment_full(
    4386             :     DTFS_STRUCTURE X1_DTFS, /* i  : reference DTFS                         */
    4387             :     DTFS_STRUCTURE X2_DTFS, /* i  : DTFS to shift                          */
    4388             :     const int16_t num_steps /* i  : resolution                             */
    4389             : );
    4390             : 
    4391             : void DTFS_phaseShift(
    4392             :     DTFS_STRUCTURE *X, /* i  : DTFS to shift                          */
    4393             :     float ph           /* i  : phase to shift                         */
    4394             : );
    4395             : 
    4396             : void erb_add(
    4397             :     float *curr_erb,       /* i/o:  current ERB                          */
    4398             :     const int16_t l,       /* i  :  current lag                          */
    4399             :     const float *prev_erb, /* i  :  previous ERB                         */
    4400             :     const int16_t pl,      /* i  :  previous lag                         */
    4401             :     const int16_t *index,  /* i  :  ERB index                            */
    4402             :     const int16_t num_erb  /* i  :  number of ERBs                       */
    4403             : );
    4404             : 
    4405             : void erb_slot(
    4406             :     int16_t lag,    /* i  : input lag                             */
    4407             :     int16_t *out,   /* o  : ERB slots                             */
    4408             :     float *mfreq,   /* i  : ERB frequencies                       */
    4409             :     int16_t num_erb /* i  : number of ERBs                        */
    4410             : );
    4411             : 
    4412             : void erb_diff(
    4413             :     const float *prev_erb, /* i  : previous ERB                          */
    4414             :     const int16_t pl,      /* i  : previous lag                          */
    4415             :     const float *curr_erb, /* i  : current ERB                           */
    4416             :     const int16_t l,       /* i  : current lag                           */
    4417             :     const float *curr_lsp, /* i  : current LSP coefficients              */
    4418             :     float *out,            /* o  : ERB difference                        */
    4419             :     int16_t *index,        /* i  : ERB index                             */
    4420             :     const int16_t num_erb  /* i  : Number of ERBs                        */
    4421             : );
    4422             : 
    4423             : void DTFS_erb_inv(
    4424             :     float *in,            /* i  : ERB inpt                               */
    4425             :     int16_t *slot,        /* i  : ERB slots filled based on lag          */
    4426             :     float *mfreq,         /* i  : erb frequence edges                    */
    4427             :     DTFS_STRUCTURE *X,    /* o  : DTFS after erb-inv                     */
    4428             :     const int16_t num_erb /* i  : Number of ERB bands                    */
    4429             : );
    4430             : 
    4431             : ivas_error ppp_quarter_encoder(
    4432             :     int16_t *returnFlag,       /* o  : return value                            */
    4433             :     BSTR_ENC_HANDLE hBstr,     /* i/o: encoder bitstream handle                 */
    4434             :     DTFS_STRUCTURE *CURRCW_Q,  /* o  : Quantized (amp/phase) DTFS               */
    4435             :     DTFS_STRUCTURE *TARGETCW,  /* o  : DTFS with quant phase but unquant Amp    */
    4436             :     const int16_t prevCW_lag,  /* i  : previous lag                             */
    4437             :     DTFS_STRUCTURE vCURRCW_NQ, /* i  : Unquantized DTFS                         */
    4438             :     const float *curr_lpc,     /* i  : LPCS                                     */
    4439             :     float *lastLgainE,         /* i/o: last low band gain                       */
    4440             :     float *lastHgainE,         /* i/o: last high band gain                      */
    4441             :     float *lasterbE,           /* i/o: last ERB vector                          */
    4442             :     DTFS_STRUCTURE PREV_CW_E   /* i  : past DTFS                                */
    4443             : );
    4444             : 
    4445             : ivas_error WIsyn(
    4446             :     DTFS_STRUCTURE PREVCW,        /* i  : Prev frame DTFS                          */
    4447             :     DTFS_STRUCTURE *CURR_CW_DTFS, /* i/o: Curr frame DTFS                          */
    4448             :     const float *curr_lpc,        /* i  : LPC                                      */
    4449             :     float *ph_offset,             /* i/o: Phase offset to line up at end of frame  */
    4450             :     float *out,                   /* o  : Waveform Interpolated time domain signal */
    4451             :     const int16_t N,              /* i  : Number of samples of output to generate  */
    4452             :     const int16_t FR_flag         /* i  : called for post-smoothing in FR          */
    4453             : );
    4454             : 
    4455             : void set_ppp_mode(
    4456             :     Encoder_State *st,             /* i/o: encoder state structure                 */
    4457             :     const int16_t noisy_speech_HO, /* i  : SC-VBR noisy speech HO flag             */
    4458             :     const int16_t clean_speech_HO, /* i  : SC-VBR clean speech HO flag             */
    4459             :     const int16_t NB_speech_HO,    /* i  : SC-VBR NB speech HO flag                */
    4460             :     const int16_t localVAD_he      /* i  : HE-SAD flag without hangover            */
    4461             : );
    4462             : 
    4463             : void lsf_syn_mem_backup(
    4464             :     Encoder_State *st,          /* i  : state structure                                       */
    4465             :     float *btilt_code,          /* i  : tilt code                                             */
    4466             :     float *bgc_threshold,       /* i  :                                                       */
    4467             :     float *clip_var_bck,        /* o  :                                                       */
    4468             :     int16_t *next_force_sf_bck, /* o  :                                                       */
    4469             :     float *lsp_new,             /* i  : LSP vector to quantize                                */
    4470             :     float *lsp_mid,             /* i  : mid-frame LSP vector                                  */
    4471             :     float *clip_var,            /* o  : pitch clipping state var                              */
    4472             :     float *mem_AR,              /* o  : quantizer memory for AR model                         */
    4473             :     float *mem_MA,              /* o  : quantizer memory for AR model                         */
    4474             :     float *lsp_new_bck,         /* o  : LSP vector to quantize- backup                        */
    4475             :     float *lsp_mid_bck,         /* o  : mid-frame LSP vector - backup                         */
    4476             :     float *Bin_E,               /* o  : FFT Bin energy 128 *2 sets                            */
    4477             :     float *Bin_E_old,           /* o  : FFT Bin energy 128 sets                               */
    4478             :     float *mem_syn_bck,         /* o  : synthesis filter memory                               */
    4479             :     float *mem_w0_bck,          /* o  : memory of the weighting filter                        */
    4480             :     float *streaklimit,
    4481             :     int16_t *pstreaklen );
    4482             : 
    4483             : void lsf_syn_mem_restore(
    4484             :     Encoder_State *st,         /* o  : state structure                                        */
    4485             :     float btilt_code,          /* i  :                                                        */
    4486             :     float gc_threshold,        /* i  :                                                        */
    4487             :     float *clip_var_bck,       /* i  :                                                        */
    4488             :     int16_t next_force_sf_bck, /* i  :                                                        */
    4489             :     float *lsp_new,            /* o  : LSP vector to quantize                                 */
    4490             :     float *lsp_mid,            /* o  : mid-frame LSP vector                                   */
    4491             :     float clip_var,            /* i  : pitch clipping state var                               */
    4492             :     float *mem_AR,             /* i  : quantizer memory for AR model                          */
    4493             :     float *mem_MA,             /* i  : quantizer memory for AR model                          */
    4494             :     float *lsp_new_bck,        /* i  : LSP vector to quantize- backup                         */
    4495             :     float *lsp_mid_bck,        /* i  : mid-frame LSP vector - backup                          */
    4496             :     float *Bin_E,              /* i  : FFT Bin energy 128 *2 sets                             */
    4497             :     float *Bin_E_old,          /* i  : FFT Bin energy 128 sets                                */
    4498             :     float *mem_syn_bck,        /* i  : synthesis filter memory                                */
    4499             :     float mem_w0_bck,          /* i  : memory of the weighting filter                         */
    4500             :     const float streaklimit,
    4501             :     const int16_t pstreaklen );
    4502             : 
    4503             : ivas_error ppp_voiced_encoder(
    4504             :     BSTR_ENC_HANDLE hBstr,             /* i/o: encoder bitstream handle                    */
    4505             :     SC_VBR_ENC_HANDLE hSC_VBR,         /* i/o: SC-VBR state structure                      */
    4506             :     const int16_t bwidth,              /* i  : audio bandwidth                             */
    4507             :     const int16_t last_coder_type_raw, /* i  : raw last_coder_type                         */
    4508             :     const float old_pitch_buf[],       /* i  : buffer of old subframe pitch values         */
    4509             :     float *in,                         /* i  : residual signal                             */
    4510             :     float *out,                        /* o  : Quantized residual signal                   */
    4511             :     const int16_t delay,               /* i  : open loop pitch                             */
    4512             :     float *lpc1,                       /* i  : prev frame de-emphasized LPC                */
    4513             :     float *lpc2,                       /* i  : current frame de-emphasized LPC             */
    4514             :     float *exc,                        /* i  : previous frame quantized excitation         */
    4515             :     float *pitch                       /* o  : floating pitch values for each subframe     */
    4516             : );
    4517             : 
    4518             : ivas_error encod_ppp(
    4519             :     Encoder_State *st,    /* i/o: state structure                                 */
    4520             :     const float speech[], /* i  : input speech                                    */
    4521             :     const float Aw[],     /* i  : weighted A(z) unquantized for subframes         */
    4522             :     const float Aq[],     /* i  : 12k8 Lp coefficient                             */
    4523             :     float *res,           /* i/o: residual signal                                 */
    4524             :     float *synth,         /* i/o: core synthesis                                  */
    4525             :     float *exc,           /* i/o: current non-enhanced excitation                 */
    4526             :     float *exc2,          /* i/o: current enhanced excitation                     */
    4527             :     float *pitch_buf,     /* i/o: floating pitch values for each subframe         */
    4528             :     float *voice_factors, /* o  : voicing factors                                 */
    4529             :     float *bwe_exc        /* o  : excitation for SWB TBE                          */
    4530             : );
    4531             : 
    4532             : void reset_rf_indices(
    4533             :     RF_ENC_HANDLE hRF,     /* i/o: RF state structure                  */
    4534             :     const int16_t L_frame, /* i  : frame length                        */
    4535             :     int16_t *rf_target_bits_write );
    4536             : 
    4537             : void signaling_enc_rf(
    4538             :     Encoder_State *st /* i/o: encoder state structure             */
    4539             : );
    4540             : 
    4541             : ivas_error acelp_core_dec(
    4542             :     Decoder_State *st,                   /* i/o: Decoder state structure             */
    4543             :     float output[],                      /* o  : synthesis @internal Fs              */
    4544             :     float synth[],                       /* o  : synthesis                           */
    4545             :     float save_hb_synth[],               /* o  : HB synthesis                        */
    4546             :     float bwe_exc_extended[],            /* i/o: bandwidth extended excitation       */
    4547             :     float *voice_factors,                /* o  : voicing factors                     */
    4548             :     float old_syn_12k8_16k[],            /* o  : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE */
    4549             :     const int16_t sharpFlag,             /* i  : formant sharpening flag             */
    4550             :     float pitch_buf[NB_SUBFR16k],        /* o  : floating pitch for each subframe    */
    4551             :     int16_t *unbits,                     /* o  : number of unused bits               */
    4552             :     int16_t *sid_bw,                     /* o  : 0-NB/WB, 1-SWB SID                  */
    4553             :     STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle            */
    4554             :     const float tdm_lspQ_PCh[M],         /* i  : Q LSPs for primary channel          */
    4555             :     const float tdm_lsfQ_PCh[M],         /* i  : Q LSFs for primary channel          */
    4556             :     const int16_t use_cldfb_for_dft,     /* i  : flag to use of CLDFB for DFT Stereo */
    4557             :     const int16_t last_element_mode,     /* i  : last element mode                   */
    4558             :     const int32_t last_element_brate,    /* i  : last element bitrate                */
    4559             :     const int16_t flag_sec_CNA,          /* i  : CNA flag for secondary channel      */
    4560             :     const int16_t nchan_out,             /* i  : number of output channels           */
    4561             :     STEREO_CNG_DEC_HANDLE hStereoCng,    /* i  :  stereo CNG handle                  */
    4562             :     const int16_t read_sid_info          /* i  : read SID info flag                  */
    4563             : );
    4564             : 
    4565             : void bass_psfilter_init(
    4566             :     BPF_DEC_HANDLE hBPF /* o  : BPF data handle                     */
    4567             : );
    4568             : 
    4569             : void bass_psfilter(
    4570             :     BPF_DEC_HANDLE hBPF,      /* o  : BPF data handle                     */
    4571             :     const int16_t Opt_AMR_WB, /* i  : AMR-WB IO flag                      */
    4572             :     const float synth_in[],   /* i  : synthesis (at 16kHz)                */
    4573             :     const int16_t L_frame,    /* i  : length of the last frame            */
    4574             :     const float pitch_buf[],  /* i  : pitch for every subfr [0,1,2,3]     */
    4575             :     const int16_t bpf_off,    /* i  : do not use BPF when set to 1        */
    4576             :     float v_stab,             /* i  : stability factor                    */
    4577             :     float *v_stab_smooth,     /* i  : smoothed stability factor           */
    4578             :     const int16_t coder_type, /* i  : coder_type                          */
    4579             :     float bpf_noise_buf[]     /* o  : BPF error signal (at int_fs)        */
    4580             : );
    4581             : 
    4582             : void CNG_reset_dec(
    4583             :     Decoder_State *st,   /* i/o: decoder state structure            */
    4584             :     float *pitch_buf,    /* o  : floating pitch for each subframe   */
    4585             :     float *voice_factors /* o  : voicing factors                    */
    4586             : );
    4587             : 
    4588             : void updt_dec(
    4589             :     Decoder_State *st,           /* i/o: state structure                         */
    4590             :     const float *old_exc,        /* i  : buffer of excitation                    */
    4591             :     const float *pitch_buf,      /* i  : floating pitch values for each subframe */
    4592             :     const float Es_pred,         /* i  : predicited scaled innovation energy     */
    4593             :     const float *Aq,             /* i  : A(z) quantized for all subframes        */
    4594             :     const float *lsf_new,        /* i  : current frame LSF vector                */
    4595             :     const float *lsp_new,        /* i  : current frame LSP vector                */
    4596             :     const float voice_factors[], /* i  : voicing factors                         */
    4597             :     const float *old_bwe_exc,    /* i  : buffer of excitation                    */
    4598             :     const float *gain_buf        /* o  : floating pitch gain for each subframe   */
    4599             : );
    4600             : 
    4601             : void updt_IO_switch_dec(
    4602             :     const int16_t output_frame, /* i  : output frame length                     */
    4603             :     Decoder_State *st           /* i/o: state structure                         */
    4604             : );
    4605             : 
    4606             : void updt_dec_common(
    4607             :     Decoder_State *st,                  /* i/o: decoder state structure     */
    4608             :     const int16_t hq_core_type,         /* i  : HQ core type                */
    4609             :     const int16_t concealWholeFrameTmp, /* i  : concealWholeFrameTmp flag   */
    4610             :     const float *synth                  /* i  : decoded synthesis           */
    4611             : );
    4612             : 
    4613             : void td_cng_dec_init(
    4614             :     DEC_CORE_HANDLE st /* i/o: decoder state structure     */
    4615             : );
    4616             : 
    4617             : void CNG_dec(
    4618             :     Decoder_State *st,               /* i/o: State structure                         */
    4619             :     const int16_t last_element_mode, /* i  : last element mode                       */
    4620             :     float Aq[],                      /* o  : LP coefficients                         */
    4621             :     float *lsp_new,                  /* i/o: current frame LSPs                      */
    4622             :     float *lsf_new,                  /* i/o: current frame LSFs                      */
    4623             :     int16_t *allow_cn_step,          /* o  : allow cn step                           */
    4624             :     int16_t *sid_bw,                 /* o  : 0-NB/WB, 1-SWB SID                      */
    4625             :     float *q_env );
    4626             : 
    4627             : void swb_CNG_dec(
    4628             :     Decoder_State *st,   /* i/o: State structure                         */
    4629             :     const float *synth,  /* i  : ACELP core synthesis at 32kHz           */
    4630             :     float *shb_synth,    /* o  : high-band CNG synthesis                 */
    4631             :     const int16_t sid_bw /* i  : 0-NB/WB, 1-SWB SID                      */
    4632             : );
    4633             : 
    4634             : void lsf_dec(
    4635             :     Decoder_State *st,               /* i/o: State structure                             */
    4636             :     const int16_t tc_subfr,          /* i  : TC subframe index                           */
    4637             :     float *Aq,                       /* o  : quantized A(z) for 4 subframes              */
    4638             :     int16_t *LSF_Q_prediction,       /* o  : LSF prediction mode                         */
    4639             :     float *lsf_new,                  /* o  : de-quantized LSF vector                     */
    4640             :     float *lsp_new,                  /* o  : de-quantized LSP vector                     */
    4641             :     float *lsp_mid,                  /* o  : de-quantized mid-frame LSP vector           */
    4642             :     const int16_t tdm_low_rate_mode, /* i  : secondary channel low rate mode flag        */
    4643             :     const float tdm_lsfQ_PCh[M]      /* i  : Q LSFs for primary channel                  */
    4644             : );
    4645             : 
    4646             : void isf_dec_amr_wb(
    4647             :     Decoder_State *st, /* i/o: State structure                             */
    4648             :     float *Aq,         /* o  : quantized A(z) for 4 subframes              */
    4649             :     float *isf_new,    /* o  : de-quantized ISF vector                     */
    4650             :     float *isp_new     /* o  : de-quantized ISP vector                     */
    4651             : );
    4652             : 
    4653             : void Es_pred_dec(
    4654             :     float *Es_pred,        /* o  : predicted scaled innovation energy          */
    4655             :     const int16_t enr_idx, /* i  : indice                                      */
    4656             :     const int16_t nb_bits, /* i  : number of bits                              */
    4657             :     const int16_t no_ltp   /* i  : no LTP flag                                 */
    4658             : );
    4659             : 
    4660             : void gaus_dec(
    4661             :     Decoder_State *st,     /* i/o: decoder state structure                     */
    4662             :     const int16_t i_subfr, /* i  : subframe index                              */
    4663             :     float *code,           /* o  : gaussian excitation                         */
    4664             :     float *norm_gain_code, /* o  : gain of the normalized gaussian excitation  */
    4665             :     float *lp_gainp,       /* i/o: lp filtered pitch gain(FER)                 */
    4666             :     float *lp_gainc,       /* i/o: lp filtered code gain (FER)                 */
    4667             :     float *gain_inov,      /* o  : unscaled innovation gain                    */
    4668             :     float *tilt_code,      /* o  : synthesis excitation spectrum tilt          */
    4669             :     float *voice_fac,      /* o  : estimated voicing factor                    */
    4670             :     float *gain_pit,       /* o  : reset pitch gain                            */
    4671             :     float *pt_pitch,       /* o  : reset floating pitch buffer                 */
    4672             :     float *exc,            /* o  : excitation signal frame                     */
    4673             :     float *gain_code,      /* o  : gain of the gaussian excitation             */
    4674             :     float *exc2            /* o  : scaled excitation signal frame              */
    4675             : );
    4676             : 
    4677             : void gain_dec_amr_wb(
    4678             :     Decoder_State *st,        /* i/o: decoder state structure               */
    4679             :     const int32_t core_brate, /* i  : core bitrate                          */
    4680             :     float *gain_pit,          /* o  : Quantized pitch gain                  */
    4681             :     float *gain_code,         /* o  : Quantized codeebook gain              */
    4682             :     float *past_qua_en,       /* i/o: gain quantization memory (4 words)    */
    4683             :     float *gain_inov,         /* o  : unscaled innovation gain              */
    4684             :     const float *code,        /* i  : algebraic code excitation             */
    4685             :     float *norm_gain_code     /* o  : norm. gain of the codebook excitation */
    4686             : );
    4687             : 
    4688             : void gain_dec_lbr(
    4689             :     Decoder_State *st,        /* i/o: decoder state structure                          */
    4690             :     const int16_t coder_type, /* i  : coding type                                      */
    4691             :     const int16_t i_subfr,    /* i  : subframe index                                   */
    4692             :     const float *code,        /* i  : algebraic excitation                             */
    4693             :     float *gain_pit,          /* o  : quantized pitch gain                             */
    4694             :     float *gain_code,         /* o  : quantized codebook gain                          */
    4695             :     float *gain_inov,         /* o  : gain of the innovation (used for normalization)  */
    4696             :     float *norm_gain_code,    /* o  : norm. gain of the codebook excitation            */
    4697             :     float gains_mem[],        /* i/o: pitch gain and code gain from previous subframes */
    4698             :     const int16_t L_subfr     /* i  : subframe length                                  */
    4699             : );
    4700             : 
    4701             : void gain_dec_mless(
    4702             :     Decoder_State *st,        /* i/o: decoder state structure               */
    4703             :     const int16_t L_frame,    /* i  : length of the frame                   */
    4704             :     const int16_t coder_type, /* i  : coding type                           */
    4705             :     const int16_t i_subfr,    /* i  : subframe number                       */
    4706             :     const int16_t tc_subfr,   /* i  : TC subframe index                     */
    4707             :     const float *code,        /* i  : algebraic code excitation             */
    4708             :     const float Es_pred,      /* i  : predicted scaled innov. energy        */
    4709             :     float *gain_pit,          /* o  : Quantized pitch gain                  */
    4710             :     float *gain_code,         /* o  : Quantized codeebook gain              */
    4711             :     float *gain_inov,         /* o  : unscaled innovation gain              */
    4712             :     float *norm_gain_code     /* o  : norm. gain of the codebook excitation */
    4713             : );
    4714             : 
    4715             : void gain_dec_SQ(
    4716             :     Decoder_State *st,     /* i/o: decoder state structure               */
    4717             :     const int16_t i_subfr, /* i  : subframe number                       */
    4718             :     const float *code,     /* i  : algebraic code excitation             */
    4719             :     const float Es_pred,   /* i  : predicted scaled innov. energy        */
    4720             :     float *gain_pit,       /* o  : Quantized pitch gain                  */
    4721             :     float *gain_code,      /* o  : Quantized codeebook gain              */
    4722             :     float *gain_inov,      /* o  : unscaled innovation gain              */
    4723             :     float *norm_gain_code  /* o  : norm. gain of the codebook excitation */
    4724             : );
    4725             : 
    4726             : /*! r: quantized codebook gain */
    4727             : float gain_dec_gaus(
    4728             :     const int16_t index,   /* i  : quantization index                      */
    4729             :     const int16_t bits,    /* i  : number of bits to quantize              */
    4730             :     const float lowBound,  /* i  : lower bound of quantizer (dB)           */
    4731             :     const float topBound,  /* i  : upper bound of quantizer (dB)           */
    4732             :     const float gain_inov, /* i  : unscaled innovation gain                */
    4733             :     float *norm_gain_code  /* o  : gain of normalized gaus. excit.         */
    4734             : );
    4735             : 
    4736             : /*! r: floating pitch value */
    4737             : float pit_decode(
    4738             :     Decoder_State *st,                  /* i/o: decoder state structure                 */
    4739             :     const int32_t core_brate,           /* i  : core bitrate                            */
    4740             :     const int16_t Opt_AMR_WB,           /* i  : flag indicating AMR-WB IO mode          */
    4741             :     const int16_t L_frame,              /* i  : length of the frame                     */
    4742             :     int16_t i_subfr,                    /* i  : subframe index                          */
    4743             :     const int16_t coder_type,           /* i  : coding type                             */
    4744             :     int16_t *limit_flag,                /* i/o: restrained(0) or extended(1) Q limits   */
    4745             :     int16_t *T0,                        /* o  : close loop integer pitch                */
    4746             :     int16_t *T0_frac,                   /* o  : close loop fractional part of the pitch */
    4747             :     int16_t *T0_min,                    /* i/o: delta search min for sf 2 & 4           */
    4748             :     int16_t *T0_max,                    /* i/o: delta search max for sf 2 & 4           */
    4749             :     const int16_t L_subfr,              /* i  : subframe length                         */
    4750             :     const int16_t tdm_Pitch_reuse_flag, /* i  : primary channel pitch reuse flag        */
    4751             :     const float tdm_Pri_pitch_buf[]     /* i  : primary channel pitch buffer            */
    4752             : );
    4753             : 
    4754             : void abs_pit_dec(
    4755             :     const int16_t fr_steps,   /* i  : fractional resolution steps (0, 2, 4)   */
    4756             :     int16_t pitch_index,      /* i  : pitch index                             */
    4757             :     const int16_t limit_flag, /* i  : restrained(0) or extended(1) Q limits   */
    4758             :     int16_t *T0,              /* o  : integer pitch lag                       */
    4759             :     int16_t *T0_frac          /* o  : pitch fraction                          */
    4760             : );
    4761             : 
    4762             : void delta_pit_dec(
    4763             :     const int16_t fr_steps,    /* i  : fractional resolution steps (0, 2, 4)   */
    4764             :     const int16_t pitch_index, /* i  : pitch index                             */
    4765             :     int16_t *T0,               /* o  : integer pitch lag                       */
    4766             :     int16_t *T0_frac,          /* o  : pitch fraction                          */
    4767             :     const int16_t T0_min       /* i  : delta search min                        */
    4768             : );
    4769             : 
    4770             : void pit_Q_dec(
    4771             :     const int16_t Opt_AMR_WB,  /* i  : flag indicating AMR-WB IO mode          */
    4772             :     const int16_t pitch_index, /* i  : pitch index                             */
    4773             :     const int16_t nBits,       /* i  : # of Q bits                             */
    4774             :     const int16_t delta,       /* i  : Half the CL searched interval           */
    4775             :     const int16_t pit_flag,    /* i  : absolute(0) or delta(1) pitch Q         */
    4776             :     const int16_t limit_flag,  /* i  : restrained(0) or extended(1) Q limits   */
    4777             :     int16_t *T0,               /* o  : integer pitch lag                       */
    4778             :     int16_t *T0_frac,          /* o  : pitch fraction                          */
    4779             :     int16_t *T0_min,           /* i/o: delta search min                        */
    4780             :     int16_t *T0_max,           /* i/o: delta search max                        */
    4781             :     int16_t *BER_detect        /* o  : BER detect flag                         */
    4782             : );
    4783             : 
    4784             : void pit16k_Q_dec(
    4785             :     const int16_t pitch_index, /* i  : pitch index                             */
    4786             :     const int16_t nBits,       /* i  : # of Q bits                             */
    4787             :     const int16_t limit_flag,  /* i  : restrained(0) or extended(1) Q limits   */
    4788             :     int16_t *T0,               /* o  : integer pitch lag                       */
    4789             :     int16_t *T0_frac,          /* o  : pitch fraction                          */
    4790             :     int16_t *T0_min,           /* i/o: delta search min                        */
    4791             :     int16_t *T0_max,           /* i/o: delta search max                        */
    4792             :     int16_t *BER_detect        /* o  : BER detect flag                         */
    4793             : );
    4794             : 
    4795             : void lp_filt_exc_dec(
    4796             :     Decoder_State *st,        /* i/o: decoder state structure                         */
    4797             :     const int16_t codec_mode, /* i  : codec mode                                      */
    4798             :     const int16_t i_subfr,    /* i  : subframe index                                  */
    4799             :     const int16_t L_subfr,    /* i  : subframe size                                   */
    4800             :     const int16_t L_Frame,    /* i  : frame size                                      */
    4801             :     int16_t lp_flag,          /* i  : operation mode signaling                        */
    4802             :     float *exc                /* i/o: pointer to the excitation signal frame          */
    4803             : );
    4804             : 
    4805             : void inov_decode(
    4806             :     Decoder_State *st,        /* i/o: decoder state structure                         */
    4807             :     const int32_t core_brate, /* i  : core bitrate                                    */
    4808             :     const int16_t Opt_AMR_WB, /* i  : flag indicating AMR-WB IO mode                  */
    4809             :     const int16_t L_frame,    /* i  : length of the frame                             */
    4810             :     const int16_t sharpFlag,  /* i  : formant sharpening flag                         */
    4811             :     const int16_t i_subfr,    /* i  : subframe index                                  */
    4812             :     const float *p_Aq,        /* i  : LP filter coefficients                          */
    4813             :     const float tilt_code,    /* i  : tilt of of the excitation of previous subframe  */
    4814             :     const float pt_pitch,     /* i  : pointer to current subframe fractional pitch    */
    4815             :     float *code,              /* o  : algebraic excitation                            */
    4816             :     const int16_t L_subfr     /* i  : subframe length                                 */
    4817             : );
    4818             : 
    4819             : void dec_acelp_1t64(
    4820             :     Decoder_State *st,    /* i/o: decoder state structure                         */
    4821             :     float code[],         /* o  : algebraic (fixed) codebook excitation           */
    4822             :     const int16_t L_subfr /* i  : subframe length                                 */
    4823             : );
    4824             : 
    4825             : void dec_acelp_2t32(
    4826             :     Decoder_State *st, /* i/o: decoder state structure                         */
    4827             :     float code[]       /* o  : algebraic (fixed) codebook excitation           */
    4828             : );
    4829             : 
    4830             : void dec_acelp_4t64(
    4831             :     Decoder_State *st,       /* i/o: decoder state structure                         */
    4832             :     int16_t nbbits,          /* i  : number of bits per codebook                     */
    4833             :     float code[],            /* o  : algebraic (fixed) codebook excitation           */
    4834             :     const int16_t Opt_AMR_WB /* i  : flag indicating AMR-WB IO mode                  */
    4835             : );
    4836             : 
    4837             : void FEC_exc_estim(
    4838             :     Decoder_State *st,     /* i/o: Decoder static memory                           */
    4839             :     const int16_t L_frame, /* i  : length of the frame                             */
    4840             :     float *old_exc,        /* i/o: excitation buffer                               */
    4841             :     float *exc2,           /* o  : excitation buffer (for synthesis)               */
    4842             :     float *exc_dct_in,     /* o  : GSC excitation in DCT domain                    */
    4843             :     float *pitch_buf,      /* o  : Floating pitch   for each subframe              */
    4844             :     float *tmp_tc,         /* o  : FEC pitch                                       */
    4845             :     float *voice_factors,  /* o  : voicing factors                                 */
    4846             :     float *bwe_exc,        /* i/o: excitation for SWB TBE                          */
    4847             :     float *lsf_new,        /* i  : ISFs at the end of the frame                    */
    4848             :     float *tmp_noise       /* o  : long-term noise energy                          */
    4849             : );
    4850             : 
    4851             : void FEC_lsf2lsp_interp(
    4852             :     Decoder_State *st,     /* i/o: Decoder static memory                           */
    4853             :     const int16_t L_frame, /* i  : length of the frame                             */
    4854             :     float *Aq,             /* o  : calculated A(z) for 4 subframes                 */
    4855             :     float *lsf,            /* o  : estimated LSF vector                            */
    4856             :     float *lsp             /* o  : estimated LSP vector                            */
    4857             : );
    4858             : 
    4859             : void FEC_lsf_estim_enc(
    4860             :     Encoder_State *st, /* i  : Encoder static memory                           */
    4861             :     float *lsf         /* o  : estimated LSF vector                            */
    4862             : );
    4863             : 
    4864             : float frame_energy(
    4865             :     const int16_t L_frame, /* i  : length of the frame                             */
    4866             :     const float *pitch,    /* i  : pitch values for each subframe                  */
    4867             :     const float *speech,   /* i  : pointer to speech signal for E computation      */
    4868             :     const float lp_speech, /* i  : long term active speech energy average          */
    4869             :     float *frame_ener      /* o  : pitch-synchronous energy at frame end           */
    4870             : );
    4871             : 
    4872             : void FEC_SinOnset(
    4873             :     float *exc,           /* i/o: exc vector to modify                           */
    4874             :     int16_t puls_pos,     /* i  : Last pulse position desired                    */
    4875             :     int16_t T0,           /* i  : decoded first frame pitch                      */
    4876             :     float enr_q,          /* i  : energy provided by the encoder                 */
    4877             :     float *Aq,            /* i  : Lsp coefficient                                */
    4878             :     const int16_t L_frame /* i  : Frame length                                   */
    4879             : );
    4880             : 
    4881             : int16_t FEC_enhACB(
    4882             :     const int16_t L_frame,      /* i  : Frame length                                                              */
    4883             :     const int16_t last_L_frame, /* i  : frame length of last frame                                                */
    4884             :     float *exc_io,              /* i/o: Adaptive codebook memory                                                  */
    4885             :     const int16_t new_pit,      /* i  : decoded first frame pitch                                                 */
    4886             :     const int16_t puls_pos,     /* i  : decoder position of the last glottal pulses decoded in the previous frame */
    4887             :     const float bfi_pitch       /* i  : Pitch used for concealment                                                */
    4888             : );
    4889             : 
    4890             : void FEC_scale_syn(
    4891             :     const int16_t L_frame,                     /* i  : length of the frame                     */
    4892             :     int16_t clas,                              /* i/o: frame classification                    */
    4893             :     const int16_t last_good,                   /* i  : last good frame classification          */
    4894             :     float *synth,                              /* i/o: synthesized speech at Fs = 12k8 Hz      */
    4895             :     const float *pitch,                        /* i  : pitch values for each subframe          */
    4896             :     float enr_old,                             /* i  : energy at the end of prvious frame      */
    4897             :     float enr_q,                               /* i  : transmitted energy for current frame    */
    4898             :     const int16_t coder_type,                  /* i  : coding type                             */
    4899             :     const int16_t LSF_Q_prediction,            /* i  : LSF prediction mode                     */
    4900             :     int16_t *scaling_flag,                     /* i/o: flag to indicate energy control of syn  */
    4901             :     float *lp_ener_FEC_av,                     /* i/o: averaged voiced signal energy           */
    4902             :     float *lp_ener_FEC_max,                    /* i/o: averaged voiced signal energy           */
    4903             :     const int16_t bfi,                         /* i  : current  frame BFI                      */
    4904             :     const int32_t total_brate,                 /* i  : total bitrate                           */
    4905             :     const int16_t prev_bfi,                    /* i  : previous frame BFI                      */
    4906             :     const int32_t last_core_brate,             /* i  : previous frame core bitrate             */
    4907             :     float *exc,                                /* i/o: excitation signal without enhancement   */
    4908             :     float *exc2,                               /* i/o: excitation signal with enhancement      */
    4909             :     const float Aq[],                          /* i  : LP filter coefs                         */
    4910             :     float *old_enr_LP,                         /* i/o: LP filter E of last good voiced frame   */
    4911             :     const float *mem_tmp,                      /* i  : temp. initial synthesis filter states   */
    4912             :     float *mem_syn,                            /* o  : initial synthesis filter states         */
    4913             :     const int16_t avoid_lpc_burst_on_recovery, /* i  : if true the excitation energy is limited if LP has big gain */
    4914             :     const int16_t force_scaling                /* i  : force scaling                           */
    4915             : );
    4916             : 
    4917             : void FEC_pitch_estim(
    4918             :     const int16_t Opt_AMR_WB,    /* i  : flag indicating AMR-WB IO mode          */
    4919             :     const int16_t last_core,     /* i  : last core                               */
    4920             :     const int16_t L_frame,       /* i  : length of the frame                     */
    4921             :     const int16_t clas,          /* i  : current frame classification            */
    4922             :     const int16_t last_good,     /* i  : last good clas information              */
    4923             :     const float pitch_buf[],     /* i  : Floating pitch   for each subframe      */
    4924             :     const float old_pitch_buf[], /* i  : buffer of old subframe pitch values     */
    4925             :     float *bfi_pitch,            /* i/o: update of the estimated pitch for FEC   */
    4926             :     int16_t *bfi_pitch_frame,    /* o  : frame length when pitch was updated     */
    4927             :     int16_t *upd_cnt,            /* i/o: update counter                          */
    4928             :     const int16_t coder_type );
    4929             : 
    4930             : void FEC_encode(
    4931             :     BSTR_ENC_HANDLE hBstr,        /* i/o: encoder bitstream handle                        */
    4932             :     const ACELP_config acelp_cfg, /* i  : configuration of the ACELP                      */
    4933             :     const float *synth,           /* i  : pointer to synthesized speech for E computation */
    4934             :     const int16_t coder_type,     /* i  : type of coder                                   */
    4935             :     int16_t clas,                 /* i  : signal clas for current frame                   */
    4936             :     const float *fpit,            /* i  : close loop fractional pitch buffer              */
    4937             :     const float *res,             /* i  : LP residual signal frame                        */
    4938             :     int16_t *last_pulse_pos,      /* i/o: Position of the last pulse                      */
    4939             :     const int16_t L_frame,        /* i  : Frame length                                    */
    4940             :     const int32_t total_brate     /* i  : total codec bitrate                             */
    4941             : );
    4942             : 
    4943             : int16_t FEC_pos_dec(
    4944             :     Decoder_State *st,          /* i/o: decoder state structure                     */
    4945             :     int16_t *last_pulse_pos,    /* o  : Last glottal pulse position in the lost ACB */
    4946             :     float *enr_q,               /* o  : Decoded energy                              */
    4947             :     const int16_t nBits_es_Pred /* i  : number of bits for Es_pred Q                */
    4948             : );
    4949             : 
    4950             : void improv_amr_wb_gs(
    4951             :     const int16_t clas,                 /* i  : bitrate allocated to the core           */
    4952             :     const int16_t coder_type,           /* i  : coder_type                              */
    4953             :     const int32_t core_brate,           /* i  : bitrate allocated to the core           */
    4954             :     int16_t *seed_tcx,                  /* i/o: Seed used for noise generation          */
    4955             :     float *old_Aq,                      /* i/o: old LPC filter coefficient              */
    4956             :     float *mem_syn2,                    /* i/o: synthesis memory                        */
    4957             :     const float lt_voice_fac,           /* i/o: long term voice factor                  */
    4958             :     const int16_t locattack,            /* i  : Flag for a detected attack              */
    4959             :     float *Aq,                          /* i/o: Decoded LP filter coefficient           */
    4960             :     float *exc2,                        /* i/o: Decoded complete excitation             */
    4961             :     float *mem_tmp,                     /* i/o: synthesis temporary memory              */
    4962             :     float *syn,                         /* i/o: Decoded synthesis to be updated         */
    4963             :     const float *pitch_buf,             /* i  : Decoded pitch buffer                    */
    4964             :     const float Last_ener,              /* i  : Last energy                             */
    4965             :     const int16_t rate_switching_reset, /* i  : rate switching reset flag               */
    4966             :     const int16_t last_coder_type,      /* i  : Last coder_type                         */
    4967             :     const int16_t VeryLowRateSTflag     /* i  : Enable the noise enhancement for very low rate stereo generic mode */
    4968             : );
    4969             : 
    4970             : int16_t tc_classif(
    4971             :     Decoder_State *st /* i/o: decoder state structure                 */
    4972             : );
    4973             : 
    4974             : void transition_dec(
    4975             :     Decoder_State *st,      /* i/o: decoder state structure                 */
    4976             :     const int16_t L_frame,  /* i  : length of the frame                     */
    4977             :     const int16_t i_subfr,  /* i  : subframe index                          */
    4978             :     const int16_t tc_subfr, /* i  : TC subframe index                       */
    4979             :     int16_t *Jopt_flag,     /* i  : joint optimization flag                 */
    4980             :     float *exc,             /* i/o: current frame excitation signal         */
    4981             :     int16_t *T0,            /* o  : close loop integer pitch                */
    4982             :     int16_t *T0_frac,       /* o  : close loop fractional part of the pitch */
    4983             :     int16_t *T0_min,        /* i/o: delta search min for sf 2 & 4           */
    4984             :     int16_t *T0_max,        /* i/o: delta search max for sf 2 & 4           */
    4985             :     float **pt_pitch,       /* o  : floating pitch values                   */
    4986             :     int16_t *position,      /* i/o: first glottal impulse position in frame */
    4987             :     float *bwe_exc          /* i/o: excitation for SWB TBE                  */
    4988             : );
    4989             : 
    4990             : void gain_dec_tc(
    4991             :     Decoder_State *st,     /* i/o: decoder state structure              */
    4992             :     const int16_t i_subfr, /* i  : subframe number                      */
    4993             :     const float Es_pred,   /* i  : predicted scaled innov. energy       */
    4994             :     const float *code,     /* i  : algebraic code excitation            */
    4995             :     float *gain_pit,       /* o  : pitch gain                           */
    4996             :     float *gain_code,      /* o  : Quantized codeebook gain             */
    4997             :     float *gain_inov,      /* o  : unscaled innovation gain             */
    4998             :     float *norm_gain_code  /* o  : norm. gain of the codebook excit.    */
    4999             : );
    5000             : 
    5001             : void stat_noise_uv_dec(
    5002             :     Decoder_State *st,              /* i/o: decoder static memory               */
    5003             :     const float *lsp_new,           /* i  : end-frame LSP vector                */
    5004             :     const float *lsp_mid,           /* i  : mid-frame LSP vector                */
    5005             :     float *Aq,                      /* o  : A(z) quantized for the 4 subframes  */
    5006             :     float *exc2,                    /* i/o: excitation buffer                   */
    5007             :     const int16_t uc_two_stage_flag /* 1  : flag undicating two-stage UC        */
    5008             : );
    5009             : 
    5010             : void sc_vbr_dec_init(
    5011             :     SC_VBR_DEC_HANDLE hSC_VBR /* i/o: SC-VBR decoder handle                */
    5012             : );
    5013             : 
    5014             : void decod_nelp(
    5015             :     Decoder_State *st,    /* i/o: decoder static memory                   */
    5016             :     float *tmp_noise,     /* o  : long term temporary noise energy        */
    5017             :     float *pitch_buf,     /* o  : floating pitch values for each subframe */
    5018             :     float *exc,           /* o  : adapt. excitation exc                   */
    5019             :     float *exc2,          /* o  : adapt. excitation/total exc             */
    5020             :     float *voice_factors, /* o  : voicing factors                         */
    5021             :     float *bwe_exc,       /* o  : excitation for SWB TBE                  */
    5022             :     const int16_t bfi,    /* i  : bad frame indicator                     */
    5023             :     float *gain_buf       /* o  : floating pitch gain for each subframe   */
    5024             : );
    5025             : 
    5026             : void nelp_decoder(
    5027             :     Decoder_State *st,        /* i/o: decoder static memory                     */
    5028             :     float *exc_nelp,          /* o  : adapt. excitation/total exc               */
    5029             :     float *exc,               /* o  : adapt. excitation exc                     */
    5030             :     int16_t bfi,              /* i  : frame error rate                          */
    5031             :     const int16_t coder_type, /* i  : coding type                               */
    5032             :     float *gain_buf           /* o  : floating pitch gain for each subframe     */
    5033             : );
    5034             : 
    5035             : ivas_error decod_ppp(
    5036             :     Decoder_State *st,    /* i/o: state structure                           */
    5037             :     const float Aq[],     /* i  : 12k8 Lp coefficient                       */
    5038             :     float *pitch_buf,     /* i/o: floating pitch values for each subframe   */
    5039             :     float *exc,           /* i/o: current non-enhanced excitation           */
    5040             :     float *exc2,          /* i/o: current enhanced excitation               */
    5041             :     float *voice_factors, /* o  : voicing factors                           */
    5042             :     float *bwe_exc,       /* o  : excitation for SWB TBE                    */
    5043             :     float *gain_buf,      /* o  : floating pitch gain for each subframe     */
    5044             :     const int16_t bfi     /* i  : BFI flag                                  */
    5045             : );
    5046             : 
    5047             : ivas_error ppp_quarter_decoder(
    5048             :     Decoder_State *st,             /* i/o: decoder state structure                 */
    5049             :     DTFS_STRUCTURE *CURRCW_Q_DTFS, /* i/o: Current CW DTFS                         */
    5050             :     int16_t prevCW_lag,            /* i  : Previous lag                            */
    5051             :     float *lastLgainD,             /* i/o: Last gain lowband                       */
    5052             :     float *lastHgainD,             /* i/o: Last gain highwband                     */
    5053             :     float *lasterbD,               /* i/o: Last ERB vector                         */
    5054             :     int16_t bfi,                   /* i  : FER flag                                */
    5055             :     DTFS_STRUCTURE PREV_CW_D       /* i  : Previous DTFS                           */
    5056             : );
    5057             : 
    5058             : ivas_error ppp_voiced_decoder(
    5059             :     Decoder_State *st, /* i/o: state structure                         */
    5060             :     float *out,        /* o  : residual signal                         */
    5061             :     const float *lpc2, /* i  : current frame LPC                       */
    5062             :     float *exc,        /* i  : previous frame excitation               */
    5063             :     float *pitch,      /* o  : floating pitch values for each subframe */
    5064             :     const int16_t bfi  /* i  : BFI flag                                */
    5065             : );
    5066             : 
    5067             : void AVQ_demuxdec(
    5068             :     Decoder_State *st,     /* i/o: decoder state structure         */
    5069             :     int16_t xriq[],        /* o  : decoded subvectors [0..8*Nsv-1] */
    5070             :     int16_t *nb_bits,      /* i/o: number of allocated bits        */
    5071             :     const int16_t Nsv,     /* i  : number of subvectors            */
    5072             :     int16_t nq[],          /* i/o: AVQ nq index                    */
    5073             :     int16_t avq_bit_sFlag, /* i  : flag for AVQ bit saving solution*/
    5074             :     int16_t trgtSvPos      /* i  : target SV for AVQ bit savings   */
    5075             : );
    5076             : 
    5077             : void re8_dec(
    5078             :     int16_t nq,         /* i  : codebook number (*n is an integer defined in {0,2,3,4,..,n_max})    */
    5079             :     const uint16_t I,   /* i  : index of c (pointer to unsigned 16-bit word)                        */
    5080             :     const int16_t kv[], /* i  : index of v (8-dimensional vector of binary indices) = Voronoi index */
    5081             :     int16_t y[]         /* o  : point in RE8 (8-dimensional integer vector)                         */
    5082             : );
    5083             : 
    5084             : void re8_decode_base_index(
    5085             :     const int16_t n, /* i  : codebook number (*n is an integer defined in {0,2,3,4,..,n_max}) */
    5086             :     uint16_t I,      /* i  : index of c (pointer to unsigned 16-bit word)                     */
    5087             :     int16_t *x       /* o  : point in RE8 (8-dimensional integer vector)                      */
    5088             : );
    5089             : 
    5090             : void Init_post_filter(
    5091             :     PFSTAT_HANDLE hPFstat /* i  : post-filter state memories              */
    5092             : );
    5093             : 
    5094             : void nb_post_filt(
    5095             :     const int16_t L_frame,    /* i  : frame length                            */
    5096             :     const int16_t L_subfr,    /* i  : sub-frame length                        */
    5097             :     PFSTAT_HANDLE hPFstat,    /* i/o: Post filter related memories            */
    5098             :     float *lp_noise,          /* i/o: long term noise energy                  */
    5099             :     const float tmp_noise,    /* i  : noise energy                            */
    5100             :     float *synth,             /* i/o: synthesis                               */
    5101             :     const float *Aq,          /* i  : LP filter coefficient                   */
    5102             :     const float *pitch_buf,   /* i  : Floating pitch   for each subframe      */
    5103             :     const int16_t coder_type, /* i  : coder_type -> deactivated in AUDIO      */
    5104             :     const int16_t BER_detect, /* i  : BER detect flag                         */
    5105             :     const int16_t disable_hpf /* i  : flag to diabled HPF                     */
    5106             : );
    5107             : 
    5108             : void decod_unvoiced(
    5109             :     Decoder_State *st,               /* i/o: decoder static memory                   */
    5110             :     const float *Aq,                 /* i  : LP filter coefficient                   */
    5111             :     const float Es_pred,             /* i  : predicted scaled innov. energy          */
    5112             :     const int16_t uc_two_stage_flag, /* i  : flag indicating two-stage UC            */
    5113             :     float *tmp_noise,                /* o  : long term temporary noise energy        */
    5114             :     float *pitch_buf,                /* o  : floating pitch values for each subframe */
    5115             :     float *voice_factors,            /* o  : voicing factors                         */
    5116             :     float *exc,                      /* o  : adapt. excitation exc                   */
    5117             :     float *exc2,                     /* o  : adapt. excitation/total exc             */
    5118             :     float *bwe_exc,                  /* i/o: excitation for SWB TBE                  */
    5119             :     float *gain_buf                  /* o  : floating pitch gain for each subfram    */
    5120             : );
    5121             : 
    5122             : void decod_tran(
    5123             :     Decoder_State *st,       /* i/o: decoder static memory                   */
    5124             :     const int16_t L_frame,   /* i  : length of the frame                     */
    5125             :     const int16_t tc_subfr,  /* i  : TC subframe index                       */
    5126             :     const float *Aq,         /* i  : LP filter coefficient                   */
    5127             :     const float Es_pred,     /* i  : predicted scaled innov. energy          */
    5128             :     float *pitch_buf,        /* o  : floating pitch values for each subframe */
    5129             :     float *voice_factors,    /* o  : voicing factors                         */
    5130             :     float *exc,              /* i/o: adapt. excitation exc                   */
    5131             :     float *exc2,             /* i/o: adapt. excitation/total exc             */
    5132             :     float *bwe_exc,          /* i/o: excitation for SWB TBE                  */
    5133             :     int16_t *unbits,         /* i/o: number of unused bits                   */
    5134             :     const int16_t sharpFlag, /* i  : formant sharpening flag                 */
    5135             :     float *gain_buf          /* o  : floating pitch gain for each subframe   */
    5136             : );
    5137             : 
    5138             : ivas_error decod_gen_voic(
    5139             :     Decoder_State *st,                  /* i/o: decoder static memory                   */
    5140             :     const int16_t L_frame,              /* i  : length of the frame                     */
    5141             :     const int16_t sharpFlag,            /* i  : formant sharpening flag                 */
    5142             :     const float *Aq,                    /* i  : LP filter coefficient                   */
    5143             :     const float Es_pred,                /* i  : predicted scaled innov. energy          */
    5144             :     const int16_t do_WI,                /* i  : FEC fast recovery flag                  */
    5145             :     float *pitch_buf,                   /* o  : floating pitch   for each subframe      */
    5146             :     float *voice_factors,               /* o  : voicing factors                         */
    5147             :     float *exc,                         /* i/o: adapt. excitation exc                   */
    5148             :     float *exc2,                        /* i/o: adapt. excitation/total exc             */
    5149             :     float *bwe_exc,                     /* i/o: excitation for SWB TBE                  */
    5150             :     int16_t *unbits,                    /* i/o: number of unused bits                   */
    5151             :     float *gain_buf,                    /* o  : floating pitch gain for each subframe   */
    5152             :     const int16_t tdm_Pitch_reuse_flag, /* i  : primary channel pitch reuse flag        */
    5153             :     const float tdm_Pri_pitch_buf[]     /* i  : primary channel pitch buffer            */
    5154             : );
    5155             : 
    5156             : void decod_amr_wb(
    5157             :     Decoder_State *st,         /* i/o: decoder static memory                     */
    5158             :     const float *Aq,           /* i  : LP filter coefficients                    */
    5159             :     float *pitch_buf,          /* o  : floating pitch values for each subframe   */
    5160             :     float *exc,                /* i/o: adapt. excitation exc                     */
    5161             :     float *exc2,               /* i/o: adapt. excitation/total exc               */
    5162             :     int16_t hf_gain[NB_SUBFR], /* o  : decoded HF gain                           */
    5163             :     float *voice_factors,      /* o  : voicing factors                           */
    5164             :     float *gain_buf            /* o  : floating pitch gain for each subframe     */
    5165             : );
    5166             : 
    5167             : ivas_error init_decoder(
    5168             :     Decoder_State *st,    /* o  : Decoder static variables structure        */
    5169             :     const int16_t idchan, /* i  : channel ID                                */
    5170             :     const MC_MODE mc_mode /* i  : MC mode                                   */
    5171             : );
    5172             : 
    5173             : void destroy_cldfb_decoder(
    5174             :     Decoder_State *st /* o  : Decoder static variables structure        */
    5175             : );
    5176             : 
    5177             : void HQ_core_dec_init(
    5178             :     HQ_DEC_HANDLE hHQ_core /* i/o: HQ core data handle                       */
    5179             : );
    5180             : 
    5181             : void HQ_nbfec_init(
    5182             :     HQ_NBFEC_HANDLE hHQ_nbfec /* i/o: HQ NB FEC data handle                    */
    5183             : );
    5184             : 
    5185             : ivas_error evs_dec(
    5186             :     Decoder_State *st,              /* i/o: Decoder state structure                   */
    5187             :     float mem_hp20_out[L_HP20_MEM], /* i/o: HP filter memory for synthesis            */
    5188             :     float *output,                  /* o  : output synthesis signal                   */
    5189             :     FRAME_MODE frameMode            /* i  : Decoder frame mode                        */
    5190             : );
    5191             : 
    5192             : void get_next_frame_parameters(
    5193             :     Decoder_State *st /* i/o: Decoder state structure                   */
    5194             : );
    5195             : 
    5196             : ivas_error amr_wb_dec(
    5197             :     Decoder_State *st,              /* i/o: decoder state structure                   */
    5198             :     float mem_hp20_out[L_HP20_MEM], /* i/o: HP filter memory for synthesis            */
    5199             :     float *output                   /* o  : synthesis output                          */
    5200             : );
    5201             : 
    5202             : void transf_cdbk_dec(
    5203             :     Decoder_State *st,             /* i/o: decoder state structure                   */
    5204             :     const int16_t harm_flag_acelp, /* i  : harmonic flag for higher rates ACELP      */
    5205             :     const int16_t i_subfr,         /* i  : subframe index                            */
    5206             :     const float Es_pred,           /* i  : predicited scaled innovation energy       */
    5207             :     const float gain_code,         /* i  : innovative excitation gain                */
    5208             :     float *gain_preQ,              /* o  : prequantizer excitation gain              */
    5209             :     float *norm_gain_preQ,         /* o  : normalized prequantizer excitation gain   */
    5210             :     float code_preQ[],             /* o  : prequantizer excitation                   */
    5211             :     int16_t *unbits                /* o  : number of AVQ unused bits                 */
    5212             : );
    5213             : 
    5214             : /*! r: decoded gain */
    5215             : float gain_dequant(
    5216             :     int16_t index,       /* i  : quantization index                        */
    5217             :     const float min_val, /* i  : value of lower limit                      */
    5218             :     const float max_val, /* i  : value of upper limit                      */
    5219             :     const int16_t bits   /* i  : number of bits to dequantize              */
    5220             : );
    5221             : 
    5222             : void HQ_core_enc_init(
    5223             :     HQ_ENC_HANDLE hHQ_core /* i/o: HQ core data handle                       */
    5224             : );
    5225             : 
    5226             : void hq_core_enc(
    5227             :     Encoder_State *st,           /* i/o: encoder state structure                   */
    5228             :     const float *audio,          /* i  : input audio signal                        */
    5229             :     const int16_t input_frame,   /* i  : frame length                              */
    5230             :     const int16_t hq_core_type,  /* i  : HQ core type                              */
    5231             :     const int16_t Voicing_flag,  /* i  : Voicing flag for FER method selection     */
    5232             :     const int16_t vad_hover_flag /* i  : VAD hangover flag                         */
    5233             : );
    5234             : 
    5235             : int16_t detect_transient(
    5236             :     Encoder_State *st, /* i/o: encoder state structure             */
    5237             :     const float *in,   /* i  : input signal                        */
    5238             :     const int16_t L    /* i  : length                              */
    5239             : );
    5240             : 
    5241             : void wtda(
    5242             :     const float *new_audio,   /* i  : input audio                         */
    5243             :     float *wtda_audio,        /* o  : windowed audio                      */
    5244             :     float *old_wtda,          /* i/o: windowed audio from previous frame  */
    5245             :     const int16_t left_mode,  /* i  : window overlap of previous frame (0: full, 2: none, or 3: half) */
    5246             :     const int16_t right_mode, /* i  : window overlap of current frame (0: full, 2: none, or 3: half) */
    5247             :     const int16_t L           /* i  : length                              */
    5248             : );
    5249             : 
    5250             : void wtda_ext(
    5251             :     const float *new_audio,    /* i  : input audio                         */
    5252             :     float *wtda_audio,         /* o  : windowed audio                      */
    5253             :     const int16_t left_mode,   /* i  : window overlap of previous frame (0: full, 2: none, or 3: half) */
    5254             :     const int16_t right_mode,  /* i  : window overlap of current frame (0: full, 2: none, or 3: half) */
    5255             :     const int16_t L,           /* i  : length                              */
    5256             :     const uint16_t kernel_type /* i  : transform kernel type (0 - 3)       */
    5257             : );
    5258             : 
    5259             : void tcx_get_windows_mode1(
    5260             :     const int16_t left_mode,  /* i  : overlap mode of left window half    */
    5261             :     const int16_t right_mode, /* i  : overlap mode of right window half   */
    5262             :     float *left_win,          /* o  : left overlap window                 */
    5263             :     float *right_win,         /* o  : right overlap window                */
    5264             :     float *left_win_int,      /* o  : left overlap window                 */
    5265             :     float *right_win_int,     /* o  : right overlap window                */
    5266             :     const int16_t L           /* i  : length                              */
    5267             : );
    5268             : 
    5269             : void direct_transform(
    5270             :     const float *in32,          /* i  : input signal                        */
    5271             :     float *out32,               /* o  : output transformation               */
    5272             :     const int16_t is_transient, /* i  : transient flag                      */
    5273             :     const int16_t L,            /* i  : length                              */
    5274             :     const int16_t element_mode  /* i  : IVAS element mode   */
    5275             : );
    5276             : 
    5277             : /*! r: index of noise attenuation */
    5278             : int16_t noise_adjust(
    5279             :     const float *coeffs_norm, /* i  : normalized coefficients             */
    5280             :     const int16_t *bitalloc,  /* i  : bit allocation                      */
    5281             :     const int16_t *sfm_start, /* i  : Start of bands                      */
    5282             :     const int16_t *sfm_end,   /* i  : End of bands                        */
    5283             :     const int16_t core_sfm    /* i  : index of the end band for core      */
    5284             : );
    5285             : 
    5286             : void interleave_spectrum(
    5287             :     float *coefs,        /* i/o: input and output coefficients       */
    5288             :     const int16_t length /* i  : length of spectrum                  */
    5289             : );
    5290             : 
    5291             : void hq_hr_enc(
    5292             :     Encoder_State *st,           /* i/o: encoder state structure             */
    5293             :     float *coefs,                /* i/o: transform-domain coefficients       */
    5294             :     const int16_t length,        /* i  : length of spectrum                  */
    5295             :     int16_t *num_bits,           /* i/o: number of available bits            */
    5296             :     const int16_t is_transient,  /* i  : transient flag                      */
    5297             :     const int16_t vad_hover_flag /* i  : VAD hangover flag                   */
    5298             : );
    5299             : 
    5300             : void logqnorm(
    5301             :     const float *x,  /* i  : coefficient vector                  */
    5302             :     int16_t *k,      /* o  : index                               */
    5303             :     const int16_t L, /* i  : codebook length                     */
    5304             :     const int16_t N, /* i  : sub-vector size                     */
    5305             :     const float *thren );
    5306             : 
    5307             : void huff_dec(
    5308             :     Decoder_State *st,         /* i/o: decoder state structure                         */
    5309             :     const int16_t N,           /* i  : Number of codewords to decode                   */
    5310             :     const int16_t buffer_len,  /* i  : Number of bits to read                          */
    5311             :     const int16_t num_lengths, /* i  : Number of different huffman codeword lengths    */
    5312             :     const int16_t *thres,      /* i  : Threshold of first codeword of each length      */
    5313             :     const int16_t *offset,     /* i  : Offset for first codeword                       */
    5314             :     const int16_t *huff_tab,   /* i  : Huffman table order by codeword lengths         */
    5315             :     int16_t *index             /* o  : Decoded index                                   */
    5316             : );
    5317             : 
    5318             : void calc_norm(
    5319             :     const float *x,           /* i  : Input vector.                       */
    5320             :     int16_t *norm,            /* o  : Quantization indices for norms      */
    5321             :     int16_t *normlg,          /* o  : Quantized norms in log2             */
    5322             :     const int16_t start_band, /* i  : Indice of band to start coding      */
    5323             :     const int16_t num_bands,  /* i  : Number of bands                     */
    5324             :     const int16_t *band_len,  /* i  : Length of bands                     */
    5325             :     const int16_t *band_start /* i  : Start of bands                      */
    5326             : );
    5327             : 
    5328             : void reordernorm(
    5329             :     const int16_t *ynrm,     /* i  : quantization indices for norms      */
    5330             :     const int16_t *normqlg2, /* i  : quantized norms                     */
    5331             :     int16_t *idxbuf,         /* o  : reordered quantization indices      */
    5332             :     int16_t *normbuf,        /* o  : reordered quantized norms           */
    5333             :     const int16_t nb_sfm     /* i  : number of bands                     */
    5334             : );
    5335             : 
    5336             : void diffcod(
    5337             :     const int16_t N, /* i  : number of sub-vectors               */
    5338             :     int16_t *y,      /* i/o: indices of quantized norms          */
    5339             :     int16_t *difidx  /* o  : differential code                   */
    5340             : );
    5341             : 
    5342             : void diffcod_lrmdct(
    5343             :     const int16_t N,           /* i  : number of sub-vectors       */
    5344             :     const int16_t be_ref,      /* i  : band energy reference       */
    5345             :     int16_t *y,                /* i/o: indices of quantized norms  */
    5346             :     int16_t *difidx,           /* o  : differential code           */
    5347             :     const int16_t is_transient /* i  : transient flag              */
    5348             : );
    5349             : 
    5350             : void normalizecoefs(
    5351             :     float *coefs,              /* i/o: MDCT coefficients                   */
    5352             :     const int16_t *ynrm,       /* i  : quantization indices for norms      */
    5353             :     const int16_t num_bands,   /* i  : Number of bands                     */
    5354             :     const int16_t *band_start, /* i  : Start of bands                      */
    5355             :     const int16_t *band_end    /* i  : End of bands                        */
    5356             : );
    5357             : 
    5358             : void bitallocsum(
    5359             :     int16_t *R,             /* i  : bit-allocation vector               */
    5360             :     const int16_t nb_sfm,   /* i  : number of sub-vectors               */
    5361             :     int16_t *sum,           /* o  : total number of bits allocated      */
    5362             :     int16_t *Rsubband,      /* o  : rate per subband (Q3)               */
    5363             :     const int16_t num_bits, /* i  : number of bits                      */
    5364             :     const int16_t length,   /* i  : length of spectrum                  */
    5365             :     const int16_t *sfmsize  /* i  : Length of bands                     */
    5366             : );
    5367             : 
    5368             : void hq_generic_hf_encoding(
    5369             :     const float *coefs,              /* i  : MDCT coefficients of weighted original      */
    5370             :     float *hq_generic_fenv,          /* i/o: energy of SWB envelope                      */
    5371             :     const int16_t hq_generic_offset, /* i  : frequency offset for extracting energy      */
    5372             :     Encoder_State *st,               /* i/o: encoder state structure                     */
    5373             :     int16_t *hq_generic_exc_clas,    /* o  : HF excitation class                         */
    5374             :     const int16_t length             /* i  : Length of spectrum                          */
    5375             : );
    5376             : 
    5377             : /*! r: BWE class */
    5378             : int16_t swb_bwe_gain_deq(
    5379             :     Decoder_State *st,       /* i/o: decoder state structure                     */
    5380             :     const int16_t core,      /* i  : core                                        */
    5381             :     float *SWB_tenv,         /* o  : time-domain BWE envelope                    */
    5382             :     float *SWB_fenv,         /* o  : frequency-domain BWE envelope               */
    5383             :     const int16_t hr_flag,   /* i  : high rate flag                              */
    5384             :     const int16_t hqswb_clas /* i  : HQ BWE class                                */
    5385             : );
    5386             : 
    5387             : void save_old_syn(
    5388             :     const int16_t L_frame,    /* i  : frame length                                */
    5389             :     const float syn[],        /* i  : ACELP synthesis                             */
    5390             :     float old_syn[],          /* o  : old synthesis buffer                        */
    5391             :     float old_syn_12k8_16k[], /* i/o: old synthesis buffer                        */
    5392             :     const float preemph_fac,  /* i  : preemphasis factor                          */
    5393             :     float *mem_deemph         /* i/o: deemphasis filter memory                    */
    5394             : );
    5395             : 
    5396             : void hq_generic_hf_decoding(
    5397             :     const int16_t HQ_mode,             /* i  : HQ mode                                     */
    5398             :     float *coeff_out1,                 /* i/o: BWE input & temporary buffer                */
    5399             :     const float *hq_generic_fenv,      /* i  : SWB frequency envelopes                     */
    5400             :     float *coeff_out,                  /* o  : SWB signal in MDCT domain                   */
    5401             :     const int16_t hq_generic_offset,   /* i  : frequency offset for representing hq swb bwe*/
    5402             :     int16_t *prev_L_swb_norm,          /* i/o: last normalize length                       */
    5403             :     const int16_t hq_swb_bwe_exc_clas, /* i  : bwe excitation class                        */
    5404             :     const int16_t *R );
    5405             : 
    5406             : void hq_core_dec(
    5407             :     Decoder_State *st,                 /* i/o: decoder state structure                 */
    5408             :     float out[],                       /* o  : output synthesis                        */
    5409             :     const int16_t output_frame,        /* i  : output frame length                     */
    5410             :     const int16_t hq_core_type,        /* i  : HQ core type                            */
    5411             :     const int16_t core_switching_flag, /* i  : ACELP->HQ switching frame flag          */
    5412             :     float *output                      /* o  : LB synthesis in case of ACELP-HQ switch */
    5413             : );
    5414             : 
    5415             : void IMDCT(
    5416             :     float *x,
    5417             :     float *old_syn_overl,
    5418             :     float *syn_Overl_TDAC,
    5419             :     float *xn_buf,
    5420             :     const float *tcx_aldo_window_1_trunc,
    5421             :     const float *tcx_aldo_window_2,
    5422             :     const float *tcx_mdct_window_half,
    5423             :     const float *tcx_mdct_window_minimum,
    5424             :     const float *tcx_mdct_window_trans,
    5425             :     const int16_t tcx_mdct_window_half_length,
    5426             :     const int16_t tcx_mdct_window_min_length,
    5427             :     int16_t index,
    5428             :     const uint16_t kernel_type, /* i  : TCX transform kernel type               */
    5429             :     const int16_t left_rect,
    5430             :     const int16_t tcx_offset,
    5431             :     const int16_t overlap,
    5432             :     const int16_t L_frame,
    5433             :     const int16_t L_frameTCX,
    5434             :     const int16_t L_spec_TCX5,
    5435             :     const int16_t L_frame_glob,
    5436             :     const int16_t frame_cnt,
    5437             :     const int16_t bfi,
    5438             :     float *old_out,
    5439             :     const int16_t FB_flag,
    5440             :     Decoder_State *st,
    5441             :     const int16_t fullband,
    5442             :     float *acelp_zir );
    5443             : 
    5444             : void hq_hr_dec(
    5445             :     Decoder_State *st,                /* i/o: decoder state structure         */
    5446             :     float *t_audio_q,                 /* o  : transform-domain coefficients   */
    5447             :     const int16_t length,             /* i  : frame length                    */
    5448             :     const int16_t num_bits,           /* i  : number of available bits        */
    5449             :     int16_t *ynrm,                    /* o  : norm quantization index vector  */
    5450             :     int16_t *is_transient,            /* o  : transient flag                  */
    5451             :     int16_t *hqswb_clas,              /* o  : HQ SWB class                    */
    5452             :     float *SWB_fenv,                  /* o  : SWB frequency envelopes         */
    5453             :     const int16_t core_switching_flag /* i  : Core switching flag             */
    5454             : 
    5455             : );
    5456             : 
    5457             : void hdecnrm_context(
    5458             :     Decoder_State *st, /* i/o: decoder state structure                 */
    5459             :     const int16_t N,   /* i  : number of norms                         */
    5460             :     int16_t *index,    /* o  : indices of quantized norms              */
    5461             :     int16_t *n_length  /* o  : decoded stream length                   */
    5462             : );
    5463             : 
    5464             : void hdecnrm_tran(
    5465             :     Decoder_State *st, /* i/o: decoder state structure     */
    5466             :     const int16_t N,   /* i  : number of norms             */
    5467             :     int16_t *index     /* o  : indices of quantized norms  */
    5468             : );
    5469             : 
    5470             : void hdecnrm_resize(
    5471             :     Decoder_State *st, /* i/o: decoder state structure                 */
    5472             :     const int16_t N,   /* i  : number of SFMs                          */
    5473             :     int16_t *index     /* o  : norm quantization index vector          */
    5474             : );
    5475             : 
    5476             : void hdecnrm(
    5477             :     Decoder_State *st, /* i/o: decoder state structure                 */
    5478             :     const int16_t N,   /* i  : number of norms                         */
    5479             :     int16_t *index     /* o  : indices of quantized norms              */
    5480             : );
    5481             : 
    5482             : /*! r: index of last band */
    5483             : int16_t find_last_band(
    5484             :     const int16_t *bitalloc, /* i  : bit allocation                          */
    5485             :     const int16_t nb_sfm     /* i  : number of possibly coded bands          */
    5486             : );
    5487             : 
    5488             : void fill_spectrum(
    5489             :     float *coeff,                      /* i/o: normalized MLT spectrum / nf spectrum                 */
    5490             :     int16_t *R,                        /* i  : number of pulses per band                             */
    5491             :     const int16_t is_transient,        /* i  : transient flag                                        */
    5492             :     int16_t norm[],                    /* i  : quantization indices for norms                        */
    5493             :     const float *hq_generic_fenv,      /* i  : HQ GENERIC envelope                                   */
    5494             :     const int16_t hq_generic_offset,   /* i  : HQ GENERIC offset                                     */
    5495             :     const int16_t nf_idx,              /* i  : noise fill index                                      */
    5496             :     const int16_t length,              /* i  : Length of spectrum (32 or 48 kHz)                     */
    5497             :     const float env_stab,              /* i  : Envelope stability measure [0..1]                     */
    5498             :     int16_t *no_att_hangover,          /* i/o: Frame counter for attenuation hangover                */
    5499             :     float *energy_lt,                  /* i/o: Long-term energy measure for transient detection      */
    5500             :     int16_t *bwe_seed,                 /* i/o: random seed for generating BWE input                  */
    5501             :     const int16_t hq_generic_exc_clas, /* i  : HF excitation class                                   */
    5502             :     const int16_t core_sfm,            /* i  : index of the end band for core                        */
    5503             :     int16_t HQ_mode,                   /* i  : HQ mode                                               */
    5504             :     float noise_level[],               /* i  : noise level for harmonic modes                        */
    5505             :     int32_t core_brate,                /* i  : target bitrate                                        */
    5506             :     float prev_noise_level[],          /* i/o: noise factor in previous frame                        */
    5507             :     int16_t *prev_R,                   /* i/o: bit allocation info. in previous frame                */
    5508             :     float *prev_coeff_out,             /* i/o: decoded spectrum in previous frame                    */
    5509             :     const int16_t *peak_idx,           /* i  : peak positions                                        */
    5510             :     const int16_t Npeaks,              /* i  : number of peaks                                       */
    5511             :     const int16_t *npulses,            /* i  : Number of assigned pulses per band                    */
    5512             :     int16_t prev_is_transient,         /* i  : previous transient flag                               */
    5513             :     float *prev_normq,                 /* i  : previous norms                                        */
    5514             :     float *prev_env,                   /* i  : previous noise envelopes                              */
    5515             :     int16_t prev_bfi,                  /* i  : previous bad frame indicator                          */
    5516             :     const int16_t *sfmsize,            /* i  : Length of bands                                       */
    5517             :     const int16_t *sfm_start,          /* i  : Start of bands                                        */
    5518             :     const int16_t *sfm_end,            /* i  : End of bands                                          */
    5519             :     int16_t *prev_L_swb_norm,          /* i/o: last normalize length for harmonic mode               */
    5520             :     int16_t prev_hq_mode,              /* i  : previous HQ mode                                      */
    5521             :     const int16_t num_sfm,             /* i  : Number of bands                                       */
    5522             :     const int16_t num_env_bands,       /* i  : Number of envelope bands                              */
    5523             :     const int16_t element_mode         /* i  : element mode                                          */
    5524             : );
    5525             : 
    5526             : void env_stab_transient_detect(
    5527             :     const int16_t is_transient, /* i  : Transient flag                                        */
    5528             :     const int16_t length,       /* i  : Length of spectrum (32 or 48 kHz)                     */
    5529             :     const int16_t norm[],       /* i  : quantization indices for norms                        */
    5530             :     int16_t *no_att_hangover,   /* i/o: Frame counter for attenuation hangover                */
    5531             :     float *energy_lt,           /* i/o: Long-term energy measure for transient detection      */
    5532             :     const int16_t HQ_mode,      /* i  : HQ coding mode                                        */
    5533             :     const int16_t bin_th,       /* i  : HVQ cross-over frequency bin                          */
    5534             :     const float *coeff          /* i  : Coded spectral coefficients                           */
    5535             : );
    5536             : 
    5537             : void de_interleave_spectrum(
    5538             :     float *coefs,  /* i/o: input and output coefficients   */
    5539             :     int16_t length /* i  : length of spectrum              */
    5540             : );
    5541             : 
    5542             : void inverse_transform(
    5543             :     const float *InMDCT,       /* i  : input MDCT vector               */
    5544             :     float *Out,                /* o  : output vector                   */
    5545             :     const int16_t IsTransient, /* i  : transient flag                  */
    5546             :     const int16_t L,           /* i  : output frame length             */
    5547             :     const int16_t L_inner,     /* i  : length of the transform         */
    5548             :     const int16_t element_mode /* i  : IVAS element mode   */
    5549             : );
    5550             : 
    5551             : void window_ola(
    5552             :     const float *ImdctOut, /* i  : input                           */
    5553             :     float *auOut,          /* o  : output audio                    */
    5554             :     float *OldauOut,       /* i/o: audio from previous frame       */
    5555             :     const int16_t L,       /* i  : length                          */
    5556             :     const int16_t right_mode,
    5557             :     const int16_t left_mode,    /* i  : window overlap of current frame (0: full, 2: none, or 3: half) */
    5558             :     const int16_t use_bfi_win,  /* i  : use BFI windowing               */
    5559             :     const int16_t oldHqVoicing, /* i  : previous HqVoicing              */
    5560             :     float *oldgapsynth          /* i  : previous gapsynth               */
    5561             : );
    5562             : 
    5563             : void window_ola_ext(
    5564             :     const float *ImdstOut, /* i  : input                       */
    5565             :     float *auOut,          /* o  : output audio                */
    5566             :     float *OldauOut,       /* i/o: audio from previous frame   */
    5567             :     const int16_t L,       /* i  : length                      */
    5568             :     const int16_t right_mode,
    5569             :     const int16_t left_mode,   /* i  : window overlap of current frame (0: full, 2: none, or 3: half) */
    5570             :     const uint16_t kernel_type /* i  : transform kernel type  */
    5571             : );
    5572             : 
    5573             : void map_quant_weight(
    5574             :     const int16_t normqlg2[],  /* i  : quantized norms                 */
    5575             :     int16_t wnorm[],           /* o  : weighted norm                   */
    5576             :     const int16_t is_transient /* i  : transient flag                  */
    5577             : );
    5578             : 
    5579             : void recovernorm(
    5580             :     const int16_t *const idxbuf, /* i  : reordered quantization indices */
    5581             :     int16_t *ynrm,               /* o  : recovered quantization indices */
    5582             :     int16_t *normqlg2,           /* o  : recovered quantized norms      */
    5583             :     const int16_t nb_sfm         /* i  : number of subbands             */
    5584             : );
    5585             : 
    5586             : void reordvct(
    5587             :     int16_t *y,      /* i/o: vector to rearrange    */
    5588             :     const int16_t N, /* i  : dimensions             */
    5589             :     int16_t *idx     /* o  : reordered vector index */
    5590             : );
    5591             : 
    5592             : void bitalloc(
    5593             :     int16_t *y,              /* i  : reordered norm of sub-vectors           */
    5594             :     int16_t *idx,            /* i  : reordered sub-vector indices            */
    5595             :     int16_t sum,             /* i  : number of available bits                */
    5596             :     int16_t N,               /* i  : number of norms                         */
    5597             :     int16_t K,               /* i  : maximum number of bits per dimension    */
    5598             :     int16_t *r,              /* o  : bit-allacation vector                   */
    5599             :     const int16_t *sfmsize,  /* i  : Length of bands                         */
    5600             :     const int16_t hqswb_clas /* i  : signal classification flag              */
    5601             : );
    5602             : 
    5603             : /*! r: Integer (truncated) number of allocated bits */
    5604             : int16_t BitAllocF(
    5605             :     int16_t *y,                 /* i  : norm of sub-vectors                     */
    5606             :     int32_t bit_rate,           /* i  : bitrate                                 */
    5607             :     int16_t B,                  /* i  : number of available bits                */
    5608             :     int16_t N,                  /* i  : number of sub-vectors                   */
    5609             :     int16_t *R,                 /* o  : bit-allocation indicator                */
    5610             :     int16_t *Rsubband,          /* o  : sub-band bit-allocation vector (Q3)     */
    5611             :     const int16_t hqswb_clas,   /* i  : hq swb class                            */
    5612             :     const int16_t num_env_bands /* i  : Number sub bands to be encoded for HQ_SWB_BWE  */
    5613             : );
    5614             : 
    5615             : /*! r: Integer (truncated) number of allocated bits */
    5616             : int16_t BitAllocWB(
    5617             :     int16_t *y,          /* i  : norm of sub-vectors                     */
    5618             :     int16_t B,           /* i  : number of available bits                */
    5619             :     int16_t N,           /* i  : number of sub-vectors                   */
    5620             :     int16_t *R,          /* o  : bit-allocation indicator                */
    5621             :     int16_t *Rsubband ); /* o  : sub-band bit-allocation vector (Q3)     */
    5622             : 
    5623             : /*! r: Number of low frequency bands */
    5624             : int16_t hvq_pvq_bitalloc(
    5625             :     int16_t num_bits,         /* i/o: Number of available bits (including gain bits) */
    5626             :     const int32_t core_brate, /* i  : bitrate                     */
    5627             :     const int16_t bwidth,     /* i  : Encoded bandwidth           */
    5628             :     const int16_t *ynrm,      /* i  : Envelope coefficients       */
    5629             :     const int32_t manE_peak,  /* i  : Peak energy mantissa        */
    5630             :     const int16_t expE_peak,  /* i  : Peak energy exponent        */
    5631             :     int16_t *Rk,              /* o  : bit allocation for concatenated vector */
    5632             :     int16_t *R,               /* i/o: Global bit allocation       */
    5633             :     int16_t *sel_bands,       /* o  : Selected bands for encoding */
    5634             :     int16_t *n_sel_bands      /* o  : No. of selected bands for encoding */
    5635             : );
    5636             : 
    5637             : void floating_point_add(
    5638             :     int32_t *mx,      /* i/o: mantissa of the addend Q31    */
    5639             :     int16_t *ex,      /* i/o: exponent of the addend Q0     */
    5640             :     const int32_t my, /* i  :  mantissa of the adder Q31    */
    5641             :     const int16_t ey  /* i  :  exponent of the adder Q0     */
    5642             : );
    5643             : 
    5644             : /*! r: Number of bits needed */
    5645             : int16_t rc_get_bits2(
    5646             :     const int16_t N,     /* i  : Number of bits currently used */
    5647             :     const uint32_t range /* i  : Range of range coder          */
    5648             : );
    5649             : 
    5650             : void rc_enc_init(
    5651             :     PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle            */
    5652             :     int16_t tot_bits     /* i  : Total bit budget              */
    5653             : );
    5654             : 
    5655             : void rc_encode(
    5656             :     BSTR_ENC_HANDLE hBstr,   /* i/o: encoder bitstream handle            */
    5657             :     PVQ_ENC_HANDLE hPVQ,     /* i/o: PVQ encoder handle                  */
    5658             :     const uint32_t cum_freq, /* i  : Cumulative frequency up to symbol   */
    5659             :     const uint32_t sym_freq, /* i  : Symbol probability                  */
    5660             :     const uint32_t tot       /* i  : Total cumulative frequency          */
    5661             : );
    5662             : 
    5663             : void rc_enc_finish(
    5664             :     BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle  */
    5665             :     PVQ_ENC_HANDLE hPVQ    /* i/o: PVQ encoder handle        */
    5666             : );
    5667             : 
    5668             : void rc_enc_bits(
    5669             :     BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle  */
    5670             :     PVQ_ENC_HANDLE hPVQ,   /* i/o: PVQ encoder handle        */
    5671             :     const uint32_t value,  /* i  : Value to encode           */
    5672             :     const int16_t bits     /* i  : Number of bits used       */
    5673             : );
    5674             : 
    5675             : void rc_enc_uniform(
    5676             :     BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle  */
    5677             :     PVQ_ENC_HANDLE hPVQ,   /* i/o: PVQ encoder handle        */
    5678             :     uint32_t value,        /* i  : Value to encode           */
    5679             :     uint32_t tot           /* i  : Maximum value             */
    5680             : );
    5681             : 
    5682             : void rc_dec_init(
    5683             :     Decoder_State *st,   /* i/o: Decoder State       */
    5684             :     PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle  */
    5685             :     int16_t tot_bits     /* i  : Total bit budget    */
    5686             : );
    5687             : 
    5688             : /*! r: Decoded value */
    5689             : uint32_t rc_decode(
    5690             :     int16_t *BER_detect, /* o  : Bit error detection flag        */
    5691             :     PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle              */
    5692             :     uint32_t tot         /* i  : Total cumulative frequency      */
    5693             : );
    5694             : 
    5695             : void rc_dec_update(
    5696             :     Decoder_State *st,       /* i/o: Decoder State           */
    5697             :     PVQ_DEC_HANDLE hPVQ,     /* i/o: PVQ decoder handle      */
    5698             :     const uint32_t cum_freq, /* i  : Cumulative frequency    */
    5699             :     const uint32_t sym_freq  /* i  : Symbol frequency        */
    5700             : );
    5701             : 
    5702             : /*! r: Decoded value   */
    5703             : uint32_t rc_dec_bits(
    5704             :     Decoder_State *st,   /* i/o: Decoder State          */
    5705             :     PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle     */
    5706             :     const int16_t bits   /* i  : Number of bits         */
    5707             : );
    5708             : 
    5709             : /*! r: Decoded value   */
    5710             : uint32_t rc_dec_uniform(
    5711             :     Decoder_State *st,   /* i/o: Decoder State          */
    5712             :     PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle     */
    5713             :     const uint32_t tot   /* i  : Maximum value          */
    5714             : );
    5715             : 
    5716             : void rc_dec_finish(
    5717             :     Decoder_State *st,  /* i/o: decoder state structure */
    5718             :     PVQ_DEC_HANDLE hPVQ /* i/o: PVQ decoder handle      */
    5719             : );
    5720             : 
    5721             : /*! r: number of bits encoded */
    5722             : int16_t pvq_core_enc(
    5723             :     BSTR_ENC_HANDLE hBstr,    /* i/o: encoder bitstream handle          */
    5724             :     float coefs_norm[],       /* i/o: normalized coefficients to encode */
    5725             :     float coefs_quant[],      /* o  : quantized coefficients            */
    5726             :     const int16_t bits_tot,   /* i  : total number of bits              */
    5727             :     const int16_t nb_sfm,     /* i  : number of bands                   */
    5728             :     const int16_t *sfm_start, /* i  : Subband start coefficient         */
    5729             :     const int16_t *sfm_end,   /* i  : Subband end coefficient           */
    5730             :     const int16_t *sfmsize,   /* i  : subband width                     */
    5731             :     int16_t *R,               /* i/o: Bit allocation/Adjusted bit alloc. (Q3) */
    5732             :     int16_t *Rs,              /* i/o: Integer bit allocation            */
    5733             :     int16_t *npulses,         /* o  : number of pulses                  */
    5734             :     int16_t *maxpulse,        /* i  : maximum pulse per band            */
    5735             :     const int16_t core        /* i  : number of bands                   */
    5736             : );
    5737             : 
    5738             : /*! r: number of bits decoded  */
    5739             : int16_t pvq_core_dec(
    5740             :     Decoder_State *st,        /* i/o: Decoder state                        */
    5741             :     const int16_t *sfm_start, /* i  : indices of first coeffs in the bands */
    5742             :     const int16_t *sfm_end,   /* i  : indices of last coeffs in the bands  */
    5743             :     const int16_t *sfmsize,   /* i  : band sizes                           */
    5744             :     float coefs_quant[],      /* o  : output MDCT                          */
    5745             :     const int16_t bits_tot,   /* i  : bit budget                           */
    5746             :     const int16_t nb_sfm,     /* i  : number of bands                      */
    5747             :     int16_t *R,               /* i/o: Bit allocation/Adjusted bit alloc.(Q3) */
    5748             :     int16_t *Rs,              /* i/o: Integer bit allocation               */
    5749             :     int16_t *npulses,         /* o  : number of pulses per band            */
    5750             :     int16_t *maxpulse,        /* o  : maximum pulse per band               */
    5751             :     const int16_t core        /* i  : core                                 */
    5752             : );
    5753             : 
    5754             : void pvq_encode(
    5755             :     BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle             */
    5756             :     PVQ_ENC_HANDLE hPVQ,   /* i/o: PVQ encoder handle                   */
    5757             :     const float *x,        /* i  : vector to quantize                   */
    5758             :     int16_t *y,            /* o  : quantized vector (non-scaled integer)*/
    5759             :     float *xq,             /* o  : quantized vector (scaled float)      */
    5760             :     const int16_t pulses,  /* i  : number of allocated pulses           */
    5761             :     const int16_t N,       /* i  : Length of vector                     */
    5762             :     const float gain       /* i  : Gain                                 */
    5763             : );
    5764             : 
    5765             : void pvq_decode(
    5766             :     Decoder_State *st,   /* i/o: Decoder State                    */
    5767             :     PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle               */
    5768             :     float *xq,           /* o  : decoded vector (scaled float)    */
    5769             :     int16_t *y,          /* o  : decoded vector (non-scaled short)*/
    5770             :     const int16_t K,     /* i  : number of allocated pulses       */
    5771             :     const int16_t N,     /* i  : Length of vector                 */
    5772             :     const float gain     /* i  : Gain                             */
    5773             : );
    5774             : 
    5775             : void rangeCoderFinalizationFBits(
    5776             :     const int16_t Brc,    /*  i  : Current number of decoded bits */
    5777             :     const uint32_t INTrc, /*  i  : Range coder state              */
    5778             :     int16_t *FBits        /*  i  : Fractional finalization bits   */
    5779             : );
    5780             : 
    5781             : void bandBitsAdjustment(
    5782             :     const int16_t Brc,     /* i  : Current number of read quanta in range coder */
    5783             :     const uint32_t INTrc,  /* i  : Range coder state                            */
    5784             :     const int16_t Bavail,  /* i  : Available number of quanta                   */
    5785             :     const int16_t Nbands,  /* i  : Number of bands                              */
    5786             :     const int16_t D,       /* i  : Remaining number of bands to encode          */
    5787             :     const int16_t L,       /* i  : Size of current band                         */
    5788             :     const int16_t Bband,   /* i  : Quanta allocation for current band           */
    5789             :     const int16_t Breserv, /* i  : Quanta reservoir                             */
    5790             :     int16_t *Bband_adj,    /* o  : Actual used number of quanta                 */
    5791             :     int16_t *Brem,         /* o  : Quanta remaining                             */
    5792             :     int16_t *Breservplus   /* o  : Quanta pool size                             */
    5793             : );
    5794             : 
    5795             : void conservativeL1Norm(
    5796             :     const int16_t L,       /* i  : Length of vector segment      */
    5797             :     const int16_t Qvec,    /* i  : Assigned number of quanta     */
    5798             :     const int16_t Fcons,   /* i  : Conservative rounding flag    */
    5799             :     const int16_t Qavail,  /* i  : Input quanta remaining        */
    5800             :     const int16_t Qreserv, /* i  : Input quanta in reservoir     */
    5801             :     const int16_t Dspec,   /* i  : assigned diracs from bitalloc */
    5802             :     int16_t *Dvec,         /* o  : actual number of diracs       */
    5803             :     int16_t *Qspare,       /* o  : Output quanta remaining       */
    5804             :     int16_t *Qreservplus,  /* o  : Output quanta in reservoir    */
    5805             :     int16_t *Dspecplus     /* o  : Output number of diracs       */
    5806             : );
    5807             : 
    5808             : void NearOppSplitAdjustment(
    5809             :     const int16_t qband,    /* i  : quanta for current band         */
    5810             :     const int16_t qzero,    /* i  : range coder finalization quanta */
    5811             :     const int16_t Qac,      /* i  : range coder current quanta      */
    5812             :     const uint32_t INTac,   /* i  : range coder state               */
    5813             :     const int16_t qglobal,  /* i  : quanta input                    */
    5814             :     const int16_t FlagCons, /* i  : conservative rounding flag      */
    5815             :     const int16_t Np,       /* i  : number of parts                 */
    5816             :     const int16_t Nhead,    /* i  : first part                      */
    5817             :     const int16_t Ntail,    /* i  : remaining parts                 */
    5818             :     const int16_t Nnear,    /* i  : length of near component        */
    5819             :     const int16_t Nopp,     /* i  : length of opposite component    */
    5820             :     int16_t oppRQ3,         /* i  : ratio                           */
    5821             :     int16_t *qnear,         /* o  : quantized near                  */
    5822             :     int16_t *qopp,          /* o  : quantized opposite              */
    5823             :     int16_t *qglobalupd     /* o  : quanta remaining                */
    5824             : );
    5825             : 
    5826             : /*! r: Approximate integer division for positive input */
    5827             : int32_t intLimCDivPos(
    5828             :     const int32_t NUM, /* i  : numerator   */
    5829             :     const int16_t DEN  /* i  : denominator */
    5830             : );
    5831             : 
    5832             : /*! r: Approximate integer division */
    5833             : int16_t shrtCDivSignedApprox(
    5834             :     const int16_t num, /* i  : numerator   */
    5835             :     const int16_t den  /* i  : denominator */
    5836             : );
    5837             : 
    5838             : void QuantaPerDsDirac(
    5839             :     const int16_t td,                  /* i  : Length of vector segment   */
    5840             :     const int16_t dsDiracIndex,        /* i  : Quanta table index         */
    5841             :     const uint8_t *const *dimFrQuanta, /* i  : Quanta lookup table        */
    5842             :     int16_t *Quanta                    /* i  : Quanta                     */
    5843             : );
    5844             : 
    5845             : void obtainEnergyQuantizerDensity(
    5846             :     const int16_t L_in, /* i  : left vector energy  */
    5847             :     const int16_t R_in, /* i  : right vector energy */
    5848             :     int16_t *Density    /* o  : quantizer density   */
    5849             : );
    5850             : 
    5851             : void densityAngle2RmsProjDec(
    5852             :     const int16_t D,        /* i  : density                   */
    5853             :     const int16_t indexphi, /* i  : decoded index from AR dec */
    5854             :     int16_t *oppQ15,        /* o  : opposite                  */
    5855             :     int16_t *nearQ15,       /* o  : near                      */
    5856             :     int16_t *oppRatioQ3     /* o  : ratio                     */
    5857             : );
    5858             : 
    5859             : void densityAngle2RmsProjEnc(
    5860             :     const int16_t D,        /* i  : density  */
    5861             :     const int16_t phiQ14uq, /* i  : angle    */
    5862             :     int16_t *indexphi,      /* o  : index    */
    5863             :     int16_t *oppQ15,        /* o  : opposite */
    5864             :     int16_t *nearQ15,       /* o  : near     */
    5865             :     int16_t *oppRatioQ3     /* o  : ratio    */
    5866             : );
    5867             : 
    5868             : void env_adj(
    5869             :     const int16_t *pulses,  /* i  : number of pulses per band             */
    5870             :     const int16_t length,   /* i  : length of spectrum                    */
    5871             :     const int16_t last_sfm, /* i  : Index of last band                    */
    5872             :     float *adj,             /* o  : Adjustment factors for the envelope   */
    5873             :     const float env_stab,   /* i  : Envelope stability parameter          */
    5874             :     const int16_t *sfmsize  /* i  : Length of bands                       */
    5875             : );
    5876             : 
    5877             : float env_stability(
    5878             :     const int16_t *ynrm,              /* i  : Norm vector for current frame          */
    5879             :     const int16_t nb_sfm,             /* i  : Number of sub-bands                    */
    5880             :     int16_t *mem_norm,                /* i/o: Norm vector memory from past frame     */
    5881             :     int16_t *mem_env_delta,           /* i/o: Envelope stability memory for smoothing*/
    5882             :     const int16_t core_switching_flag /* i  : Core switching flag             */
    5883             : );
    5884             : 
    5885             : /*! r: New speech/music state */
    5886             : float env_stab_smo(
    5887             :     float env_stab,          /* i  : env_stab value                         */
    5888             :     float *env_stab_state_p, /* i/o: env_stab state probabilities           */
    5889             :     int16_t *ho_cnt          /* i/o: hangover counter for speech state      */
    5890             : );
    5891             : 
    5892             : void core_switching_pre_enc(
    5893             :     Encoder_State *st,              /* i/o: encoder state structure                 */
    5894             :     const float *old_inp_12k8,      /* i  : old input signal @12.8kHz               */
    5895             :     const float *old_inp_16k,       /* i  : old input signal @16kHz                 */
    5896             :     const int16_t active_cnt,       /* i  : Active frame counter                    */
    5897             :     const int16_t last_element_mode /* i  : last_element_mode                       */
    5898             : );
    5899             : 
    5900             : void core_switching_post_enc(
    5901             :     Encoder_State *st,         /* i/o: encoder state structure                 */
    5902             :     const float *old_inp_12k8, /* i  : old input signal @12.8kHz               */
    5903             :     const float *old_inp_16k,  /* i  : old input signal @16kHz                 */
    5904             :     const float A[]            /* i  : unquant LP filter coefs.                */
    5905             : );
    5906             : 
    5907             : ivas_error core_switching_post_dec(
    5908             :     Decoder_State *st,                   /* i/o: decoder state structure                 */
    5909             :     float *synth,                        /* i/o: output synthesis                        */
    5910             :     float *output,                       /* i/o: LB synth/upsampled LB synth             */
    5911             :     float output_mem[],                  /* i  : OLA memory from last TCX/HQ frame       */
    5912             :     const int16_t use_cldfb_for_dft,     /* i  : flag to use of CLDFB for DFT Stereo     */
    5913             :     const int16_t output_frame,          /* i  : frame length                            */
    5914             :     const int16_t core_switching_flag,   /* i  : ACELP->HQ switching frame flag          */
    5915             :     const int16_t sba_dirac_stereo_flag, /* i  : signal stereo output for SBA DirAC      */
    5916             :     const int16_t nchan_out,             /* i  : number of output channels               */
    5917             :     const int16_t last_element_mode      /* i  : element mode of previous frame          */
    5918             : );
    5919             : 
    5920             : ivas_error core_switching_pre_dec(
    5921             :     Decoder_State *st,                 /* i/o: decoder state structure              */
    5922             :     const int16_t output_frame,        /* i  : frame length                         */
    5923             :     const int32_t last_core_brate_st0, /* i  : channel 0 last core bitrate          */
    5924             :     const int16_t nchan_out,           /* i  : number of output channels            */
    5925             :     const int16_t last_element_mode,   /* i  : last_element_mode                    */
    5926             :     const int32_t last_element_brate   /* i  : last element bitrate                 */
    5927             : );
    5928             : 
    5929             : void bandwidth_switching_detect(
    5930             :     Decoder_State *st /* i/o: decoder state structure                 */
    5931             : );
    5932             : 
    5933             : void bw_switching_pre_proc(
    5934             :     Decoder_State *st,                /* i/o: decoder state structure                 */
    5935             :     const float *old_syn_12k8_16k,    /* i  : ACELP core synthesis @ 12.8kHz or 16kHz */
    5936             :     const int32_t last_element_brate, /* i  : last element bitrate                     */
    5937             :     const int16_t nchan_out           /* i  : number of output channels               */
    5938             : );
    5939             : 
    5940             : void updt_bw_switching(
    5941             :     Decoder_State *st, /* i/o: decoder state structure                 */
    5942             :     const float *synth /* i  : float synthesis signal                  */
    5943             : );
    5944             : 
    5945             : void swb_tbe_reset(
    5946             :     float mem_csfilt[],
    5947             :     float mem_genSHBexc_filt_down_shb[],
    5948             :     float state_lpc_syn[],
    5949             :     float syn_overlap[],
    5950             :     float state_syn_shbexc[],
    5951             :     float *tbe_demph,
    5952             :     float *tbe_premph,
    5953             :     float mem_stp_swb[],
    5954             :     float *gain_prec_swb );
    5955             : 
    5956             : void swb_tbe_reset_synth(
    5957             :     float genSHBsynth_Hilbert_Mem[],
    5958             :     float genSHBsynth_state_lsyn_filt_shb_local[] );
    5959             : 
    5960             : void find_td_envelope(
    5961             :     const float inp[],
    5962             :     const int16_t len,
    5963             :     const int16_t len_h,
    5964             :     float mem_h[],
    5965             :     float out[] );
    5966             : 
    5967             : void fb_tbe_reset_enc(
    5968             :     float elliptic_bpf_2_48k_mem[][4],
    5969             :     float *prev_fb_energy );
    5970             : 
    5971             : void fb_tbe_reset_synth(
    5972             :     float fbbwe_hpf_mem[][4],
    5973             :     float *prev_fbbwe_ratio );
    5974             : 
    5975             : void wb_tbe_extras_reset(
    5976             :     float mem_genSHBexc_filt_down_wb2[],
    5977             :     float mem_genSHBexc_filt_down_wb3[] );
    5978             : 
    5979             : void wb_tbe_extras_reset_synth(
    5980             :     float state_lsyn_filt_shb[],
    5981             :     float state_lsyn_filt_dwn_shb[],
    5982             :     float mem_resamp_HB[] );
    5983             : 
    5984             : void tbe_celp_exc(
    5985             :     const int16_t element_mode, /* i  : element mode                            */
    5986             :     const int16_t idchan,       /* i  : channel ID                              */
    5987             :     float *bwe_exc,             /* i/o: BWE excitation                          */
    5988             :     const int16_t L_frame,      /* i  : frame length                            */
    5989             :     const int16_t L_subfr,      /* i  : subframe length                         */
    5990             :     const int16_t i_subfr,      /* i  : subframe index                          */
    5991             :     const int16_t T0,           /* i  : integer pitch lag                       */
    5992             :     const int16_t T0_frac,      /* i  : fraction of lag                         */
    5993             :     float *error,               /* i/o: error                                   */
    5994             :     const int16_t tdm_LRTD_flag /* i  : LRTD stereo mode flag                   */
    5995             : );
    5996             : 
    5997             : void prep_tbe_exc(
    5998             :     const int16_t L_frame,      /* i  : length of the frame                     */
    5999             :     const int16_t L_subfr,      /* i  : subframe length                         */
    6000             :     const int16_t i_subfr,      /* i  : subframe index                          */
    6001             :     const float gain_pit,       /* i  : Pitch gain                              */
    6002             :     const float gain_code,      /* i  : algebraic codebook gain                 */
    6003             :     const float code[],         /* i  : algebraic excitation                    */
    6004             :     const float voice_fac,      /* i  : voicing factor                          */
    6005             :     float *voice_factors,       /* o  : TBE voicing factor                      */
    6006             :     float bwe_exc[],            /* i/o: excitation for TBE                      */
    6007             :     const float gain_preQ,      /* i  : prequantizer excitation gain            */
    6008             :     const float code_preQ[],    /* i  : prequantizer excitation                 */
    6009             :     const int16_t T0,           /* i  : integer pitch variables                 */
    6010             :     const int16_t coder_type,   /* i  : coding type                             */
    6011             :     const int32_t core_brate,   /* i  : core bitrate                            */
    6012             :     const int16_t element_mode, /* i  : element mode                            */
    6013             :     const int16_t idchan,       /* i  : channel ID                              */
    6014             :     const int16_t flag_TD_BWE,  /* i  : flag indicating whether hTD_BWE exists  */
    6015             :     const int16_t tdm_LRTD_flag /* i  : LRTD stereo mode flag                   */
    6016             : );
    6017             : 
    6018             : void synthesise_fb_high_band(
    6019             :     const float excitation_in[], /* i  : full band excitation                    */
    6020             :     float output[],              /* o  : high band speech - 14.0 to 20 kHz       */
    6021             :     const float fb_exc_energy,   /* i  : full band excitation energy             */
    6022             :     const float ratio,           /* i  : energy ratio                            */
    6023             :     const int16_t L_frame,       /* i  : ACELP frame length                      */
    6024             :     const int16_t bfi,           /* i  : BFI flag                                */
    6025             :     float *prev_fbbwe_ratio,     /* o  : previous frame energy for FEC           */
    6026             :     float bpf_memory[][4]        /* i/o: memory for elliptic bpf 48k             */
    6027             : );
    6028             : 
    6029             : void elliptic_bpf_48k_generic(
    6030             :     const float input[],           /* i  : input signal                            */
    6031             :     float output[],                /* o  : output signal                           */
    6032             :     float memory[][4],             /* i/o: 4 arrays for memory                     */
    6033             :     const float full_band_bpf[][5] /* i  : filter coefficients b0,b1,b2,a0,a1,a2   */
    6034             : );
    6035             : 
    6036             : void HQ_FEC_processing(
    6037             :     Decoder_State *st,            /* i/o: decoder state structure                          */
    6038             :     float *t_audio_q,             /* o  : MDCT coeffs. (for synthesis)                     */
    6039             :     int16_t is_transient,         /* i  : Old flag for transient                           */
    6040             :     float ynrm_values[][MAX_PGF], /* i  : Old average Norm values for each group of bands  */
    6041             :     float r_p_values[][MAX_ROW],  /* i  : Computed y-intercept and slope by Regression     */
    6042             :     int16_t num_Sb,               /* i  : Number of sub-band group                         */
    6043             :     int16_t nb_sfm,               /* i  : Number of sub-band                               */
    6044             :     int16_t *Num_bands_p,         /* i  : Number of coeffs. for each sub-band              */
    6045             :     int16_t output_frame,         /* i  : Frame size                                       */
    6046             :     const int16_t *sfm_start,     /* i  : Start of bands                                   */
    6047             :     const int16_t *sfm_end        /* i  : End of bands                                     */
    6048             : );
    6049             : 
    6050             : void HQ_FEC_Mem_update(
    6051             :     Decoder_State *st, /* i/o: decoder state structure            */
    6052             :     const float *t_audio_q,
    6053             :     float *normq,
    6054             :     int16_t *ynrm,
    6055             :     const int16_t *Num_bands_p,
    6056             :     const int16_t is_transient,
    6057             :     const int16_t hqswb_clas,
    6058             :     const int16_t c_switching_flag,
    6059             :     const int16_t nb_sfm,
    6060             :     const int16_t num_Sb,
    6061             :     float *mean_en_high,
    6062             :     const int16_t hq_core_type, /* i  : normal or low-rate MDCT(HQ) core */
    6063             :     const int16_t output_frame  /* i  : Frame size                       */
    6064             : );
    6065             : 
    6066             : void time_domain_FEC_HQ(
    6067             :     Decoder_State *st,         /* i  : Decoder State                           */
    6068             :     float *wtda_audio,         /* i  : input                                   */
    6069             :     float *out,                /* o  : output audio                            */
    6070             :     const float mean_en_high,  /* i  : transient flag                          */
    6071             :     const int16_t output_frame /* i  : Frame size                               */
    6072             : );
    6073             : 
    6074             : void save_synthesis_hq_fec(
    6075             :     Decoder_State *st,          /* i/o: decoder state structure                 */
    6076             :     const float *output,        /* i  : decoded synthesis                       */
    6077             :     const int16_t output_frame, /* i  : decoded synthesis                       */
    6078             :     CPE_DEC_HANDLE hCPE         /* i  : CPE decoder structure                   */
    6079             : );
    6080             : 
    6081             : void Next_good_after_burst_erasures(
    6082             :     const float *ImdctOut, /* i  : input                                   */
    6083             :     float *auOut,          /* o  : output audio                            */
    6084             :     float *OldauOut,       /* i/o: audio from previous frame               */
    6085             :     const int16_t ol_size  /* i  : overlap size                            */
    6086             : );
    6087             : 
    6088             : void update_average_rate(
    6089             :     SC_VBR_ENC_HANDLE hSC_VBR, /* i/o: SC-VBR state structure                  */
    6090             :     const int32_t core_brate   /* i  : core bitrate                            */
    6091             : );
    6092             : 
    6093             : void reset_preecho_dec(
    6094             :     HQ_DEC_HANDLE hHQ_core /* i/o: HQ decoder handle                       */
    6095             : );
    6096             : 
    6097             : void preecho_sb(
    6098             :     const int32_t core_brate,  /* i  : core bitrate                                            */
    6099             :     const float wtda_audio[],  /* i  : imdct signal                                            */
    6100             :     float *rec_sig,            /* i  : reconstructed signal, output of the imdct transform     */
    6101             :     const int16_t framelength, /* i  : frame length                                            */
    6102             :     float *memfilt_lb,         /* i/o: memory                                                  */
    6103             :     float *mean_prev_hb,       /* i/o: memory                                                  */
    6104             :     float *smoothmem,          /* i/o: memory                                                  */
    6105             :     float *mean_prev,          /* i/o: memory                                                  */
    6106             :     float *mean_prev_nc,       /* i/o: memory                                                  */
    6107             :     float *wmold_hb,           /* i/o: memory                                                  */
    6108             :     int16_t *prevflag,         /* i/o: flag                                                    */
    6109             :     int16_t *pastpre,          /* i/o: flag                                                    */
    6110             :     const int16_t bwidth       /* i  : audio bandwidth                                         */
    6111             : );
    6112             : 
    6113             : void hq2_core_configure(
    6114             :     const int16_t frame_length, /* i  : frame length                            */
    6115             :     const int16_t num_bits,     /* i  : number of bits                          */
    6116             :     const int16_t is_transient, /* i  : transient flag                          */
    6117             :     int16_t *bands,
    6118             :     int16_t *length,
    6119             :     int16_t band_width[],
    6120             :     int16_t band_start[],
    6121             :     int16_t band_end[],
    6122             :     Word32 *L_qint,              /* o  : Q29 */
    6123             :     Word16 *eref_fx,             /* o  : Q10 */
    6124             :     Word16 *bit_alloc_weight_fx, /* o  : Q13 */
    6125             :     int16_t *gqlevs,
    6126             :     int16_t *Ngq,
    6127             :     int16_t *p2a_bands,
    6128             :     float *p2a_th,
    6129             :     float *pd_thresh,
    6130             :     float *ld_slope,
    6131             :     float *ni_coef,
    6132             :     float *ni_pd_th,
    6133             :     int32_t bwe_br );
    6134             : 
    6135             : void hq_lr_enc(
    6136             :     Encoder_State *st,         /* i/o: encoder state structure                 */
    6137             :     float t_audio[],           /* i/o: transform-domain coefs.                 */
    6138             :     const int16_t inner_frame, /* i  : inner frame length                      */
    6139             :     int16_t *num_bits,         /* i/o: number of available bits                */
    6140             :     const int16_t is_transient /* i  : transient flag                          */
    6141             : );
    6142             : 
    6143             : void hq_lr_dec(
    6144             :     Decoder_State *st,         /* i/o: decoder state structure                 */
    6145             :     float yout[],              /* o  : transform-domain output coefs.          */
    6146             :     const int16_t inner_frame, /* i  : inner frame length                      */
    6147             :     int16_t num_bits,          /* i  : number of available bits                */
    6148             :     int16_t *is_transient      /* o  : transient flag                          */
    6149             : );
    6150             : 
    6151             : void hq2_bit_alloc(
    6152             :     const float band_energy[],  /* i  : band energy of each subband                 */
    6153             :     const int16_t bands,        /* i  : total number of subbands in a frame         */
    6154             :     Word32 L_Rk[],              /* i/o: Bit allocation/Adjusted bit alloc.          */
    6155             :     int16_t *bit_budget,        /* i/o: bit bugdet                                  */
    6156             :     int16_t *p2a_flags,         /* i  : HF tonal indicator                          */
    6157             :     const Word16 weight_fx,     /* i  : weight (Q13)                                */
    6158             :     const int16_t band_width[], /* i  : Sub band bandwidth                          */
    6159             :     const int16_t num_bits,     /* i  : available bits                              */
    6160             :     const int16_t hqswb_clas,   /* i  : HQ2 class information                       */
    6161             :     const int16_t bwidth,       /* i  : input bandwidth                             */
    6162             :     const int16_t is_transient  /* i  : indicator HQ_TRANSIENT or not               */
    6163             : );
    6164             : 
    6165             : void hq2_noise_inject(
    6166             :     float y2hat[],
    6167             :     const int16_t band_start[],
    6168             :     const int16_t band_end[],
    6169             :     const int16_t band_width[],
    6170             :     float Ep[],
    6171             :     float Rk[],
    6172             :     const int16_t npulses[],
    6173             :     int16_t ni_seed,
    6174             :     const int16_t bands,
    6175             :     const int16_t ni_start_band,
    6176             :     const int16_t bw_low,
    6177             :     const int16_t bw_high,
    6178             :     const float enerL,
    6179             :     const float enerH,
    6180             :     float last_ni_gain[],
    6181             :     float last_env[],
    6182             :     int16_t *last_max_pos_pulse,
    6183             :     int16_t *p2a_flags,
    6184             :     int16_t p2a_bands,
    6185             :     const int16_t hqswb_clas,
    6186             :     const int16_t bwidth,
    6187             :     const int32_t bwe_br );
    6188             : 
    6189             : void mdct_spectrum_denorm(
    6190             :     const int32_t inp_vector[],
    6191             :     float y2[],
    6192             :     const int16_t band_start[],
    6193             :     const int16_t band_end[],
    6194             :     const int16_t band_width[],
    6195             :     const float band_energy[],
    6196             :     const int16_t npulses[],
    6197             :     const int16_t bands,
    6198             :     const float ld_slope,
    6199             :     const float pd_thresh );
    6200             : 
    6201             : void reverse_transient_frame_energies(
    6202             :     float band_energy[], /* o  : band energies                           */
    6203             :     const int16_t bands  /* i  : number of bands                         */
    6204             : );
    6205             : 
    6206             : int16_t peak_vq_enc(
    6207             :     BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle    */
    6208             :     const int16_t bwidth,  /* i  : audio bandwidth             */
    6209             : #ifdef DEBUGGING
    6210             :     const int16_t idchan, /* i  : channel ID                  */
    6211             : #endif
    6212             :     const float *coefs,       /* i  : Input coefficient vector    */
    6213             :     float *coefs_out,         /* o  : Quantized output vector     */
    6214             :     const int32_t core_brate, /* i  : Core bitrate                */
    6215             :     const int16_t num_bits,   /* i  : Number of bits for HVQ      */
    6216             :     const int16_t vq_peaks,   /* i  : Number of identified peaks  */
    6217             :     const int16_t *ynrm,      /* i  : Envelope coefficients       */
    6218             :     int16_t *R,               /* i/o: Bit allocation/updated bit allocation */
    6219             :     int16_t *vq_peak_idx,     /* i  : Peak index vector           */
    6220             :     float *nf_gains           /* i  : Estimated noise floor gains */
    6221             : );
    6222             : 
    6223             : void hvq_dec(
    6224             :     Decoder_State *st,        /* i/o: decoder state structure                */
    6225             :     const int16_t num_bits,   /* i  : Number of available bits               */
    6226             :     const int32_t core_brate, /* i  : Core bitrate                           */
    6227             :     const int16_t *ynrm,      /* i  : Envelope coefficients                  */
    6228             :     int16_t *R,               /* i/o: Bit allocation/updated bit allocation  */
    6229             :     float *noise_level,       /* o  : Noise level                            */
    6230             :     int16_t *peak_idx,        /* o  : Peak position vector                   */
    6231             :     int16_t *Npeaks,          /* o  : Total number of peaks                  */
    6232             :     float *coefsq_norm,       /* o  : Output vector                          */
    6233             :     const int16_t core        /* i  : Core                                   */
    6234             : );
    6235             : 
    6236             : void hq_configure_bfi(
    6237             :     int16_t *nb_sfm,           /* o  : Number of sub bands               */
    6238             :     int16_t *num_Sb,           /* o  : Number of FEC sub bands ?         */
    6239             :     int16_t *num_bands_p,      /* o  : FEC sub bands                     */
    6240             :     const int16_t **sfmsize,   /* o  : Subband bandwidths                */
    6241             :     const int16_t **sfm_start, /* o  : Subband start coefficients        */
    6242             :     const int16_t **sfm_end    /* o  : Subband end coefficients          */
    6243             : );
    6244             : 
    6245             : void swb_bwe_enc_lr(
    6246             :     Encoder_State *st,         /* i/o: encoder state structure     */
    6247             :     const float m_core[],      /* i  : core synthesis (MDCT)       */
    6248             :     const float m_orig[],      /* i/o: scaled orig signal (MDCT)   */
    6249             :     float m[],                 /* o  : output, SWB part (MDCT)     */
    6250             :     const int32_t total_brate, /* i  : total bitrate for selecting subband pattern */
    6251             :     int16_t BANDS,
    6252             :     int16_t *band_start,
    6253             :     int16_t *band_end,
    6254             :     float *band_energy,
    6255             :     int16_t *p2a_flags,
    6256             :     const int16_t hqswb_clas,
    6257             :     int16_t lowlength,
    6258             :     int16_t highlength,
    6259             :     int16_t *prev_frm_index,
    6260             :     const int16_t har_bands,
    6261             :     int16_t *prev_frm_hfe2,
    6262             :     int16_t *prev_stab_hfe2,
    6263             :     int16_t band_width[],
    6264             :     const float y2_ni[],
    6265             :     int16_t *ni_seed );
    6266             : 
    6267             : void swb_bwe_dec_lr(
    6268             :     Decoder_State *st,         /* i/o: decoder state structure                     */
    6269             :     const float m_core[],      /* i  : lowband synthesis                           */
    6270             :     float m[],                 /* o  : highband synthesis with lowband zeroed      */
    6271             :     const int32_t total_brate, /* i  : total bitrate for selecting subband pattern */
    6272             :     int16_t BANDS,
    6273             :     int16_t *band_start,
    6274             :     int16_t *band_end,
    6275             :     float *band_energy,
    6276             :     int16_t *p2a_flags,
    6277             :     const int16_t hqswb_clas,
    6278             :     int16_t lowlength,
    6279             :     int16_t highlength,
    6280             :     const int16_t har_bands,
    6281             :     int16_t *prev_frm_hfe2,
    6282             :     int16_t *prev_stab_hfe2,
    6283             :     int16_t band_width[],
    6284             :     const float y2_ni[],
    6285             :     int16_t *ni_seed );
    6286             : 
    6287             : int16_t get_usebit_npswb(
    6288             :     const int16_t hqswb_clas );
    6289             : 
    6290             : void GetPredictedSignal(
    6291             :     const float *predBuf, /* i  : prediction buffer        */
    6292             :     float *outBuf,        /* o  : output buffer            */
    6293             :     const int16_t lag,    /* i  : prediction buffer offset */
    6294             :     const int16_t fLen,   /* i  : length of loop (output)  */
    6295             :     const float gain      /* i  : gain to be applied       */
    6296             : );
    6297             : 
    6298             : void convert_lagIndices_pls2smp(
    6299             :     int16_t lagIndices_in[],
    6300             :     int16_t nBands_search,
    6301             :     int16_t lagIndices_out[],
    6302             :     const float sspectra[],
    6303             :     const int16_t sbWidth[],
    6304             :     const int16_t fLenLow );
    6305             : 
    6306             : void FindNBiggest2_simple(
    6307             :     const float *inBuf, /* i  : input buffer (searched)                     */
    6308             :     GainItem *g,        /* o  : N biggest components found                  */
    6309             :     const int16_t nIdx, /* i  : search length                               */
    6310             :     int16_t *n,         /* i  : number of components searched (N biggest)   */
    6311             :     const int16_t N_NBIGGESTSEARCH );
    6312             : 
    6313             : void updat_prev_frm(
    6314             :     float y2[],
    6315             :     float t_audio[],
    6316             :     const int32_t bwe_br,
    6317             :     const int16_t length,
    6318             :     const int16_t inner_frame,
    6319             :     const int16_t bands,
    6320             :     const int16_t bwidth,
    6321             :     const int16_t is_transient,
    6322             :     const int16_t hqswb_clas,
    6323             :     int16_t *prev_hqswb_clas,
    6324             :     int16_t *prev_SWB_peak_pos,
    6325             :     int16_t prev_SWB_peak_pos_tmp[],
    6326             :     int16_t *prev_frm_hfe2,
    6327             :     int16_t *prev_stab_hfe2,
    6328             :     const int16_t bws_cnt );
    6329             : 
    6330             : void hf_parinitiz(
    6331             :     const int32_t total_brate,
    6332             :     const int16_t hqswb_clas,
    6333             :     int16_t lowlength,
    6334             :     int16_t highlength,
    6335             :     int16_t wBands[],
    6336             :     const int16_t **subband_search_offset,
    6337             :     const int16_t **subband_offsets,
    6338             :     int16_t *nBands,
    6339             :     int16_t *nBands_search,
    6340             :     int16_t *swb_lowband,
    6341             :     int16_t *swb_highband );
    6342             : 
    6343             : float spectrumsmooth_noiseton(
    6344             :     float spectra[],
    6345             :     const float spectra_ni[],
    6346             :     float sspectra[],
    6347             :     float sspectra_diff[],
    6348             :     float sspectra_ni[],
    6349             :     const int16_t fLenLow,
    6350             :     int16_t *ni_seed );
    6351             : 
    6352             : void noiseinj_hf(
    6353             :     float xSynth_har[],
    6354             :     const float th_g[],
    6355             :     const float band_energy[],
    6356             :     float *prev_En_sb,
    6357             :     const int16_t p2a_flags[],
    6358             :     const int16_t BANDS,
    6359             :     const int16_t band_start[],
    6360             :     const int16_t band_end[],
    6361             :     const int16_t fLenLow );
    6362             : 
    6363             : void noise_extr_corcod(
    6364             :     float spectra[],
    6365             :     const float spectra_ni[],
    6366             :     float sspectra[],
    6367             :     float sspectra_diff[],
    6368             :     float sspectra_ni[],
    6369             :     const int16_t fLenLow,
    6370             :     int16_t prev_hqswb_clas,
    6371             :     float *prev_ni_ratio );
    6372             : 
    6373             : void genhf_noise(
    6374             :     float noise_flr[],
    6375             :     float xSynth_har[],
    6376             :     float *predBuf,
    6377             :     int16_t bands,         /* i  : total number of subbands in a frame         */
    6378             :     int16_t harmonic_band, /* i  : Number of LF harmonic frames                */
    6379             :     int16_t har_freq_est2,
    6380             :     int16_t pos_max_hfe2,
    6381             :     int16_t *pul_res,
    6382             :     GainItem pk_sf[],
    6383             :     const int16_t fLenLow,
    6384             :     const int16_t fLenHigh,
    6385             :     const int16_t sbWidth[],
    6386             :     const int16_t lagIndices[],
    6387             :     const int16_t subband_offsets[],
    6388             :     const int16_t subband_search_offset[] );
    6389             : 
    6390             : void ton_ene_est(
    6391             :     float xSynth_har[],
    6392             :     float be_tonal[],
    6393             :     float band_energy[],
    6394             :     int16_t band_start[],
    6395             :     int16_t band_end[],
    6396             :     int16_t band_width[],
    6397             :     const int16_t fLenLow,
    6398             :     const int16_t fLenHigh,
    6399             :     int16_t bands,
    6400             :     int16_t har_bands,
    6401             :     float ni_lvl,
    6402             :     GainItem pk_sf[],
    6403             :     int16_t *pul_res );
    6404             : 
    6405             : void Gettonl_scalfact(
    6406             :     float *outBuf,          /* o  : synthesized spectrum                        */
    6407             :     const float *codbuf,    /* i  : core coder                                  */
    6408             :     const int16_t fLenLow,  /* i  : lowband length                              */
    6409             :     const int16_t fLenHigh, /* i  : highband length                             */
    6410             :     int16_t harmonic_band,  /* i  : Number of LF harmonic frames                */
    6411             :     int16_t bands,          /* i  : total number of subbands in a frame         */
    6412             :     float *band_energy,     /* i  : band energy of each subband                 */
    6413             :     int16_t *band_start,    /* i  : subband start indices                       */
    6414             :     int16_t *band_end,      /* i  : subband end indices                         */
    6415             :     const int16_t p2aflags[],
    6416             :     float be_tonal[],
    6417             :     GainItem *pk_sf,
    6418             :     int16_t *pul_res );
    6419             : 
    6420             : void SpectrumSmoothing(
    6421             :     float *inBuf,
    6422             :     float *outBuf,
    6423             :     const int16_t fLen,
    6424             :     const float th_cut );
    6425             : 
    6426             : void hq2_bit_alloc_har(
    6427             :     float *y,  /* i  : band energy of sub-vectors                    */
    6428             :     int16_t B, /* i  : number of available bits                      */
    6429             :     int16_t N, /* i  : number of sub-vectors                         */
    6430             :     Word32 *L_Rsubband,
    6431             :     int16_t p2a_bands,
    6432             :     int32_t core_brate, /* i  : core bitrate                                 */
    6433             :     int16_t p2a_flags[],
    6434             :     int16_t band_width[] );
    6435             : 
    6436             : void GetSynthesizedSpecThinOut(
    6437             :     const float *predBuf,
    6438             :     float *outBuf,
    6439             :     const int16_t nBands,
    6440             :     const int16_t *sbWidth,
    6441             :     const int16_t *lagIndices,
    6442             :     const float *lagGains,
    6443             :     const int16_t predBufLen );
    6444             : 
    6445             : void return_bits_normal2(
    6446             :     int16_t *bit_budget,
    6447             :     const int16_t p2a_flags[],
    6448             :     const int16_t bands,
    6449             :     const int16_t bits_lagIndices[] );
    6450             : 
    6451             : void GetlagGains(
    6452             :     const float *predBuf,
    6453             :     const float *band_energy,
    6454             :     const int16_t nBands,
    6455             :     const int16_t *sbWidth,
    6456             :     const int16_t *lagIndices,
    6457             :     const int16_t predBufLen,
    6458             :     float *lagGains );
    6459             : 
    6460             : void preset_hq2_swb(
    6461             :     const int16_t hqswb_clas,
    6462             :     const int16_t band_end[],
    6463             :     int16_t *har_bands,
    6464             :     int16_t p2a_bands,
    6465             :     const int16_t length,
    6466             :     const int16_t bands,
    6467             :     int16_t *lowlength,
    6468             :     int16_t *highlength,
    6469             :     float m[] );
    6470             : 
    6471             : void post_hq2_swb(
    6472             :     const float m[],
    6473             :     const int16_t lowlength,
    6474             :     const int16_t highlength,
    6475             :     const int16_t hqswb_clas,
    6476             :     const int16_t har_bands,
    6477             :     const int16_t bands,
    6478             :     const int16_t p2a_flags[],
    6479             :     const int16_t band_start[],
    6480             :     const int16_t band_end[],
    6481             :     float y2[],
    6482             :     int16_t npulses[] );
    6483             : 
    6484             : void har_denorm_pulcnt(
    6485             :     float spectra[],            /* i/o: MDCT domain spectrum                        */
    6486             :     const int16_t band_start[], /* i  : Number subbands/Frame                       */
    6487             :     const int16_t band_end[],   /* i  : Band Start of each SB                       */
    6488             :     const float band_energy[],  /* i  : Band end of each SB                         */
    6489             :     const int16_t band_width[],
    6490             :     const int16_t npulses[],
    6491             :     const int16_t har_bands /* i  : No. of harmonic bands                       */
    6492             : );
    6493             : 
    6494             : int16_t har_est(
    6495             :     float spectra[],
    6496             :     const int16_t N,
    6497             :     int16_t *har_freq_est1,
    6498             :     int16_t *har_freq_est2,
    6499             :     int16_t *flag_dis,
    6500             :     int16_t *prev_frm_hfe2,
    6501             :     const int16_t subband_search_offset[],
    6502             :     const int16_t sbWidth[],
    6503             :     int16_t *prev_stab_hfe2 );
    6504             : 
    6505             : void spt_shorten_domain_pre(
    6506             :     const int16_t band_start[],
    6507             :     const int16_t band_end[],
    6508             :     const int16_t prev_SWB_peak_pos[],
    6509             :     const int16_t BANDS,
    6510             :     const int32_t bwe_br,
    6511             :     int16_t new_band_start[],
    6512             :     int16_t new_band_end[],
    6513             :     int16_t new_band_width[] );
    6514             : 
    6515             : void spt_shorten_domain_band_save(
    6516             :     const int16_t bands,
    6517             :     const int16_t band_start[],
    6518             :     const int16_t band_end[],
    6519             :     const int16_t band_width[],
    6520             :     int16_t org_band_start[],
    6521             :     int16_t org_band_end[],
    6522             :     int16_t org_band_width[] );
    6523             : 
    6524             : void spt_shorten_domain_band_restore(
    6525             :     const int16_t bands,
    6526             :     int16_t band_start[],
    6527             :     int16_t band_end[],
    6528             :     int16_t band_width[],
    6529             :     const int16_t org_band_start[],
    6530             :     const int16_t org_band_end[],
    6531             :     const int16_t org_band_width[] );
    6532             : 
    6533             : void spt_swb_peakpos_tmp_save(
    6534             :     const float y2[],
    6535             :     const int16_t bands,
    6536             :     const int16_t band_start[],
    6537             :     const int16_t band_end[],
    6538             :     int16_t prev_SWB_peak_pos_tmp[] );
    6539             : 
    6540             : void hq_ecu(
    6541             :     const float *prevsynth,            /* i  : buffer of previously synthesized signal   */
    6542             :     float *ecu_rec,                    /* o  : reconstructed frame in tda domain         */
    6543             :     int16_t *time_offs,                /* i/o: Sample offset for consecutive frame losses*/
    6544             :     float *X_sav,                      /* i/o: Stored spectrum of prototype frame        */
    6545             :     int16_t *num_p,                    /* i/o: Number of identified peaks                */
    6546             :     int16_t *plocs,                    /* i/o: Peak locations                            */
    6547             :     float *plocsi,                     /* i/o: Interpolated peak locations               */
    6548             :     const float env_stab,              /* i  : Envelope stability parameter              */
    6549             :     int16_t *last_fec,                 /* i/o: Flag for usage of pitch dependent ECU     */
    6550             :     const int16_t ph_ecu_HqVoicing,    /* i  : HQ Voicing flag                           */
    6551             :     int16_t *ph_ecu_active,            /* i  : Phase ECU active flag                     */
    6552             :     float *gapsynth,                   /* o  : Gap synthesis                             */
    6553             :     const int16_t prev_bfi,            /* i  : indicating burst frame error              */
    6554             :     const int16_t old_is_transient[2], /* i  : flags indicating previous transient frames*/
    6555             :     float *mag_chg_1st,                /* i/o: per band magnitude modifier for transients*/
    6556             :     float Xavg[LGW_MAX],               /* i/o: Frequency group average gain to fade to   */
    6557             :     float *beta_mute,                  /* o  : Factor for long-term mute                 */
    6558             :     const int16_t output_frame,        /* i  : frame length                              */
    6559             :     Decoder_State *st                  /* i/o: decoder state structure                   */
    6560             : );
    6561             : 
    6562             : void peakfinder(
    6563             :     const float *x0,        /* i  : vector from which the maxima will be found                     */
    6564             :     const int16_t len0,     /* i  : length of input vector                                         */
    6565             :     int16_t *plocs,         /* o  : the indicies of the identified peaks in x0                     */
    6566             :     int16_t *cInd,          /* o  : number of identified peaks                                     */
    6567             :     const float sel,        /* i  : The amount above surrounding data for a peak to be identified  */
    6568             :     const int16_t endpoints /* i  : Flag to include endpoints in peak search                       */
    6569             : );
    6570             : 
    6571             : /*! r: interpolated maximum position */
    6572             : float imax_pos(
    6573             :     const float *y /* i  : Input vector for peak interpolation */
    6574             : );
    6575             : 
    6576             : 
    6577             : void fft3(
    6578             :     const float X[], /* i  : input frame                                */
    6579             :     float Y[],       /* o  : DFT of input frame                         */
    6580             :     const int16_t n  /* i  : block length (must be radix 3)             */
    6581             : );
    6582             : 
    6583             : void ifft3(
    6584             :     const float X[], /* i  : input frame                                */
    6585             :     float Y[],       /* o  : iDFT of input frame                        */
    6586             :     const int16_t n  /* i  : block length (must be radix 3)             */
    6587             : );
    6588             : 
    6589             : /*! r: updated estimate of background noise */
    6590             : void minimumStatistics(
    6591             :     float *noiseLevelMemory,  /* i/o: internal state                            */
    6592             :     int16_t *noiseLevelIndex, /* i/o: internal state                            */
    6593             :     int16_t *currLevelIndex,  /* i/o: internal state (circular buffer)          */
    6594             :     float *noiseEstimate,     /* i/o: previous estimate of background noise     */
    6595             :     float *lastFrameLevel,    /* i/o: level of the last frame                   */
    6596             :     float currentFrameLevel,  /* i  : level of the current frame                */
    6597             :     const float minLev,       /* i  : minimum level                             */
    6598             :     const int16_t buffSize    /* i  : buffer size                               */
    6599             : );
    6600             : 
    6601             : void E_LPC_int_lpc_tcx(
    6602             :     const float lsf_old[], /* i  : LSFs from past frame                      */
    6603             :     const float lsf_new[], /* i  : LSFs from present frame                   */
    6604             :     float a[]              /* o  : interpolated LP coefficients              */
    6605             : );
    6606             : 
    6607             : int16_t E_GAIN_closed_loop_search(
    6608             :     float exc[],
    6609             :     float xn[],
    6610             :     float h[],
    6611             :     int16_t t0_min,
    6612             :     int16_t t0_min_frac,
    6613             :     int16_t t0_max,
    6614             :     int16_t t0_max_frac,
    6615             :     const int16_t t0_min_max_res,
    6616             :     int16_t *pit_frac,
    6617             :     int16_t *pit_res,
    6618             :     const int16_t pit_res_max,
    6619             :     const int16_t i_subfr,
    6620             :     const int16_t pit_min,
    6621             :     const int16_t pit_fr2,
    6622             :     const int16_t pit_fr1,
    6623             :     const int16_t L_subfr );
    6624             : 
    6625             : void E_ACELP_toeplitz_mul(
    6626             :     const float R[],
    6627             :     const float c[],
    6628             :     float d[] );
    6629             : 
    6630             : void acelp_pulsesign(
    6631             :     const float cn[],
    6632             :     float dn[],
    6633             :     float dn2[],
    6634             :     float sign[],
    6635             :     float vec[],
    6636             :     const float alp );
    6637             : 
    6638             : void E_ACELP_4t(
    6639             :     float dn[],
    6640             :     float cn[],
    6641             :     float H[],
    6642             :     float R[],
    6643             :     const int16_t acelpautoc,
    6644             :     float code[],
    6645             :     const int16_t cdk_index,
    6646             :     int16_t _index[],
    6647             :     const int16_t L_frame,
    6648             :     const int16_t last_L_frame,
    6649             :     const int32_t total_brate,
    6650             :     const int16_t i_subfr,
    6651             :     const int16_t cmpl_flag );
    6652             : 
    6653             : void E_ACELP_4tsearch(
    6654             :     float dn[],
    6655             :     const float cn[],
    6656             :     const float H[],
    6657             :     float code[],
    6658             :     PulseConfig *config,
    6659             :     int16_t ind[],
    6660             :     float y[] );
    6661             : 
    6662             : void E_ACELP_4tsearchx(
    6663             :     float dn[],
    6664             :     const float cn[],
    6665             :     float Rw[],
    6666             :     float code[],
    6667             :     PulseConfig *config,
    6668             :     int16_t ind[] );
    6669             : 
    6670             : int16_t E_ACELP_indexing(
    6671             :     float code[],
    6672             :     PulseConfig config,
    6673             :     const int16_t num_tracks,
    6674             :     int16_t prm[] );
    6675             : 
    6676             : void acelp_findcandidates(
    6677             :     float dn2[],
    6678             :     int16_t dn2_pos[],
    6679             :     int16_t pos_max[],
    6680             :     const int16_t L_subfr,
    6681             :     const int16_t tracks );
    6682             : 
    6683             : void E_ACELP_innovative_codebook(
    6684             :     const float *exc,           /* i  : pointer to the excitation frame                  */
    6685             :     const int16_t T0,           /* i  : integer pitch lag                                */
    6686             :     const int16_t T0_frac,      /* i  : fraction of lag                                  */
    6687             :     const int16_t T0_res,       /* i  : pitch resolution                                 */
    6688             :     const float pitch_gain,     /* i  : adaptive codebook gain                           */
    6689             :     const float tilt_code,      /* i  : tilt factor                                      */
    6690             :     ACELP_config *acelp_cfg,    /* i/o: configuration of the ACELP                       */
    6691             :     const int16_t i_subfr,      /* i  : subframe index                                   */
    6692             :     const float *Aq,            /* i  : quantized LPC coefficients                       */
    6693             :     const float *h1,            /* i  : impulse response of weighted synthesis filter    */
    6694             :     const float *xn,            /* i  : Close-loop Pitch search target vector            */
    6695             :     const float *cn,            /* i  : Innovative codebook search target vector         */
    6696             :     const float *y1,            /* i  : zero-memory filtered adaptive excitation         */
    6697             :     float *y2,                  /* o  : zero-memory filtered algebraic excitation        */
    6698             :     const int16_t acelpautoc,   /* i  : autocorrelation mode enabled                     */
    6699             :     int16_t **pt_indice,        /* i/o: quantization indices pointer                     */
    6700             :     float *code,                /* o  : innovative codebook                              */
    6701             :     const int16_t L_frame,      /* i  : length of the frame                              */
    6702             :     const int16_t last_L_frame, /* i  : length of the last frame                         */
    6703             :     const int32_t total_brate   /* i  : total bitrate                                    */
    6704             : );
    6705             : 
    6706             : int16_t E_ACELP_code43bit(
    6707             :     const float code[],
    6708             :     uint32_t *ps,
    6709             :     int16_t *p,
    6710             :     uint16_t idxs[] );
    6711             : 
    6712             : void fcb_pulse_track_joint(
    6713             :     uint16_t *idxs,
    6714             :     const int16_t wordcnt,
    6715             :     uint32_t *index_n,
    6716             :     const int16_t *pulse_num,
    6717             :     const int16_t track_num );
    6718             : 
    6719             : void D_ACELP_indexing(
    6720             :     float code[],
    6721             :     PulseConfig config,
    6722             :     const int16_t num_tracks,
    6723             :     int16_t prm[],
    6724             :     int16_t *BER_detect );
    6725             : 
    6726             : void D_ACELP_decode_43bit(
    6727             :     uint16_t idxs[],
    6728             :     float code[],
    6729             :     int16_t *pulsestrack );
    6730             : 
    6731             : void fcb_pulse_track_joint_decode(
    6732             :     uint16_t *idxs,
    6733             :     const int16_t wordcnt,
    6734             :     uint32_t *index_n,
    6735             :     const int16_t *pulse_num,
    6736             :     const int16_t track_num );
    6737             : 
    6738             : void lag_wind(
    6739             :     float r[],             /* i/o: autocorrelations                                       */
    6740             :     const int16_t m,       /* i  : order of LP filter                                     */
    6741             :     const int32_t sr_core, /* i  : sampling rate                                          */
    6742             :     const int16_t strength /* i  : LAGW_WEAK, LAGW_MEDIUM, or LAGW_STRONG                 */
    6743             : );
    6744             : 
    6745             : void adapt_lag_wind(
    6746             :     float r[],            /* i/o: autocorrelations                                       */
    6747             :     const int16_t m,      /* i  : order of LP filter                                     */
    6748             :     const int16_t Top,    /* i  : open loop pitch lags from curr. frame (or NULL if n/a) */
    6749             :     const float Tnc,      /* i  : open loop pitch gains from curr. frame (NULL if n/a)   */
    6750             :     const int32_t sr_core /* i  : core sampling rate                                     */
    6751             : );
    6752             : 
    6753             : void hp20(
    6754             :     Float32 signal[],
    6755             :     const Word16 lg,
    6756             :     Float32 mem[],
    6757             :     const Word32 Fs );
    6758             : 
    6759             : void ham_cos_window(
    6760             :     float *fh,
    6761             :     const int16_t n1,
    6762             :     const int16_t n2 );
    6763             : 
    6764             : /*! r: noise dependent voicing correction */
    6765             : float correlation_shift(
    6766             :     const float totalNoise /* i  : noise estimate over all critical bands  */
    6767             : );
    6768             : 
    6769             : void init_coder_ace_plus(
    6770             :     Encoder_State *st,              /* i  : Encoder state handle                */
    6771             :     const int32_t last_total_brate, /* i  : last total bitrate                  */
    6772             :     const int32_t igf_brate,        /* i  : IGF configuration bitrate           */
    6773             :     const int16_t MCT_flag          /* i  : hMCT handle allocated (1) or not (0)*/
    6774             : );
    6775             : 
    6776             : void core_coder_reconfig(
    6777             :     Encoder_State *st,             /* i/o: encoder state structure             */
    6778             :     const int32_t last_total_brate /* i  : last total bitrate                  */
    6779             : );
    6780             : 
    6781             : void core_coder_mode_switch(
    6782             :     Encoder_State *st,              /* i/o: encoder state structure             */
    6783             :     const int32_t last_total_brate, /* i  : last bitrate                        */
    6784             :     const int16_t MCT_flag          /* i  : hMCT handle allocated (1) or not (0)*/
    6785             : );
    6786             : 
    6787             : void enc_acelp_tcx_main(
    6788             :     Encoder_State *st,                 /* i/o: encoder state structure             */
    6789             :     const float new_samples[],         /* i  : new samples                         */
    6790             :     float Aw[NB_SUBFR16k * ( M + 1 )], /* i  : weighted A(z) unquant. for subframes*/
    6791             :     const float lsp_new[M],            /* i  : LSPs at the end of the frame        */
    6792             :     const float lsp_mid[M],            /* i  : LSPs at the middle of the frame     */
    6793             :     float bwe_exc_extended[],          /* i/o: bandwidth extended excitation       */
    6794             :     float *voice_factors,              /* o  : voicing factors                     */
    6795             :     float pitch_buf[],                 /* o  : floating pitch for each subframe    */
    6796             :     const int16_t vad_hover_flag       /* i  : VAD hangover flag                   */
    6797             : );
    6798             : 
    6799             : void getTCXMode(
    6800             :     Decoder_State *st,     /* i/o: decoder memory state                */
    6801             :     Decoder_State *st0,    /* i  : bitstream                           */
    6802             :     const int16_t MCT_flag /* i  : hMCT handle allocated (1) or not (0)*/
    6803             : );
    6804             : 
    6805             : void getTCXWindowing(
    6806             :     const int16_t core,         /* i  : current frame mode                  */
    6807             :     const int16_t last_core,    /* i  : last frame mode                     */
    6808             :     const int16_t element_mode, /* i  : element mode                        */
    6809             :     TCX_CONFIG_HANDLE hTcxCfg,  /* i/o: TCX configuration handle            */
    6810             :     Decoder_State *st0          /* i  : bitstream                           */
    6811             : );
    6812             : 
    6813             : void getLPCparam(
    6814             :     Decoder_State *st,            /* i/o: decoder memory state                */
    6815             :     int16_t param_lpc[],          /* o  : LTP parameters                      */
    6816             :     Decoder_State *st0,           /* i  : bitstream                           */
    6817             :     const int16_t ch,             /* i  : channel                             */
    6818             :     const int16_t sns_low_br_mode /* i  : SNS low-bitrate mode                */
    6819             : );
    6820             : 
    6821             : void getTCXparam(
    6822             :     Decoder_State *st,           /* i/o: Decoder State handle                  */
    6823             :     Decoder_State *st0,          /* i  : bitstream                             */
    6824             :     CONTEXT_HM_CONFIG hm_cfg,    /* i/o: HM config                             */
    6825             :     int16_t param[],             /* o  : decoded parameters                    */
    6826             :     const int16_t bits_common,   /* i  : number of common bits                 */
    6827             :     const int16_t start_bit_pos, /* i  : position of the start bit             */
    6828             :     const int16_t *no_param_tns, /* i  : number of TNS parameters per subframe */
    6829             :     int16_t p_param[2],          /* o  : pointer to parameters for next round of bs reading*/
    6830             :     int16_t nTnsBitsTCX10[2],
    6831             :     const int16_t pre_past_flag );
    6832             : 
    6833             : void pitch_pred_linear_fit(
    6834             :     const int16_t nbLostCmpt, /* i  : bfi counter                                     */
    6835             :     const int16_t last_good,  /* i  : last classification type                        */
    6836             :     float *old_pitch_buf,     /* i  : pitch lag buffer                                */
    6837             :     float *old_fpitch,        /* i/o: pitch used for initial ACB generation           */
    6838             :     float *T0_out,            /* o  : estimated close loop pitch                      */
    6839             :     const int16_t pit_min,    /* i  : Minimum pitch lag                               */
    6840             :     const int16_t pit_max,    /* i  : Maximum pitch lag                               */
    6841             :     float *mem_pitch_gain,    /* i  : lag pitch gain [0] is the most recent subfr lag */
    6842             :     const int16_t limitation,
    6843             :     const int16_t plc_use_future_lag, /* i  : number of subframes to predict                  */
    6844             :     int16_t *extrapolationFailed,     /* o  : flag if extrap decides not to change the pitch  */
    6845             :     const int16_t nb_subfr            /* i  : number of ACELP subframes                       */
    6846             : );
    6847             : 
    6848             : void get_subframe_pitch(
    6849             :     const int16_t nSubframes, /* i  : number of subframes                             */
    6850             :     float pitchStart,         /* i  : starting pitch lag (in subframe -1)             */
    6851             :     float pitchEnd,           /* i  : ending pitch lag (in subframe nSubframes-1)     */
    6852             :     float *pitchBuf           /* o  : interpolated pitch lag per subframe             */
    6853             : );
    6854             : 
    6855             : void core_encode_openloop(
    6856             :     Encoder_State *st,                       /* i/o: encoder state structure             */
    6857             :     const float Aw[NB_SUBFR16k * ( M + 1 )], /* i  : weighted A(z) unquant. for subframes*/
    6858             :     const float lsp_new[M],                  /* i  : LSPs at the end of the frame        */
    6859             :     const float lsp_mid[M],                  /* i  : LSPs at the middle of the frame     */
    6860             :     float *pitch_buf,                        /* i/o: floating pitch values for each subfr*/
    6861             :     float *voice_factors,                    /* o  : voicing factors                     */
    6862             :     float *ptr_bwe_exc,                      /* o  : excitation for SWB TBE              */
    6863             :     const int16_t vad_hover_flag             /* i  : VAD hangover flag                   */
    6864             : );
    6865             : 
    6866             : void core_acelp_tcx20_switching(
    6867             :     Encoder_State *st,            /* i/o: encoder state structure                   */
    6868             :     float non_staX,               /* i  : unbound non-stationarity for sp/mu clas   */
    6869             :     float *pitch_fr,              /* i/o: fraction pitch values                     */
    6870             :     float *voicing_fr,            /* i/o: fractional voicing values                 */
    6871             :     const float currTempFlatness, /* i  : flatness                                  */
    6872             :     const float lsp_mid[M],       /* i  : LSPs at the middle of the frame           */
    6873             :     const float stab_fac          /* i  : LP filter stability                       */
    6874             : );
    6875             : 
    6876             : void core_encode_twodiv(
    6877             :     Encoder_State *st,                 /* i/o: coder memory state                  */
    6878             :     const float new_samples[],         /* i  : new samples                         */
    6879             :     float Aw[NB_SUBFR16k * ( M + 1 )], /* i  : weighted A(z) unquant. for subframes*/
    6880             :     const int16_t vad_hover_flag       /* i  : VAD hangover flag                   */
    6881             : );
    6882             : 
    6883             : void core_encode_update(
    6884             :     Encoder_State *st /* i/o: encoder state structure             */
    6885             : );
    6886             : 
    6887             : void core_encode_update_cng(
    6888             :     Encoder_State *st, /* i/o: encoder state structure             */
    6889             :     float *timeDomainBuffer,
    6890             :     float *A,
    6891             :     const float Aw[] /* i  : weighted A(z) unquant. for subframes*/
    6892             : );
    6893             : 
    6894             : void core_signal_analysis_high_bitrate(
    6895             :     const float *new_samples,
    6896             :     const int16_t T_op[3], /* i  : open-loop pitch values for quantiz. */
    6897             :     float lsp_new[],
    6898             :     float lsp_mid[],
    6899             :     Encoder_State *st,
    6900             :     float *mdst_spectrum[2],
    6901             :     int16_t pTnsSize[],
    6902             :     int16_t pTnsBits[],
    6903             :     int16_t param_core[],
    6904             :     int16_t *ltpBits,
    6905             :     float *windowed_samples, /* i/o: backup of windowed time signal */
    6906             :     const int16_t L_frame,
    6907             :     const int16_t L_frameTCX,
    6908             :     const int16_t last_element_mode,
    6909             :     const int16_t vad_hover_flag /* i  : VAD hangover flag                          */
    6910             : );
    6911             : 
    6912             : /*! r: codebook gain (adaptive or fixed) */
    6913             : float get_gain(
    6914             :     const float x[], /* i  : target signal                        */
    6915             :     const float y[], /* i  : filtered codebook excitation         */
    6916             :     const int16_t n, /* i  : segment length                       */
    6917             :     float *en_y      /* o  : energy of y (sum of y[]^2, optional) */
    6918             : );
    6919             : 
    6920             : void encode_acelp_gains(
    6921             :     const float *code,
    6922             :     const int16_t gains_mode,
    6923             :     const float mean_ener_code,
    6924             :     const int16_t clip_gain,
    6925             :     ACELP_CbkCorr *g_corr,
    6926             :     float *gain_pit,
    6927             :     float *gain_code,
    6928             :     int16_t **pt_indice,
    6929             :     float *past_gcode,
    6930             :     float *gain_inov,
    6931             :     const int16_t L_subfr,
    6932             :     float *code2,
    6933             :     float *gain_code2,
    6934             :     const int16_t noisy_speech_flag );
    6935             : 
    6936             : int16_t gain_enc_gacelp_uv(
    6937             :     const float *code,              /* i  : algebraic excitation                                            */
    6938             :     const float *code2,             /* i  : gaussian excitation                                             */
    6939             :     const int16_t lcode,            /* i  : Subframe size                                                   */
    6940             :     const float mean_ener,          /* i  : quantized mean energy of the frame                              */
    6941             :     float *gain_pit,                /* o  : quantized pitch gain                                            */
    6942             :     float *gain_code,               /* o  : quantized codebook gain                                         */
    6943             :     float *gain_code2,              /* o  : quantized codebook gain                                         */
    6944             :     ACELP_CbkCorr *coeff,           /* i/o: correlations <y1,y1>, -2<xn,y1>,<y2,y2>, -2<xn,y2> and 2<y1,y2> */
    6945             :     float *past_gcode,              /* i/o: past gain of code                                               */
    6946             :     float *gain_inov,               /* o  : unscaled innovation gain                                        */
    6947             :     const int16_t noisy_speech_flag /* i  : noisy speech flag                                               */
    6948             : );
    6949             : 
    6950             : int16_t Mode2_gain_enc_mless(
    6951             :     const float *code,       /* i  : algebraic excitation                                            */
    6952             :     const int16_t lcode,     /* i  : Subframe size                                                   */
    6953             :     float *gain_pit,         /* o  : quantized pitch gain                                            */
    6954             :     float *gain_code,        /* o  : quantized codebook gain                                         */
    6955             :     ACELP_CbkCorr *coeff,    /* i/o: correlations <y1,y1>, -2<xn,y1>,<y2,y2>, -2<xn,y2> and 2<y1,y2> */
    6956             :     const float mean_ener,   /* i  : mean_ener defined in open-loop (3 bits)                         */
    6957             :     const int16_t clip_gain, /* i  : gain pitch clipping flag (1 = clipping)                         */
    6958             :     float *past_gcode,       /* i/o: past gain of code                                               */
    6959             :     float *gain_inov,        /* o  : unscaled innovation gain                                        */
    6960             :     const int16_t coder_type /* i  : type of coder                                                   */
    6961             : );
    6962             : 
    6963             : void decode_acelp_gains(
    6964             :     const float *code,
    6965             :     const int16_t gains_mode,
    6966             :     const float mean_ener_code,
    6967             :     float *gain_pit,
    6968             :     float *gain_code,
    6969             :     int16_t **pt_indice,
    6970             :     float *past_gpit,
    6971             :     float *past_gcode,
    6972             :     float *gain_inov,
    6973             :     const int16_t L_subfr,
    6974             :     float *code2,
    6975             :     float *gain_code2 );
    6976             : 
    6977             : void gain_dec_gacelp_uv(
    6978             :     int16_t index,         /* i/o: Quantization index vector             */
    6979             :     const float *code,     /* i  : algebraic code excitation             */
    6980             :     const float *code2,    /* i  : algebraic code excitation             */
    6981             :     const float mean_ener, /* i  : mean energy                           */
    6982             :     const int16_t lcode,   /* i  : Subframe size                         */
    6983             :     float *gain_pit,       /* o  : Quantized pitch gain                  */
    6984             :     float *gain_code,      /* o  : Quantized codebook gain               */
    6985             :     float *gain_code2,     /* o  : Quantized codebook gain               */
    6986             :     float *past_gpit,      /* i/o: past gain of pitch                    */
    6987             :     float *past_gcode,     /* i/o: past energy of code                   */
    6988             :     float *gain_inov       /* o  : unscaled innovation gain              */
    6989             : );
    6990             : 
    6991             : void Mode2_pit_encode(
    6992             :     const int16_t coder_type, /* i  : coding model                               */
    6993             :     const int16_t i_subfr,    /* i  : subframe index                             */
    6994             :     int16_t **pt_indice,      /* i/o: quantization indices pointer               */
    6995             :     float *exc,               /* i/o: pointer to excitation signal frame         */
    6996             :     const int16_t *T_op,      /* i  : open loop pitch estimates in current frame */
    6997             :     int16_t *T0_min,          /* i/o: lower limit for close-loop search          */
    6998             :     int16_t *T0_min_frac,     /* i/o: lower limit for close-loop search          */
    6999             :     int16_t *T0_max,          /* i/o: higher limit for close-loop search         */
    7000             :     int16_t *T0_max_frac,     /* i/o: higher limit for close-loop search         */
    7001             :     int16_t *T0,              /* i/o: close loop integer pitch                   */
    7002             :     int16_t *T0_frac,         /* i/o: close loop fractional part of the pitch    */
    7003             :     int16_t *T0_res,          /* i/o: close loop pitch resolution                */
    7004             :     float *h1,                /* i  : weighted filter impulse response           */
    7005             :     float *xn,                /* i  : target vector                              */
    7006             :     const int16_t pit_min,
    7007             :     const int16_t pit_fr1,
    7008             :     const int16_t pit_fr1b,
    7009             :     const int16_t pit_fr2,
    7010             :     const int16_t pit_max,
    7011             :     const int16_t pit_res_max );
    7012             : 
    7013             : void limit_T0_voiced(
    7014             :     const int16_t nbits,
    7015             :     const int16_t res,
    7016             :     const int16_t T0,      /* i  : rough pitch estimate around which the search is done */
    7017             :     const int16_t T0_frac, /* i  : pitch estimate fractional part                       */
    7018             :     const int16_t T0_res,  /* i  : pitch resolution                                     */
    7019             :     int16_t *T0_min,       /* o  : lower pitch limit                                    */
    7020             :     int16_t *T0_min_frac,  /* o  : lower pitch limit                                    */
    7021             :     int16_t *T0_max,       /* o  : higher pitch limit                                   */
    7022             :     int16_t *T0_max_frac,  /* o  : higher pitch limit                                   */
    7023             :     const int16_t pit_min, /* i  : Minimum pitch lag                                    */
    7024             :     const int16_t pit_max  /* i  : Maximum pitch lag                                    */
    7025             : );
    7026             : 
    7027             : void Mode2_abs_pit_enc(
    7028             :     const int16_t T0,      /* i  : integer pitch lag              */
    7029             :     const int16_t T0_frac, /* i  : pitch fraction                 */
    7030             :     int16_t **pt_indice,   /* i/o: pointer to Vector of Q indexes */
    7031             :     const int16_t pit_min,
    7032             :     const int16_t pit_fr1,
    7033             :     const int16_t pit_fr2,
    7034             :     const int16_t pit_res_max );
    7035             : 
    7036             : void Mode2_delta_pit_enc(
    7037             :     const int16_t T0,          /* i  : integer pitch lag              */
    7038             :     const int16_t T0_frac,     /* i  : pitch fraction                 */
    7039             :     const int16_t T0_res,      /* i  : pitch resolution               */
    7040             :     const int16_t T0_min,      /* i  : delta search min               */
    7041             :     const int16_t T0_min_frac, /* i  : delta search min               */
    7042             :     int16_t **pt_indice        /* o  : pointer to Vector of Q indexes */
    7043             : );
    7044             : 
    7045             : /*! r: floating pitch value */
    7046             : float Mode2_pit_decode(
    7047             :     const int16_t coder_type, /* i  : coding model                            */
    7048             :     const int16_t i_subfr,    /* i  : subframe index                          */
    7049             :     const int16_t L_subfr,    /* i  : sub-frame length                */
    7050             :     int16_t **pt_indice,      /* i/o: quantization indices pointer            */
    7051             :     int16_t *T0,              /* o  : close loop integer pitch                */
    7052             :     int16_t *T0_frac,         /* o  : close loop fractional part of the pitch */
    7053             :     int16_t *T0_res,          /* i/o: pitch resolution                        */
    7054             :     int16_t *T0_min,          /* i/o: lower limit for close-loop search       */
    7055             :     int16_t *T0_min_frac,     /* i/o: lower limit for close-loop search       */
    7056             :     int16_t *T0_max,          /* i/o: higher limit for close-loop search      */
    7057             :     int16_t *T0_max_frac,     /* i/o: higher limit for close-loop search      */
    7058             :     const int16_t pit_min,
    7059             :     const int16_t pit_fr1,
    7060             :     const int16_t pit_fr1b,
    7061             :     const int16_t pit_fr2,
    7062             :     const int16_t pit_max,
    7063             :     const int16_t pit_res_max );
    7064             : 
    7065             : void Mode2_abs_pit_dec(
    7066             :     int16_t *T0,         /* o  : integer pitch lag              */
    7067             :     int16_t *T0_frac,    /* o  : pitch fraction                 */
    7068             :     int16_t *T0_res,     /* o  : pitch resolution               */
    7069             :     int16_t **pt_indice, /* i/o: pointer to Vector of Q indexes */
    7070             :     const int16_t pit_min,
    7071             :     const int16_t pit_fr1,
    7072             :     const int16_t pit_fr2,
    7073             :     const int16_t pit_res_max );
    7074             : 
    7075             : void Mode2_delta_pit_dec(
    7076             :     int16_t *T0,          /* o  : integer pitch lag              */
    7077             :     int16_t *T0_frac,     /* o  : pitch fraction                 */
    7078             :     int16_t T0_res,       /* i  : pitch resolution               */
    7079             :     int16_t *T0_min,      /* i  : delta search min               */
    7080             :     int16_t *T0_min_frac, /* i  : delta search min               */
    7081             :     int16_t **pt_indice   /* i/o: pointer to Vector of Q indexes */
    7082             : );
    7083             : 
    7084             : void formant_post_filt(
    7085             :     PFSTAT_HANDLE hPFstat, /* i/o: Post filter related memories    */
    7086             :     float *synth_in,       /* i  : 12k8 synthesis                  */
    7087             :     const float *Aq,       /* i  : LP filter coefficient           */
    7088             :     float *synth_out,      /* i/o: input signal                    */
    7089             :     const int16_t L_frame, /* i  : frame length                    */
    7090             :     const int16_t L_subfr, /* i  : sub-frame length                */
    7091             :     const float lp_noise,  /* i  : background noise energy         */
    7092             :     const int32_t brate,   /* i  : bitrate                         */
    7093             :     const int16_t off_flag /* i  : Off flag                        */
    7094             : );
    7095             : 
    7096             : void qlpc_avq(
    7097             :     const float *lsp,     /* i  : Input LSF vectors              */
    7098             :     const float *lspmid,  /* i  : Input mid-LSF vectors          */
    7099             :     float *lsf_q,         /* o  : Quantized LFS vectors          */
    7100             :     float *lsfmid_q,      /* o  : Quantized mid-LFS vectors      */
    7101             :     int16_t *index,       /* o  : Quantization indices           */
    7102             :     int16_t *nb_indices,  /* o  : Number of quantization indices */
    7103             :     int16_t *nbbits,      /* o  : Number of quantization bits    */
    7104             :     const int16_t core,   /* i  : core                           */
    7105             :     const int32_t sr_core /* i  : internal sampling rate         */
    7106             : );
    7107             : 
    7108             : int16_t encode_lpc_avq(
    7109             :     BSTR_ENC_HANDLE hBstr,     /* i/o: bitstream handle                */
    7110             :     const int16_t numlpc,      /* i  : Number of sets of lpc           */
    7111             :     const int16_t *param_lpc,  /* i  : lpc parameters                  */
    7112             :     const int16_t core,        /* i  : core                            */
    7113             :     const int16_t element_mode /* i  : element mode                    */
    7114             : );
    7115             : 
    7116             : int16_t dlpc_avq(
    7117             :     int16_t *index,       /* i  : Quantization indices            */
    7118             :     float *LSF_Q,         /* o  : Quantized LSF vectors           */
    7119             :     const int16_t numlpc, /* i  : Number of sets of lpc           */
    7120             :     const int32_t sr_core /* i  : internal sampling rate          */
    7121             : );
    7122             : 
    7123             : int16_t decode_lpc_avq(
    7124             :     Decoder_State *st,            /* i/o: decoder state structure         */
    7125             :     const int16_t numlpc,         /* i  : Number of sets of lpc           */
    7126             :     int16_t *param_lpc,           /* o  : lpc parameters                  */
    7127             :     const int16_t ch,             /* i  : channel                         */
    7128             :     const int16_t element_mode,   /* i  : element mode                    */
    7129             :     const int16_t sns_low_br_mode /* i  : SNS low-bitrate mode            */
    7130             : );
    7131             : 
    7132             : /*! r: codebook index */
    7133             : int16_t vlpc_1st_cod(
    7134             :     const float *lsf,      /* i  : vector to quantize              */
    7135             :     float *lsfq,           /* i/o: i:prediction   o:quantized lsf  */
    7136             :     const int32_t sr_core, /* i  : internal sampling rate          */
    7137             :     float *w               /* o  : lsf weights                     */
    7138             : );
    7139             : 
    7140             : /*! r: number of allocated bits */
    7141             : int16_t vlpc_2st_cod(
    7142             :     const float *lsf,     /* i  : normalized vector to quantize   */
    7143             :     float *lsfq,          /* i/o: i:1st stage   o:1st+2nd stage   */
    7144             :     int16_t *indx,        /* o  : index[] (4 bits per words)      */
    7145             :     const int16_t mode,   /* i  : 0=abs, >0=rel                   */
    7146             :     const int32_t sr_core /* i  : internal sampling rate          */
    7147             : );
    7148             : 
    7149             : void vlpc_2st_dec(
    7150             :     float *lsfq,          /* i/o: i:1st stage   o:1st+2nd stage   */
    7151             :     int16_t *indx,        /* i  : index[] (4 bits per words)      */
    7152             :     const int16_t mode,   /* i  : 0=abs, >0=rel                   */
    7153             :     const int32_t sr_core /* i  : internal sampling rate          */
    7154             : );
    7155             : 
    7156             : void lsf_weight_2st(
    7157             :     const float *lsfq,
    7158             :     float *w,
    7159             :     const int16_t mode,
    7160             :     const int32_t sr_core );
    7161             : 
    7162             : void mdct_window_sine(
    7163             :     float *window,
    7164             :     const int32_t Fs,
    7165             :     const int16_t n,
    7166             :     const int16_t window_type,
    7167             :     const int16_t element_mode );
    7168             : 
    7169             : void mdct_window_aldo(
    7170             :     float *window1,
    7171             :     float *window2,
    7172             :     const int16_t n );
    7173             : 
    7174             : void AVQ_cod_lpc(
    7175             :     const float nvec[], /* i  : vector to quantize              */
    7176             :     int16_t nvecq[],    /* o  : quantized normalized vector (assuming the bit budget is enough) */
    7177             :     int16_t *indx,      /* o  : index[] (4 bits per words)      */
    7178             :     const int16_t Nsv   /* i  : number of subvectors (lg=Nsv*8) */
    7179             : );
    7180             : 
    7181             : void AVQ_dec_lpc(
    7182             :     const int16_t indx[], /* i  : index[] (4 bits per words)      */
    7183             :     int16_t nvecq[],      /* o  : vector quantized                */
    7184             :     const int16_t Nsv     /* i  : number of subvectors (lg=Nsv*8) */
    7185             : );
    7186             : 
    7187             : void vlpc_1st_dec(
    7188             :     const int16_t index, /* i  : codebook index                  */
    7189             :     float *lsfq,         /* i/o: i:prediction   o:quantized lsf  */
    7190             :     const int32_t sr_core );
    7191             : 
    7192             : void WindowSignal(
    7193             :     TCX_CONFIG_HANDLE hTcxCfg,        /* i  : configuration of TCX                */
    7194             :     int16_t offset,                   /* i  : left folding point offset relative to the input signal pointer */
    7195             :     const int16_t left_overlap_mode,  /* i  : overlap mode of left window half    */
    7196             :     const int16_t right_overlap_mode, /* i  : overlap mode of right window half   */
    7197             :     int16_t *left_overlap_length,     /* o  : TCX window left overlap length      */
    7198             :     int16_t *right_overlap_length,    /* o  : TCX window right overlap length     */
    7199             :     const float in[],                 /* i  : input signal                        */
    7200             :     int16_t *L_frame,                 /* i/o: frame length                        */
    7201             :     float out[],                      /* o  : output windowed signal              */
    7202             :     const int16_t truncate_aldo,      /* i  : nonzero to truncate long ALDO slope */
    7203             :     const int16_t fullband            /* i  : fullband flag                       */
    7204             : );
    7205             : 
    7206             : void HBAutocorrelation(
    7207             :     TCX_CONFIG_HANDLE hTcxCfg, /* i  : configuration of TCX               */
    7208             :     const int16_t left_mode,   /* i  : overlap mode of left window half   */
    7209             :     const int16_t right_mode,  /* i  : overlap mode of right window half  */
    7210             :     float speech[],            /* i  : speech                             */
    7211             :     int16_t L_frame_glob,      /* i/o: frame length                       */
    7212             :     float *r                   /* o  : autocorrelations vector            */
    7213             : );
    7214             : 
    7215             : void TNSAnalysis(
    7216             :     TCX_CONFIG_HANDLE hTcxCfg,    /* i  : configuration of TCX                                                                    */
    7217             :     const int16_t L_frame,        /* i  : frame length                                                                            */
    7218             :     int16_t L_spec,               /* i  : length of the spectrum                                                                  */
    7219             :     const int16_t transform_type, /* i  : transform type for the frame/subframe - TCX20 | TCX10 | TCX 5 (meaning 2 x TCX 5)       */
    7220             :     const int16_t isAfterACELP,   /* i  : Flag indicating if the last frame was ACELP. For the second TCX subframe it should be 0 */
    7221             :     float spectrum[],             /* i  : MDCT spectrum of the subframe                                                           */
    7222             :     TRAN_DET_HANDLE hTranDet,     /* i  : handle transient detection                                                              */
    7223             :     const float ltp_gain,         /* i  : ltp gain                                                                                */
    7224             :     STnsData *pTnsData,           /* o  : TNS data                                                                                */
    7225             :     int16_t *pfUseTns,            /* o  : Flag indicating if TNS is used                                                          */
    7226             :     float *predictionGain         /* o  : TNS prediction gain                                                                     */
    7227             : );
    7228             : 
    7229             : void CalculateTnsFilt(
    7230             :     STnsConfig const *pTnsConfig, /* i  : TNS Configuration struct          */
    7231             :     const float pSpectrum[],      /* i  : MDCT spectrum                     */
    7232             :     STnsData *pTnsData,           /* o  : TNS data struct                   */
    7233             :     float *predictionGain         /* o  : TNS prediction gain               */
    7234             : );
    7235             : 
    7236             : void ShapeSpectrum(
    7237             :     TCX_CONFIG_HANDLE hTcxCfg,  /* i  : configuration of TCX                */
    7238             :     const float A[],            /* i  : quantized coefficients NxAz_q[M+1]  */
    7239             :     float gainlpc[],            /* o  : MDCT gains for the previous frame   */
    7240             :     const int16_t L_frame_glob, /* i  : frame length                        */
    7241             :     int16_t L_spec,             /* i  : length of the spectrum              */
    7242             :     float spectrum[],           /* i/o: MDCT spectrum                       */
    7243             :     const int16_t fUseTns,      /* i  : Flag indicating if TNS is used      */
    7244             :     Encoder_State *st,          /* i/o: encoder state structure             */
    7245             :     float *scf                  /* i  : scale factors                       */
    7246             : );
    7247             : 
    7248             : void QuantizeSpectrum(
    7249             :     Encoder_State *st,           /* i/o: encoder state structure                     */
    7250             :     const float A[],             /* i  : quantized coefficients NxAz_q[M+1]          */
    7251             :     const Word16 Aqind[],        /* i  : frame-independent quantized coeffs (M+1)    */
    7252             :     float gainlpc[],             /* i  : MDCT gains of the previous frame            */
    7253             :     float synth[],               /* o  : synthesis buffer                            */
    7254             :     const int16_t nb_bits,       /* i  : bit budget                                  */
    7255             :     const int16_t tnsSize,       /* i  : number of tns parameters put into prm       */
    7256             :     int16_t prm[],               /* o  : tcx parameters                              */
    7257             :     const int16_t frame_cnt,     /* i  : frame counter in the super_frame            */
    7258             :     CONTEXT_HM_CONFIG *hm_cfg,   /* i  : HM configuration                            */
    7259             :     const int16_t vad_hover_flag /* i  : VAD hangover flag                           */
    7260             : );
    7261             : 
    7262             : /*! r: index of next coefficient */
    7263             : int16_t get_next_coeff_mapped(
    7264             :     int16_t ii[2],            /* i/o: coefficient indexes                         */
    7265             :     int32_t *pp,              /* o  : peak(1)/hole(0) indicator                   */
    7266             :     int16_t *idx,             /* o  : index in unmapped domain                    */
    7267             :     CONTEXT_HM_CONFIG *hm_cfg /* i  : HM configuration                            */
    7268             : );
    7269             : 
    7270             : /*! r: index of next coefficient */
    7271             : int16_t get_next_coeff_unmapped(
    7272             :     int16_t *ii, /* i/o: coefficient index                           */
    7273             :     int16_t *idx /* o  : index in unmapped domain                    */
    7274             : );
    7275             : 
    7276             : int32_t update_mixed_context(
    7277             :     int32_t ctx,
    7278             :     int16_t a );
    7279             : 
    7280             : void ACcontextMapping_encode2_no_mem_s17_LC(
    7281             :     BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle                            */
    7282             :     int16_t *x,
    7283             :     int16_t nt,
    7284             :     int16_t lastnz,
    7285             :     int16_t nbbits,
    7286             :     int16_t resQMaxBits,
    7287             :     CONTEXT_HM_CONFIG *hm_cfg );
    7288             : 
    7289             : int16_t ACcontextMapping_decode2_no_mem_s17_LC(
    7290             :     Decoder_State *st,        /* i/o: decoder state                               */
    7291             :     int16_t *x,               /* o  : decoded spectrum                            */
    7292             :     int16_t nt,               /* i  : size of spectrum                            */
    7293             :     int16_t nbbits,           /* i  : bit budget                                  */
    7294             :     int16_t resQMaxBits,      /* i  : residual coding maximum bits                */
    7295             :     CONTEXT_HM_CONFIG *hm_cfg /* i  : context-based harmonic model configuration  */
    7296             : );
    7297             : 
    7298             : int16_t ACcontextMapping_encode2_estimate_no_mem_s17_LC(
    7299             :     const int16_t *x,
    7300             :     const int16_t nt,
    7301             :     int16_t *lastnz,
    7302             :     int16_t *nEncoded,
    7303             :     const int16_t target,
    7304             :     int16_t *stop,
    7305             :     CONTEXT_HM_CONFIG *hm_cfg );
    7306             : 
    7307             : void RCcontextMapping_encode2_no_mem_s17_LCS(
    7308             :     BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle                        */
    7309             :     int16_t *x,
    7310             :     const int16_t nt,
    7311             :     int16_t lastnz,
    7312             :     const int16_t nbbits,
    7313             :     const int16_t resQMaxBits,
    7314             :     CONTEXT_HM_CONFIG *hm_cfg );
    7315             : 
    7316             : int16_t RCcontextMapping_decode2_no_mem_s17_LCS(
    7317             :     Decoder_State *st,         /* i/o: decoder state                               */
    7318             :     int16_t *x,                /* o  : decoded spectrum                            */
    7319             :     const int16_t nt,          /* i  : size of spectrum                            */
    7320             :     const int16_t nbbits,      /* i  : bit budget                                  */
    7321             :     const int16_t resQMaxBits, /* i  : residual coding maximum bits                */
    7322             :     CONTEXT_HM_CONFIG *hm_cfg  /* i  : context-based harmonic model configuration  */
    7323             : );
    7324             : 
    7325             : int16_t RCcontextMapping_encode2_estimate_no_mem_s17_LCS(
    7326             :     int16_t *x,       /* Spectral coefficients */
    7327             :     const int16_t nt, /* L - size of spectrum (no. of spectral coefficients) */
    7328             :     int16_t *lastnz_out,
    7329             :     int16_t *nEncoded,    /* No. of spectral coefficients that can be coded without an overflow occuring */
    7330             :     const int16_t target, /* Target bits */
    7331             :     int16_t *stop,
    7332             :     int16_t mode,
    7333             :     CONTEXT_HM_CONFIG *hm_cfg /* context-based harmonic model configuration */
    7334             : );
    7335             : 
    7336             : int16_t RCcontextMapping_encode2_estimate_bandWise_start(
    7337             :     int16_t *x,
    7338             :     const int16_t nt,
    7339             :     const int16_t target,
    7340             :     HANDLE_RC_CONTEXT_MEM hContextMem );
    7341             : 
    7342             : int16_t RCcontextMapping_encode2_estimate_bandWise(
    7343             :     int16_t *x,
    7344             :     const int16_t start_line,
    7345             :     const int16_t end_line,
    7346             :     HANDLE_RC_CONTEXT_MEM hContextMem );
    7347             : 
    7348             : void tcx_get_windows(
    7349             :     TCX_CONFIG_HANDLE hTcxCfg, /* i  : TCX configuration                   */
    7350             :     const int16_t left_mode,   /* i  : overlap mode of left window half    */
    7351             :     const int16_t right_mode,  /* i  : overlap mode of right window half   */
    7352             :     int16_t *left_overlap,     /* o  : left overlap length                 */
    7353             :     const float **left_win,    /* o  : left overlap window                 */
    7354             :     int16_t *right_overlap,    /* o  : right overlap length                */
    7355             :     const float **right_win,   /* o  : right overlap window                */
    7356             :     const int16_t fullband     /* i  : fullband flag                       */
    7357             : );
    7358             : 
    7359             : void tcx_windowing_analysis(
    7360             :     const float *signal,         /* i  : signal vector                              */
    7361             :     const int16_t L_frame,       /* i  : frame length                               */
    7362             :     const int16_t left_overlap,  /* i  : left overlap length                        */
    7363             :     const float *left_win,       /* i  : left overlap window                        */
    7364             :     const int16_t right_overlap, /* i  : right overlap length                       */
    7365             :     const float *right_win,      /* i  : right overlap window                       */
    7366             :     float *output                /* o  : windowed signal vector                     */
    7367             : );
    7368             : 
    7369             : void tcx_windowing_synthesis_current_frame(
    7370             :     float *signal,                    /* i/o: signal vector                              */
    7371             :     const float *window,              /* i  : TCX window vector                          */
    7372             :     const float *window_half,         /* i  : TCX window vector for half-overlap window  */
    7373             :     const float *window_min,          /* i  : TCX minimum overlap window                 */
    7374             :     const int16_t window_length,      /* i  : TCX window length                          */
    7375             :     const int16_t window_half_length, /* i  : TCX half window length                     */
    7376             :     const int16_t window_min_length,  /* i  : TCX minimum overlap length                 */
    7377             :     const int16_t left_rect,          /* i  : left part is rectangular                   */
    7378             :     const int16_t left_mode,          /* i  : overlap mode of left window half           */
    7379             :     float *acelp_zir,                 /* i/o: acelp ZIR                                  */
    7380             :     const float *old_syn,             /* i  : old synthesis                              */
    7381             :     const float *syn_overl,           /* i  : overlap synthesis                          */
    7382             :     const float *A_zir,
    7383             :     const float *window_trans, /* i  : window for transition from ACELP           */
    7384             :     int16_t acelp_zir_len,
    7385             :     const int16_t acelp_mem_len,
    7386             :     const int16_t last_core_bfi, /* i  : last mode                                  */
    7387             :     const int16_t last_is_cng,
    7388             :     const int16_t fullbandScale );
    7389             : 
    7390             : void tcx_windowing_synthesis_past_frame(
    7391             :     float *signal,                    /* i/o: signal vector                              */
    7392             :     const float *window,              /* i  : TCX window vector                          */
    7393             :     const float *window_half,         /* i  : TCX window vector for half-overlap window  */
    7394             :     const float *window_min,          /* i  : TCX minimum overlap window                 */
    7395             :     const int16_t window_length,      /* i  : TCX window length                          */
    7396             :     const int16_t window_half_length, /* i  : TCX half window length                     */
    7397             :     const int16_t window_min_length,  /* i  : TCX minimum overlap length                 */
    7398             :     const int16_t right_mode          /* i  : overlap mode (left_mode of current frame)  */
    7399             : );
    7400             : 
    7401             : void ProcessIGF(
    7402             :     Encoder_State *st,              /* i  : Encoder state                               */
    7403             :     float *pMDCTSpectrum,           /* i  : MDCT spectrum                               */
    7404             :     const float *pITFMDCTSpectrum,  /* i  : MDCT spectrum fir ITF                       */
    7405             :     float *pPowerSpectrum,          /* i  : MDCT^2 + MDST^2 spectrum, or estimate       */
    7406             :     const int16_t isTCX20,          /* i  : flag indicating if the input is TCX20 or TCX10/2xTCX5 */
    7407             :     const int16_t frameno,          /* i  : flag indicating index of current subframe   */
    7408             :     const int16_t sp_aud_decision0, /* i  : first stage switching decision             */
    7409             :     const int16_t vad_hover_flag    /* i  : VAD hangover flag                          */
    7410             : );
    7411             : 
    7412             : void ProcessStereoIGF(
    7413             :     STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct,
    7414             :     Encoder_State *sts[CPE_CHANNELS],                 /* i  : Encoder state                           */
    7415             :     int16_t ms_mask[2][MAX_SFB],                      /* i  : bandwise MS mask                        */
    7416             :     float *pITFMDCTSpectrum[CPE_CHANNELS][NB_DIV],    /* i  : MDCT spectrum fir ITF                   */
    7417             :     float *pPowerSpectrum[CPE_CHANNELS],              /* i/o: MDCT^2 + MDST^2 spectrum, or estimate   */
    7418             :     float *pPowerSpectrumMsInv[CPE_CHANNELS][NB_DIV], /* i  : inverse power spectrum                  */
    7419             :     float *inv_spectrum[CPE_CHANNELS][NB_DIV],        /* i  : inverse spectrum                        */
    7420             :     const int16_t frameno,                            /* i  : flag indicating index of current subframe*/
    7421             :     const int16_t sp_aud_decision0,                   /* i  : sp_aud_decision0                        */
    7422             :     const int32_t element_brate,                      /* i  : element bitrate                         */
    7423             :     const int16_t mct_on                              /* i  : flag mct block (1) or stereo (0)        */
    7424             : );
    7425             : 
    7426             : void AnalyzePowerSpectrum(
    7427             :     Encoder_State *st,           /* i/o: encoder states                                */
    7428             :     const int16_t L_frame,       /* i  : frame length                                  */
    7429             :     const int16_t L_frameTCX,    /* i  : full band frame length                        */
    7430             :     const int16_t left_overlap,  /* i  : left overlap length                           */
    7431             :     const int16_t right_overlap, /* i  : right overlap length                          */
    7432             :     const float mdctSpectrum[],  /* i  : MDCT spectrum                                 */
    7433             :     const float signal[],        /* i  : windowed signal corresponding to mdctSpectrum */
    7434             :     float powerSpec[]            /* o  : Power spectrum                                */
    7435             : );
    7436             : 
    7437             : void lpc2mdct(
    7438             :     float *lpcCoeffs,
    7439             :     const int16_t lpcOrder,
    7440             :     float mdct_gains[],
    7441             :     const int16_t length,
    7442             :     const int16_t noInverse );
    7443             : 
    7444             : void mdct_preShaping(
    7445             :     float x[],
    7446             :     const int16_t lg,
    7447             :     const float gains[] );
    7448             : 
    7449             : void mdct_noiseShaping(
    7450             :     float x[],
    7451             :     const int16_t lg,
    7452             :     const float gains[],
    7453             :     const int16_t nBands );
    7454             : 
    7455             : void AdaptLowFreqEmph(
    7456             :     float x[],
    7457             :     int16_t xq[],
    7458             :     float invGain,
    7459             :     const int16_t tcx_lpc_shaped_ari,
    7460             :     const float lpcGains[],
    7461             :     const int16_t lg );
    7462             : 
    7463             : void PsychAdaptLowFreqEmph(
    7464             :     float x[],
    7465             :     const float lpcGains[] );
    7466             : 
    7467             : void PsychAdaptLowFreqDeemph(
    7468             :     float x[],
    7469             :     const float lpcGains[],
    7470             :     float lf_deemph_factors[] );
    7471             : 
    7472             : void AdaptLowFreqDeemph(
    7473             :     float x[],
    7474             :     int16_t tcx_lpc_shaped_ari,
    7475             :     const float lpcGains[],
    7476             :     const int16_t lg,
    7477             :     float lf_deemph_factors[] );
    7478             : 
    7479             : /*! r: SQ gain */
    7480             : float SQ_gain(
    7481             :     const float x[],       /* i  : vector to quantize           */
    7482             :     const int16_t nbitsSQ, /* i  : number of bits targeted      */
    7483             :     const int16_t lg       /* i  : vector size (2048 max)       */
    7484             : );
    7485             : 
    7486             : /*! r: SQ gain */
    7487             : float SQ_gain_estimate(
    7488             :     const float x[],       /* i  :  vector to quantize           */
    7489             :     const int16_t nbitsSQ, /* i  :  number of bits targeted      */
    7490             :     const int16_t lg       /* i  :  vector size (2048 max)       */
    7491             : );
    7492             : 
    7493             : 
    7494             : void tcx_scalar_quantization(
    7495             :     float *x,               /* i  : input coefficients            */
    7496             :     int16_t *xq,            /* o  : quantized coefficients        */
    7497             :     const int16_t L_frame,  /* i  : frame length                  */
    7498             :     const float gain,       /* i  : quantization gain             */
    7499             :     const float offset,     /* i  : rounding offset (deadzone)    */
    7500             :     int16_t *memQuantZeros, /* o  : coefficients set to 0         */
    7501             :     const int16_t tcxonly );
    7502             : 
    7503             : int16_t tcx_scalar_quantization_rateloop(
    7504             :     float *x,                       /* i  : input coefficients            */
    7505             :     int16_t *xq,                    /* o  : quantized coefficients        */
    7506             :     const int16_t L_frame,          /* i  : frame length                  */
    7507             :     float *gain,                    /* i/o: quantization gain             */
    7508             :     float offset,                   /* i  : rounding offset (deadzone)    */
    7509             :     int16_t *memQuantZeros,         /* o  : coefficients set to 0         */
    7510             :     int16_t *lastnz_out,            /* i/o: last nonzero coeff index      */
    7511             :     const int16_t target,           /* i  : target number of bits         */
    7512             :     int16_t *nEncoded,              /* o  : number of encoded coeff       */
    7513             :     int16_t *stop,                  /* i/o: stop param                    */
    7514             :     const int16_t sqBits_in_noStop, /* i  : number of sqBits as determined in prev. quant. stage, w/o using stop mechanism (ie might exceed target bits) */
    7515             :     const int16_t sqBits_in,        /* i  : number of sqBits as determined in prev. quant. stage, using stop mechanism (ie always <= target bits) */
    7516             :     const int16_t tcxRateLoopOpt,   /* i  : turns on/off rateloop optimization */
    7517             :     const int16_t tcxonly,
    7518             :     CONTEXT_HM_CONFIG *hm_cfg,
    7519             :     const int16_t iter_max,
    7520             :     const int16_t element_mode );
    7521             : 
    7522             : void tcx_QuantizeGain(
    7523             :     const int16_t n,
    7524             :     float *pGain,
    7525             :     int16_t *pQuantizedGain );
    7526             : 
    7527             : void tcx_noise_factor(
    7528             :     const float *x_orig,        /* i  : unquantized mdct coefficients             */
    7529             :     float *sqQ,                 /* i/o: quantized mdct coefficients               */
    7530             :     const int16_t iFirstLine,   /* i  : first coefficient to be considered        */
    7531             :     const int16_t lowpassLine,  /* i  : last nonzero coefficients after low-pass  */
    7532             :     const int16_t nMinHoleSize, /* i  : minimum size of hole to be checked        */
    7533             :     const int16_t L_frame,      /* i  : frame length                              */
    7534             :     const float gain_tcx,       /* i  : tcx gain                                  */
    7535             :     const float tiltCompFactor, /* i  : LPC tilt compensation factor              */
    7536             :     float *fac_ns,              /* o  : noise factor                              */
    7537             :     int16_t *quantized_fac_ns,  /* o  : quantized noise factor                    */
    7538             :     const int16_t element_mode  /* i  : IVAS element mode                         */
    7539             : );
    7540             : 
    7541             : void tcx_noise_filling(
    7542             :     float *Q,
    7543             :     const int16_t noiseFillSeed,
    7544             :     const int16_t iFirstLine,
    7545             :     const int16_t lowpassLine,
    7546             :     const int16_t nTransWidth,
    7547             :     const int16_t L_frame,
    7548             :     const float tiltCompFactor,
    7549             :     float fac_ns,
    7550             :     uint8_t *infoTCXNoise,
    7551             :     const int16_t element_mode /* i  : IVAS element mode                         */
    7552             : );
    7553             : 
    7554             : void tcx_encoder_memory_update(
    7555             :     Encoder_State *st, /* i/o: encoder memory state                        */
    7556             :     float *xn_buf,     /* i/o: mdct output buffer/TD weigthed synthesis    */
    7557             :     const float *Ai,   /* i  : Unquantized (interpolated) LPC coefficients */
    7558             :     const float *A     /* i  : Quantized LPC coefficients                  */
    7559             : );
    7560             : 
    7561             : void tcx_decoder_memory_update(
    7562             :     Decoder_State *st,   /* i/o: decoder memory state                        */
    7563             :     const float *xn_buf, /* i  : mdct output buffer                          */
    7564             :     float *synth,        /* i/o: synth                                       */
    7565             :     const float *A       /* i  : Quantized LPC coefficients                  */
    7566             : );
    7567             : 
    7568             : /*! r: number of bits used (including "bits") */
    7569             : int16_t tcx_ari_res_Q_spec(
    7570             :     const float x_orig[],  /* i  : original spectrum                           */
    7571             :     const int16_t signs[], /* i  : signs (x_orig[.]<0)                         */
    7572             :     float x_Q[],           /* i/o: quantized spectrum                          */
    7573             :     const int16_t L_frame, /* i  : number of lines                             */
    7574             :     const float gain,      /* i  : TCX gain                                    */
    7575             :     int16_t prm[],         /* o  : bitstream                                   */
    7576             :     int16_t target_bits,   /* i  : number of bits available                    */
    7577             :     int16_t bits,          /* i  : number of bits used so far                  */
    7578             :     const float deadzone,  /* i  : quantizer deadzone                          */
    7579             :     const float x_fac[]    /* i  : spectrum post-quantization factors          */
    7580             : );
    7581             : 
    7582             : /*! r: number of bits used (including "bits") */
    7583             : int16_t tcx_ari_res_invQ_spec(
    7584             :     float x_Q[],           /* i/o: quantized spectrum                          */
    7585             :     const int16_t L_frame, /* i  : number of lines                             */
    7586             :     const int16_t prm[],   /* i  : bitstream                                   */
    7587             :     int16_t target_bits,   /* i  : number of bits available                    */
    7588             :     int16_t bits,          /* i  : number of bits used so far                  */
    7589             :     const float deadzone,  /* i  : quantizer deadzone                          */
    7590             :     const float x_fac[]    /* i  : spectrum post-quantization factors          */
    7591             : );
    7592             : 
    7593             : int16_t tcx_res_Q_gain(
    7594             :     float sqGain,
    7595             :     float *gain_tcx,
    7596             :     int16_t *prm,
    7597             :     int16_t sqTargetBits );
    7598             : 
    7599             : int16_t tcx_res_Q_spec(
    7600             :     const float *x_orig,
    7601             :     float *x_Q,
    7602             :     const int16_t L_frame,
    7603             :     const float sqGain,
    7604             :     int16_t *prm,
    7605             :     int16_t sqTargetBits,
    7606             :     int16_t bits,
    7607             :     const float sq_round,
    7608             :     const float lf_deemph_factors[] );
    7609             : 
    7610             : int16_t tcx_res_invQ_gain(
    7611             :     float *gain_tcx,
    7612             :     const int16_t *prm,
    7613             :     const int16_t resQBits );
    7614             : 
    7615             : int16_t tcx_res_invQ_spec(
    7616             :     float *x,
    7617             :     const int16_t L_frame,
    7618             :     const int16_t *prm,
    7619             :     int16_t resQBits,
    7620             :     int16_t bits,
    7621             :     const float sq_round,
    7622             :     const float lf_deemph_factors[] );
    7623             : 
    7624             : void InitTnsConfigs(
    7625             :     const int16_t bwidth,
    7626             :     const int16_t L_frame,
    7627             :     STnsConfig tnsConfig[2][2],
    7628             :     const int16_t igfStopFreq,
    7629             :     const int32_t total_brate,
    7630             :     const int16_t element_mode,
    7631             :     const int16_t MCT_flag );
    7632             : 
    7633             : void SetAllowTnsOnWhite(
    7634             :     STnsConfig tnsConfig[2][2],
    7635             :     const int8_t allowTnsOnWhite );
    7636             : 
    7637             : void SetTnsConfig(
    7638             :     TCX_CONFIG_HANDLE hTcxCfg,
    7639             :     const int16_t isTCX20,
    7640             :     const int16_t isAfterACELP );
    7641             : 
    7642             : void ari_copy_states(
    7643             :     Tastat *source,
    7644             :     Tastat *dest );
    7645             : 
    7646             : int32_t mul_sbc_14bits(
    7647             :     int32_t r,
    7648             :     int32_t c );
    7649             : 
    7650             : void ari_start_encoding_14bits(
    7651             :     Tastat *s );
    7652             : 
    7653             : int16_t ari_encode_14bits_ext(
    7654             :     int16_t *ptr,
    7655             :     int16_t bp,
    7656             :     Tastat *s,
    7657             :     int32_t symbol,
    7658             :     const uint16_t *cum_freq );
    7659             : 
    7660             : int16_t ari_done_encoding_14bits(
    7661             :     int16_t *ptr,
    7662             :     int16_t bp,
    7663             :     Tastat *s );
    7664             : 
    7665             : void ari_start_decoding_14bits(
    7666             :     Decoder_State *st,
    7667             :     Tastat *s );
    7668             : 
    7669             : int16_t ari_start_decoding_14bits_prm(
    7670             :     const int16_t *ptr,
    7671             :     int16_t bp,
    7672             :     Tastat *s );
    7673             : 
    7674             : void ari_decode_14bits_s17_ext(
    7675             :     Decoder_State *st,
    7676             :     uint16_t *res,
    7677             :     Tastat *s,
    7678             :     const uint16_t *cum_freq );
    7679             : 
    7680             : void ari_decode_14bits_s27_ext(
    7681             :     Decoder_State *st,
    7682             :     uint16_t *res,
    7683             :     Tastat *s,
    7684             :     const uint16_t *cum_freq );
    7685             : 
    7686             : void ari_decode_14bits_bit_ext(
    7687             :     Decoder_State *st,
    7688             :     uint16_t *res,
    7689             :     Tastat *s );
    7690             : 
    7691             : /*! r: Q15 */
    7692             : Word16 expfp(
    7693             :     const Word16 x,  /* i  : mantissa  Q15-e                         */
    7694             :     const Word16 x_e /* i  : exponent  Q0                            */
    7695             : );
    7696             : 
    7697             : void powfp_odd2(
    7698             :     const Word16 base, /* Q15 */
    7699             :     const Word16 exp,  /* Q0  */
    7700             :     Word16 *pout1,     /* Q15 */
    7701             :     Word16 *pout2      /* Q15 */
    7702             : );
    7703             : 
    7704             : void tcx_arith_scale_envelope(
    7705             :     const Word16 L_spec_core,    /* i  : number of lines to scale    Q0          */
    7706             :     Word16 L_frame,              /* i  : number of lines             Q0          */
    7707             :     const Word32 env[],          /* i  : unscaled envelope           Q16         */
    7708             :     Word16 target_bits,          /* i  : number of available bits    Q0          */
    7709             :     const Word16 low_complexity, /* i  : low-complexity flag         Q0          */
    7710             :     Word16 s_env[],              /* o  : scaled envelope             Q15-e       */
    7711             :     Word16 *s_env_e              /* o  : scaled envelope exponent    Q0          */
    7712             : );
    7713             : 
    7714             : void tcx_arith_render_envelope(
    7715             :     const Word16 A_ind[],     /* i  : LPC coefficients of signal envelope     */
    7716             :     const Word16 L_frame,     /* i  : number of spectral lines                */
    7717             :     const Word16 L_spec,      /* i  : length of the coded spectrum            */
    7718             :     const Word16 preemph_fac, /* i  : pre-emphasis factor                     */
    7719             :     const Word16 gamma_w,     /* i  : A_ind -> weighted envelope factor       */
    7720             :     const Word16 gamma_uw,    /* i  : A_ind -> non-weighted envelope factor   */
    7721             :     Word32 env[]              /* o  : shaped signal envelope                  */
    7722             : );
    7723             : 
    7724             : int16_t ari_encode_14bits_range(
    7725             :     int16_t *ptr,
    7726             :     int16_t bp,
    7727             :     int32_t bits,
    7728             :     Tastat *s,
    7729             :     uint16_t cum_freq_low,
    7730             :     uint16_t cum_freq_high );
    7731             : 
    7732             : int16_t ari_encode_14bits_sign(
    7733             :     int16_t *ptr,
    7734             :     int16_t bp,
    7735             :     int32_t bits,
    7736             :     Tastat *s,
    7737             :     int32_t sign );
    7738             : 
    7739             : int16_t ari_done_cbr_encoding_14bits(
    7740             :     int16_t *ptr,
    7741             :     int16_t bp,
    7742             :     int32_t bits,
    7743             :     Tastat *s );
    7744             : 
    7745             : int16_t ari_decode_14bits_pow(
    7746             :     const int16_t *ptr,
    7747             :     int16_t bp,
    7748             :     int16_t bits,
    7749             :     int16_t *res,
    7750             :     Tastat *s,
    7751             :     uint16_t base );
    7752             : 
    7753             : int16_t ari_decode_14bits_sign(
    7754             :     const int16_t *ptr,
    7755             :     int16_t bp,
    7756             :     int16_t bits,
    7757             :     uint16_t *res,
    7758             :     Tastat *s );
    7759             : 
    7760             : void tcx_arith_encode_envelope(
    7761             :     float spectrum[],            /* i/o: MDCT coefficients             */
    7762             :     int16_t signs[],             /* o  : signs (spectrum[.]<0)         */
    7763             :     const int16_t L_frame,       /* i  : frame or MDCT length          */
    7764             :     const int16_t L_spec,        /* i  : length w/o BW limitation      */
    7765             :     Encoder_State *st,           /* i/o: coder state                   */
    7766             :     const Word16 A_ind[],        /* i  : quantised LPC coefficients    */
    7767             :     int16_t target_bits,         /* i  : number of available bits      */
    7768             :     int16_t prm[],               /* o  : bitstream parameters          */
    7769             :     const int16_t use_hm,        /* i  : use HM in current frame?      */
    7770             :     int16_t prm_hm[],            /* o  : HM parameter area             */
    7771             :     const int16_t tcxltp_pitch,  /* i  : TCX LTP pitch in FD, -1 if n/a*/
    7772             :     int16_t *arith_bits,         /* o  : bits used for ari. coding     */
    7773             :     int16_t *signaling_bits,     /* o  : bits used for signaling       */
    7774             :     const int16_t low_complexity /* i  : low-complexity flag           */
    7775             : );
    7776             : 
    7777             : void tcx_arith_decode_envelope(
    7778             :     Decoder_State *st,           /* i/o: coder state                   */
    7779             :     float q_spectrum[],          /* o  : quantised MDCT coefficients   */
    7780             :     const int16_t L_frame,       /* i  : frame or MDCT length          */
    7781             :     int16_t L_spec,              /* i  : length w/o BW limitation      */
    7782             :     const Word16 A_ind[],        /* i  : quantised LPC coefficients    */
    7783             :     const int16_t target_bits,   /* i  : number of available bits      */
    7784             :     const int16_t prm[],         /* i  : bitstream parameters          */
    7785             :     const int16_t use_hm,        /* i  : use HM in current frame?      */
    7786             :     const int16_t prm_hm[],      /* i  : HM parameter area             */
    7787             :     int16_t tcxltp_pitch,        /* i  : TCX LTP pitch in FD, -1 if n/a*/
    7788             :     int16_t *arith_bits,         /* o  : bits used for ari. coding     */
    7789             :     int16_t *signaling_bits,     /* o  : bits used for signaling       */
    7790             :     const int16_t low_complexity /* i  : low-complexity flag           */
    7791             : );
    7792             : 
    7793             : void UnmapIndex(
    7794             :     const int16_t PeriodicityIndex,
    7795             :     const int16_t Bandwidth,
    7796             :     const int16_t LtpPitchLag,
    7797             :     const int16_t SmallerLags,
    7798             :     int16_t *FractionalResolution,
    7799             :     int32_t *Lag );
    7800             : 
    7801             : /*! r: PeriodicityIndex */
    7802             : int16_t SearchPeriodicityIndex(
    7803             :     const float Mdct[],            /* i  : Coefficients, Mdct[0..NumCoeffs-1]                      */
    7804             :     const float UnfilteredMdct[],  /* i  : Unfiltered coefficients, UnfilteredMdct[0..NumCoeffs-1] */
    7805             :     const int16_t NumCoeffs,       /* i  : Number of coefficients                                  */
    7806             :     const int16_t shortTargetBits, /* i  : Target bit budget (excl. Done flag)                     */
    7807             :     const int16_t LtpPitchLag,     /* i  : TCX-LTP pitch                                           */
    7808             :     const float LtpGain,           /* i  : LTP gain                                                */
    7809             :     float *RelativeScore           /* o  : Energy concentration factor                             */
    7810             : );
    7811             : 
    7812             : void ConfigureContextHm(
    7813             :     const int16_t NumCoeffs,        /* i  : Number of coefficients                                  */
    7814             :     const int16_t TargetBits,       /* i  : Target bit budget (excl. Done flag)                     */
    7815             :     const int16_t PeriodicityIndex, /* i  : Pitch related index                                     */
    7816             :     const int16_t LtpPitchLag,      /* i  : TCX-LTP pitch in F.D.                                   */
    7817             :     CONTEXT_HM_CONFIG *hm_cfg       /* o  : Context-based harmonic model configuration              */
    7818             : );
    7819             : 
    7820             : int16_t EncodeIndex(
    7821             :     const int16_t Bandwidth, /* o  : NB, 1: (S)WB                                            */
    7822             :     int16_t PeriodicityIndex,
    7823             :     BSTR_ENC_HANDLE hBstr );
    7824             : 
    7825             : int16_t CountIndexBits(
    7826             :     const int16_t Bandwidth, /* o  : NB, 1: (S)WB                                            */
    7827             :     const int16_t PeriodicityIndex );
    7828             : 
    7829             : int16_t DecodeIndex(
    7830             :     Decoder_State *st,
    7831             :     const int16_t Bandwidth, /* o  : NB, 1: (S)WB                                            */
    7832             :     int16_t *PeriodicityIndex );
    7833             : 
    7834             : #define GET_ADJ( T, L )     GET_ADJ2( T, L, *FractionalResolution )
    7835             : #define GET_ADJ2( T, L, F ) ( ( ( L ) << ( F ) ) - ( T ) )
    7836             : 
    7837             : int16_t tcx_hm_render(
    7838             :     const int32_t lag,       /* i  : pitch lag                             */
    7839             :     const int16_t fract_res, /* i  : fractional resolution of the lag      */
    7840             :     Word16 p[]               /* o  : harmonic model (Q13)                  */
    7841             : );
    7842             : 
    7843             : void tcx_hm_modify_envelope(
    7844             :     const Word16 gain, /* i  : HM gain (Q11)                         */
    7845             :     const int32_t lag,
    7846             :     const int16_t fract_res,
    7847             :     const Word16 p[],     /* i  : harmonic model (Q13)                  */
    7848             :     Word32 env[],         /* i/o: envelope (Q16)                        */
    7849             :     const int16_t L_frame /* i  : number of spectral lines              */
    7850             : );
    7851             : 
    7852             : void tcx_hm_analyse(
    7853             :     const float abs_spectrum[], /* i  : absolute spectrum                     */
    7854             :     const int16_t L_frame,      /* i  : number of spectral lines              */
    7855             :     Word32 env[],               /* i/o: envelope shape (Q16)                  */
    7856             :     const int16_t targetBits,   /* i  : target bit budget                     */
    7857             :     const int16_t coder_type,   /* i  : GC/VC coder type                      */
    7858             :     int16_t prm_hm[],           /* o  : HM parameters                         */
    7859             :     int16_t LtpPitchLag,        /* i  : LTP pitch lag or -1 if none           */
    7860             :     const float LtpGain,        /* i  : LTP gain                              */
    7861             :     int16_t *hm_bits            /* o  : bit consumption                       */
    7862             : );
    7863             : 
    7864             : void tcx_hm_decode(
    7865             :     const int16_t L_frame,     /* i  : number of spectral lines              */
    7866             :     Word32 env[],              /* i/o: envelope shape (Q16)                  */
    7867             :     const int16_t targetBits,  /* i  : target bit budget                     */
    7868             :     const int16_t coder_type,  /* i  : GC/VC coder type                      */
    7869             :     const int16_t prm_hm[],    /* i  : HM parameters                         */
    7870             :     const int16_t LtpPitchLag, /* i  : LTP pitch lag or -1 if none           */
    7871             :     int16_t *hm_bits           /* o  : bit consumption                       */
    7872             : );
    7873             : 
    7874             : void coder_tcx(
    7875             :     Encoder_State *st,          /* i/o: encoder state structure               */
    7876             :     TCX_CONFIG_HANDLE hTcxCfg,  /* i  : configuration of TCX                  */
    7877             :     const float A[],            /* i  : quantized coefficients NxAz_q[M+1]    */
    7878             :     const Word16 Aqind[],       /* i  : frame-independent quantized coefficients (M+1) */
    7879             :     float synth[],              /* o  : decoded synthesis                     */
    7880             :     const int16_t L_frame_glob, /* i  : frame length                          */
    7881             :     const int16_t L_frameTCX_glob,
    7882             :     const int16_t L_spec,
    7883             :     int16_t nb_bits,  /* i  : bit budget                            */
    7884             :     float spectrum[], /* i/o: MDCT spectrum                         */
    7885             :     int16_t prm[],    /* o  : tcx parameters                        */
    7886             :     CONTEXT_HM_CONFIG *hm_cfg,
    7887             :     const int16_t vad_hover_flag /* i  : VAD hangover flag */
    7888             : );
    7889             : 
    7890             : void coder_tcx_post(
    7891             :     Encoder_State *st, /* i/o: encoder memory state                        */
    7892             :     float *A,          /* o  : Quantized LPC coefficients                  */
    7893             :     const float *Ai    /* i  : Unquantized (interpolated) LPC coefficients */
    7894             : );
    7895             : 
    7896             : void decoder_tcx(
    7897             :     Decoder_State *st,                  /* i/o: coder memory state                    */
    7898             :     int16_t prm[],                      /* i  : parameters                            */
    7899             :     float A[],                          /* i  : coefficients NxAz[M+1]                */
    7900             :     Word16 Aind[],                      /* i  : frame-independent coefficients Az[M+1]*/
    7901             :     float synth[],                      /* i/o: synth[-M..lg]                         */
    7902             :     float synthFB[],                    /* i/o: encoder memory state                  */
    7903             :     const int16_t bfi,                  /* i  : Bad frame indicator                   */
    7904             :     const int16_t frame_cnt,            /* i  : frame counter in the super_frame      */
    7905             :     const int16_t sba_dirac_stereo_flag /* i  : signal stereo output for SBA DirAC    */
    7906             : );
    7907             : 
    7908             : void decoder_tcx_post(
    7909             :     Decoder_State *st, /* i/o: decoder memory state          */
    7910             :     float *synth,
    7911             :     float *synthFB,
    7912             :     float *A, /* i  : A(z) filter coefficients             */
    7913             :     const int16_t bfi,
    7914             :     const int16_t isMCT );
    7915             : 
    7916             : void coder_acelp(
    7917             :     Encoder_State *st,    /* i/o: coder memory state          */
    7918             :     const float A[],      /* i  : coefficients 4xAz[M+1]      */
    7919             :     const float Aq[],     /* i  : coefficients 4xAz_q[M+1]    */
    7920             :     const float speech[], /* i  : speech[-M..lg]              */
    7921             :     LPD_state *LPDmem,    /* i/o: ACELP memories              */
    7922             :     int16_t *prm,         /* o  : acelp parameters            */
    7923             :     const float stab_fac,
    7924             :     const int16_t target_bits,
    7925             :     float *gain_pitch_buf, /* o  : gain pitch values           */
    7926             :     float *gain_code_buf,  /* o  : gain code values            */
    7927             :     float *pitch_buf,      /* o  : pitch values for each subfr.*/
    7928             :     float *voice_factors,  /* o  : voicing factors             */
    7929             :     float *bwe_exc         /* o  : excitation for SWB TBE      */
    7930             : );
    7931             : 
    7932             : void coder_acelp_rf(
    7933             :     const int16_t target_bits,   /* i  :   target bits               */
    7934             :     const float speech[],        /* i  : speech[-M..lg]              */
    7935             :     const int16_t coder_type,    /* i  : coding type                 */
    7936             :     const int16_t rf_frame_type, /* i  : rf_frame_type               */
    7937             :     const float A[],             /* i  : coefficients 4xAz[M+1]      */
    7938             :     const float Aq[],            /* i  : coefficients 4xAz_q[M+1]    */
    7939             :     const float voicing[],       /* i  : open-loop LTP gain          */
    7940             :     const int16_t T_op[],        /* i  : open-loop LTP lag           */
    7941             :     const float stab_fac,        /* i  : LP stability factor         */
    7942             :     Encoder_State *st,           /* i/o: coder memory state          */
    7943             :     ACELP_config *acelp_cfg,     /* i/o: configuration of the ACELP  */
    7944             :     float *exc_rf,               /* i/o: pointer to RF excitation    */
    7945             :     float *syn_rf                /* i/o: pointer to RF synthesis     */
    7946             : );
    7947             : 
    7948             : void decoder_acelp(
    7949             :     Decoder_State *st,              /* i/o:  coder memory state         */
    7950             :     int16_t prm[],                  /* i  : parameters                  */
    7951             :     const float A[],                /* i  : coefficients NxAz[M+1]      */
    7952             :     ACELP_config acelp_cfg,         /* i  : ACELP config                */
    7953             :     float synth[],                  /* i/o: synthesis                   */
    7954             :     int16_t *pT,                    /* o  : pitch for all subframe      */
    7955             :     float *pgainT,                  /* o  : pitch gain for all subfr    */
    7956             :     const float stab_fac,           /* i  : stability of isf            */
    7957             :     float *pitch_buffer,            /* o  : pitch values for each subfr.*/
    7958             :     float *voice_factors,           /* o  : voicing factors             */
    7959             :     const int16_t LSF_Q_prediction, /* i  : LSF prediction mode         */
    7960             :     float *bwe_exc                  /* o  : excitation for SWB TBE      */
    7961             : );
    7962             : 
    7963             : void writeTCXMode(
    7964             :     Encoder_State *st,      /* i/o: encoder state structure             */
    7965             :     BSTR_ENC_HANDLE hBstr,  /* i/o: bitstream handle                    */
    7966             :     const int16_t MCT_flag, /* i  : hMCT handle allocated (1) or not (0)*/
    7967             :     int16_t *nbits_start    /* o  : nbits start                         */
    7968             : );
    7969             : 
    7970             : void writeTCXWindowing(
    7971             :     BSTR_ENC_HANDLE hBstr,     /* i/o: bitstream handle            */
    7972             :     const int16_t overlap_mode /* i  : overlap mode                */
    7973             : );
    7974             : 
    7975             : void writeLPCparam(
    7976             :     Encoder_State *st,              /* i/o: encoder state structure     */
    7977             :     BSTR_ENC_HANDLE hBstr,          /* i/o: bitstream handle            */
    7978             :     const int16_t param_lpc[],      /* i  : LPC parameters to write     */
    7979             :     const int16_t bits_param_lpc[], /* i  : bits per LPC parameter      */
    7980             :     const int16_t no_param_lpc,     /* i  : number of LPC parameters    */
    7981             :     int16_t *nbits_lpc              /* o  : LPC bits written            */
    7982             : );
    7983             : 
    7984             : void enc_prm(
    7985             :     Encoder_State *st,   /* i/o: encoder state structure     */
    7986             :     int16_t param[],     /* i  : parameters                  */
    7987             :     int16_t param_lpc[], /* i  : LPC parameters              */
    7988             :     CONTEXT_HM_CONFIG hm_cfg[],
    7989             :     const int16_t bits_param_lpc[],
    7990             :     const int16_t no_param_lpc );
    7991             : 
    7992             : void writeTCXparam(
    7993             :     Encoder_State *st,          /* i/o: Encoder State handle        */
    7994             :     BSTR_ENC_HANDLE hBstr,      /* i/o: bitstream handle            */
    7995             :     CONTEXT_HM_CONFIG hm_cfg[], /* i/o: HM config                   */
    7996             :     int16_t param[],            /* i  : parameters                  */
    7997             :     const int16_t nbits_header,
    7998             :     const int16_t nbits_start,
    7999             :     const int16_t nbits_lpc,
    8000             :     const int16_t *no_param_tns, /* i  : number of TNS parameters per subframe          */
    8001             :     int16_t p_param[2],          /* i/o: pointer to parameters from previous bs writing */
    8002             :     const int16_t target_bitsTCX10[2],
    8003             :     const int16_t pre_past_flag );
    8004             : 
    8005             : void enc_prm_rf(
    8006             :     Encoder_State *st, /* i/o: encoder memory state          */
    8007             :     const int16_t rf_frame_type,
    8008             :     const int16_t fec_offset );
    8009             : 
    8010             : void dec_prm_hm(
    8011             :     Decoder_State *st, /* i/o: decoder memory state          */
    8012             :     int16_t *prm_hm,
    8013             :     const int16_t hm_size );
    8014             : 
    8015             : void dec_prm(
    8016             :     Decoder_State *st,     /* i/o: decoder memory state          */
    8017             :     int16_t param[],       /* o  : decoded parameters            */
    8018             :     int16_t param_lpc[],   /* i  : LPC parameters                */
    8019             :     int16_t *total_nbbits, /* i/o: number of bits / decoded bits */
    8020             :     int16_t *bitsRead );
    8021             : 
    8022             : void gauss_L2(
    8023             :     const float h[],       /* i  : weighted LP filter impulse response     */
    8024             :     float code[],          /* o  : gaussian excitation                     */
    8025             :     float y2[],            /* i  : zero-memory filtered code. excitation   */
    8026             :     float y11[],           /* o  : zero-memory filtered gauss. excitation  */
    8027             :     float *gain,           /* o  : excitation gain                         */
    8028             :     float g_corr[],        /* i/o: correlation structure for gain coding   */
    8029             :     float tilt_code,       /* i  : tilt of code                            */
    8030             :     const float *Aq,       /* i  : quantized LPCs                          */
    8031             :     float formant_enh_num, /* i  : formant enhancement factor              */
    8032             :     int16_t *seed_acelp    /* i/o: random seed                             */
    8033             : );
    8034             : 
    8035             : void gaus_L2_dec(
    8036             :     float *code, /* o  : decoded gaussian codevector             */
    8037             :     float tilt_code,
    8038             :     const float *A,
    8039             :     float formant_enh_num,
    8040             :     int16_t *seed_acelp /* i/o: random seed             */
    8041             : );
    8042             : 
    8043             : /*! r: interpolated value */
    8044             : float interpolation(
    8045             :     const float *x,        /* i  : input vector            */
    8046             :     const float *win,      /* i  : interpolation window    */
    8047             :     const int16_t frac,    /* i  : fraction                */
    8048             :     const int16_t up_samp, /* i  : upsampling factor       */
    8049             :     const int16_t nb_coef  /* i  : nb of filter coef       */
    8050             : );
    8051             : 
    8052             : void predict_signal(
    8053             :     const float excI[],     /* i  : input excitation buffer  */
    8054             :     float excO[],           /* o  : output excitation buffer */
    8055             :     const int16_t T0,       /* i  : integer pitch lag        */
    8056             :     int16_t frac,           /* i  : fraction of lag          */
    8057             :     const int16_t frac_max, /* i  : max fraction             */
    8058             :     const int16_t L_subfr   /* i  : subframe size            */
    8059             : );
    8060             : 
    8061             : void tcx_ltp_encode(
    8062             :     Encoder_State *st,
    8063             :     const int16_t tcxMode,
    8064             :     const int16_t L_frame,
    8065             :     const float *speech,
    8066             :     float *speech_ltp,
    8067             :     const float *wsp,
    8068             :     const int16_t Top[],
    8069             :     int16_t *ltp_param,
    8070             :     int16_t *ltp_bits,
    8071             :     float *A,
    8072             :     const int16_t disable_ltp,
    8073             :     const int16_t element_mode );
    8074             : 
    8075             : void tcx_ltp_post(
    8076             :     Decoder_State *st,
    8077             :     TCX_LTP_DEC_HANDLE hTcxLtpDec,
    8078             :     const int16_t core,
    8079             :     const int16_t output_frame,
    8080             :     const int16_t L_frame,
    8081             :     float sig[],
    8082             :     const float tcx_buf[] );
    8083             : 
    8084             : int16_t tcx_ltp_decode_params(
    8085             :     int16_t *ltp_param,
    8086             :     int16_t *pitch_int,
    8087             :     int16_t *pitch_fr,
    8088             :     float *gain,
    8089             :     const int16_t pitmin,
    8090             :     const int16_t pitfr1,
    8091             :     const int16_t pitfr2,
    8092             :     const int16_t pitmax,
    8093             :     const int16_t pitres );
    8094             : 
    8095             : int16_t enc_lsf_tcxlpc(
    8096             :     const int16_t **indices, /* i  : Ptr to VQ indices                                   */
    8097             :     BSTR_ENC_HANDLE hBstr    /* i/o: encoder bitstream handle                            */
    8098             : );
    8099             : 
    8100             : void msvq_enc(
    8101             :     const float *const *cb,      /* i  : Codebook (indexed cb[*stages][levels][p])            */
    8102             :     const int16_t dims[],        /* i  : Dimension of each codebook stage (NULL: full dim.)   */
    8103             :     const int16_t offs[],        /* i  : Starting dimension of each codebook stage (NULL: 0)  */
    8104             :     const float u[],             /* i  : Vector to be encoded (prediction and mean removed)   */
    8105             :     const int16_t *levels,       /* i  : Number of levels in each stage                       */
    8106             :     const int16_t maxC,          /* i  : Tree search size (number of candidates kept from one stage to the next == M-best) */
    8107             :     const int16_t stages,        /* i  : Number of stages                                     */
    8108             :     const float w[],             /* i  : Weights                                              */
    8109             :     const int16_t N,             /* i  : Vector dimension                                     */
    8110             :     const int16_t maxN,          /* i  : Codebook dimension                                   */
    8111             :     const int16_t applyDCT_flag, /* i  : applyDCT flag                                   */
    8112             :     float *invTrfMatrix,         /* i/o: expanded synthesis matrix                            */
    8113             :     int16_t Idx[]                /* o  : Indices                                              */
    8114             : );
    8115             : 
    8116             : void msvq_dec(
    8117             :     const float *const *cb,       /* i  : Codebook (indexed cb[*stages][levels][p])            */
    8118             :     const int16_t dims[],         /* i  : Dimension of each codebook stage (NULL: full dim.)   */
    8119             :     const int16_t offs[],         /* i  : Starting dimension of each codebook stage (NULL: 0)  */
    8120             :     const int16_t stages,         /* i  : Number of stages                                     */
    8121             :     const int16_t N,              /* i  : Vector dimension                                     */
    8122             :     const int16_t maxN,           /* i  : Codebook dimension                                   */
    8123             :     const int16_t Idx[],          /* i  : Indices                                              */
    8124             :     const int16_t applyIDCT_flag, /* i  : applyIDCT flag                                 */
    8125             :     const float *invTrfMatrix,    /* i  : synthesis matrix                                     */
    8126             :     float *uq,                    /* o  : quantized vector                                     */
    8127             :     Word16 *uq_ind                /* o  : quantized vector (fixed point)                       */
    8128             : );
    8129             : 
    8130             : 
    8131             : void dec_FDCNG_MSVQ_stage1(
    8132             :     int16_t j_full,            /* i  : index full range                     */
    8133             :     int16_t n,                 /* i  : dimension to generate                */
    8134             :     const float *invTrfMatrix, /* i  : IDCT matrix for synthesis            */
    8135             :     const DCTTYPE idcttype,    /* i  : specify which IDCT                   */
    8136             :     float *uq,                 /* o  : synthesized stage1 vector            */
    8137             :     Word16 *uq_ind             /* o  : synthesized stage1 vector in BASOP   */
    8138             : );
    8139             : 
    8140             : void create_IDCT_N_Matrix(
    8141             :     float *inv_matrixFloatQ, /* i/o: RAM buffer */
    8142             :     const int16_t N,         /* i  : DCT length, number of time samples             */
    8143             :     const int16_t n_cols,    /* i  : number of dct coeffs (as DCT may be truncated) */
    8144             :     const int16_t alloc_size /* i  : RAM buffer size in elements                    */
    8145             : );
    8146             : 
    8147             : void dctT2_N_apply_matrix(
    8148             :     const float *input,           /* i  : input  in fdcng or DCT(fdcng) domain     */
    8149             :     float *output,                /* o  : output in DCT(fdcng) or fdcng ordomain   */
    8150             :     const int16_t dct_dim,        /* i  : dct processing dim possibly truncated    */
    8151             :     const int16_t fdcngvq_dim,    /* i  : fdcng domain length                      */
    8152             :     const float *matrix,          /* i  : IDCT matrix                              */
    8153             :     const int16_t matrix_row_dim, /* i  :                                          */
    8154             :     const DCTTYPE dcttype         /* i  : matrix  operation type                   */
    8155             : );
    8156             : 
    8157             : void extend_dctN_input(
    8158             :     const float *input,     /* i  : input in fdcng domain                         */
    8159             :     const float *dct_input, /* i  : input in dctN(fdcng) domain                   */
    8160             :     const int16_t in_dim,   /* i  : in_dim == N                                   */
    8161             :     float *ext_sig,         /* o  : extended output in fdcng domain               */
    8162             :     const int16_t out_dim,  /* i  : output total dim                              */
    8163             :     float *matrix,          /* i  : idct synthesis matrix N rows, n_cols  columns */
    8164             :     const int16_t n_cols,   /* i  : number of columns ==  DCT truncation length   */
    8165             :     const DCTTYPE dcttype   /* i  : matrix operation type                         */
    8166             : );
    8167             : 
    8168             : /*! r: (p_max , best candidate sofar ) */
    8169             : int16_t msvq_stage1_dct_search(
    8170             :     const float *u,                           /* i  : target                                        */
    8171             :     const int16_t N,                          /* i  : target length and  IDCT synthesis length      */
    8172             :     const int16_t maxC_st1,                   /* i  : number of final stage 1 candidates to provide */
    8173             :     const DCTTYPE dcttype,                    /* e.g. DCT_T2_16_XX, DCT_T2_24_XX;                   */
    8174             :     const int16_t max_dct_trunc,              /* i  :  maximum of truncation lenghts                */
    8175             :     float *invTrfMatrix,                      /* i  : IDCT synthesis matrix for dim N               */
    8176             :     const float *midQ_truncQ,                 /* i  : midQ  vector                                  */
    8177             :     const float *dct_invScaleF,               /* i  : global inv scale factors                      */
    8178             :     const float *dct_scaleF,                  /* i  : global scale factors                          */
    8179             :     const Word16 n_segm,                      /* i  : number of segments                            */
    8180             :     const Word16 *cols_per_segment,           /* i  : remaining length per segment                  */
    8181             :     const Word16 *trunc_dct_cols_per_segment, /* i  : trunc length per segment                      */
    8182             :     const Word16 *entries_per_segment,        /* i  : number of rows per segment                    */
    8183             :     const Word16 *cum_entries_per_segment,    /* i  : number of cumulative entries                  */
    8184             :     const Word8 *const W8Qx_dct_sections[],   /* i  : Word8(byte) segment  table ptrs               */
    8185             :     const Word16 *col_syn_shift[],            /* i  : columnwise  syn shift tables                  */
    8186             :     const Word8 *segm_neighbour_fwd,          /* i  : circular neighbour list fwd                   */
    8187             :     const Word8 *segm_neighbour_rev,          /* i  : circular neighbour list reverse               */
    8188             :     const Word16 npost_check,                 /* i  : number of neigbours to check , should be even */
    8189             :     float *st1_mse_ptr,                       /* i  : dynRAM buffer for MSEs                        */
    8190             :     int16_t *indices_st1_local,               /* o  :  selected cand indices                        */
    8191             :     float *st1_syn_vec_ptr,                   /* i/o:  buffer for IDCT24 synthesis                  */
    8192             :     float *dist1_ptr                          /* o  :  resulting stage 1 MSEs in DCT-N domain       */
    8193             : );
    8194             : 
    8195             : /*! r: (updated p_max) */
    8196             : int16_t msvq_stage1_dct_recalc_candidates_fdcng_wb(
    8197             :     const float *st1_syn_vec_ptr, /* i  : IDCT24 synthesis vectors       */
    8198             :     const float *u,               /* i  : target   signal                */
    8199             :     const int16_t maxC_st1,       /* i  : number of candidates in stage1 */
    8200             :     float *dist_ptr               /* i/o: updated  MSE vector for stage1 */
    8201             : );
    8202             : 
    8203             : void PulseResynchronization(
    8204             :     const float *src_exc,       /* i  : Input excitation buffer                 */
    8205             :     float *dst_exc,             /* o  : output excitation buffer                */
    8206             :     const int16_t nFrameLength, /* i  : frame length                            */
    8207             :     const int16_t nSubframes,   /* i  : Number of subframes                     */
    8208             :     const float pitchStart,     /* i  : Pitch at the end of the last frame      */
    8209             :     const float pitchEnd        /* i  : Pitch at the end of the current  frame  */
    8210             : );
    8211             : 
    8212             : void con_acelp(
    8213             :     float A[],                /* i  : coefficients NxAz[M+1]      */
    8214             :     const int16_t coder_type, /* i  : ACELP coder type            */
    8215             :     float synth[],            /* i/o: synthesis                   */
    8216             :     int16_t *pT,              /* o  :   pitch for all subframe    */
    8217             :     float *pgainT,            /* o  :   pitch gain for all subfr  */
    8218             :     float stab_fac,           /* i  : stability of isf            */
    8219             :     Decoder_State *st,        /* i/o:  coder memory state         */
    8220             :     float pitch_buffer[],     /* i/o: floating pitch values for each subframe          */
    8221             :     float *voice_factors,     /* o  : voicing factors             */
    8222             :     float *bwe_exc            /* o  : excitation for SWB TBE      */
    8223             : );
    8224             : 
    8225             : void con_tcx(
    8226             :     Decoder_State *st,       /* i/o: coder memory state          */
    8227             :     float synth[],           /* i/o: synth[]                     */
    8228             :     const float coh,         /* i  : coherence of stereo signal  */
    8229             :     int16_t *noise_seed,     /* i/o: noise seed for stereo       */
    8230             :     const int16_t only_left, /* i  : TD-PLC only in left channel */
    8231             :     const float A_cng[]      /* i  : CNG LP filter coefficients  */
    8232             : );
    8233             : 
    8234             : /*! r: codebook index */
    8235             : int16_t tcxlpc_get_cdk(
    8236             :     const int16_t coder_type /* i  : GC/VC indicator             */
    8237             : );
    8238             : 
    8239             : int16_t lsf_msvq_ma_encprm(
    8240             :     BSTR_ENC_HANDLE hBstr,
    8241             :     const int16_t *param_lpc,
    8242             :     const int16_t core,
    8243             :     const int16_t acelp_mode,
    8244             :     const int16_t acelp_midLpc,
    8245             :     const int16_t bits_param_lpc[],
    8246             :     const int16_t no_indices );
    8247             : 
    8248             : int16_t lsf_msvq_ma_decprm(
    8249             :     Decoder_State *st,
    8250             :     int16_t *param_lpc );
    8251             : 
    8252             : int16_t dec_lsf_tcxlpc(
    8253             :     Decoder_State *st,        /* i  : Decoder state        */
    8254             :     int16_t **indices,        /* o  : Ptr to VQ indices    */
    8255             :     const int16_t narrowband, /* i  : narrowband flag      */
    8256             :     const int16_t cdk         /* i  : codebook selector    */
    8257             : );
    8258             : 
    8259             : int16_t D_lsf_tcxlpc(
    8260             :     const int16_t indices[],  /* i  : VQ indices           */
    8261             :     float lsf_q[],            /* o  : quantized lsf        */
    8262             :     Word16 lsp_q_ind[],       /* o  : quantized lsp (w/o MA prediction) */
    8263             :     const int16_t narrowband, /* i  : narrowband flag      */
    8264             :     const int16_t cdk,        /* i  : codebook selector    */
    8265             :     const float mem_MA[]      /* i  : MA memory            */
    8266             : );
    8267             : 
    8268             : void lsf_update_memory(
    8269             :     const int16_t narrowband, /* i  : narrowband flag                             */
    8270             :     const float qlsf[],       /* i  : quantized lsf coefficients                  */
    8271             :     float old_mem_MA[],       /* i  : MA memory                                   */
    8272             :     float mem_MA[]            /* o  : updated MA memory                           */
    8273             : );
    8274             : 
    8275             : int16_t Q_lsf_tcxlpc(
    8276             :     /* const */ float lsf[],  /* i  : original lsf             */
    8277             :     float lsf_q[],            /* o  : quantized lsf            */
    8278             :     Word16 lsp_q_ind[],       /* o  : quantized lsp (w/o MA prediction) */
    8279             :     int16_t indices[],        /* o  : VQ indices               */
    8280             :     const int16_t narrowband, /* i  : narrowband flag          */
    8281             :     const int16_t cdk,        /* i  : codebook selector        */
    8282             :     const float mem_MA[],     /* i  : MA memory                */
    8283             :     const int16_t coder_type, /* i  : acelp extended mode      */
    8284             :     const float *Bin_Ener     /* i  : Spectrum energy          */
    8285             : );
    8286             : 
    8287             : int16_t E_LPC_lsp_unweight(
    8288             :     const float lsp_w[],  /* i  : weighted lsp             */
    8289             :     float lsp_uw[],       /* o  : unweighted lsp           */
    8290             :     float lsf_uw[],       /* o  : unweighted lsf           */
    8291             :     const float inv_gamma /* i  : inverse weighting factor */
    8292             : );
    8293             : 
    8294             : int16_t lsf_ind_is_active(
    8295             :     const Word16 lsf_q_ind[],
    8296             :     const float means[],
    8297             :     const int16_t narrowband,
    8298             :     const int16_t cdk );
    8299             : 
    8300             : void midlsf_enc(
    8301             :     const float qlsf0[],
    8302             :     const float qlsf1[],
    8303             :     const float lsf[],
    8304             :     int16_t *idx,
    8305             :     const int16_t N,
    8306             :     const float *Bin_Ener,
    8307             :     const int16_t narrowBand,
    8308             :     const int32_t sr_core,
    8309             :     const int16_t coder_type );
    8310             : 
    8311             : void midlsf_dec(
    8312             :     const float qlsf0[],
    8313             :     const float qlsf1[],
    8314             :     const int16_t idx,
    8315             :     float qlsf[],
    8316             :     const int16_t N,
    8317             :     const int16_t coder_type,
    8318             :     int16_t *mid_lsf_int,
    8319             :     const int16_t prev_bfi,
    8320             :     const int16_t safety_net );
    8321             : 
    8322             : void lsf_end_enc(
    8323             :     Encoder_State *st,
    8324             :     const float *lsf,
    8325             :     float *qlsf,
    8326             :     const int16_t nBits,
    8327             :     const int16_t coder_type_org,
    8328             :     const int16_t force_sf,
    8329             :     int16_t *lpc_param,
    8330             :     int16_t *no_stages,
    8331             :     int16_t *bits_param_lpc,
    8332             :     const int16_t coder_type_raw,
    8333             :     const float tdm_lsfQ_PCh[M] /* i  : Q LSFs for primary channel          */
    8334             : );
    8335             : 
    8336             : void lsf_end_dec(
    8337             :     Decoder_State *st,            /* i/o: decoder state structure                 */
    8338             :     const int16_t coder_type_org, /* i  : coding type                             */
    8339             :     const int16_t bwidth,         /* i  : input signal bandwidth                  */
    8340             :     const int16_t nBits,          /* i  : number of bits used for ISF quantization*/
    8341             :     float *qlsf,                  /* o  : quantized LSFs in the cosine domain     */
    8342             :     int16_t *lpc_param,           /* i  : LPC parameters                          */
    8343             :     int16_t *LSF_Q_prediction,    /* o  : LSF prediction mode                     */
    8344             :     int16_t *nb_indices,          /* o  : number of indices                       */
    8345             :     const float tdm_lsfQ_PCh[M]   /* i  : Q LSFs for primary channel          */
    8346             : );
    8347             : 
    8348             : ivas_error find_pred_mode(
    8349             :     int16_t *predmode,
    8350             :     const int16_t coder_type,
    8351             :     const int16_t bwidth,
    8352             :     const int32_t int_fs,
    8353             :     int16_t *p_mode_lvq,
    8354             :     int16_t *p_mode_lvq_p,
    8355             :     const int32_t core_brate );
    8356             : 
    8357             : void lpc_quantization(
    8358             :     Encoder_State *st,
    8359             :     const float lsp[],
    8360             :     const float lspmid[],
    8361             :     float lsp_q[],
    8362             :     float lsf_q[],
    8363             :     float lspmid_q[],
    8364             :     const int16_t coder_type,
    8365             :     const int16_t acelp_midLpc,
    8366             :     int16_t param_lpc[],
    8367             :     int16_t nbits_lpc[],
    8368             :     int16_t *bits_param_lpc,
    8369             :     int16_t *no_param_lpc );
    8370             : 
    8371             : void lpc_unquantize(
    8372             :     Decoder_State *st,
    8373             :     float *lsf,
    8374             :     float *lsp,
    8375             :     int16_t *param_lpc,
    8376             :     float *lspmid,
    8377             :     float *lsfmid,
    8378             :     const int16_t coder_type,
    8379             :     int16_t *LSF_Q_prediction /* o  : LSF prediction mode                     */
    8380             : );
    8381             : 
    8382             : void dlpc_bfi(
    8383             :     const int16_t L_frame,
    8384             :     float *lsf_q,             /* o  : quantized lsfs                         */
    8385             :     const float *lsfold,      /* i  : past quantized lsf                     */
    8386             :     const int16_t last_good,  /* i  : last good received frame               */
    8387             :     const int16_t nbLostCmpt, /* i  : counter of consecutive bad frames      */
    8388             :     float mem_MA[],           /* i/o: quantizer memory for MA model          */
    8389             :     float mem_AR[],           /* i/o: quantizer memory for MA model          */
    8390             :     float *stab_fac,          /* i  : lsf stability factor                   */
    8391             :     float *lsf_adaptive_mean, /* i  : lsf adaptive mean, updated when BFI==0 */
    8392             :     const int16_t numlpc,     /* i  : Number of division per superframe      */
    8393             :     float lsf_cng[],
    8394             :     const int16_t plcBackgroundNoiseUpdated,
    8395             :     float *lsf_q_cng,     /* o  : quantized lsfs of background noise      */
    8396             :     float *old_lsf_q_cng, /* o  : old quantized lsfs for background noise */
    8397             :     const float lsfBase[] /* i  : base for differential lsf coding        */
    8398             : );
    8399             : 
    8400             : void lsf_dec_bfi(
    8401             :     const int16_t codec_mode,                /* i  : codec_mode: MODE1 | MODE2              */
    8402             :     float *lsf,                              /* o  : estimated LSF vector                   */
    8403             :     const float *lsfold,                     /* i  : past quantized lsf                     */
    8404             :     float *lsf_adaptive_mean,                /* i  : lsf adaptive mean, updated when BFI==0 */
    8405             :     const float lsfBase[],                   /* i  : base for differential lsf coding       */
    8406             :     float *mem_MA,                           /* i/o: quantizer memory for MA model          */
    8407             :     float *mem_AR,                           /* o  : quantizer memory for AR model          */
    8408             :     const float stab_fac,                    /* i  : lsf stability factor                   */
    8409             :     const int16_t last_coder_type,           /* i  : last coder type                        */
    8410             :     const int16_t L_frame,                   /* i  : frame length                           */
    8411             :     const int16_t last_good,                 /* i  : last good received frame               */
    8412             :     const int16_t nbLostCmpt,                /* i  : counter of consecutive bad frames      */
    8413             :     const int16_t plcBackgroundNoiseUpdated, /* i  : background noise already updated?      */
    8414             :     float *lsf_q_cng,                        /* o  : quantized lsfs of background noise     */
    8415             :     float *lsf_cng,                          /* i  : long term target for fading to bg noise*/
    8416             :     float *old_lsf_q_cng,                    /* o  : old quantized lsfs for background noise*/
    8417             :     const int16_t Last_GSC_pit_band_idx,     /* i  : AC mode (GSC) - Last pitch band index  */
    8418             :     const int16_t Opt_AMR_WB,                /* i  : IO flag                                */
    8419             :     const int16_t bwidth                     /* i  : coded bandwidth                        */
    8420             : );
    8421             : 
    8422             : const float *PlcGetlsfBase(
    8423             :     const int16_t pcQuantization,
    8424             :     const int16_t narrowBand,
    8425             :     const int32_t sr_core );
    8426             : 
    8427             : void Unified_weighting(
    8428             :     const float Bin_Ener_128[], /* i  : FFT Bin energy 128 bins in two sets     */
    8429             :     const float lsf[],          /* i  : LSF vector                              */
    8430             :     float w[],                  /* o  : LP weighting filter (numerator)         */
    8431             :     const int16_t narrowBand,   /* i  : flag for Narrowband                     */
    8432             :     const int16_t unvoiced,     /* i  : flag for Unvoiced frame                 */
    8433             :     const int32_t sr_core,      /* i  : sampling rate of core-coder             */
    8434             :     const int16_t order         /* i  : LP order                                */
    8435             : );
    8436             : 
    8437             : int16_t vad_init(
    8438             :     VAD_CLDFB_HANDLE hVAD_CLDFB /* i/o: CLDFB VAD state                         */
    8439             : );
    8440             : 
    8441             : int16_t vad_proc(
    8442             :     float realValues[16][60],    /* i  : CLDFB real values                       */
    8443             :     float imagValues[16][60],    /* i  : CLDFB imag values                       */
    8444             :     float *sb_power,             /* i/o: Energy of CLDFB data                    */
    8445             :     const int16_t numBands,      /* i  : number of input bands                   */
    8446             :     VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state                         */
    8447             :     int16_t *cldfb_addition,
    8448             :     const int16_t vada_flag /* i  : VAD flag                                */
    8449             : );
    8450             : 
    8451             : void subband_FFT(
    8452             :     float Sr[16][60], /* i  : real part                               */
    8453             :     float Si[16][60], /* i  : imag part                               */
    8454             :     float *spec_amp   /* o  : spectral amplitude                      */
    8455             : );
    8456             : 
    8457             : int16_t update_decision(
    8458             :     VAD_CLDFB_HANDLE hVAD_CLDFB,    /* i/o: CLDFB VAD state                        */
    8459             :     const float snr,                /* i  : frequency domain SNR                    */
    8460             :     const float tsnr,               /* i  : time domain SNR                         */
    8461             :     const float frame_energy,       /* i  : current frame energy                    */
    8462             :     const float high_eng,           /* i  : current frame high frequency energy     */
    8463             :     const int16_t vad_flag,         /* i  : VAD flag                                */
    8464             :     const int16_t music_backgound_f /* i  : background music flag                   */
    8465             : );
    8466             : 
    8467             : void frame_spec_dif_cor_rate(
    8468             :     float spec_amp[],         /* i  : spectral amplitude                      */
    8469             :     float pre_spec_low_dif[], /* i/o: low spectrum different                  */
    8470             :     float f_tonality_rate[]   /* o  : tonality rate                           */
    8471             : );
    8472             : 
    8473             : void ltd_stable(
    8474             :     float frames_power[],     /* i/o: energy of several frames                */
    8475             :     float ltd_stable_rate[],  /* o  : time-domain stable rate                 */
    8476             :     const float frame_energy, /* i  : current frame energy                    */
    8477             :     const int16_t frameloop   /* i  : number of  frames                       */
    8478             : );
    8479             : 
    8480             : void SNR_calc(
    8481             :     const float frame_sb_energy[], /* i  : energy of sub-band divided non-uniformly*/
    8482             :     const float sb_bg_energy[],    /* i  : sub-band background energy              */
    8483             :     const float t_bg_energy,       /* i  : time background energy of several frames*/
    8484             :     float *snr,                    /* o  : frequency domain SNR                    */
    8485             :     float *tsnr,                   /* o  : time domain SNR                         */
    8486             :     const float frame_energy,      /* i  : current frame energy                    */
    8487             :     const int16_t bwidth           /* i  : audio bandwidth                         */
    8488             : );
    8489             : 
    8490             : void background_update(
    8491             :     VAD_CLDFB_HANDLE hVAD_CLDFB,     /* i/o: CLDFB VAD state                         */
    8492             :     float frame_energy,              /* i  : current frame energy 2                  */
    8493             :     const int16_t update_flag,       /* i  : current frame update flag               */
    8494             :     const int16_t music_backgound_f, /* i  : background music flag                   */
    8495             :     const float snr );
    8496             : 
    8497             : void bg_music_decision(
    8498             :     VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state                         */
    8499             :     int16_t *music_backgound_f,  /* i  : background music flag                   */
    8500             :     const float frame_energy     /* i  : current frame energy 1                  */
    8501             : );
    8502             : 
    8503             : void est_energy(
    8504             :     float sb_power[],        /* o  : energy of sub-band divided uniformly    */
    8505             :     float frame_sb_energy[], /* o  : energy of sub-band divided non-uniformly*/
    8506             :     float *p_frame_energy,   /* o  : frame energy 1                          */
    8507             :     float *p_frame_energy2,  /* o  : frame energy 2                          */
    8508             :     float *p_high_energy,    /* o  : high frequency energy                   */
    8509             :     const int16_t bw         /* i  : bandwidth                               */
    8510             : );
    8511             : 
    8512             : void spec_center(
    8513             :     float spec_power[],    /* i  : energy of sub-band divided uniformly    */
    8514             :     float sp_center[],     /* o  : spectral center                         */
    8515             :     const int16_t bw_index /* i  : bandwidth                               */
    8516             : );
    8517             : 
    8518             : void spec_flatness(
    8519             :     float spec_amp[],        /* i  : spectral amplitude                      */
    8520             :     float smooth_spec_amp[], /* i  : smoothed spectral amplitude             */
    8521             :     float sSFM[]             /* o  : spectral flatness rate                  */
    8522             : );
    8523             : 
    8524             : int16_t comvad_decision(
    8525             :     VAD_CLDFB_HANDLE hVAD_CLDFB,     /* i/o: CLDFB VAD state                         */
    8526             :     const float snr,                 /* i  : frequency domain SNR                    */
    8527             :     const float tsnr,                /* i  : time domain SNR                         */
    8528             :     const float snr_flux,            /* i  : average tsnr of several frames          */
    8529             :     const float lt_snr,              /* i  : long time SNR calculated by fg_energy and bg_energy*/
    8530             :     const float lt_snr_org,          /* i  : original long time SNR                  */
    8531             :     const float lf_snr,              /* i  : long time frequency domain SNR calculated by l_speech_snr and l_silence_snr*/
    8532             :     const float frame_energy,        /* i  : current frame energy                    */
    8533             :     const int16_t music_backgound_f, /* i  : background music flag                   */
    8534             :     int16_t *cldfb_addition,
    8535             :     const int16_t vada_flag /* i  : VAD flag                                */
    8536             : );
    8537             : 
    8538             : void calc_snr_flux(
    8539             :     float tsnr,      /* i  : time-domain SNR                         */
    8540             :     float pre_snr[], /* i/o:  time-domain SNR storage                */
    8541             :     float *snr_flux  /* o  : average tsnr                            */
    8542             : );
    8543             : 
    8544             : void calc_lt_snr(
    8545             :     float *lt_snr_org,              /* o  : original long time SNR                  */
    8546             :     float *lt_snr,                  /* o  : long time SNR calculated by fg_energy and bg_energy*/
    8547             :     const float fg_energy,          /* i  : foreground energy sum                   */
    8548             :     const int16_t fg_energy_count,  /* i  : number of the foreground energy frame   */
    8549             :     const float bg_energy,          /* i  : background energy sum                   */
    8550             :     const int16_t bg_energy_count,  /* i  : number of the background energy frame   */
    8551             :     const int16_t bw_index,         /* i  : band width index                        */
    8552             :     const float lt_noise_sp_center0 /* i  : long time noise spectral center by 0    */
    8553             : );
    8554             : 
    8555             : void calc_lf_snr(
    8556             :     float *lf_snr_smooth,              /* o  : smoothed lf_snr                         */
    8557             :     float *lf_snr,                     /* o  : long time frequency domain SNR calculated by l_speech_snr and l_silence_snr*/
    8558             :     const float l_speech_snr,          /* i  : sum of active frames snr                */
    8559             :     const int16_t l_speech_snr_count,  /* i  : number of the active frame              */
    8560             :     const float l_silence_snr,         /* i  : sum of the nonactive frames snr         */
    8561             :     const int16_t l_silence_snr_count, /* i  : number of the nonactive frame           */
    8562             :     const int16_t fg_energy_count,     /* i  : number of the foreground energy frame   */
    8563             :     const int16_t bg_energy_count,     /* i  : number of the background energy frame   */
    8564             :     const int16_t bw_index             /* i  : band width index                        */
    8565             : );
    8566             : 
    8567             : float construct_snr_thresh(
    8568             :     const float sp_center[],             /* i  : spectral center                         */
    8569             :     const float snr_flux,                /* i  : snr flux                                */
    8570             :     const float lt_snr,                  /* i  : long time time domain snr               */
    8571             :     const float lf_snr,                  /* i  : long time frequency domain snr          */
    8572             :     const int16_t continuous_speech_num, /* i  : continuous speech number                */
    8573             :     const int16_t continuous_noise_num,  /* i  : continuous noise number                 */
    8574             :     const int16_t fg_energy_est_start,   /* i  : whether if estimated energy             */
    8575             :     const int16_t bw_index               /* i  : band width index                        */
    8576             : );
    8577             : 
    8578             : ivas_error createFdCngCom(
    8579             :     HANDLE_FD_CNG_COM *hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */
    8580             : );
    8581             : 
    8582             : void deleteFdCngCom(
    8583             :     HANDLE_FD_CNG_COM *hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */
    8584             : );
    8585             : 
    8586             : void initFdCngCom(
    8587             :     HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */
    8588             :     const float scale );
    8589             : 
    8590             : void initPartitions(
    8591             :     const int16_t *part_in,
    8592             :     const int16_t npart_in,
    8593             :     const int16_t startBand,
    8594             :     const int16_t stopBand,
    8595             :     int16_t *part_out,
    8596             :     int16_t *npart_out,
    8597             :     int16_t *midband,
    8598             :     float *psize,
    8599             :     float *psize_inv,
    8600             :     const int16_t stopBandFR );
    8601             : 
    8602             : void minimum_statistics(
    8603             :     const int16_t len,    /* i  : Vector length                                       */
    8604             :     const int16_t lenFFT, /* i  : Length of the FFT part of the vectors               */
    8605             :     float *psize,
    8606             :     float *msPeriodog, /* i  : Periodograms                                        */
    8607             :     float *msNoiseFloor,
    8608             :     float *msNoiseEst, /* o  : Noise estimates                                     */
    8609             :     float *msAlpha,
    8610             :     float *msPsd,
    8611             :     float *msPsdFirstMoment,
    8612             :     float *msPsdSecondMoment,
    8613             :     float *msMinBuf,
    8614             :     float *msBminWin,
    8615             :     float *msBminSubWin,
    8616             :     float *msCurrentMin,
    8617             :     float *msCurrentMinOut,
    8618             :     float *msCurrentMinSubWindow,
    8619             :     int16_t *msLocalMinFlag,
    8620             :     int16_t *msNewMinFlag,
    8621             :     float *msPeriodogBuf,
    8622             :     int16_t *msPeriodogBufPtr,
    8623             :     HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables   */
    8624             :     const int16_t enc_dec,       /* i  : encoder/decoder indicator                               */
    8625             :     const int16_t element_mode   /* i  : IVAS element mode                                       */
    8626             : );
    8627             : 
    8628             : void generate_comfort_noise_enc(
    8629             :     Encoder_State *st /* i/o: encoder state structure                 */
    8630             : );
    8631             : 
    8632             : void generate_comfort_noise_dec(
    8633             :     float **bufferReal,     /* o  : Real part of input bands                                */
    8634             :     float **bufferImag,     /* o  : Imaginary part of input bands                           */
    8635             :     Decoder_State *st,      /* i/o: decoder state structure                                 */
    8636             :     const int16_t nchan_out /* i  : number of output channels                               */
    8637             : );
    8638             : 
    8639             : void generate_comfort_noise_dec_hf(
    8640             :     float **bufferReal,          /* o  : Real part of input bands                                */
    8641             :     float **bufferImag,          /* o  : Imaginary part of input bands                           */
    8642             :     HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables   */
    8643             :     const int16_t cng_flag       /* i  : CNG Flag */
    8644             : );
    8645             : 
    8646             : void generate_masking_noise(
    8647             :     float *timeDomainBuffer,          /* i/o: time-domain signal                               */
    8648             :     HANDLE_FD_CNG_COM hFdCngCom,      /* i/o: FD_CNG structure containing all buffers and variables   */
    8649             :     const int16_t length,             /* i  : frame size                                       */
    8650             :     const int16_t core,               /* i  : core                                             */
    8651             :     const int16_t return_noise,       /* i  : noise is returned instead of added               */
    8652             :     const int16_t secondary,          /* i  : indicator for secondary channel                  */
    8653             :     const int16_t element_mode,       /* i  : element mode                                     */
    8654             :     STEREO_CNG_DEC_HANDLE hStereoCng, /* i  : stereo CNG handle                                */
    8655             :     const int16_t nchan_out           /* i  : number of output channels */
    8656             : );
    8657             : 
    8658             : void generate_masking_noise_update_seed(
    8659             :     HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables   */
    8660             : );
    8661             : 
    8662             : void generate_masking_noise_mdct(
    8663             :     float *mdctBuffer,          /* i/o: time-domain signal                                      */
    8664             :     HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables   */
    8665             : );
    8666             : 
    8667             : void SynthesisSTFT_dirac(
    8668             :     float *fftBuffer, /* i  : FFT bins */
    8669             :     float *timeDomainOutput,
    8670             :     float *olapBuffer,
    8671             :     const float *olapWin,
    8672             :     const int16_t samples_out,
    8673             :     HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */
    8674             : );
    8675             : 
    8676             : void generate_masking_noise_dirac(
    8677             :     HANDLE_FD_CNG_COM hFdCngCom,      /* i/o: FD_CNG structure containing all buffers and variables */
    8678             :     HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i  : filterbank state                                      */
    8679             :     float *tdBuffer,                  /* i/o: time-domain signal, if NULL no LB-CNA                 */
    8680             :     float *Cldfb_RealBuffer,          /* o  : CLDFD real buffer                                     */
    8681             :     float *Cldfb_ImagBuffer,          /* o  : CLDFD imaginary buffer                                */
    8682             :     const int16_t slot_index,         /* i  : CLDFB slot index                                      */
    8683             :     const int16_t cna_flag,           /* i  : CNA flag for LB and HB                                */
    8684             :     const int16_t fd_cng_flag         /* i  : FD-CNG flag for HB                                    */
    8685             : );
    8686             : 
    8687             : void generate_stereo_masking_noise(
    8688             :     float *syn,                          /* i/o: time-domain signal              */
    8689             :     Decoder_State *st,                   /* i/o: decoder state structure         */
    8690             :     STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i  : TD stereo structure             */
    8691             :     const int16_t flag_sec_CNA,          /* i  : CNA flag for secondary channel  */
    8692             :     const int16_t fadeOut,               /* i  : only fade out of previous state */
    8693             :     STEREO_CNG_DEC_HANDLE hStereoCng,    /* i  : stereo CNG handle               */
    8694             :     const int16_t nchan_out              /* i  : number of output channels       */
    8695             : );
    8696             : 
    8697             : void apply_scale(
    8698             :     float *scale,                  /* i  : scale factor                                            */
    8699             :     const int16_t bwidth,          /* i  : audio bandwidth                                         */
    8700             :     const int32_t brate,           /* i  : Bit rate                                                */
    8701             :     const SCALE_SETUP *scaleTable, /* i  : Scale table                                             */
    8702             :     const int16_t scaleTableSize   /* i  : Size of scale table                                     */
    8703             : );
    8704             : 
    8705             : void compress_range(
    8706             :     float *in,
    8707             :     float *out,
    8708             :     const int16_t len );
    8709             : 
    8710             : void expand_range(
    8711             :     float *in,
    8712             :     float *out,
    8713             :     const int16_t len );
    8714             : 
    8715             : void bandcombinepow(
    8716             :     const float *bandpow,   /* i  : Power for each band */
    8717             :     const int16_t nband,    /* i  : Number of bands */
    8718             :     int16_t *part,          /* i  : Partition upper boundaries (band indices starting from 0) */
    8719             :     const int16_t npart,    /* i  : Number of partitions */
    8720             :     const float *psize_inv, /* i  : Inverse partition sizes */
    8721             :     float *partpow          /* o  : Power for each partition */
    8722             : );
    8723             : 
    8724             : void scalebands(
    8725             :     const float *partpow,   /* i  : Power for each partition */
    8726             :     int16_t *part,          /* i  : Partition upper boundaries (band indices starting from 0) */
    8727             :     const int16_t npart,    /* i  : Number of partitions */
    8728             :     int16_t *midband,       /* i  : Central band of each partition */
    8729             :     const int16_t nFFTpart, /* i  : Number of FFT partitions */
    8730             :     const int16_t nband,    /* i  : Number of bands */
    8731             :     float *bandpow,         /* o  : Power for each band */
    8732             :     const int16_t flag_fft_en );
    8733             : 
    8734             : void AnalysisSTFT(
    8735             :     const float *timeDomainInput,
    8736             :     float *fftBuffer,    /* o  : FFT bins */
    8737             :     HANDLE_FD_CNG_COM st /* i/o: FD_CNG structure containing all buffers and variables */
    8738             : );
    8739             : 
    8740             : void SynthesisSTFT(
    8741             :     float *fftBuffer,
    8742             :     float *timeDomainOutput,
    8743             :     float *olapBuffer,
    8744             :     const float *olapWin,
    8745             :     const int16_t tcx_transition,
    8746             :     HANDLE_FD_CNG_COM hFdCngCom,
    8747             :     const int16_t element_mode, /* i  : element mode              */
    8748             :     const int16_t nchan_out     /* i  : number of output channels */
    8749             : );
    8750             : 
    8751             : float rand_gauss(
    8752             :     float *x,
    8753             :     int16_t *seed );
    8754             : 
    8755             : void lpc_from_spectrum(
    8756             :     HANDLE_FD_CNG_COM hFdCngCom,
    8757             :     const int16_t start,
    8758             :     const int16_t stop,
    8759             :     const float preemph_fac );
    8760             : 
    8761             : ivas_error createFdCngDec(
    8762             :     HANDLE_FD_CNG_DEC *hFdCngDec );
    8763             : 
    8764             : void deleteFdCngDec(
    8765             :     HANDLE_FD_CNG_DEC *hFdCngDec );
    8766             : 
    8767             : void initFdCngDec(
    8768             :     DEC_CORE_HANDLE st /* i/o: decoder state structure     */
    8769             : );
    8770             : 
    8771             : void configureFdCngDec(
    8772             :     HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: Contains the variables related to the FD-based CNG process  */
    8773             :     const int16_t bwidth,
    8774             :     const int32_t total_brate,
    8775             :     const int16_t L_frame,
    8776             :     const int16_t last_L_frame,
    8777             :     const int16_t element_mode );
    8778             : 
    8779             : void ApplyFdCng(
    8780             :     float *timeDomainInput,
    8781             :     float *powerSpectrum,
    8782             :     float **realBuffer, /* i/o: Real part of the buffer                 */
    8783             :     float **imagBuffer, /* i/o: Imaginary part of the buffer            */
    8784             :     Decoder_State *st,
    8785             :     const int16_t concealWholeFrame, /* i  : binary flag indicating frame loss       */
    8786             :     const int16_t is_music );
    8787             : 
    8788             : void generate_comfort_noise_dec(
    8789             :     float **bufferReal,     /* o  : Real part of input bands      */
    8790             :     float **bufferImag,     /* o  : Imaginary part of input bands */
    8791             :     Decoder_State *st,      /* i/o: decoder state structure       */
    8792             :     const int16_t nchan_out /* i  : number of output channels     */
    8793             : );
    8794             : 
    8795             : /*! r: CNG energy */
    8796             : float cng_energy(
    8797             :     const int16_t element_mode, /* i  : element mode                            */
    8798             :     const int16_t bwidth,       /* i  : audio bandwidh                          */
    8799             :     const int16_t CNG_mode,     /* i  : mode for DTX configuration              */
    8800             :     const float CNG_att,        /* i  : attenuation factor for CNG              */
    8801             :     const float *inputBuffer,   /* i  : input signal                            */
    8802             :     const int16_t len           /* i  : vector length                           */
    8803             : );
    8804             : 
    8805             : void FdCng_decodeSID(
    8806             :     Decoder_State *st /* i/o: decoder state structure                 */
    8807             : );
    8808             : 
    8809             : void FdCng_exc(
    8810             :     HANDLE_FD_CNG_COM hFdCngCom,
    8811             :     int16_t *CNG_mode,
    8812             :     const int16_t L_frame,
    8813             :     const float *lsp_old,
    8814             :     const int16_t first_CNG,
    8815             :     float *lsp_CNG,
    8816             :     float *Aq,      /* o  : LPC coeffs                              */
    8817             :     float *lsp_new, /* o  : lsp                                     */
    8818             :     float *lsf_new, /* o  : lsf                                     */
    8819             :     float *exc,     /* o  : LP excitation                           */
    8820             :     float *exc2,    /* o  : LP excitation                           */
    8821             :     float *bwe_exc  /* o  : LP excitation for BWE                   */
    8822             : );
    8823             : 
    8824             : void noisy_speech_detection(
    8825             :     HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: FD_CNG structure                        */
    8826             :     const int16_t vad,           /* i  : VAD flag                                */
    8827             :     const float syn[]            /* i  : input time-domain frame                 */
    8828             : );
    8829             : 
    8830             : ivas_error createFdCngEnc(
    8831             :     HANDLE_FD_CNG_ENC *hFdCngEnc /* i/o: FD_CNG structure                        */
    8832             : );
    8833             : 
    8834             : void deleteFdCngEnc(
    8835             :     HANDLE_FD_CNG_ENC *hFdCngEnc /* i/o: FD_CNG structure                        */
    8836             : );
    8837             : 
    8838             : void configureFdCngEnc(
    8839             :     HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: Contains the variables related to the FD-based CNG process */
    8840             :     const int16_t bwidth,
    8841             :     const int32_t total_brate );
    8842             : 
    8843             : void initFdCngEnc(
    8844             :     HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: Contains the variables related to the FD-based CNG process */
    8845             :     const int32_t input_Fs,      /* i  : input signal sampling frequency in Hz                      */
    8846             :     const float scale            /* i  : scaling factor                                             */
    8847             : );
    8848             : 
    8849             : void resetFdCngEnc(
    8850             :     Encoder_State *st /* i/o: encoder state structure                                    */
    8851             : );
    8852             : 
    8853             : void perform_noise_estimation_enc(
    8854             :     float *band_energies,        /* i  : energy in critical bands without minimum noise floor E_MIN */
    8855             :     float *enerBuffer,           /* i  : energy buffer                                              */
    8856             :     HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: CNG structure containing all buffers and variables         */
    8857             :     const int32_t input_Fs,      /* i  : input sampling rate                                        */
    8858             :     CPE_ENC_HANDLE hCPE );
    8859             : 
    8860             : void AdjustFirstSID(
    8861             :     Encoder_State *st /* i/o: encoder state structure                                    */
    8862             : );
    8863             : 
    8864             : void FdCng_encodeSID(
    8865             :     Encoder_State *st /* i/o: encoder state structure                                    */
    8866             : );
    8867             : 
    8868             : void GetParameters(
    8869             :     ParamsBitMap const *paramsBitMap,
    8870             :     const int16_t nParams,
    8871             :     void const *pParameter,
    8872             :     int16_t **pStream,
    8873             :     int16_t *pnSize,
    8874             :     int16_t *pnBits );
    8875             : 
    8876             : void SetParameters(
    8877             :     ParamsBitMap const *paramsBitMap,
    8878             :     const int16_t nParams,
    8879             :     void *pParameter,
    8880             :     const int16_t **pStream,
    8881             :     int16_t *pnSize );
    8882             : 
    8883             : void WriteToBitstream(
    8884             :     ParamsBitMap const *paramsBitMap,
    8885             :     const int16_t nParams,
    8886             :     const int16_t **pStream,
    8887             :     int16_t *pnSize,
    8888             :     BSTR_ENC_HANDLE hBstr,
    8889             :     int16_t *pnBits );
    8890             : 
    8891             : void ReadFromBitstream(
    8892             :     ParamsBitMap const *paramsBitMap,
    8893             :     const int16_t nArrayLength,
    8894             :     Decoder_State *st,
    8895             :     int16_t **pStream,
    8896             :     int16_t *pnSize );
    8897             : 
    8898             : void const *GetTnsFilterOrder( void const *p, const int16_t index, int16_t *pValue );
    8899             : void *SetTnsFilterOrder( void *p, const int16_t index, const int16_t value );
    8900             : void const *GetNumOfTnsFilters( void const *p, const int16_t index, int16_t *pValue );
    8901             : void *SetNumOfTnsFilters( void *p, const int16_t index, const int16_t value );
    8902             : void const *GetTnsEnabled( void const *p, const int16_t index, int16_t *pValue );
    8903             : void *SetTnsEnabled( void *p, const int16_t index, const int16_t value );
    8904             : void const *GetTnsEnabledSingleFilter( void const *p, const int16_t index, int16_t *pValue );
    8905             : void *SetTnsEnabledSingleFilter( void *p, const int16_t index, const int16_t value );
    8906             : void const *GetTnsFilterCoeff( void const *p, const int16_t index, int16_t *pValue );
    8907             : void *SetTnsFilterCoeff( void *p, const int16_t index, const int16_t value );
    8908             : 
    8909             : void const *GetTnsOnWhite( void const *p, const int16_t index, int16_t *pValue );
    8910             : void *SetTnsOnWhite( void *p, const int16_t index, const int16_t value );
    8911             : 
    8912             : int16_t GetSWBTCX10TnsFilterCoeffBits( const int16_t value, const int16_t index );
    8913             : int16_t EncodeSWBTCX10TnsFilterCoeff( const int16_t value, const int16_t index );
    8914             : int16_t DecodeSWBTCX10TnsFilterCoeff( Decoder_State *st, const int16_t index, int16_t *pValue );
    8915             : int16_t GetSWBTCX20TnsFilterCoeffBits( const int16_t value, const int16_t index );
    8916             : int16_t EncodeSWBTCX20TnsFilterCoeff( const int16_t value, const int16_t index );
    8917             : int16_t DecodeSWBTCX20TnsFilterCoeff( Decoder_State *st, const int16_t index, int16_t *pValue );
    8918             : 
    8919             : int16_t GetWBTCX20TnsFilterCoeffBits( const int16_t value, const int16_t index );
    8920             : int16_t EncodeWBTCX20TnsFilterCoeff( const int16_t, const int16_t index );
    8921             : int16_t DecodeWBTCX20TnsFilterCoeff( Decoder_State *st, const int16_t index, int16_t *pValue );
    8922             : 
    8923             : int16_t GetTnsFilterOrderBitsSWBTCX10( const int16_t value, const int16_t index );
    8924             : int16_t EncodeTnsFilterOrderSWBTCX10( const int16_t value, const int16_t index );
    8925             : int16_t DecodeTnsFilterOrderSWBTCX10( Decoder_State *st, const int16_t index, int16_t *pValue );
    8926             : int16_t GetTnsFilterOrderBitsSWBTCX20( const int16_t value, const int16_t index );
    8927             : int16_t EncodeTnsFilterOrderSWBTCX20( const int16_t value, const int16_t index );
    8928             : int16_t DecodeTnsFilterOrderSWBTCX20( Decoder_State *st, const int16_t index, int16_t *pValue );
    8929             : int16_t GetTnsFilterOrderBits( const int16_t value, const int16_t index );
    8930             : int16_t EncodeTnsFilterOrder( const int16_t value, const int16_t index );
    8931             : int16_t DecodeTnsFilterOrder( Decoder_State *st, const int16_t index, int16_t *pValue );
    8932             : 
    8933             : void ResetTnsData(
    8934             :     STnsData *pTnsData );
    8935             : 
    8936             : void ClearTnsFilterCoefficients(
    8937             :     STnsFilter *pTnsFilter );
    8938             : 
    8939             : void InitTnsConfiguration(
    8940             :     const int16_t bwidth,
    8941             :     const int16_t frameLength,
    8942             :     STnsConfig *pTnsConfig,
    8943             :     const int16_t igfStopFreq,
    8944             :     const int32_t total_brate,
    8945             :     const int16_t element_mode,
    8946             :     const int16_t MCT_flag );
    8947             : 
    8948             : int16_t DetectTnsFilt(
    8949             :     const STnsConfig *pTnsConfig, /* i  : TNS Configuration struct     */
    8950             :     const float pSpectrum[],      /* i  : MDCT spectrum                */
    8951             :     TRAN_DET_HANDLE hTranDet,     /* i  : transient detection handle   */
    8952             :     const int16_t isTCX10,        /* i  : TCX10 or TCX20?              */
    8953             :     const float ltp_gain,         /* i  : LTP gain                     */
    8954             :     STnsData *pTnsData,           /* o  : TNS data struct              */
    8955             :     float *predictionGain         /* o  : TNS prediction gain          */
    8956             : );
    8957             : 
    8958             : void ApplyTnsFilter(
    8959             :     STnsConfig const *pTnsConfig,
    8960             :     STnsData const *pTnsData,
    8961             :     float spectrum[],
    8962             :     const int16_t fIsAnalysis );
    8963             : 
    8964             : int16_t ITF_Detect(
    8965             :     const float pSpectrum[],
    8966             :     const int16_t startLine,
    8967             :     const int16_t stopLine,
    8968             :     const int16_t maxOrder,
    8969             :     float *A,
    8970             :     float *predictionGain,
    8971             :     int16_t *curr_order );
    8972             : 
    8973             : void ITF_Apply(
    8974             :     float spectrum[],
    8975             :     const int16_t startLine,
    8976             :     const int16_t stopLine,
    8977             :     const float *A,
    8978             :     const int16_t curr_order );
    8979             : 
    8980             : void EncodeTnsData(
    8981             :     STnsConfig const *pTnsConfig, /* i  : TNS Configuration struct          */
    8982             :     STnsData const *pTnsData,     /* i  : TNS data struct (quantized param) */
    8983             :     int16_t *stream,              /* o  : internal data stream              */
    8984             :     int16_t *pnSize,              /* o  : number of written parameters      */
    8985             :     int16_t *pnBits               /* o  : number of written bits            */
    8986             : );
    8987             : 
    8988             : int16_t DecodeTnsData(
    8989             :     STnsConfig const *pTnsConfig,
    8990             :     const int16_t *stream,
    8991             :     int16_t *pnSize,
    8992             :     STnsData *pTnsData );
    8993             : 
    8994             : void WriteTnsData(
    8995             :     const STnsConfig *pTnsConfig, /* i  : TNS Configuration struct          */
    8996             :     const int16_t *stream,        /* i  : internal data stream              */
    8997             :     int16_t *pnSize,              /* o  : number of written parameters      */
    8998             :     BSTR_ENC_HANDLE hBstr,        /* o  : bitstream                         */
    8999             :     int16_t *pnBits               /* o  : number of written bits            */
    9000             : );
    9001             : 
    9002             : void ReadTnsData(
    9003             :     STnsConfig const *pTnsConfig,
    9004             :     Decoder_State *st,
    9005             :     int16_t *pnBits,
    9006             :     int16_t *stream,
    9007             :     int16_t *pnSize );
    9008             : 
    9009             : void cldfbAnalysis(
    9010             :     const float *timeIn,             /* i  : time buffer                 */
    9011             :     float **realBuffer,              /* o  : real value buffer           */
    9012             :     float **imagBuffer,              /* o  : imag value buffer           */
    9013             :     const int16_t samplesToProcess,  /* i  : number of input samples     */
    9014             :     HANDLE_CLDFB_FILTER_BANK h_cldfb /* i  : filterbank state            */
    9015             : );
    9016             : 
    9017             : void cldfbAnalysis_ts(
    9018             :     const float *timeIn,                     /* i  : time buffer                 */
    9019             :     float realBuffer[CLDFB_NO_CHANNELS_MAX], /* o  : real value buffer           */
    9020             :     float imagBuffer[CLDFB_NO_CHANNELS_MAX], /* o  : imag value buffer           */
    9021             :     const int16_t samplesToProcess,          /* i  : samples to process          */
    9022             :     HANDLE_CLDFB_FILTER_BANK h_cldfb         /* i  : filterbank state            */
    9023             : );
    9024             : 
    9025             : void cldfbSynthesis(
    9026             :     float **realBuffer,              /* i  : real values                 */
    9027             :     float **imagBuffer,              /* i  : imag values                 */
    9028             :     float *timeOut,                  /* o  : synthesized output          */
    9029             :     const int16_t samplesToProcess,  /* i  : number of samples           */
    9030             :     HANDLE_CLDFB_FILTER_BANK h_cldfb /* i  : filter bank state           */
    9031             : );
    9032             : 
    9033             : void configureCldfb(
    9034             :     HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: filter bank handle        */
    9035             :     const int32_t sampling_rate       /* i  : sampling rate             */
    9036             : );
    9037             : 
    9038             : void analysisCldfbEncoder(
    9039             :     Encoder_State *st, /* i/o: encoder state structure     */
    9040             :     const float *timeIn,
    9041             :     const int16_t samplesToProcess,
    9042             :     float realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
    9043             :     float imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
    9044             :     float *ppBuf_Ener );
    9045             : 
    9046             : ivas_error openCldfb(
    9047             :     HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle               */
    9048             :     CLDFB_TYPE type,                   /* i  : analysis or synthesis            */
    9049             :     const int32_t sampling_rate,       /* i  : sampling rate                    */
    9050             :     CLDFB_PROTOTYPE prototype          /* i  : CLDFB version (1.25ms/5ms delay) */
    9051             : );
    9052             : 
    9053             : void resampleCldfb(
    9054             :     HANDLE_CLDFB_FILTER_BANK hs, /* i/o: filter bank handle          */
    9055             :     const int32_t newSamplerate  /* i  : new samplerate to operate   */
    9056             : );
    9057             : 
    9058             : ivas_error cldfb_save_memory(
    9059             :     HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle          */
    9060             : );
    9061             : 
    9062             : void cldfb_restore_memory(
    9063             :     HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle          */
    9064             : );
    9065             : 
    9066             : void cldfb_reset_memory(
    9067             :     HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle          */
    9068             : );
    9069             : 
    9070             : void deleteCldfb(
    9071             :     HANDLE_CLDFB_FILTER_BANK *h_cldfb /* i/o: filter bank handle          */
    9072             : );
    9073             : 
    9074             : void fft_cldfb(
    9075             :     float *data,       /* i/o: input/output vector         */
    9076             :     const int16_t size /* i  : size of fft operation       */
    9077             : );
    9078             : 
    9079             : void BITS_ALLOC_init_config_acelp(
    9080             :     const int32_t bit_rate,
    9081             :     const int16_t narrowBand,
    9082             :     const int16_t nb_subfr,
    9083             :     ACELP_config *acelp_cfg /* o  : configuration structure of ACELP    */
    9084             : );
    9085             : 
    9086             : int16_t BITS_ALLOC_config_acelp(
    9087             :     const int16_t bits_frame, /* i  : remaining bit budget for the frame  */
    9088             :     const int16_t coder_type, /* i  : acelp coder type                    */
    9089             :     ACELP_config *acelp_cfg,  /* i/o: configuration structure of ACELP    */
    9090             :     const int16_t narrowband, /* i  : narrowband flag                     */
    9091             :     const int16_t nb_subfr    /* i  : number of subframes                 */
    9092             : );
    9093             : 
    9094             : ivas_error config_acelp1(
    9095             :     const int16_t enc_dec,                  /* i  : encoder/decoder flag                */
    9096             :     const int32_t total_brate,              /* i  : total bitrate                       */
    9097             :     const int32_t core_brate_inp,           /* i  : core bitrate                        */
    9098             :     const int16_t core,                     /* i  : core                                */
    9099             :     const int16_t extl,                     /* i  : extension layer                     */
    9100             :     const int32_t extl_brate,               /* i  : extension layer bitrate             */
    9101             :     const int16_t L_frame,                  /* i  : frame length at internal Fs         */
    9102             :     const int16_t GSC_noisy_speech,         /* i  : GSC on SWB noisy speech flag        */
    9103             :     ACELP_config *acelp_cfg,                /* i  : ACELP bit-allocation                */
    9104             :     const int16_t signaling_bits,           /* i  : number of signaling bits            */
    9105             :     const int16_t coder_type,               /* i  : coder type                          */
    9106             :     const int16_t inactive_coder_type_flag, /* i  : AVQ (0) or GSC (1) IC flag          */
    9107             :     const int16_t tc_subfr,                 /* i  : TC subfr ID                         */
    9108             :     const int16_t tc_call,                  /* i  : TC call number (0,1,2)              */
    9109             :     int16_t *nBits_es_Pred,                 /* o  : number of bits for Es_pred Q        */
    9110             :     int16_t *unbits,                        /* o  : number of unused bits               */
    9111             :     const int16_t element_mode,             /* i  : element mode                        */
    9112             :     int16_t *uc_two_stage_flag,             /* o  : flag undicating two-stage UC        */
    9113             :     const int16_t tdm_lp_reuse_flag,        /* i  : LPC reuse flag (can be 1 only with secondary channel*/
    9114             :     const int16_t tdm_low_rate_mode,        /* i  : secondary channel low rate mode flag*/
    9115             :     const int16_t idchan,                   /* i  : channel id                          */
    9116             :     const int16_t active_cnt,               /* i  : Active frame counter                */
    9117             :     const int16_t tdm_Pitch_reuse_flag,     /* i  : primary channel pitch reuse flag    */
    9118             :     const int16_t tdm_LRTD_flag,            /* i  : LRTD stereo mode flag               */
    9119             :     const int16_t GSC_IVAS_mode             /* i  : GSC IVAS mode                       */
    9120             : );
    9121             : 
    9122             : /*! r: ACELP16k flag */
    9123             : int16_t set_ACELP_flag(
    9124             :     const int16_t element_mode,  /* i  : element mode                        */
    9125             :     const int32_t element_brate, /* i  : element bitrate                     */
    9126             :     const int32_t total_brate,   /* i  : total bitrate per channel           */
    9127             :     const int16_t idchan,        /* i  : Channel id                          */
    9128             :     const int16_t tdm_LRTD_flag, /* i  : LRTD stereo mode flag               */
    9129             :     const int16_t bwidth,        /* i  : audio bandwidth                     */
    9130             :     const int16_t cng_type       /* i  : CNG type                            */
    9131             : );
    9132             : 
    9133             : void FEC_clas_estim(
    9134             :     const float *syn,
    9135             :     const float *pitch,                /* i  : pitch values for each subframe                 */
    9136             :     const int16_t L_frame,             /* i  : length of the frame                            */
    9137             :     const int16_t coder_type,          /* i  : coder type                                     */
    9138             :     const int16_t codec_mode,          /* i  : codec mode                                     */
    9139             :     float *mem_syn_clas_estim,         /* i/o: memory of the synthesis signal for frame class estimation */
    9140             :     int16_t *clas,                     /* i/o: frame classification                           */
    9141             :     float *lp_speech,                  /* i/o: long term active speech energy average         */
    9142             :     const int16_t Opt_AMR_WB,          /* i  : flag indicating AMR-WB IO mode                 */
    9143             :     int16_t *decision_hyst,            /* i/o: hysteresis of the music/speech decision        */
    9144             :     int16_t *locattack,                /* i/o: detection of attack (mainly to localized speech burst) */
    9145             :     int16_t *UV_cnt,                   /* i/o: number of consecutives frames classified as UV */
    9146             :     float *LT_UV_cnt,                  /* i/o: long term consecutives frames classified as UV */
    9147             :     float *Last_ener,                  /* i/o: last_energy frame                              */
    9148             :     int16_t *amr_io_class,             /* i/o: classification for AMR-WB IO mode              */
    9149             :     float *lt_diff_etot,               /* i/o: long-term total energy variation               */
    9150             :     float *class_para,                 /* o  : classification para. fmerit1                   */
    9151             :     const float LTP_Gain,              /* i  :                                                */
    9152             :     const int16_t narrowBand,          /* i  :                                                */
    9153             :     const SIGNAL_CLASSIFIER_MODE mode, /* i  :                                                */
    9154             :     const int16_t bfi,                 /* i  :                                                */
    9155             :     const float preemph_fac,           /* i  :                                                */
    9156             :     const int16_t tcxonly,             /* i  :                                                */
    9157             :     const int32_t last_core_brate,     /* i  : last core bitrate                              */
    9158             :     const int16_t FEC_mode             /* i  : ACELP FEC mode                                 */
    9159             : );
    9160             : 
    9161             : void InitTransientDetection(
    9162             :     const int16_t nFrameLength,
    9163             :     const int16_t nTCXDelay,
    9164             :     TRAN_DET_HANDLE hTranDet,
    9165             :     const int16_t ext_mem_flag );
    9166             : 
    9167             : void RunTransientDetection(
    9168             :     const float *input,      /* i  : input signal                            */
    9169             :     const int16_t length,    /* i  : frame length                            */
    9170             :     TRAN_DET_HANDLE hTranDet /* i/o: transient detection handle              */
    9171             : );
    9172             : 
    9173             : float GetTCXAvgTemporalFlatnessMeasure(
    9174             :     TRAN_DET_HANDLE hTranDet,
    9175             :     const int16_t nCurrentSubblocks,
    9176             :     const int16_t nPrevSubblocks );
    9177             : 
    9178             : float GetTCXMaxenergyChange(
    9179             :     TRAN_DET_HANDLE hTranDet,
    9180             :     const int16_t isTCX10,
    9181             :     const int16_t nCurrentSubblocks,
    9182             :     const int16_t nPrevSubblocks );
    9183             : 
    9184             : void SetTCXModeInfo(
    9185             :     Encoder_State *st,        /* i/o: encoder state structure                 */
    9186             :     TRAN_DET_HANDLE hTranDet, /* i/o: transient detection handle              */
    9187             :     int16_t *tcxModeOverlap   /* o  : window overlap of current frame         */
    9188             : );
    9189             : 
    9190             : void TCX_MDCT(
    9191             :     const float *x,
    9192             :     float *y,
    9193             :     const int16_t l,
    9194             :     const int16_t m,
    9195             :     const int16_t r,
    9196             :     const int16_t element_mode );
    9197             : 
    9198             : void TCX_MDST(
    9199             :     const float *x,
    9200             :     float *y,
    9201             :     const int16_t l,
    9202             :     const int16_t m,
    9203             :     const int16_t r,
    9204             :     const int16_t element_mode );
    9205             : 
    9206             : void TCX_MDCT_Inverse(
    9207             :     const float *x,
    9208             :     float *y,
    9209             :     const int16_t l,
    9210             :     const int16_t m,
    9211             :     const int16_t r,
    9212             :     const int16_t element_mode );
    9213             : 
    9214             : void TCX_MDST_Inverse(
    9215             :     const float *x,
    9216             :     float *y,
    9217             :     const int16_t l,
    9218             :     const int16_t m,
    9219             :     const int16_t r,
    9220             :     const int16_t element_mode );
    9221             : 
    9222             : void TCX_MDXT_Inverse(
    9223             :     const float *x,
    9224             :     float *y,
    9225             :     const int16_t l,
    9226             :     const int16_t m,
    9227             :     const int16_t r,
    9228             :     const uint16_t kernel_type );
    9229             : 
    9230             : void post_decoder(
    9231             :     Decoder_State *st,
    9232             :     float synth_buf[],
    9233             :     const float pit_gain[],
    9234             :     const int16_t pitch[],
    9235             :     float signal_out[],
    9236             :     float bpf_noise_buf[] );
    9237             : 
    9238             : float bass_pf_enc(
    9239             :     const float *orig,          /* i  : 12.8kHz original signal                     */
    9240             :     const float *syn,           /* i  : 12.8kHz synthesis to postfilter             */
    9241             :     const float pitch_buf[],    /* i  : Pitch gain for all subframes (gainT_sf[16]) */
    9242             :     const float gainT_sf[],     /* i  : Pitch gain for all subframes (gainT_sf[16]) */
    9243             :     const int16_t l_frame,      /* i  : frame length (should be multiple of l_subfr)*/
    9244             :     const int16_t l_subfr_in,   /* i  : sub-frame length (60/64)                    */
    9245             :     float mem_bpf[],            /* i/o: memory state [2*L_FILT]                     */
    9246             :     float mem_error_bpf[],      /* i/o: memory state [2*L_FILT]                     */
    9247             :     int16_t *gain_factor_param, /* o  : quantized gain factor                       */
    9248             :     const int16_t mode,         /* i  : coding mode of adapt bpf                    */
    9249             :     float *mem_deemph_err,      /* i/o: Error deemphasis memory                     */
    9250             :     float *lp_ener              /* i/o: long_term error signal energy               */
    9251             : );
    9252             : 
    9253             : void cldfb_synth_set_bandsToZero(
    9254             :     Decoder_State *st, /* i/o: decoder state structure             */
    9255             :     float **rAnalysis,
    9256             :     float **iAnalysis,
    9257             :     const int16_t nTimeSlots );
    9258             : 
    9259             : void longadd(
    9260             :     uint16_t a[],       /* i/o: vector of the length lena */
    9261             :     const uint16_t b[], /* i/o: vector of the length lenb */
    9262             :     const int16_t lena, /* i/o: length of vector a[]      */
    9263             :     const int16_t lenb  /* i/o: length of vector b[]      */
    9264             : );
    9265             : 
    9266             : void longshiftright(
    9267             :     uint16_t a[],      /* i  : vector of the length lena                */
    9268             :     const int16_t b,   /* i  : number of bit positions to shift right   */
    9269             :     uint16_t d[],      /* o  : vector of the length lend                */
    9270             :     int16_t lena,      /* i  : length of vector a[]                     */
    9271             :     const int16_t lend /* i  : length of vector d[]                     */
    9272             : );
    9273             : 
    9274             : void longshiftleft(
    9275             :     const uint16_t a[], /* i  : vector of the length len              */
    9276             :     const int16_t b,    /* i  : number of bit positions to shift left */
    9277             :     uint16_t d[],       /* o  : vector of the length len              */
    9278             :     const int16_t len   /* i  : length of vector a[] and d[]          */
    9279             : );
    9280             : 
    9281             : void open_decoder_LPD(
    9282             :     Decoder_State *st,               /* i/o: decoder state structure                */
    9283             :     const int32_t total_brate,       /* i  : total bitrate                          */
    9284             :     const int32_t last_total_brate,  /* i  : last total bitrate                     */
    9285             :     const int16_t bwidth,            /* i  : audio bandwidth                        */
    9286             :     const int16_t MCT_flag,          /* i  : hMCT handle allocated (1) or not (0)   */
    9287             :     const int16_t last_element_mode, /* i  : last element mode                      */
    9288             :     const int16_t is_init            /* i  : indicate call during initialization    */
    9289             : );
    9290             : 
    9291             : void acelp_plc_mdct_transition(
    9292             :     Decoder_State *st /* i/o: Decoder state */
    9293             : );
    9294             : 
    9295             : void tcxltp_dec_init(
    9296             :     TCX_LTP_DEC_HANDLE hTcxLtpDec,
    9297             :     const int16_t ini_frame,
    9298             :     const int16_t last_codec_mode,
    9299             :     const int16_t element_mode,
    9300             :     const int16_t pit_max,
    9301             :     const int32_t sr_core );
    9302             : 
    9303             : void reset_tcx_overl_buf(
    9304             :     TCX_DEC_HANDLE hTcxDec /* i/o: TCX decoder handle          */
    9305             : );
    9306             : 
    9307             : void update_decoder_LPD_cng(
    9308             :     Decoder_State *st, /* i/o: decoder state structure     */
    9309             :     float *timeDomainBuffer,
    9310             :     float *A,
    9311             :     float *bpf_noise_buf );
    9312             : 
    9313             : void reconfig_decoder_LPD(
    9314             :     Decoder_State *st,         /* i/o: decoder state structure  */
    9315             :     const int16_t bits_frame,  /* i  : bit budget               */
    9316             :     const int16_t bwidth,      /* i  : audio bandwidth          */
    9317             :     const int32_t total_brate, /* i  : total bitrate            */
    9318             :     const int16_t L_frame_old  /* i  : frame length             */
    9319             : );
    9320             : 
    9321             : void mode_switch_decoder_LPD(
    9322             :     Decoder_State *st,              /* i/o: decoder state structure             */
    9323             :     const int16_t bwidth,           /* i  : audio bandwidth                     */
    9324             :     const int32_t total_brate,      /* i  : total bitrate                       */
    9325             :     const int32_t last_total_brate, /* i  : last frame total bitrate            */
    9326             :     const int16_t frame_size_index, /* i  : index determining the frame size    */
    9327             :     const int16_t MCT_flag,         /* i  : hMCT handle allocated (1) or not (0)*/
    9328             :     const int16_t last_element_mode /* i  : last element mode                   */
    9329             : );
    9330             : 
    9331             : void dec_acelp_tcx_frame(
    9332             :     Decoder_State *st,               /* i/o: decoder state structure             */
    9333             :     int16_t *concealWholeFrame,      /* i/o: concealment flag                    */
    9334             :     float *output,                   /* o  : synthesis                           */
    9335             :     float *bpf_noise_buf,            /* i/o: BPF noise buffer                    */
    9336             :     float *pcmbufFB,                 /* o  : synthesis @output_FS                */
    9337             :     float bwe_exc_extended[],        /* i/o: bandwidth extended excitation       */
    9338             :     float *voice_factors,            /* o  : voicing factors                     */
    9339             :     float pitch_buf[],               /* o  : floating pitch for each subframe    */
    9340             :     STEREO_CNG_DEC_HANDLE hStereoCng /* i  : stereo CNG handle                   */
    9341             : );
    9342             : 
    9343             : void decoder_LPD(
    9344             :     Decoder_State *st,     /* i/o: decoder memory state pointer        */
    9345             :     float signal_out[],    /* o  : signal with LPD delay (7 subfrs)    */
    9346             :     float signal_outFB[],  /* o  : synthesis @output_FS                */
    9347             :     int16_t *total_nbbits, /* i/o: number of bits / decoded bits       */
    9348             :     float *bpf_noise_buf,  /* i/o: BPF noise buffer                    */
    9349             :     int16_t bfi,           /* i  : BFI flag                            */
    9350             :     int16_t *bitsRead,     /* o  : number of read bits                 */
    9351             :     int16_t param[],       /* o  : buffer of parameters                */
    9352             :     float *pitch_buf,      /* i/o: floating pitch values for each subfr*/
    9353             :     float *voice_factors,  /* o  : voicing factors                     */
    9354             :     float *ptr_bwe_exc     /* o  : excitation for SWB TBE              */
    9355             : );
    9356             : 
    9357             : int16_t tcxGetNoiseFillingTilt(
    9358             :     const float A[],
    9359             :     const int16_t L_frame,
    9360             :     const int16_t mode,
    9361             :     float *noiseTiltFactor );
    9362             : 
    9363             : void tcxFormantEnhancement(
    9364             :     float xn_buf[],
    9365             :     const float *gainlpc,
    9366             :     float spectrum[],
    9367             :     const int16_t L_frame );
    9368             : 
    9369             : void tcxInvertWindowGrouping(
    9370             :     TCX_CONFIG_HANDLE hTcxCfg,
    9371             :     float xn_buf[],
    9372             :     float spectrum[],
    9373             :     const int16_t L_frame,
    9374             :     const int16_t fUseTns,
    9375             :     const int16_t last_core,
    9376             :     const int16_t index,
    9377             :     const int16_t frame_cnt,
    9378             :     const int16_t bfi );
    9379             : 
    9380             : void tcx5SpectrumInterleaving(
    9381             :     const int16_t tcx5Size,
    9382             :     float *spectrum );
    9383             : 
    9384             : void tcx5SpectrumDeinterleaving(
    9385             :     const int16_t tcx5Size,
    9386             :     float *spectrum );
    9387             : 
    9388             : void tcx5TnsGrouping(
    9389             :     const int16_t L_frame,
    9390             :     const int16_t L_spec,
    9391             :     float *spectrum );
    9392             : 
    9393             : void tcx5TnsUngrouping(
    9394             :     const int16_t L_frame,
    9395             :     const int16_t L_spec,
    9396             :     float *spectrum,
    9397             :     const int16_t enc_dec );
    9398             : 
    9399             : void lerp(
    9400             :     const float *f,
    9401             :     float *f_out,
    9402             :     const int16_t bufferNewSize,
    9403             :     const int16_t bufferOldSize );
    9404             : 
    9405             : void encoderSideLossSimulation(
    9406             :     Encoder_State *st,
    9407             :     PLC_ENC_EVS_HANDLE hPlc_Ext,
    9408             :     float *isf_q,
    9409             :     const float stab_fac,
    9410             :     const int16_t calcOnlyISF,
    9411             :     const int16_t L_frame );
    9412             : 
    9413             : void enc_prm_side_Info(
    9414             :     PLC_ENC_EVS_HANDLE hPlc_Ext,
    9415             :     Encoder_State *st );
    9416             : 
    9417             : void GplcTcxEncSetup(
    9418             :     const int16_t tcxltp_pitch_int,
    9419             :     PLC_ENC_EVS_HANDLE hPlc_Ext );
    9420             : 
    9421             : int16_t encSideSpecPowDiffuseDetector(
    9422             :     float *isf_ref,
    9423             :     float *isf_con,
    9424             :     const int32_t sr_core,
    9425             :     float *prev_isf4_mean,
    9426             :     const int16_t sw,
    9427             :     const int16_t coder_type );
    9428             : 
    9429             : void updateSpecPowDiffuseIdx(
    9430             :     const float gain_pitch_buf[], /* i  : gain pitch values   */
    9431             :     const float gain_code_buf[],  /* i  : gain pitch values   */
    9432             :     int16_t glr_idx[2],           /* o  : */
    9433             :     float mean_gc[2]              /* o  : */
    9434             : );
    9435             : 
    9436             : void getLookAheadResSig(
    9437             :     float *speechLookAhead,
    9438             :     const float *A,
    9439             :     float *res,
    9440             :     const int16_t L_frame,
    9441             :     const int16_t L_subfr,
    9442             :     const int16_t m,
    9443             :     const int16_t numSubFrame );
    9444             : 
    9445             : void updatelsfForConcealment(
    9446             :     PLC_ENC_EVS_HANDLE decState,
    9447             :     float *lsf );
    9448             : 
    9449             : void getConcealedLP(
    9450             :     PLC_ENC_EVS_HANDLE memDecState,
    9451             :     float *AqCon,
    9452             :     const float xsfBase[],
    9453             :     const int32_t sr_core,
    9454             :     const int16_t last_good,
    9455             :     const int16_t L_frame );
    9456             : 
    9457             : void RecLpcSpecPowDiffuseLc(
    9458             :     float *ispq,
    9459             :     float *isp_old,
    9460             :     float *isfq,
    9461             :     Decoder_State *st,
    9462             :     const int16_t reset_q );
    9463             : 
    9464             : void modify_lsf(
    9465             :     float *lsf,
    9466             :     const int16_t n,
    9467             :     const int32_t sr_core,
    9468             :     const int16_t reset_q );
    9469             : 
    9470             : void init_PLC_enc(
    9471             :     PLC_ENC_EVS_HANDLE hPlcExt,
    9472             :     const int32_t sr_core );
    9473             : 
    9474             : void gPLC_encInfo(
    9475             :     PLC_ENC_EVS_HANDLE hPlcExt,
    9476             :     const int32_t total_brate,
    9477             :     const int16_t bwidth,
    9478             :     const int16_t last_clas,
    9479             :     const int16_t coder_type );
    9480             : 
    9481             : void resetTecDec(
    9482             :     TEC_DEC_HANDLE hTecDec );
    9483             : 
    9484             : void calcGainTemp_TBE(
    9485             :     float **pCldfbRealSrc,
    9486             :     float **pCldfbImagSrc,
    9487             :     float *loBuffer,
    9488             :     const int16_t startPos,   /*!<  Start position of the current envelope. */
    9489             :     const int16_t stopPos,    /*!<  Stop position of the current envelope. */
    9490             :     const int16_t lowSubband, /* lowSubband */
    9491             :     float *pGainTemp,
    9492             :     const int16_t code );
    9493             : 
    9494             : void procTecTfa_TBE(
    9495             :     float *hb_synth,
    9496             :     float *gain,
    9497             :     const int16_t flat_flag,
    9498             :     const int16_t last_core,
    9499             :     const int16_t L_subfr,
    9500             :     const int16_t code );
    9501             : 
    9502             : void resetTecEnc(
    9503             :     TEC_ENC_HANDLE hTecEnc,
    9504             :     const int16_t flag );
    9505             : 
    9506             : void calcHiEnvLoBuff(
    9507             :     const int16_t noCols,
    9508             :     const int16_t *pFreqBandTable, /* i  : freqbandTable            */
    9509             :     const int16_t nSfb,            /* i  : Number of scalefactors   */
    9510             :     float **pYBuf,
    9511             :     float *loBuf,
    9512             :     float *hiTempEnv );
    9513             : 
    9514             : void calcLoEnvCheckCorrHiLo(
    9515             :     const int16_t noCols,
    9516             :     const int16_t *pFreqBandTable, /* i  : freqbandTable           */
    9517             :     float *loBuf,
    9518             :     float *loTempEnv,
    9519             :     float *loTempEnv_ns,
    9520             :     float *hiTempEnv,
    9521             :     int16_t *corr_flag /* o  : 0 for original, 1 for TEC */
    9522             : );
    9523             : 
    9524             : void tfaCalcEnv(
    9525             :     const float *shb_speech,
    9526             :     float *enr );
    9527             : 
    9528             : int16_t tfaEnc_TBE(
    9529             :     const float *enr,
    9530             :     const int16_t last_core,
    9531             :     const float *voicing,
    9532             :     const float *pitch_buf );
    9533             : 
    9534             : void tecEnc_TBE(
    9535             :     int16_t *corrFlag,
    9536             :     const float *voicing,
    9537             :     const int16_t coder_type );
    9538             : 
    9539             : void set_TEC_TFA_code(
    9540             :     const int16_t corrFlag,
    9541             :     int16_t *tec_flag,
    9542             :     int16_t *tfa_flag );
    9543             : 
    9544             : float Damping_fact(
    9545             :     const int16_t coder_type, /* i  : ACELP core coder type                            */
    9546             :     const int16_t nbLostCmpt, /* i  : compt for number of consecutive lost frame       */
    9547             :     int16_t last_good,        /* i  : class of last good received frame                */
    9548             :     float stab_fac,           /* i  : LSF stability factor                             */
    9549             :     float *lp_gainp,          /* i/o: low passed pitch gain used for concealment       */
    9550             :     const int16_t core        /* i  : current core: ACELP = 0, TCX20 = 1, TCX10 = 2    */
    9551             : );
    9552             : 
    9553             : void fer_energy(
    9554             :     const int16_t L_frame,  /* i  : frame length                           */
    9555             :     const int16_t clas,     /* i  : frame classification                   */
    9556             :     const float synth[],    /* i  : synthesized speech at Fs = 12k8 Hz     */
    9557             :     const float pitch,      /* i  : pitch period                           */
    9558             :     float *enr,             /* o  : pitch-synchronous or half_frame energy */
    9559             :     const int16_t useOffset /* i  : speech pointer offset (0 or L_FRAME)   */
    9560             : );
    9561             : 
    9562             : float getLevelSynDeemph(
    9563             :     const float h1Init[],    /* i  : input value or vector to be processed */
    9564             :     const float A[],         /* i  : LPC coefficients                      */
    9565             :     const int16_t lenLpcExc, /* i  : length of the LPC excitation buffer   */
    9566             :     const float preemph_fac, /* i  : preemphasis factor                    */
    9567             :     const int16_t numLoops   /* i  : number of loops                       */
    9568             : );
    9569             : 
    9570             : void genPlcFiltBWAdap(
    9571             :     const int32_t sr_core, /* i  : core sampling rate                                         */
    9572             :     float *lpFiltAdapt,    /* o  : filter coefficients for filtering codebooks in case of flc */
    9573             :     const int16_t type,    /* i  : type of filter, either 0 : lowpass or 1 : highpass         */
    9574             :     const float alpha      /* i  : fade out factor [0 1) used decrease filter tilt            */
    9575             : );
    9576             : 
    9577             : void highPassFiltering(
    9578             :     const int16_t last_good, /* i  : last classification type                           */
    9579             :     const int16_t L_buffer,  /* i  : buffer length                                      */
    9580             :     float exc2[],            /* i/o: unvoiced excitation before the high pass filtering */
    9581             :     const float hp_filt[],   /* i  : high pass filter coefficients                      */
    9582             :     const int16_t l_fir_fer  /* i  : high pass filter length                            */
    9583             : );
    9584             : 
    9585             : int16_t GetPLCModeDecision(
    9586             :     Decoder_State *st /* i/o: decoder memory state pointer                        */
    9587             : );
    9588             : 
    9589             : void addBassPostFilter(
    9590             :     const float *harm_timeIn,
    9591             :     const int16_t samplesToProcess,
    9592             :     float **rAnalysis,
    9593             :     float **iAnalysis,
    9594             :     HANDLE_CLDFB_FILTER_BANK cldfb );
    9595             : 
    9596             : ivas_error TonalMDCTConceal_Init(
    9597             :     TonalMDCTConcealPtr hTonalMDCTConc,
    9598             :     const uint16_t samplesPerBlock,
    9599             :     const uint16_t nSamplesCore,
    9600             :     const uint16_t nScaleFactors,
    9601             :     TCX_CONFIG_HANDLE hTcxCfg );
    9602             : 
    9603             : void TonalMDCTConceal_SaveFreqSignal(
    9604             :     TonalMDCTConcealPtr hTonalMDCTConc,
    9605             :     const float *mdctSpectrum,
    9606             :     const uint16_t numSamples,
    9607             :     const uint16_t nNewSamplesCore,
    9608             :     const float *scaleFactors,
    9609             :     const int16_t infoIGFStartLine );
    9610             : 
    9611             : void TonalMDCTConceal_UpdateState(
    9612             :     TonalMDCTConcealPtr hTonalMDCTConc,
    9613             :     const int16_t numSamples,
    9614             :     const float pitchLag,
    9615             :     const int16_t badBlock,
    9616             :     const int16_t tonalConcealmentActive );
    9617             : 
    9618             : void TonalMDCTConceal_SaveTimeSignal(
    9619             :     TonalMDCTConcealPtr hTonalMDCTConc,
    9620             :     float *timeSignal,
    9621             :     const int16_t numSamples );
    9622             : 
    9623             : void TonalMDCTConceal_Detect(
    9624             :     const TonalMDCTConcealPtr hTonalMDCTConc,          /*IN */
    9625             :     const float pitchLag,                              /*IN */
    9626             :     int16_t *umIndices,                                /*OUT*/
    9627             :     const PsychoacousticParameters *psychParamsCurrent /*IN*/
    9628             : );
    9629             : 
    9630             : void TonalMDCTConceal_Apply(
    9631             :     TonalMDCTConcealPtr hTonalMDCTConc,                /*IN */
    9632             :     float *mdctSpectrum,                               /*OUT*/
    9633             :     const PsychoacousticParameters *psychParamsCurrent /*IN*/
    9634             : );
    9635             : 
    9636             : void TonalMDCTConceal_InsertNoise(
    9637             :     const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */
    9638             :     float *mdctSpectrum,                      /*OUT*/
    9639             :     const int16_t tonalConcealmentActive,
    9640             :     int16_t *pSeed, /*IN/OUT*/
    9641             :     const float tiltCompFactor,
    9642             :     const float crossfadeGain,
    9643             :     const float concealment_noise[L_FRAME48k],
    9644             :     const float cngLevelBackgroundTrace_bfi,
    9645             :     const int16_t crossOverFreq );
    9646             : 
    9647             : void DetectTonalComponents(
    9648             :     uint16_t indexOfTonalPeak[],
    9649             :     uint16_t lowerIndex[],
    9650             :     uint16_t upperIndex[],
    9651             :     uint16_t *pNumIndexes,
    9652             :     const float lastPitchLag,
    9653             :     const float currentPitchLag,
    9654             :     const float lastMDCTSpectrum[],
    9655             :     const float scaleFactors[],
    9656             :     const float secondLastPowerSpectrum[],
    9657             :     const uint16_t nSamples,
    9658             :     const uint16_t nSamplesCore,
    9659             :     float floorPowerSpectrum,
    9660             :     const PsychoacousticParameters *psychParamsCurrent );
    9661             : 
    9662             : void RefineTonalComponents(
    9663             :     uint16_t indexOfTonalPeak[],
    9664             :     uint16_t lowerIndex[],
    9665             :     uint16_t upperIndex[],
    9666             :     float phaseDiff[],
    9667             :     float phases[],
    9668             :     uint16_t *pNumIndexes,
    9669             :     const float lastPitchLag,
    9670             :     const float currentPitchLag,
    9671             :     const float lastMDCTSpectrum[],
    9672             :     const float scaleFactors[],
    9673             :     const float secondLastPowerSpectrum[],
    9674             :     const uint16_t nSamples,
    9675             :     const uint16_t nSamplesCore,
    9676             :     float floorPowerSpectrum,
    9677             :     const PsychoacousticParameters *psychParamsCurrent );
    9678             : 
    9679             : ivas_error PsychoacousticParameters_Init(
    9680             :     const int32_t sr_core,  /* i  : sampling rate of core-coder                                     */
    9681             :     const int16_t nBins,    /* i  : Number of bins (spectral lines)                                 */
    9682             :     const int8_t nBands,    /* i  : Number of spectrum subbands                                     */
    9683             :     const int16_t isTCX20,  /* i  : Flag indicating if the subband division is for TCX20 or TCX10   */
    9684             :     const int16_t isWarped, /* i  : Flag indicating if the scale is linear or warped                */
    9685             :     PsychoacousticParameters *pPsychParams );
    9686             : 
    9687             : void concealment_init(
    9688             :     const int16_t L_frameTCX,
    9689             :     T_PLCInfo_HANDLE hPlcInfo );
    9690             : 
    9691             : void concealment_decode(
    9692             :     const int16_t core,
    9693             :     float *invkoef,
    9694             :     T_PLCInfo_HANDLE hPlcInfo );
    9695             : 
    9696             : void concealment_update(
    9697             :     const int16_t bfi,
    9698             :     const int16_t core,
    9699             :     const int16_t harmonic,
    9700             :     float *invkoef,
    9701             :     T_PLCInfo_HANDLE hPlcInfo );
    9702             : 
    9703             : void concealment_update2(
    9704             :     const float *outx_new,
    9705             :     T_PLCInfo_HANDLE hPlcInfo,
    9706             :     const int16_t L_frameTCX );
    9707             : 
    9708             : void concealment_signal_tuning(
    9709             :     Decoder_State *st,
    9710             :     const int16_t bfi,
    9711             :     float *outx_new,
    9712             :     const int16_t past_core_mode );
    9713             : 
    9714             : void waveform_adj2(
    9715             :     T_PLCInfo_HANDLE hPlcInfo,
    9716             :     float *overlapbuf,
    9717             :     float *outx_new,
    9718             :     const int16_t delay,
    9719             :     const int16_t bfi_cnt,
    9720             :     const int16_t bfi );
    9721             : 
    9722             : float SFM_Cal(
    9723             :     const float fcoef[],
    9724             :     const int16_t n );
    9725             : 
    9726             : void set_state(
    9727             :     int16_t *state,
    9728             :     const int16_t num,
    9729             :     const int16_t N );
    9730             : 
    9731             : int16_t RFFTN(
    9732             :     float *afftData,
    9733             :     const float *trigPtr,
    9734             :     const int16_t len,
    9735             :     const int16_t isign );
    9736             : 
    9737             : void DoFFT(
    9738             :     float *re2,
    9739             :     float *im2,
    9740             :     const int16_t length );
    9741             : 
    9742             : /*! r: flag indicating a valid bitrate */
    9743             : int16_t is_EVS_bitrate(
    9744             :     const int32_t ivas_total_brate, /* i  : EVS total bitrate  */
    9745             :     int16_t *Opt_AMR_WB             /* i  : AMR-WB IO flag     */
    9746             : );
    9747             : 
    9748             : /*! r: codec mode */
    9749             : int16_t get_codec_mode(
    9750             :     const int32_t total_brate /* i  : total bitrate   */
    9751             : );
    9752             : 
    9753             : int16_t getTcxonly(
    9754             :     const int16_t element_mode, /* i  : IVAS element mode                   */
    9755             :     const int32_t total_brate,  /* i  : total bitrate                       */
    9756             :     const int16_t MCT_flag,     /* i  : hMCT handle allocated (1) or not (0)*/
    9757             :     const int16_t is_ism_format /* i  : flag indicating ISM format          */
    9758             : );
    9759             : 
    9760             : int16_t getTnsAllowed(
    9761             :     const int32_t total_brate, /* i  : total bitrate               */
    9762             :     const int16_t igf,         /* i  : flag indicating IGF activity*/
    9763             :     const int16_t element_mode /* i  : IVAS element mode           */
    9764             : );
    9765             : 
    9766             : int16_t getCtxHm(
    9767             :     const int16_t element_mode, /* i  : IVAS element mode           */
    9768             :     const int32_t total_brate,  /* i  : total bitrate               */
    9769             :     const int16_t rf_flag       /* i  : flag to signal the RF mode  */
    9770             : );
    9771             : 
    9772             : int16_t getResq(
    9773             :     const int32_t total_brate /* i  : total bitrate   */
    9774             : );
    9775             : 
    9776             : int16_t getRestrictedMode(
    9777             :     const int16_t element_mode, /* i  : IVAS element mode               */
    9778             :     const int32_t total_brate,  /* i  : total bitrate                   */
    9779             :     const int16_t Opt_AMR_WB    /* i  : flag indicating AMR-WB IO mode  */
    9780             : );
    9781             : 
    9782             : int16_t getMdctWindowLength(
    9783             :     const int16_t fscale );
    9784             : 
    9785             : int16_t sr2fscale(
    9786             :     const int32_t sr_core /* i  : internal sampling rate        */
    9787             : );
    9788             : 
    9789             : int32_t getCoreSamplerateMode2(
    9790             :     const int16_t element_mode,     /* i  : IVAS element mode              */
    9791             :     const int32_t total_brate,      /* i  : total bitrate                  */
    9792             :     const int16_t bwidth,           /* i  : audio bandwidth                */
    9793             :     const int16_t flag_ACELP16k,    /* i  : ACELP@16kHz flag               */
    9794             :     const int16_t rf_mode,          /* i  : flag to signal the RF mode     */
    9795             :     const IVAS_FORMAT is_ism_format /* i  : flag indicating ISM format     */
    9796             : );
    9797             : 
    9798             : float getTcxBandwidth(
    9799             :     const int16_t bwidth /* i  : audio bandwidth        */
    9800             : );
    9801             : 
    9802             : int16_t getIgfPresent(
    9803             :     const int16_t element_mode, /* i  : IVAS element mode           */
    9804             :     const int32_t total_brate,  /* i  : total bitrate               */
    9805             :     const int16_t bwidth,       /* i  : audio bandwidth             */
    9806             :     const int16_t rf_mode       /* i  : flag to signal the RF mode  */
    9807             : );
    9808             : 
    9809             : int16_t getCnaPresent(
    9810             :     const int16_t element_mode,  /* i  : element mode             */
    9811             :     const int32_t element_brate, /* i  : element bitrate          */
    9812             :     const int32_t total_brate,   /* i  : total bitrate            */
    9813             :     const int16_t bwidth         /* i  : audio bandwidth          */
    9814             : );
    9815             : 
    9816             : int16_t getTcxLtp(
    9817             :     const int32_t sr_core /* i  : internal sampling rate                              */
    9818             : );
    9819             : 
    9820             : int16_t initPitchLagParameters(
    9821             :     const int32_t sr_core, /* i  : internal sampling rate                              */
    9822             :     int16_t *pit_min,
    9823             :     int16_t *pit_fr1,
    9824             :     int16_t *pit_fr1b,
    9825             :     int16_t *pit_fr2,
    9826             :     int16_t *pit_max );
    9827             : 
    9828             : void attenuateNbSpectrum(
    9829             :     const int16_t L_frame,
    9830             :     float *spectrum );
    9831             : 
    9832             : void SetModeIndex(
    9833             :     Encoder_State *st,               /* i  : Encoder state                          */
    9834             :     const int32_t last_total_brate,  /* i  : last total bitrate                     */
    9835             :     const int16_t last_element_mode, /* i  : last IVAS element mode                 */
    9836             :     const int16_t MCT_flag           /* i  : hMCT handle allocated (1) or not (0)   */
    9837             : );
    9838             : 
    9839             : int16_t getNumTcxCodedLines(
    9840             :     const int16_t bwidth /* i  : audio bandwidth        */
    9841             : );
    9842             : 
    9843             : int16_t getTcxLpcShapedAri(
    9844             :     const int32_t total_brate, /* i  : total bitrate                */
    9845             :     const int16_t rf_mode,     /* i  : flag to signal the RF mode   */
    9846             :     const int16_t element_mode /* i  : IVAS element mode            */
    9847             : );
    9848             : 
    9849             : void IGFEncApplyMono(
    9850             :     Encoder_State *st,              /* i  : Encoder state                                          */
    9851             :     const int16_t igfGridIdx,       /* i  : IGF grid index                                         */
    9852             :     float *pMDCTSpectrum,           /* i/o: MDCT spectrum                                          */
    9853             :     float *pPowerSpectrum,          /* i/o: MDCT^2 + MDST^2 spectrum, or estimate                  */
    9854             :     const int16_t isTCX20,          /* i  : flag indicating if the input is TCX20 or TCX10/2xTCX5  */
    9855             :     const int16_t isTNSActive,      /* i  : flag indicating if the TNS is active                   */
    9856             :     const int16_t sp_aud_decision0, /* i  : first stage switching decision                         */
    9857             :     const int16_t vad_hover_flag    /* i  : VAD hangover flag                                      */
    9858             : );
    9859             : 
    9860             : void IGFEncApplyStereo(
    9861             :     STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct,             /* i/o: MDCT stereo encoder structure               */
    9862             :     int16_t ms_mask[2][MAX_SFB],                         /* i  : bandwise MS mask                            */
    9863             :     const IGF_ENC_INSTANCE_HANDLE hIGFEnc[CPE_CHANNELS], /* i  : instance handle of IGF Encoder              */
    9864             :     const int16_t igfGridIdx,                            /* i  : IGF grid index                              */
    9865             :     Encoder_State *sts[CPE_CHANNELS],                    /* i  : Encoder state                               */
    9866             :     float *pPowerSpectrum[CPE_CHANNELS],                 /* i/o: MDCT^2 + MDST^2 spectrum, or estimate       */
    9867             :     float *pPowerSpectrumMsInv[CPE_CHANNELS][NB_DIV],    /* i/o: inverse power spectrum                      */
    9868             :     float *inv_spectrum[CPE_CHANNELS][NB_DIV],           /* i  : inverse spectrum                            */
    9869             :     const int16_t frameno,                               /* i  : flag indicating index of current subframe   */
    9870             :     const int16_t sp_aud_decision0,                      /* i  : sp_aud_decision0                            */
    9871             :     const int32_t element_brate,                         /* i  : element bitrate                             */
    9872             :     const int16_t mct_on                                 /* i  : flag mct block (1) or stereo (0)              */
    9873             : );
    9874             : 
    9875             : void IGFEncConcatenateBitstream(
    9876             :     const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i  : instance handle of IGF Encoder                 */
    9877             :     const int16_t bsBits,                  /* i  : number of IGF bits written to list of indices  */
    9878             :     BSTR_ENC_HANDLE hBstr                  /* i/o: bitstream handle                               */
    9879             : );
    9880             : 
    9881             : void IGFEncResetTCX10BitCounter(
    9882             :     const IGF_ENC_INSTANCE_HANDLE hIGFEnc /* i  : instance handle of IGF Encoder */
    9883             : );
    9884             : 
    9885             : ivas_error IGF_Reconfig(
    9886             :     IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder  */
    9887             :     const int16_t igf,                /* i  : IGF on/off                      */
    9888             :     const int16_t reset,              /* i  : reset flag                      */
    9889             :     const int32_t brate,              /* i  : bitrate for configuration       */
    9890             :     const int16_t bwidth,             /* i  : signal bandwidth                */
    9891             :     const int16_t element_mode,       /* i  : IVAS element mode               */
    9892             :     const int16_t rf_mode             /* i  : flag to signal the RF mode      */
    9893             : );
    9894             : 
    9895             : void IGFEncSetMode(
    9896             :     const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i  : instance handle of IGF Encoder */
    9897             :     const int32_t total_brate,             /* i  : encoder total bitrate          */
    9898             :     const int16_t bwidth,                  /* i  : encoder audio bandwidth        */
    9899             :     const int16_t element_mode,            /* i  : IVAS element mode              */
    9900             :     const int16_t rf_mode                  /* i  : flag to signal the RF mode     */
    9901             : );
    9902             : 
    9903             : /*! r: number of bits written per frame */
    9904             : int16_t IGFEncWriteBitstream(
    9905             :     const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i  : instance handle of IGF Encoder                                              */
    9906             :     BSTR_ENC_HANDLE hBstr,                 /* i/o: encoder bitstream handle                                                    */
    9907             :     int16_t *pBitOffset,                   /* i  : ptr to bitOffset counter                                                    */
    9908             :     const int16_t igfGridIdx,              /* i  : igf grid index see declaration of IGF_GRID_IDX for details                  */
    9909             :     const int16_t isIndepFlag              /* i  : if 1 frame is independent, 0 = frame is coded with data from previous frame */
    9910             : );
    9911             : 
    9912             : /*! r: total number of bits written */
    9913             : int16_t IGFEncWriteConcatenatedBitstream(
    9914             :     const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i  : instance handle of IGF Encoder */
    9915             :     BSTR_ENC_HANDLE hBstr                  /* i/o: encoder bitstream handle       */
    9916             : );
    9917             : 
    9918             : void IGFDecApplyMono(
    9919             :     const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i  : instance handle of IGF Decoder                       */
    9920             :     float *spectrum,                       /* i/o: MDCT spectrum                                        */
    9921             :     const int16_t igfGridIdx,              /* i  : in case of CELP->TCX switching, use 1.25 framelength */
    9922             :     const int16_t bfi,                     /* i  : frame loss == 1, frame good == 0                     */
    9923             :     const int16_t element_mode             /* i  : IVAS element mode                                    */
    9924             : );
    9925             : 
    9926             : void IGFDecCopyLPCFlatSpectrum(
    9927             :     const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Decoder     */
    9928             :     const float *pSpectrumFlat,            /* i  : LPC flattend spectrum from TCX dec */
    9929             :     const int16_t igfGridIdx               /* i  : IGF grid index                     */
    9930             : );
    9931             : 
    9932             : void IGFDecReadData(
    9933             :     const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Deccoder                      */
    9934             :     Decoder_State *st,                     /* i  : decoder state                                        */
    9935             :     const int16_t igfGridIdx,              /* i  : in case of CELP->TCX switching, use 1.25 framelength */
    9936             :     const int16_t isIndepFrame             /* i  : if 1: arith dec force reset, if 0: no reset          */
    9937             : );
    9938             : 
    9939             : /*! r: return igfAllZero flag indicating if no envelope is transmitted */
    9940             : int16_t IGFDecReadLevel(
    9941             :     const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Deccoder                                  */
    9942             :     Decoder_State *st,                     /* i  : decoder state                                                    */
    9943             :     const int16_t igfGridIdx,              /* i  : in case of CELP->TCX switching, use 1.25 framelength             */
    9944             :     const int16_t isIndepFrame             /* i  : if 1: arith dec force reset, if 0: no reset                      */
    9945             : );
    9946             : 
    9947             : void IGFDecRestoreTCX10SubFrameData(
    9948             :     const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* o  : instance handle of IGF Decoder      */
    9949             :     const int16_t subFrameIdx              /* i  : index of subframe                   */
    9950             : );
    9951             : 
    9952             : void init_igf_dec(
    9953             :     IGF_DEC_INSTANCE_HANDLE hIGFDec /* i/o: IGF decoder handle                  */
    9954             : );
    9955             : 
    9956             : void IGFDecSetMode(
    9957             :     const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* o  : instance handle of IGF Decoder      */
    9958             :     const int32_t total_brate,             /* i  : bitrate                             */
    9959             :     const int16_t bwidth,                  /* i  : audio bandwidth                     */
    9960             :     const int16_t element_mode,            /* i  : IVAS element mode                   */
    9961             :     const int16_t defaultStartLine,        /* i  : default start subband index         */
    9962             :     const int16_t defaultStopLine,         /* i  : default stop subband index          */
    9963             :     const int16_t rf_mode                  /* i  : flag to signal the RF mode          */
    9964             : );
    9965             : 
    9966             : void IGFDecStoreTCX10SubFrameData(
    9967             :     const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Decoder      */
    9968             :     const int16_t subFrameIdx              /* i  : index of subframe                   */
    9969             : );
    9970             : 
    9971             : void IGFDecUpdateInfo(
    9972             :     const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Decoder      */
    9973             :     const int16_t subFrameIdx,             /* i  : subframe index                      */
    9974             :     const int16_t igfGridIdx               /* i  : IGF grid index                      */
    9975             : );
    9976             : 
    9977             : /*! r: error value: 0 -> error, 1 -> ok */
    9978             : int16_t IGFCommonFuncsIGFConfiguration(
    9979             :     const int32_t total_brate,  /* i  : bitrate in bs e.g. 9600 for 9.6kbs  */
    9980             :     const int16_t bwidth,       /* i  : audio bandwidth                     */
    9981             :     const int16_t element_mode, /* i  : IVAS element mode                   */
    9982             :     H_IGF_INFO hIGFInfo,        /* o  : IGF info handle                     */
    9983             :     const int16_t rf_mode       /* i  : flag to signal the RF mode          */
    9984             : );
    9985             : 
    9986             : /*! r: error value: 0 -> error, 1 -> ok */
    9987             : int16_t IGFCommonFuncsIGFGetCFTables(
    9988             :     const int32_t total_brate,   /* i  : bitrate in bs e.g. 9600 for 9.6kbs  */
    9989             :     const int16_t bwidth,        /* i  : audio bandwidth                     */
    9990             :     const int16_t element_mode,  /* i  : element mode                        */
    9991             :     const int16_t rf_mode,       /* i  : flag to signal the RF mode          */
    9992             :     const uint16_t **cf_se00,    /* i  : CF table for t == 0 and f == 0      */
    9993             :     const uint16_t **cf_se01,    /* i  : CF table for t == 0 and f == 1      */
    9994             :     int16_t *cf_off_se01,        /* o  : offset for CF table above           */
    9995             :     const uint16_t **cf_se02,    /* i  : CF tables for t == 0 and f >= 2     */
    9996             :     const int16_t **cf_off_se02, /* o  : offsets for CF tables above         */
    9997             :     const uint16_t **cf_se10,    /* i  : CF table for t == 1 and f == 0      */
    9998             :     int16_t *cf_off_se10,        /* o  : offset for CF table above           */
    9999             :     const uint16_t **cf_se11,    /* i  : CF tables for t == 1 and f >= 1     */
   10000             :     const int16_t **cf_off_se11  /* o  : offsets for CF tables above         */
   10001             : );
   10002             : 
   10003             : /*! r: multiplication factor */
   10004             : int16_t IGF_ApplyTransFac(
   10005             :     const int16_t val,   /* i  : input value for multiplication, Q15                                          */
   10006             :     const float transFac /* i  : multiplicator for variable val, Q14: 1.25f=0x5000, 1.0f=0x4000, 0.5f=0x2000  */
   10007             : );
   10008             : 
   10009             : /*! r: return bitrate index */
   10010             : int16_t IGF_MapBitRateToIndex(
   10011             :     const int32_t brate,        /* i  : bitrate                         */
   10012             :     const int16_t bwidth,       /* i  : audio bandwidth                 */
   10013             :     const int16_t element_mode, /* i  : IVAS element mode               */
   10014             :     const int16_t rf_mode       /* i  : flag to signal the RF mode      */
   10015             : );
   10016             : 
   10017             : void IGFSCFEncoderOpen(
   10018             :     IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i  : handle to public data           */
   10019             :     H_IGF_INFO hIgfInfo,                   /* i  : IGF info handle                 */
   10020             :     const int32_t total_brate,             /* i  : total bitrate                   */
   10021             :     const int16_t bwidth,                  /* i  : audio bandwidth                 */
   10022             :     const int16_t element_mode,            /* i  : IVAS element mode               */
   10023             :     const int16_t rf_mode                  /* i  : flag to signal the RF mode      */
   10024             : );
   10025             : 
   10026             : void IGFSCFEncoderReset(
   10027             :     IGFSCFENC_INSTANCE_HANDLE hPublicData /* i  : handle to public data or NULL in case there was no instance created */
   10028             : );
   10029             : 
   10030             : int16_t IGFSCFEncoderEncode(
   10031             :     IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i  : handle to public data or NULL in case there was no instance created          */
   10032             :     BSTR_ENC_HANDLE hBstr,                 /* i/o: encoder bitstream handle                                                     */
   10033             :     const int16_t bitCount,                /* i  : offset to the first bit in bitbuffer which should be readed by iisArithDecoderDecode function */
   10034             :     int16_t *sfe,                          /* i  : ptr to an array which contain quantized scalefactor energies                 */
   10035             :     const int16_t igfGridIdx,              /* i  : igf grid index see declaration of IGF_GRID_IDX for details                   */
   10036             :     const int16_t indepFlag                /* i  : if 1 frame is independent, 0 = frame is coded with data from previous frame  */
   10037             : );
   10038             : 
   10039             : void IGFSCFEncoderSaveContextState(
   10040             :     IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i  : handle to public data or NULL in case there was no instance created */
   10041             :     const int16_t igfGridIdx               /* i  : igf grid index see declaration of IGF_GRID_IDX for details          */
   10042             : );
   10043             : 
   10044             : void IGFSCFEncoderRestoreContextState(
   10045             :     IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i  : handle to public data or NULL in case there was no instance created */
   10046             :     const int16_t igfGridIdx               /* i  : igf grid index see declaration of IGF_GRID_IDX for details          */
   10047             : );
   10048             : 
   10049             : void IGFSCFDecoderOpen(
   10050             :     IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i  : handle to public data       */
   10051             :     H_IGF_INFO hIgfInfo,                   /* i  : IGF info handle             */
   10052             :     const int32_t total_brate,
   10053             :     const int16_t bwidth,
   10054             :     const int16_t element_mode,
   10055             :     const int16_t rf_mode );
   10056             : 
   10057             : void IGFSCFDecoderReset(
   10058             :     IGFSCFDEC_INSTANCE_HANDLE hPublicData /* i  : handle to public data or NULL in case there was no instance created     */
   10059             : );
   10060             : 
   10061             : void IGFSCFDecoderDecode(
   10062             :     IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i  : handle to public data or NULL in case there was no instance created     */
   10063             :     Decoder_State *st,                     /* i/o: pointer to decoder state                                                */
   10064             :     int16_t *sfe,                          /* o  : ptr to an array which will contain the decoded quantized coefficients   */
   10065             :     const int16_t igfGridIdx,              /* i  : igf grid index see declaration of IGF_GRID_IDX for details              */
   10066             :     const int16_t indepFlag                /* i  : if  1 on input the decoder will be forced to reset,
   10067             :                                                    if  0 on input the decoder will be forced to encode without a reset     */
   10068             : );
   10069             : 
   10070             : /*! r: offset value */
   10071             : int16_t tbe_celp_exc_offset(
   10072             :     const int16_t T0,     /* i  : Integer pitch */
   10073             :     const int16_t T0_frac /* i  : Fractional part of the pitch */
   10074             : );
   10075             : 
   10076             : void blend_subfr2(
   10077             :     float *sigIn1, /* i  : input signal for fade-out */
   10078             :     float *sigIn2, /* i  : input signal for fade-in  */
   10079             :     float *sigOut  /* o  : output signal             */
   10080             : );
   10081             : 
   10082             : void init_tcx_window_cfg(
   10083             :     TCX_CONFIG_HANDLE hTcxCfg,          /* i  : TCX Config handle        */
   10084             :     const int32_t sr_core,              /* i  : SR core                  */
   10085             :     const int32_t input_Fs,             /* i  : input/output SR          */
   10086             :     const int16_t L_frame,              /* i  : L_frame at sr_core       */
   10087             :     const int16_t L_frameTCX,           /* i  : L_frame at i/o SR        */
   10088             :     const int16_t encoderLookahead_enc, /* i  : encoder LA at sr_core    */
   10089             :     const int16_t encoderLookahead_FB,  /* i  : encoder LA at i/o SR     */
   10090             :     const int16_t mdctWindowLength,     /* i  : window length at sr_core */
   10091             :     const int16_t mdctWindowLengthFB,   /* i  : window length at i/o SR  */
   10092             :     const int16_t element_mode          /* i  : mode of CPE/SCE          */
   10093             : );
   10094             : 
   10095             : void init_tcx_cfg(
   10096             :     TCX_CONFIG_HANDLE hTcxCfg,
   10097             :     const int32_t total_brate,
   10098             :     const int32_t sr_core,
   10099             :     const int32_t input_Fs,
   10100             :     const int16_t L_frame,
   10101             :     const int16_t bwidth,
   10102             :     const int16_t L_frameTCX,
   10103             :     const int16_t fscale,
   10104             :     const int16_t encoderLookahead_enc,
   10105             :     const int16_t encoderLookahead_FB,
   10106             :     const float preemph_fac,
   10107             :     const int16_t tcxonly,
   10108             :     const int16_t rf_mode,
   10109             :     const int16_t igf,
   10110             :     const int16_t infoIGFStopFreq,
   10111             :     const int16_t element_mode,
   10112             :     const int16_t ini_frame,
   10113             :     const int16_t MCT_flag /* i  : hMCT handle allocated (1) or not (0)  */
   10114             : );

Generated by: LCOV version 1.14