LCOV - code coverage report
Current view: top level - lib_com - prot.h (source / functions) Hit Total Coverage
Test: Coverage on main -- short test vectors @ fec202a8f89be4a2f278a9fc377bfb58b58fab11 Lines: 3 3 100.0 %
Date: 2025-09-12 08:48:38 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             : 
     488             : ivas_error push_indice(
     489             :     BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle                    */
     490             :     int16_t id,            /* i  : ID of the indice                            */
     491             :     uint16_t value,        /* i  : value of the quantized indice               */
     492             :     int16_t nb_bits        /* i  : number of bits used to quantize the indice  */
     493             : );
     494             : 
     495             : #if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS )
     496             : #define push_next_indice( ... ) push_next_indice_( __func__, __VA_ARGS__ )
     497             : #define push_next_bits( ... )   push_next_bits_( __func__, __VA_ARGS__ );
     498             : #endif
     499             : 
     500             : 
     501             : #if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS )
     502             : ivas_error push_next_indice_(
     503             :     const char *caller,
     504             : #else
     505             : ivas_error push_next_indice(
     506             : #endif
     507             :     BSTR_ENC_HANDLE hBstr,
     508             :     uint16_t value, /* i  : value of the quantized indice          */
     509             :     int16_t nb_bits /* i  : number of bits used to quantize the indice */
     510             : );
     511             : 
     512             : #if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS )
     513             : ivas_error push_next_bits_(
     514             :     const char *caller,
     515             : #else
     516             : ivas_error push_next_bits(
     517             : #endif
     518             :     BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle               */
     519             :     const uint16_t bits[], /* i  : bit buffer to pack, sequence of single bits */
     520             :     const int16_t nb_bits  /* i  : number of bits to pack                 */
     521             : );
     522             : 
     523             : /*! r: maximum number of indices */
     524             : int16_t get_ivas_max_num_indices(
     525             :     const IVAS_FORMAT ivas_format, /* i  : IVAS format               */
     526             :     const int32_t ivas_total_brate /* i  : IVAS total bitrate           */
     527             : );
     528             : 
     529             : /*! r: maximum number of indices */
     530             : int16_t get_BWE_max_num_indices(
     531             :     const int32_t extl_brate /* i  : extensiona layer bitrate  */
     532             : );
     533             : 
     534             : /*! r: maximum number of indices */
     535             : int16_t get_ivas_max_num_indices_metadata(
     536             :     const IVAS_FORMAT ivas_format, /* i  : IVAS format               */
     537             :     const int32_t ivas_total_brate /* i  : IVAS total bitrate       */
     538             : );
     539             : 
     540             : ivas_error ind_list_realloc(
     541             :     INDICE_HANDLE old_ind_list,    /* i  : pointer to the beginning of the old buffer of indices */
     542             :     const int16_t max_num_indices, /* i  : new maximum number of allowed indices in the list */
     543             :     Encoder_Struct *st_ivas        /* i  : IVAS encoder structure                  */
     544             : );
     545             : 
     546             : ivas_error check_ind_list_limits(
     547             :     BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle                    */
     548             : );
     549             : 
     550             : void move_indices(
     551             :     INDICE_HANDLE old_ind_list, /* i/o: old location of indices */
     552             :     INDICE_HANDLE new_ind_list, /* i/o: new location of indices */
     553             :     const int16_t nb_indices    /* i  : number of moved indices */
     554             : );
     555             : 
     556             : /*! r: index of the indice in the list, -1 if not found */
     557             : int16_t find_indice(
     558             :     BSTR_ENC_HANDLE hBstr, /* i  : encoder bitstream handle                    */
     559             :     const int16_t id,      /* i  : ID of the indice                            */
     560             :     uint16_t *value,       /* o  : value of the quantized indice               */
     561             :     int16_t *nb_bits       /* o  : number of bits used to quantize the indice  */
     562             : );
     563             : 
     564             : /*! r: number of deleted indices                   */
     565             : uint16_t delete_indice(
     566             :     BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle                    */
     567             :     const int16_t id       /* i  : ID of the indice                            */
     568             : );
     569             : 
     570             : /*! r: value of the indice */
     571             : uint16_t get_next_indice(
     572             :     Decoder_State *st, /* i/o: decoder state structure                */
     573             :     int16_t nb_bits    /* i  : number of bits that were used to quantize the indice */
     574             : );
     575             : 
     576             : /*! r: value of the indice */
     577             : uint16_t get_next_indice_1(
     578             :     Decoder_State *st /* i/o: decoder state structure                */
     579             : );
     580             : 
     581             : void get_next_indice_tmp(
     582             :     Decoder_State *st, /* o  : decoder state structure                */
     583             :     int16_t nb_bits    /* i  : number of bits that were used to quantize the indice */
     584             : );
     585             : 
     586             : /*! r: value of the indice */
     587             : uint16_t get_indice(
     588             :     Decoder_State *st, /* i/o: decoder state structure                */
     589             :     int16_t pos,       /* i  : absolute position in the bitstream     */
     590             :     int16_t nb_bits    /* i  : number of bits that were used to quantize the indice */
     591             : );
     592             : 
     593             : /*! r: value of the indice */
     594             : uint16_t get_indice_1(
     595             :     Decoder_State *st, /* i/o: decoder state structure                */
     596             :     int16_t pos        /* i  : absolute position in the bitstream     */
     597             : );
     598             : 
     599             : void reset_indices_enc(
     600             :     BSTR_ENC_HANDLE hBstr,        /* i/o: encoder bitstream handle               */
     601             :     const int16_t max_num_indices /* i  : max number of indices                  */
     602             : );
     603             : 
     604             : void reset_indices_dec(
     605             :     Decoder_State *st /* i/o: decoder state structure                */
     606             : );
     607             : 
     608             : ivas_error write_indices_ivas(
     609             :     Encoder_Struct *st_ivas, /* i/o: encoder state structure                                       */
     610             :     uint16_t *bit_stream,    /* i/o: output bitstream                                              */
     611             :     uint16_t *num_bits       /* i/o: number of bits written to output                              */
     612             : );
     613             : 
     614             : Word16 rate2EVSmode(
     615             :     const Word32 brate, /* i  : bitrate                                                    */
     616             :     int16_t *is_amr_wb  /* o  : (flag) does the bitrate belong to AMR-WB? Can be NULL      */
     617             : );
     618             : 
     619             : 
     620             : /*! r: 1 = OK, 0 = something wrong */
     621             : ivas_error read_indices(
     622             :     Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure                 */
     623             :     uint16_t bit_stream[],   /* i  : bitstream buffer                       */
     624             :     UWord16 num_bits,        /* i  : number of bits in bitstream            */
     625             :     int16_t *prev_ft_speech,
     626             :     int16_t *CNG,
     627             :     int16_t bfi /* i  : bad frame indicator                    */
     628             : );
     629             : 
     630             : #ifdef DEBUGGING
     631             : /*! r: 1 = reading OK, 0 = problem */
     632             : ivas_error preview_indices(
     633             :     Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure                 */
     634             :     uint16_t bit_stream[],   /* i  : bitstream buffer                       */
     635             :     UWord16 num_bits         /* i  : number of bits in bitstream            */
     636             : );
     637             : #endif
     638             : 
     639             : void ivas_set_bitstream_pointers(
     640             :     Decoder_Struct *st_ivas /* i/o: IVAS decoder structure    */
     641             : );
     642             : 
     643             : Decoder_State **reset_elements(
     644             :     Decoder_Struct *st_ivas /* i/o: IVAS decoder structure      */
     645             : );
     646             : 
     647             : 
     648             : void convertSerialToBytestream(
     649             :     const uint16_t *const serial, /* i  : input serial bitstream with values 0 and 1  */
     650             :     const uint16_t num_bits,      /* i  : number of bits in the input bitstream       */
     651             :     uint8_t *const bytestream     /* o  : output compact bitstream (bytestream)       */
     652             : );
     653             : 
     654             : void convertBytestreamToSerial(
     655             :     const uint8_t *const bytestream, /* i  : input compact bitstream (bytestream)        */
     656             :     const uint16_t num_bits,         /* i  : number of bits in the input bitstream       */
     657             :     uint16_t *const serial           /* o  : output serial bitstream with values 0 and 1 */
     658             : );
     659             : 
     660             : void mdct_switching_dec(
     661             :     Decoder_State *st /* i/o: decoder state structure                 */
     662             : );
     663             : 
     664             : void evs_dec_previewFrame(
     665             :     uint8_t *bitstream,            /* i  : bitstream pointer                       */
     666             :     int16_t bitstreamSize,         /* i  : bitstream size                          */
     667             :     int16_t *partialCopyFrameType, /* o  : frame type of the partial copy          */
     668             :     int16_t *partialCopyOffset     /* o  : offset of the partial copy relative to the primary copy */
     669             : );
     670             : 
     671             : 
     672             : void getPartialCopyInfo(
     673             :     Decoder_State *st, /* i  : decoder state structure                 */
     674             :     int16_t *sharpFlag );
     675             : 
     676             : void get_NextCoderType(
     677             :     uint8_t *bitstream,      /* i  : bitstream                               */
     678             :     int16_t *next_coder_type /* o  : next coder type                         */
     679             : );
     680             : 
     681             : int16_t print_disclaimer(
     682             :     FILE *fPtr );
     683             : 
     684             : void autocorr(
     685             :     const float *x,         /* i  : input signal                            */
     686             :     float *r,               /* o  : autocorrelations vector                 */
     687             :     const int16_t m,        /* i  : order of LP filter                      */
     688             :     const int16_t len,      /* i  : window size                             */
     689             :     const float *wind,      /* i  : window                                  */
     690             :     const int16_t rev_flag, /* i  : flag to reverse window                  */
     691             :     const int16_t sym_flag, /* i  : symmetric window flag                   */
     692             :     const int16_t no_thr    /* i  : flag to avoid thresholding              */
     693             : );
     694             : 
     695             : /*! r: energy of prediction error */
     696             : int16_t lev_dur(
     697             :     float *a,        /* o  :   LP coefficients (a[0] = 1.0)          */
     698             :     const float *r,  /* i  :   vector of autocorrelations            */
     699             :     const int16_t m, /* i  :   order of LP filter                    */
     700             :     float epsP[]     /* o  :   prediction error energy               */
     701             : );
     702             : 
     703             : /*! r: delay value in ns */
     704             : int32_t get_delay(
     705             :     const int16_t enc_dec,                  /* i  : encoder/decoder flag                  */
     706             :     const int32_t io_fs,                    /* i  : input/output sampling frequency       */
     707             :     const IVAS_FORMAT ivas_format,          /* i  : IVAS format                           */
     708             :     HANDLE_CLDFB_FILTER_BANK hCldfb,        /* i  : Handle of Cldfb analysis              */
     709             :     const int16_t flag_binaural_split_coded /* i  : split rendering on/off flag         */
     710             : );
     711             : 
     712             : void decision_matrix_enc(
     713             :     Encoder_State *st,    /* i/o: encoder state structure                   */
     714             :     int16_t *hq_core_type /* o  : HQ core type                              */
     715             : );
     716             : 
     717             : void signaling_enc(
     718             :     Encoder_State *st /* i  : encoder state structure                   */
     719             : );
     720             : 
     721             : int16_t signaling_mode1_tcx20_enc(
     722             :     Encoder_State *st, /* i/o: encoder state structure                   */
     723             :     const int16_t push /* i  : flag to push indice                       */
     724             : );
     725             : 
     726             : void decision_matrix_dec(
     727             :     Decoder_State *st,           /* i/o: decoder state structure                   */
     728             :     int16_t *sharpFlag,          /* o  : formant sharpening flag                   */
     729             :     int16_t *hq_core_type,       /* o  : HQ core type                              */
     730             :     int16_t *core_switching_flag /* o  : ACELP->HQ switching frame flag            */
     731             : );
     732             : 
     733             : /*! r: LP filter stability */
     734             : float lsf_stab(
     735             :     const float *lsf,         /* i  : LSF vector                                  */
     736             :     const float *lsfold,      /* i  : old LSF vector                              */
     737             :     const int16_t Opt_AMR_WB, /* i  : flag indicating AMR-WB IO mode              */
     738             :     const int16_t L_frame     /* i  : frame length                                */
     739             : );
     740             : 
     741             : void amr_wb_dec_init(
     742             :     AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle                            */
     743             : );
     744             : 
     745             : void hf_synth_amr_wb_init(
     746             :     AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle                            */
     747             : );
     748             : 
     749             : void hf_synth_amr_wb_reset(
     750             :     AMRWB_IO_DEC_HANDLE hAmrwb_IO, /* i/o: AMR-WB IO data handle                            */
     751             :     ZERO_BWE_DEC_HANDLE hBWE_zero  /* o  : zero BWE decoder handle                          */
     752             : );
     753             : 
     754             : void hf_synth_amr_wb(
     755             :     AMRWB_IO_DEC_HANDLE hAmrwb_IO, /* i/o: AMR-WB IO data handle                             */
     756             :     ZERO_BWE_DEC_HANDLE hBWE_zero, /* o  : zero BWE decoder handle                           */
     757             :     const int32_t core_brate,      /* i  : core bitrate                                      */
     758             :     const int16_t output_frame,    /* i  : output frame length                               */
     759             :     const float *Aq,               /* i  : quantized Az                                      */
     760             :     const float *exc,              /* i  : excitation at 12.8 kHz                            */
     761             :     float *synth,                  /* i/o: synthesis signal at 12.8 kHz                      */
     762             :     int16_t *amr_io_class,         /* i  : signal class (determined by FEC algorithm)        */
     763             :     float *synth_out,              /* i/o: synthesis signal at output Fs                     */
     764             :     float fmerit,                  /* i  : classify parameter from FEC                       */
     765             :     const int16_t *hf_gain,        /* i  : decoded HF gain                                   */
     766             :     const float *voice_factors,    /* i  : voicing factors                                   */
     767             :     const float pitch_buf[],       /* i  : pitch buffer                                      */
     768             :     const float ng_ener_ST,        /* i  : Noise gate - short-term energy                    */
     769             :     const float *lsf_new           /* i  : ISF vector                                        */
     770             : );
     771             : 
     772             : void hf_cod_init(
     773             :     float *mem_hp400_enc,  /* o  : memory of hp 400 Hz filter   */
     774             :     float *mem_hf1_enc,    /* o  : HF band-pass filter memory   */
     775             :     float *mem_syn_hf_enc, /* o  : HF synthesis memory          */
     776             :     float *mem_hf2_enc,    /* o  : HF band-pass filter memory   */
     777             :     float *gain_alpha      /* o  : smoothing gain for transitions between active and inactive frames */
     778             : );
     779             : 
     780             : void hf_cod(
     781             :     const int32_t core_brate, /* i  : core bitrate                 */
     782             :     const float *speech16k,   /* i  : original speech at 16 kHz    */
     783             :     const float Aq[],         /* i  : quantized Aq                 */
     784             :     const float exc[],        /* i  : excitation at 12.8 kHz       */
     785             :     float synth[],            /* i  : 12.8kHz synthesis signal     */
     786             :     int16_t *seed2_enc,       /* i/o: random seed for HF noise gen */
     787             :     float *mem_hp400_enc,     /* i/o: memory of hp 400 Hz filter   */
     788             :     float *mem_syn_hf_enc,    /* i/o: HF synthesis memory          */
     789             :     float *mem_hf1_enc,       /* i/o: HF band-pass filter memory   */
     790             :     float *mem_hf2_enc,       /* i/o: HF band-pass filter memory   */
     791             :     const int16_t *dtxHangoverCount,
     792             :     float *gain_alpha, /* i/o: smoothing gain for transitions between active and inactive frames */
     793             :     int16_t *hf_gain   /* o  :  HF gain to be transmitted to decoder */
     794             : );
     795             : 
     796             : void hf_synth_init(
     797             :     ZERO_BWE_DEC_HANDLE hBWE_zero /* o  : zero BWE decoder handle     */
     798             : );
     799             : 
     800             : void hf_synth_reset(
     801             :     ZERO_BWE_DEC_HANDLE hBWE_zero /* o  : zero BWE decoder handle     */
     802             : );
     803             : 
     804             : void hf_synth(
     805             :     ZERO_BWE_DEC_HANDLE hBWE_zero, /* o  : zero BWE decoder handle     */
     806             :     const int32_t core_brate,      /* i  : core bitrate                */
     807             :     const int16_t output_frame,    /* i  : output frame length         */
     808             :     const float *Aq,               /* i  : quantized Az                */
     809             :     const float *exc,              /* i  : excitation at 12.8 kHz      */
     810             :     float *synth,                  /* i/o: 12.8kHz synthesis signal    */
     811             :     float *synth16k                /* i/o: 16kHz synthesis signal      */
     812             : );
     813             : 
     814             : int16_t lsp_convert_poly(
     815             :     float w[],              /* i/o: LSP or ISP parameters          */
     816             :     const int16_t L_frame,  /* i  : flag for up or down conversion */
     817             :     const int16_t Opt_AMRWB /* i  : flag for the AMR-WB IO mode    */
     818             : );
     819             : 
     820             : /*! r: pulse position */
     821             : int16_t findpulse(
     822             :     const int16_t L_frame, /* i  : length of the frame   */
     823             :     const float res[],     /* i  : residual signal       */
     824             :     const int16_t T0,      /* i  : integer pitch         */
     825             :     const int16_t enc_dec, /* i  : flag enc/dec, 0 - enc, 1 - dec */
     826             :     int16_t *sign          /* i/o: sign of the maximum   */
     827             : );
     828             : 
     829             : void fft_rel(
     830             :     float x[],       /* i/o: input/output vector    */
     831             :     const int16_t n, /* i  : vector length          */
     832             :     const int16_t m  /* i  : log2 of vector length  */
     833             : );
     834             : 
     835             : void ifft_rel(
     836             :     float io[],      /* i/o: input/output vector   */
     837             :     const int16_t n, /* i  : vector length         */
     838             :     const int16_t m  /* i  : log2 of vector length */
     839             : );
     840             : 
     841             : void preemph(
     842             :     float *signal,   /* i/o: signal             */
     843             :     const float mu,  /* i  : preemphasis factor */
     844             :     const int16_t L, /* i  : vector size        */
     845             :     float *mem       /* i/o: memory (x[-1])     */
     846             : );
     847             : 
     848             : void cb_shape(
     849             :     const int16_t preemphFlag,     /* i  : flag for pre-emphasis                       */
     850             :     const int16_t pitchFlag,       /* i  : flag for pitch sharpening                   */
     851             :     const int16_t scramblingFlag,  /* i  : flag for phase scrambling                   */
     852             :     const int16_t formantFlag,     /* i  : flag for formant sharpening                 */
     853             :     const int16_t formantTiltFlag, /* i  : flag for formant tilt                       */
     854             :     const float g1,                /* i  : formant sharpening numerator weighting      */
     855             :     const float g2,                /* i  : formant sharpening denominator weighting    */
     856             :     const float *p_Aq,             /* i  : LP filter coefficients                      */
     857             :     float *code,                   /* i/o: signal to shape                             */
     858             :     const float tilt_code,         /* i  : tilt of code                                */
     859             :     const float pt_pitch,          /* i  : pointer to current subframe fractional pitch*/
     860             :     const int16_t L_subfr          /* i  : subfframe length                            */
     861             : );
     862             : 
     863             : void isp2a(
     864             :     const float *isp, /* i  : ISP vector (in the cosine domain)       */
     865             :     float *a,         /* o  : LP filter coefficients                  */
     866             :     const int16_t m   /* i  : order of LP analysis                    */
     867             : );
     868             : 
     869             : void isp2isf(
     870             :     const float isp[], /* i  : isp[m] (range: -1<=val<1)               */
     871             :     float isf[],       /* o  : isf[m] normalized (range: 0<=val<=fs/2) */
     872             :     const int16_t m,   /* i  : LPC order                               */
     873             :     const int32_t Fs   /* i  : sampling frequency                      */
     874             : );
     875             : 
     876             : void isf2isp(
     877             :     const float isf[], /* i  : isf[m] normalized (range: 0<=val<=fs/2) */
     878             :     float isp[],       /* o  : isp[m] (range: -1<=val<1)               */
     879             :     const int16_t m,   /* i  : LPC order                               */
     880             :     const int32_t Fs   /* i  : sampling frequency                      */
     881             : );
     882             : 
     883             : void reorder_isf(
     884             :     float *isf,           /* i/o: vector of isfs in the frequency domain (0..0.5)*/
     885             :     const float min_dist, /* i  : minimum required distance               */
     886             :     const int16_t n,      /* i  : LPC order                               */
     887             :     const float Fs        /* i  : sampling frequency                      */
     888             : );
     889             : 
     890             : void lsp2lsf(
     891             :     const float lsp[], /* i  : isp[m] (range: -1<=val<1)               */
     892             :     float lsf[],       /* o  : isf[m] normalized (range: 0<=val<=fs/2) */
     893             :     const int16_t m,   /* i  : LPC order                               */
     894             :     const int32_t Fs   /* i  : sampling frequency                      */
     895             : );
     896             : 
     897             : void lsf2lsp(
     898             :     const float lsf[], /* i  : isf[m] normalized (range: 0<=val<=fs/2) */
     899             :     float lsp[],       /* o  : isp[m] (range: -1<=val<1)               */
     900             :     const int16_t m,   /* i  : LPC order                               */
     901             :     const int32_t Fs   /* i  : sampling frequency                      */
     902             : );
     903             : 
     904             : void lsp2isp(
     905             :     const float *lsp,  /* i  : LSP vector                              */
     906             :     float *isp,        /* o  : ISP filter coefficients                 */
     907             :     float *stable_isp, /* i/o: ISP filter coefficients                 */
     908             :     const int16_t m    /* i  : order of LP analysis                    */
     909             : );
     910             : 
     911             : void isp2lsp(
     912             :     const float *isp,  /* i  : LSP vector                              */
     913             :     float *lsp,        /* o  : ISP filter coefficients                 */
     914             :     float *stable_lsp, /* i/o: stable LSP filter coefficients          */
     915             :     const int16_t m    /* i  : order of LP analysis                    */
     916             : );
     917             : 
     918             : void reorder_lsf(
     919             :     float *lsf,           /* i/o: vector of lsfs in the frequency domain (0..0.5)*/
     920             :     const float min_dist, /* i  : minimum required distance               */
     921             :     const int16_t n,      /* i  : LPC order                               */
     922             :     const int32_t Fs      /* i  : sampling frequency                      */
     923             : );
     924             : 
     925             : void CNG_exc(
     926             :     const int32_t core_brate,      /* i  : core bitrate                            */
     927             :     const int16_t L_frame,         /* i  : length of the frame                     */
     928             :     float *Enew,                   /* i/o: decoded SID energy                      */
     929             :     int16_t *seed,                 /* i/o: random generator seed                   */
     930             :     float exc[],                   /* o  : current non-enhanced excitation         */
     931             :     float exc2[],                  /* o  : current enhanced excitation             */
     932             :     float *lp_ener,                /* i/o: LP filtered E                           */
     933             :     const int32_t last_core_brate, /* i  : previous frame core bitrate             */
     934             :     int16_t *first_CNG,            /* i/o: first CNG frame flag for energy init.   */
     935             :     int16_t *cng_ener_seed,        /* i/o: random generator seed for CNG energy    */
     936             :     float bwe_exc[],               /* o  : excitation for SWB TBE                  */
     937             :     const int16_t allow_cn_step,   /* i  : allow CN step                           */
     938             :     int16_t *last_allow_cn_step,   /* i/o: last CN_step                            */
     939             :     const int16_t num_ho,          /* i  : number of selected hangover frames      */
     940             :     float q_env[],
     941             :     float *lp_env,
     942             :     float *old_env,
     943             :     float *exc_mem,
     944             :     float *exc_mem1,
     945             :     int16_t *sid_bw,
     946             :     int16_t *cng_ener_seed1,
     947             :     float exc3[],
     948             :     const int16_t Opt_AMR_WB,  /* i  : AMR-WB interop flag                     */
     949             :     const int16_t element_mode /* i  : IVAS Element mode                       */
     950             : );
     951             : 
     952             : void cng_params_upd(
     953             :     const float lsp_new[],           /* i  : LSP aprameters                                      */
     954             :     const float exc2[],              /* i  : current enhanced excitation                         */
     955             :     const int16_t L_frame,           /* i  : frame length                                        */
     956             :     int16_t *ho_circ_ptr,            /* i/o: pointer for CNG averaging buffers                   */
     957             :     float ho_ener_circ[],            /* o  : energy buffer for CNG averaging                     */
     958             :     int16_t *ho_circ_size,           /* i/o: size of DTX hangover history buffer for averaging   */
     959             :     float ho_lsp_circ[],             /* o  : old LSP buffer for CNG averaging                    */
     960             :     const int16_t enc_dec_flag,      /* i  : Flag indicating encoder or decoder (ENC,DEC)        */
     961             :     float ho_env_circ[],             /* i/o: Envelope buffer                                     */
     962             :     int16_t *cng_buf_cnt,            /* i/o: Counter of postponed FFT-processing instances       */
     963             :     float cng_exc2_buf[],            /* i/o: Excitation buffer                                   */
     964             :     int32_t cng_brate_buf[],         /* i/o: last_active_brate buffer                            */
     965             :     const int32_t last_active_brate, /* i  : Last active bitrate                                 */
     966             :     const int16_t element_mode,      /* i  : Element mode                                        */
     967             :     const int16_t bwidth             /* i  : audio bandwidth                                     */
     968             : );
     969             : 
     970             : void cng_params_postupd(
     971             :     const int16_t ho_circ_ptr,    /* i  : pointer for CNG averaging buffers                   */
     972             :     int16_t *cng_buf_cnt,         /* i/o: counter for CNG store buffers                       */
     973             :     const float *cng_exc2_buf,    /* i  : Excitation buffer                                   */
     974             :     const int32_t *cng_brate_buf, /* i  : bitrate buffer                                      */
     975             :     float ho_env_circ[],          /* i/o: Envelope buffer                                     */
     976             :     const int16_t element_mode,   /* i  : Element mode                                        */
     977             :     const int16_t bwidth          /* i  : audio bandwidth                                     */
     978             : );
     979             : 
     980             : void calculate_hangover_attenuation_gain(
     981             :     Encoder_State *st,           /* i  : encoder state structure                               */
     982             :     float *att,                  /* o  : attenuation factor                                    */
     983             :     const int16_t vad_hover_flag /* i  : VAD hangover flag                          */
     984             : );
     985             : 
     986             : int16_t get_cng_mode(
     987             :     const int32_t last_active_brate /* i  : last active bitrate                                 */
     988             : );
     989             : 
     990             : void disf_ns_28b(
     991             :     int16_t *indice, /* i  : quantized indices, use indice[0] = -1 in the decoder*/
     992             :     float *isf_q     /* o  : ISF in the frequency domain (0..6400)               */
     993             : );
     994             : 
     995             : void limit_T0(
     996             :     const int16_t L_frame,    /* i  : length of the frame                                  */
     997             :     const int16_t delta,      /* i  : Half the close-loop searched interval                */
     998             :     const int16_t pit_flag,   /* i  : selecting absolute(0) or delta(1) pitch quantization */
     999             :     const int16_t limit_flag, /* i  : flag for limits (0=restrained, 1=extended)           */
    1000             :     const int16_t T0,         /* i  : rough pitch estimate around which the search is done */
    1001             :     const int16_t T0_frac,    /* i  : pitch estimate fractional part                       */
    1002             :     int16_t *T0_min,          /* o  : lower pitch limit                                    */
    1003             :     int16_t *T0_max           /* o  : higher pitch limit                                   */
    1004             : );
    1005             : 
    1006             : /*! r: interpolated value */
    1007             : float interpolation(
    1008             :     const float *x,        /* i  : input vector                                */
    1009             :     const float *win,      /* i  : interpolation window                        */
    1010             :     const int16_t frac,    /* i  : fraction                                    */
    1011             :     const int16_t up_samp, /* i  : upsampling factor                           */
    1012             :     const int16_t nb_coef  /* i  : nb of filter coef                           */
    1013             : );
    1014             : 
    1015             : void deemph(
    1016             :     float *signal,   /* i/o: signal                                      */
    1017             :     const float mu,  /* i  : deemphasis factor                           */
    1018             :     const int16_t L, /* i  : vector size                                 */
    1019             :     float *mem       /* i/o: memory (y[-1])                              */
    1020             : );
    1021             : 
    1022             : /*! r: tilt of the code */
    1023             : float est_tilt(
    1024             :     const float *adpt_exc,  /* i  : adaptive excitation vector                  */
    1025             :     const float gain_pit,   /* i  : adaptive gain                               */
    1026             :     const float *fixe_exc,  /* i  : algebraic exctitation vector                */
    1027             :     const float gain_code,  /* i  : algebraic code gain                         */
    1028             :     float *voice_fac,       /* o  : voicing factor                              */
    1029             :     const int16_t L_subfr,  /* i  : subframe size                               */
    1030             :     const int16_t flag_tilt /* i  : flag for special tilt                       */
    1031             : );
    1032             : 
    1033             : void weight_a(
    1034             :     const float *a,    /* i  : LP filter coefficients                      */
    1035             :     float *ap,         /* o  : weighted LP filter coefficients             */
    1036             :     const float gamma, /* i  : weighting factor                            */
    1037             :     const int16_t m    /* i  : order of LP filter                          */
    1038             : );
    1039             : 
    1040             : void weight_a_subfr(
    1041             :     const int16_t nb_subfr, /* i  : number of subframes                         */
    1042             :     const float *a,         /* i  : LP filter coefficients                      */
    1043             :     float *ap,              /* o  : weighted LP filter coefficients             */
    1044             :     const float gamma,      /* i  : weighting factor                            */
    1045             :     const int16_t m         /* i  : order of LP filter                          */
    1046             : );
    1047             : 
    1048             : void syn_12k8(
    1049             :     const int16_t L_frame, /* i  : length of the frame                         */
    1050             :     const float *Aq,       /* i  : LP filter coefficients                      */
    1051             :     const float *exc,      /* i  : input signal                                */
    1052             :     float *synth,          /* o  : output signal                               */
    1053             :     float *mem,            /* i/o: initial filter states                       */
    1054             :     const int16_t update_m /* i  : update memory flag: 0 --> no memory update  */
    1055             : );                         /*                          1 --> update of memory  */
    1056             : 
    1057             : void syn_filt(
    1058             :     const float a[],       /* i  : LP filter coefficients                      */
    1059             :     const int16_t m,       /* i  : order of LP filter                          */
    1060             :     const float x[],       /* i  : input signal                                */
    1061             :     float y[],             /* o  : output signal                               */
    1062             :     const int16_t l,       /* i  : size of filtering                           */
    1063             :     float mem[],           /* i/o: initial filter states                       */
    1064             :     const int16_t update_m /* i  : update memory flag: 0 --> no memory update  */
    1065             : );                         /*                          1 --> update of memory  */
    1066             : 
    1067             : void synth_mem_updt2(
    1068             :     const int16_t L_frame,      /* i  : frame length                                */
    1069             :     const int16_t last_L_frame, /* i  : frame length                                */
    1070             :     float old_exc[],            /* i/o: excitation buffer                           */
    1071             :     float mem_syn_r[],          /* i/o: synthesis filter memory                     */
    1072             :     float mem_syn2[],           /* o  : synthesis filter memory for find_target     */
    1073             :     float mem_syn[],            /* o  : synthesis filter memory for find_target     */
    1074             :     const int16_t dec           /* i  : flag for decoder indication                 */
    1075             : );
    1076             : 
    1077             : void int_lsp(
    1078             :     const int16_t L_frame,   /* i  : length of the frame                         */
    1079             :     const float lsp_old[],   /* i  : LSPs from past frame                        */
    1080             :     const float lsp_new[],   /* i  : LSPs from present frame                     */
    1081             :     float *Aq,               /* o  : LP coefficients in both subframes           */
    1082             :     const int16_t m,         /* i  : order of LP filter                          */
    1083             :     const float *int_coeffs, /* i  : interpolation coefficients                  */
    1084             :     const int16_t Opt_AMR_WB /* i  : flag indicating AMR-WB IO mode              */
    1085             : );
    1086             : 
    1087             : void int_lsp4(
    1088             :     const int16_t L_frame,        /* i  : length of the frame                         */
    1089             :     const float lsp_old[],        /* i  : previous end-frame LSPs                     */
    1090             :     const float lsp_mid[],        /* i  : current mid-frame LSPs                      */
    1091             :     const float lsp_new[],        /* i  : current end-frame LSPs                      */
    1092             :     float *Aq,                    /* o  : LP coefficients in both subframes           */
    1093             :     const int16_t m,              /* i  : order of LP filter                          */
    1094             :     int16_t relax_prev_lsf_interp /* i  : relax prev frame lsf interp after erasure   */
    1095             : );
    1096             : 
    1097             : /*! r: length of output */
    1098             : int16_t modify_Fs(
    1099             :     const float sigIn[], /* i  : signal to decimate                          */
    1100             :     const int16_t lg,    /* i  : length of input                             */
    1101             :     const int32_t fin,   /* i  : frequency of input                          */
    1102             :     float sigOut[],      /* o  : decimated signal                            */
    1103             :     const int32_t fout,  /* i  : frequency of output                         */
    1104             :     float mem[],         /* i/o: filter memory                               */
    1105             :     const int16_t nblp   /* i  : flag indicating if NB low-pass is applied   */
    1106             : );
    1107             : 
    1108             : void pred_lt4(
    1109             :     const float excI[],     /* i  : input excitation buffer                     */
    1110             :     float excO[],           /* o  : output excitation buffer                    */
    1111             :     const int16_t T0,       /* i  : integer pitch lag                           */
    1112             :     int16_t frac,           /* i  : fraction of lag                             */
    1113             :     const int16_t L_subfr,  /* i  : subframe size                               */
    1114             :     const float *win,       /* i  : interpolation window                        */
    1115             :     const int16_t nb_coef,  /* i  : nb of filter coef                           */
    1116             :     const int16_t up_sample /* i  : up_sample                                   */
    1117             : );
    1118             : 
    1119             : void pred_lt4_tc(
    1120             :     float exc[],           /* i  : excitation buffer                           */
    1121             :     const int16_t T0,      /* i  : integer pitch lag                           */
    1122             :     int16_t frac,          /* i  : fraction of lag                             */
    1123             :     const float *win,      /* i  : interpolation window                        */
    1124             :     const int16_t imp_pos, /* i  : glottal impulse position                    */
    1125             :     const int16_t i_subfr  /* i  : subframe index                              */
    1126             : );
    1127             : 
    1128             : void residu(
    1129             :     const float *a,  /* i  : LP filter coefficients                      */
    1130             :     const int16_t m, /* i  : order of LP filter                          */
    1131             :     const float *x,  /* i  : input signal (usually speech)               */
    1132             :     float *y,        /* o  : output signal (usually residual)            */
    1133             :     const int16_t l  /* i  : size of filtering                           */
    1134             : );
    1135             : 
    1136             : void calc_residu(
    1137             :     const float *speech,  /* i  : weighted speech signal                      */
    1138             :     float *res,           /* o  : residual signal                             */
    1139             :     const float *p_Aq,    /* i  : quantized LP filter coefficients            */
    1140             :     const int16_t L_frame /* i  : size of frame                               */
    1141             : );
    1142             : 
    1143             : /*! r: impulse response energy */
    1144             : float enr_1_Az(
    1145             :     const float Aq[], /* i  : LP filter coefs                             */
    1146             :     const int16_t len /* i  : impulse response length                     */
    1147             : );
    1148             : 
    1149             : void Es_pred_enc(
    1150             :     float *Es_pred,          /* o  : predicited scaled innovation energy         */
    1151             :     int16_t *Es_pred_indice, /* o  : indice corresponding to above parameter     */
    1152             :     const int16_t L_frame,   /* i  : length of the frame                         */
    1153             :     const int16_t L_subfr,   /* i  : length of the subframe                      */
    1154             :     const float *res,        /* i  : residual signal                             */
    1155             :     const float *voicing,    /* i  : normal. correlattion in three 1/2frames     */
    1156             :     const int16_t nb_bits,   /* i  : allocated number of bits                    */
    1157             :     const int16_t no_ltp     /* i  : no_ltp flag                                 */
    1158             : );
    1159             : 
    1160             : void create_offset(
    1161             :     UWord32 *offset_scale1,
    1162             :     UWord32 *offset_scale2,
    1163             :     const int16_t mode,
    1164             :     const int16_t prediction_flag );
    1165             : 
    1166             : float mslvq(
    1167             :     float *pTmp,            /* i  : M-dimensional input vector                  */
    1168             :     float *quant,           /* o  : quantized vector                            */
    1169             :     float *cv_out,          /* o  : corresponding 8-dim lattice codevectors (without the scaling) */
    1170             :     int16_t *idx_lead,      /* o  : leader index for each 8-dim subvector       */
    1171             :     int16_t *idx_scale,     /* o  : scale index for each subvector              */
    1172             :     const float *w,         /* i  : weights for LSF quantization                */
    1173             :     const int16_t mode,     /* i  : number indicating the coding mode           */
    1174             :     const int16_t mode_glb, /* i  : LVQ coding mode                             */
    1175             :     const int16_t pred_flag /* i  : prediction flag (0: safety net, 1 - predictive )*/
    1176             : );
    1177             : 
    1178             : void permute(
    1179             :     float *pTmp1,       /* i/o: vector whose components are to be permuted  */
    1180             :     const int16_t *perm /* i  : permutation info (indexes that should be interchanged), max two perms */
    1181             : );
    1182             : 
    1183             : void sort_desc_ind(
    1184             :     float *s,
    1185             :     const int16_t len,
    1186             :     int16_t *ind );
    1187             : 
    1188             : float mslvq_cng(
    1189             :     int16_t idx_cv,     /* i  : index of cv from previous stage             */
    1190             :     float *pTmp,        /* i  : 16 dimensional input vector                 */
    1191             :     float *quant,       /* o  : quantized vector                            */
    1192             :     float *cv_out,      /* o  : corresponding 8-dim lattice codevectors (without the scaling) */
    1193             :     int16_t *idx_lead,  /* o  : leader index for each 8-dim subvector       */
    1194             :     int16_t *idx_scale, /* o  : scale index for each subvector              */
    1195             :     const float *w      /* i  : weights for LSF quantization                */
    1196             : );
    1197             : 
    1198             : int16_t deindex_lvq_cng(
    1199             :     int16_t *index,       /* i  : index to be decoded, as an array of 3 short */
    1200             :     float *x_lvq,         /* o  : decoded codevector                          */
    1201             :     const int16_t idx_cv, /* i  : relative mode_lvq, wrt START_CNG            */
    1202             :     const int16_t no_bits /* i  : number of bits for lattice                  */
    1203             : );
    1204             : 
    1205             : void multiply32_32_64(
    1206             :     UWord32 x,   /* i  : operand 1                                   */
    1207             :     UWord32 y,   /* i  : operand 2                                   */
    1208             :     UWord32 *res /* o  : result as array of two uint32               */
    1209             : );
    1210             : 
    1211             : int16_t deindex_lvq(
    1212             :     int16_t *index,        /* i  : index to be decoded, as an array of 3 short */
    1213             :     float *x_lvq,          /* o  : decoded codevector                          */
    1214             :     const int16_t mode,    /* i  : LVQ  coding mode (select scales & no_lead ), or idx_cv */
    1215             :     const int16_t sf_flag, /* i  : safety net flag                             */
    1216             :     const int16_t no_bits  /* i  : number of bits for lattice                  */
    1217             : );
    1218             : 
    1219             : int16_t vq_dec_lvq(
    1220             :     int16_t sf_flag,      /* i  : safety net flag                             */
    1221             :     float x[],            /* o  : Decoded vector                              */
    1222             :     int16_t indices[],    /* i  : Indices                                     */
    1223             :     const int16_t stages, /* i  : Number of stages                            */
    1224             :     const int16_t N,      /* i  : Vector dimension                            */
    1225             :     const int16_t mode,   /* i  : lvq coding type                             */
    1226             :     const int16_t no_bits /* i  : no. bits for lattice                        */
    1227             : );
    1228             : 
    1229             : void index_lvq(
    1230             :     float *quant,                 /* i  : codevector to be indexed (2 8-dim subvectors)                     */
    1231             :     int16_t *idx_lead,            /* i  : leader class index for each subvector                             */
    1232             :     int16_t *idx_scale,           /* i  : scale index for each subvector                                    */
    1233             :     const int16_t mode,           /* i  : integer signaling the quantizer structure for the current bitrate */
    1234             :     int16_t *index,               /* o  : encoded index (represented on 3 short each with 15 bits )         */
    1235             :     const int16_t prediction_flag /* i  : predictive mode or not                                            */
    1236             : );
    1237             : 
    1238             : int16_t qlsf_ARSN_tcvq_Dec_16k(
    1239             :     float *y,           /* o  : Quantized LSF vector                        */
    1240             :     int16_t *indice,    /* i  : Indices                                     */
    1241             :     const int16_t nBits /* i  : number of bits                              */
    1242             : );
    1243             : 
    1244             : int16_t lsf_bctcvq_encprm(
    1245             :     BSTR_ENC_HANDLE hBstr,
    1246             :     const int16_t *param_lpc,
    1247             :     const int16_t *bits_param_lpc,
    1248             :     const int16_t no_indices );
    1249             : 
    1250             : int16_t lsf_bctcvq_decprm(
    1251             :     Decoder_State *st,
    1252             :     int16_t *param_lpc );
    1253             : 
    1254             : ivas_error lsf_allocate(
    1255             :     const int16_t nBits,       /* i  : Number of bits to use for quantization      */
    1256             :     const int16_t framemode,   /* i  : ISF quantizer mode                          */
    1257             :     const int16_t framemode_p, /* i  : ISF quantizer mode                          */
    1258             :     int16_t *stages0,          /* o  : Number of stages for safety-net quantizer   */
    1259             :     int16_t *stages1,          /* o  : Number of stages for predictive quantizer   */
    1260             :     int16_t levels0[],         /* o  : Number of vectors for each stage for SFNET  */
    1261             :     int16_t levels1[],         /* o  : Number of vectors for each stage for pred   */
    1262             :     int16_t bits0[],           /* o  : Number of bits for each stage safety net    */
    1263             :     int16_t bits1[]            /* o  : Number of bits for each stage predictive    */
    1264             : );
    1265             : 
    1266             : void disf_2s_36b(
    1267             :     int16_t *indice, /* i  : quantized indices (use indice[0] = -1 in the decoder) */
    1268             :     float *isf_q,    /* o  : quantized ISFs in the cosine domain         */
    1269             :     float *mem_AR,   /* i/o: quantizer memory for AR model               */
    1270             :     float *mem_MA    /* i/o: quantizer memory for MA model               */
    1271             : );
    1272             : 
    1273             : void disf_2s_46b(
    1274             :     int16_t *indice, /* i  : quantized indices (use indice[0] = -1 in the decoder) */
    1275             :     float *isf_q,    /* o  : quantized ISFs in the cosine domain         */
    1276             :     float *mem_AR,   /* o  : quantizer memory for AR model               */
    1277             :     float *mem_MA    /* i/o: quantizer memory for MA model               */
    1278             : );
    1279             : 
    1280             : void re8_k2y(
    1281             :     const int16_t *k, /* i  : Voronoi index k[0..7]                                   */
    1282             :     const int16_t m,  /* i  : Voronoi modulo (m = 2^r = 1<<r, where r is integer >=2) */
    1283             :     int16_t *y        /* o  : 8-dimensional point y[0..7] in RE8                      */
    1284             : );
    1285             : 
    1286             : void re8_PPV(
    1287             :     const float x[], /* i  : point in R^8                                */
    1288             :     int16_t y[]      /* o  : point in RE8 (8-dimensional integer vector) */
    1289             : );
    1290             : 
    1291             : void enhancer(
    1292             :     const int16_t codec_mode,   /* i  : flag indicating Codec Mode              */
    1293             :     const int32_t core_brate,   /* i  : core bitrate                            */
    1294             :     const int16_t cbk_index,    /* i  :                                         */
    1295             :     const int16_t Opt_AMR_WB,   /* i  : flag indicating AMR-WB IO mode          */
    1296             :     const int16_t coder_type,   /* i  : coding type                             */
    1297             :     const int16_t L_frame,      /* i  : frame size                              */
    1298             :     const float voice_fac,      /* i  : subframe voicing estimation             */
    1299             :     const float stab_fac,       /* i  : LP filter stablility measure            */
    1300             :     const float norm_gain_code, /* i  : normalized innovative cb. gain          */
    1301             :     const float gain_inov,      /* i  : gain of the unscaled innovation         */
    1302             :     float *gc_threshold,        /* i/o: code threshold                          */
    1303             :     float *code,                /* i/o: innovation                              */
    1304             :     float *exc2,                /* i/o: adapt. excitation/total exc.            */
    1305             :     const float gain_pit,       /* i  : Quantized pitch gain                    */
    1306             :     float *dispMem              /* i/o: Phase dispersion algorithm memory       */
    1307             : );
    1308             : 
    1309             : void phase_dispersion(
    1310             :     const float gain_code, /* i  : gain of code                            */
    1311             :     const float gain_pit,  /* i  : gain of pitch                           */
    1312             :     float code[],          /* i/o: code vector                             */
    1313             :     const int16_t mode,    /* i  : level, 0=hi, 1=lo, 2=off                */
    1314             :     float disp_mem[]       /* i/o: static memory (size = 8)                */
    1315             : );
    1316             : 
    1317             : void re8_vor(
    1318             :     int16_t y[], /* i  : point in RE8 (8-dimensional integer vector)      */
    1319             :     int16_t *n,  /* o  : codebook number n=0,2,3,4,... (scalar integer)   */
    1320             :     int16_t k[], /* o  : Voronoi index (integer vector of dimension 8) used only if n>4 */
    1321             :     int16_t c[], /* o  : codevector in Q0, Q2, Q3, or Q4 if n<=4, y=c     */
    1322             :     int16_t *ka  /* o  : identifier of absolute leader (needed to index c)*/
    1323             : );
    1324             : 
    1325             : void edct(
    1326             :     const float *x,            /* i  : input signal        */
    1327             :     float *y,                  /* o  : output transform    */
    1328             :     const int16_t length,      /* i  : length              */
    1329             :     const int16_t element_mode /* i  : IVAS element mode   */
    1330             : );
    1331             : 
    1332             : void edst(
    1333             :     const float *x,            /* i  : input signal        */
    1334             :     float *y,                  /* o  : output transform    */
    1335             :     const int16_t length,      /* i  : length              */
    1336             :     const int16_t element_mode /* i  : IVAS element mode   */
    1337             : );
    1338             : 
    1339             : void edxt(
    1340             :     const float *x,            /* i  : input signal        */
    1341             :     float *y,                  /* o  : output transform    */
    1342             :     const int16_t length,      /* i  : length              */
    1343             :     const uint16_t kernelType, /* i  : kernel type (0 - 3) */
    1344             :     const uint16_t synthesis   /* i  : nonzero for inverse */
    1345             : );
    1346             : 
    1347             : void iedct_short(
    1348             :     const float *in,              /* i  : input vector        */
    1349             :     float *out,                   /* o  : output vector       */
    1350             :     const int16_t segment_length, /* i  : length              */
    1351             :     const int16_t element_mode    /* i  : IVAS element mode   */
    1352             : );
    1353             : 
    1354             : void DoRTFT480(
    1355             :     float *x, /* i/o: real part of input and output data       */
    1356             :     float *y  /* i/o: imaginary part of input and output data  */
    1357             : );
    1358             : 
    1359             : void DoRTFT320(
    1360             :     float *x, /* i/o: real part of input and output data       */
    1361             :     float *y  /* i/o: imaginary part of input and output data  */
    1362             : );
    1363             : 
    1364             : void DoRTFT160(
    1365             :     float *x, /* i/o: real part of input and output data       */
    1366             :     float *y  /* i/o: imaginary part of input and output data  */
    1367             : );
    1368             : 
    1369             : void DoRTFT128(
    1370             :     float *x, /* i/o: real part of input and output data       */
    1371             :     float *y  /* i/o: imaginary part of input and output data  */
    1372             : );
    1373             : 
    1374             : void DoRTFT120(
    1375             :     float *x, /* i/o: real part of input and output data       */
    1376             :     float *y  /* i/o: imaginary part of input and output data  */
    1377             : );
    1378             : 
    1379             : void DoRTFT80(
    1380             :     float *x, /* i/o: real part of input and output data       */
    1381             :     float *y  /* i/o: imaginary part of input and output data  */
    1382             : );
    1383             : 
    1384             : void DoRTFT20(
    1385             :     float *x, /* i/o: real part of input and output data       */
    1386             :     float *y  /* i/o: imaginary part of input and output data  */
    1387             : );
    1388             : 
    1389             : void DoRTFT40(
    1390             :     float *x, /* i/o: real part of input and output data       */
    1391             :     float *y  /* i/o: imaginary part of input and output data  */
    1392             : );
    1393             : 
    1394             : void DoRTFTn(
    1395             :     float *x,       /* i/o: real part of input and output data       */
    1396             :     float *y,       /* i/o: imaginary part of input and output data  */
    1397             :     const int16_t n /* i  : size of the FFT n=(2^k) up to 1024       */
    1398             : );
    1399             : 
    1400             : void BASOP_cfft(
    1401             :     Word32 *re,   /* i/o: real part                                 */
    1402             :     Word32 *im,   /* i/o: imag part                                 */
    1403             :     Word16 s,     /* i  : stride real and imag part                 */
    1404             :     Word16 *scale /* i  : scalefactor                               */
    1405             : );
    1406             : 
    1407             : void fft(
    1408             :     float *re,            /* i/o: real part                         */
    1409             :     float *im,            /* i/o: imag part                         */
    1410             :     const int16_t length, /* i  : length of fft                     */
    1411             :     const int16_t s       /* i  : sign                              */
    1412             : );
    1413             : 
    1414             : void rfft(
    1415             :     float *x,             /* i/o: values                            */
    1416             :     const float *w,       /* i  : window                            */
    1417             :     const int16_t length, /* i  : length of fft                     */
    1418             :     const int16_t isign   /* i  : sign                              */
    1419             : );
    1420             : 
    1421             : void sinq(
    1422             :     const float tmp, /* i  : sinus factor cos(tmp*i+phi)  */
    1423             :     const float phi, /* i  : sinus phase cos(tmp*i+phi)   */
    1424             :     const int16_t N, /* i  : size of output               */
    1425             :     float x[]        /* o  : output vector                */
    1426             : );
    1427             : 
    1428             : void edct2(
    1429             :     const int16_t n,
    1430             :     const int16_t isgn,
    1431             :     float *in,
    1432             :     float *a,
    1433             :     const int16_t *ip,
    1434             :     const float *w );
    1435             : 
    1436             : void stat_noise_uv_mod(
    1437             :     const int16_t coder_type,   /* i  : coder type                           */
    1438             :     float noisiness,            /* i  : noisiness parameter                  */
    1439             :     const float *const lsp_old, /* i  : old LSP vector at 4th sfr            */
    1440             :     const float *const lsp_new, /* i  : LSP vector at 4th sfr                */
    1441             :     const float *const lsp_mid, /* i  : LSP vector at 2nd sfr                */
    1442             :     float *Aq,                  /* o  : A(z) quantized for the 4 subframes   */
    1443             :     float *exc2,                /* o  : excitation buffer                    */
    1444             :     const int16_t bfi,          /* i  : bad frame indicator                  */
    1445             :     float *ge_sm,               /* i/o: smoothed excitation gain             */
    1446             :     int16_t *uv_count,          /* i/o: unvoiced counter                     */
    1447             :     int16_t *act_count,         /* i/o: activation counter                   */
    1448             :     float lspold_s[],           /* i/o: old LSP                              */
    1449             :     int16_t *noimix_seed,       /* i/o: mixture seed                         */
    1450             :     float *st_min_alpha,        /* i/o: minimum alpha                        */
    1451             :     float *exc_pe,              /* i/o: memory of the preemphasis filter     */
    1452             :     const int32_t bitrate,      /* i  : core bitrate                         */
    1453             :     const int16_t bwidth        /* i  : audio bandwidth                      */
    1454             : );
    1455             : 
    1456             : void pre_echo_att(
    1457             :     float *Last_frame_ener,        /* i/o: Energy of the last frame                */
    1458             :     float *exc,                    /* i/o: Excitation of the current frame         */
    1459             :     const int16_t attack_flag,     /* i  : attack flag (GSC or TC)                 */
    1460             :     const int16_t last_coder_type, /* i  : Last coder type                         */
    1461             :     const int16_t L_frame          /* i  : frame length                            */
    1462             : );
    1463             : 
    1464             : void limit_band_noise_level_calc(
    1465             :     const int16_t *wnorm,     /* i  : reordered norm of sub-vectors           */
    1466             :     int16_t *limit,           /* o  : highest band of bit allocation          */
    1467             :     const int32_t core_brate, /* i  : core bitrate                            */
    1468             :     float *noise_level        /* o  : noise level                             */
    1469             : );
    1470             : 
    1471             : /*! r: hqswb_clas */
    1472             : int16_t peak_avrg_ratio(
    1473             :     const int32_t total_brate, /* i  : total bitrate              */
    1474             :     const float *input_hi,     /* i  : input signal               */
    1475             :     const int16_t N,           /* i  : number of coefficients     */
    1476             :     int16_t *mode_count,       /* i/o: HQ_HARMONIC mode count     */
    1477             :     int16_t *mode_count1       /* i/o: HQ_NORMAL mode count       */
    1478             : );
    1479             : 
    1480             : /*! r: Number of coefficients in nf codebook */
    1481             : int16_t build_nf_codebook(
    1482             :     const int16_t flag_32K_env_ho, /* i  : Envelope attenuation hangover flag */
    1483             :     const float *coeff,            /* i  : Coded spectral coefficients        */
    1484             :     const int16_t *sfm_start,      /* i  : Subband start indices              */
    1485             :     const int16_t *sfmsize,        /* i  : Subband widths                     */
    1486             :     const int16_t *sfm_end,        /* i  : Subband end indices                */
    1487             :     const int16_t nb_sfm,          /* i  : Last coded band                    */
    1488             :     const int16_t *R,              /* i  : Per-band bit allocation            */
    1489             :     float *CodeBook,               /* o  : Noise-fill codebook                */
    1490             :     float *CodeBook_mod            /* o  : Densified noise-fill codebook      */
    1491             : );
    1492             : 
    1493             : void apply_noisefill_HQ(
    1494             :     const int16_t *R,              /* i  : bit allocation                   */
    1495             :     const int16_t length,          /* i  : input frame length               */
    1496             :     const int16_t flag_32K_env_ho, /* i  : envelope stability hangover flag */
    1497             :     const int32_t core_brate,      /* i  : core bitrate                     */
    1498             :     const int16_t last_sfm,        /* i  : last coded subband               */
    1499             :     const float *CodeBook,         /* i  : Noise-fill codebook              */
    1500             :     const float *CodeBook_mod,     /* i  : Densified noise-fill codebook    */
    1501             :     const int16_t cb_size,         /* i  : Codebook length                  */
    1502             :     const int16_t *sfm_start,      /* i  : Subband start coefficient        */
    1503             :     const int16_t *sfm_end,        /* i  : Subband end coefficient          */
    1504             :     const int16_t *sfmsize,        /* i  : Subband band width               */
    1505             :     float *coeff                   /* i/o: coded/noisefilled spectrum       */
    1506             : );
    1507             : 
    1508             : void harm_bwe_fine(
    1509             :     const int16_t *R,         /* i  : bit allocation                          */
    1510             :     const int16_t last_sfm,   /* i  : last coded subband                      */
    1511             :     const int16_t high_sfm,   /* i  : higher transition band to BWE           */
    1512             :     const int16_t num_sfm,    /* i  : total number of bands                   */
    1513             :     const int16_t *norm,      /* i  : quantization indices for norms          */
    1514             :     const int16_t *sfm_start, /* i  : Subband start coefficient               */
    1515             :     const int16_t *sfm_end,   /* i  : Subband end coefficient                 */
    1516             :     int16_t *prev_L_swb_norm, /* i/o: last normalize length                   */
    1517             :     float *coeff,             /* i/o: coded/noisefilled normalized spectrum   */
    1518             :     float *coeff_out,         /* o  : coded/noisefilled spectrum              */
    1519             :     float *coeff_fine         /* o  : BWE fine structure                      */
    1520             : );
    1521             : 
    1522             : void hvq_bwe_fine(
    1523             :     const int16_t last_sfm,   /* i  : last coded subband                      */
    1524             :     const int16_t num_sfm,    /* i  : total number of bands                   */
    1525             :     const int16_t *sfm_end,   /* i  : Subband end coefficient                 */
    1526             :     const int16_t *peak_idx,  /* i  : Peak index                              */
    1527             :     const int16_t Npeaks,     /* i  : Number of peaks                         */
    1528             :     int16_t *peak_pos,        /* i/o: Peak positions                          */
    1529             :     int16_t *prev_L_swb_norm, /* i/o: last normalize length                   */
    1530             :     float *coeff,             /* i/o: coded/noisefilled normalized spectrum   */
    1531             :     int16_t *bwe_peaks,       /* o  : Positions of peaks in BWE               */
    1532             :     float *coeff_fine         /* o  : HVQ BWE fine structure                  */
    1533             : );
    1534             : 
    1535             : void hq_fold_bwe(
    1536             :     const int16_t last_sfm, /* i  : last coded subband                      */
    1537             :     const int16_t *sfm_end, /* i  : Subband end coefficient                 */
    1538             :     const int16_t num_sfm,  /* i  : Number of subbands                      */
    1539             :     float *coeff            /* i/o: coded/noisefilled normalized spectrum   */
    1540             : );
    1541             : 
    1542             : void apply_nf_gain(
    1543             :     const int16_t nf_idx,     /* i  : noise fill gain index                   */
    1544             :     const int16_t last_sfm,   /* i  : last coded subband                      */
    1545             :     const int16_t *R,         /* i  : bit allocation                          */
    1546             :     const int16_t *sfm_start, /* i  : Subband start coefficient               */
    1547             :     const int16_t *sfm_end,   /* i  : Subband end coefficient                 */
    1548             :     float *coeff              /* i/o: coded/noisefilled normalized spectrum   */
    1549             : 
    1550             : );
    1551             : 
    1552             : void hq_generic_fine(
    1553             :     float *coeff,             /* i  : coded/noisefilled normalized spectrum   */
    1554             :     const int16_t last_sfm,   /* i  : Last coded band                         */
    1555             :     const int16_t *sfm_start, /* i  : Subband start coefficient               */
    1556             :     const int16_t *sfm_end,   /* i  : Subband end coefficient                 */
    1557             :     int16_t *bwe_seed,        /* i/o: random seed for generating BWE input    */
    1558             :     float *coeff_out1         /* o  : HQ GENERIC input                        */
    1559             : );
    1560             : 
    1561             : void harm_bwe(
    1562             :     const float *coeff_fine,    /* i  : fine structure for BWE                  */
    1563             :     const float *coeff,         /* i  : coded/noisefilled normalized spectrum   */
    1564             :     const int16_t num_sfm,      /* i  : Number of subbands                      */
    1565             :     const int16_t *sfm_start,   /* i  : Subband start coefficient               */
    1566             :     const int16_t *sfm_end,     /* i  : Subband end coefficient                 */
    1567             :     const int16_t last_sfm,     /* i  : last coded subband                      */
    1568             :     const int16_t high_sfm,     /* i  : higher transition band to BWE           */
    1569             :     const int16_t *R,           /* i  : bit allocation                          */
    1570             :     const int16_t prev_hq_mode, /* i  : previous hq mode                        */
    1571             :     int16_t *norm,              /* i/o: quantization indices for norms          */
    1572             :     float *noise_level,         /* i/o: noise levels for harmonic modes         */
    1573             :     float *prev_noise_level,    /* i/o: noise factor in previous frame          */
    1574             :     int16_t *bwe_seed,          /* i/o: random seed for generating BWE input    */
    1575             :     float *coeff_out,           /* o  : coded/noisefilled spectrum              */
    1576             :     const int16_t element_mode  /* i  : element mode                            */
    1577             : );
    1578             : 
    1579             : void hvq_bwe(
    1580             :     const float *coeff,         /* i  : coded/noisefilled spectrum              */
    1581             :     const float *coeff_fine,    /* i  : BWE fine structure                      */
    1582             :     const int16_t *sfm_start,   /* i  : Subband start coefficient               */
    1583             :     const int16_t *sfm_end,     /* i  : Subband end coefficient                 */
    1584             :     const int16_t *sfm_len,     /* i  : Subband length                          */
    1585             :     const int16_t last_sfm,     /* i  : last coded subband                      */
    1586             :     const int16_t prev_hq_mode, /* i  : previous hq mode                        */
    1587             :     const int16_t *bwe_peaks,   /* i  : HVQ bwe peaks                           */
    1588             :     const int16_t bin_th,       /* i  : HVQ transition bin                      */
    1589             :     const int16_t num_sfm,      /* i  : Number of bands                         */
    1590             :     const int32_t core_brate,   /* i  : Core bitrate                            */
    1591             :     const int16_t *R,           /* i  : Bit allocation                          */
    1592             :     int16_t *norm,              /* i/o: quantization indices for norms          */
    1593             :     float *noise_level,         /* i/o: noise levels for harmonic modes         */
    1594             :     float *prev_noise_level,    /* i/o: noise factor in previous frame          */
    1595             :     int16_t *bwe_seed,          /* i/o: random seed for generating BWE input    */
    1596             :     float *coeff_out            /* o  : coded/noisefilled spectrum              */
    1597             : );
    1598             : 
    1599             : void hvq_concat_bands(
    1600             :     const int16_t pvq_bands,  /* i  : Number of bands in concatenated PVQ target  */
    1601             :     const int16_t *sel_bnds,  /* i  : Array of selected high bands                */
    1602             :     const int16_t n_sel_bnds, /* i  : Number of selected high bands               */
    1603             :     int16_t *hvq_band_start,  /* o  : Band start indices                          */
    1604             :     int16_t *hvq_band_width,  /* o  : Band widths                                 */
    1605             :     int16_t *hvq_band_end     /* o  : Band end indices                            */
    1606             : );
    1607             : 
    1608             : void hq_generic_bwe(
    1609             :     const int16_t HQ_mode,             /* i  : HQ mode                                     */
    1610             :     float *coeff_out1,                 /* i/o: BWE input & temporary buffer                */
    1611             :     const float *hq_generic_fenv,      /* i  : SWB frequency envelopes                     */
    1612             :     float *coeff_out,                  /* o  : SWB signal in MDCT domain                   */
    1613             :     const int16_t hq_generic_offset,   /* i  : frequency offset for representing hq generic*/
    1614             :     int16_t *prev_L_swb_norm,          /* i/o: last normalize length                       */
    1615             :     const int16_t hq_generic_exc_clas, /* i  : hq generic hf excitation class              */
    1616             :     const int16_t *sfm_end,            /* i  : End of bands                                */
    1617             :     const int16_t num_sfm,             /* i  : Number of bands                             */
    1618             :     const int16_t num_env_bands,       /* i  : Number of coded envelope bands              */
    1619             :     const int16_t *R                   /* i  : Bit allocation                              */
    1620             : );
    1621             : 
    1622             : void logqnorm_2(
    1623             :     const float *env_fl,      /* o  : index                   */
    1624             :     const int16_t L,          /* i  : codebook length         */
    1625             :     const int16_t n_env_band, /* i  : sub-vector size         */
    1626             :     const int16_t nb_sfm,     /* i  : sub-vector size         */
    1627             :     int16_t *ynrm,            /* o  : norm indices            */
    1628             :     int16_t *normqlg2,        /* o  : quantized norm values   */
    1629             :     const float *thren        /* i  : quantization thresholds */
    1630             : );
    1631             : 
    1632             : void map_hq_generic_fenv_norm(
    1633             :     const int16_t hqswb_clas,       /* i  : signal classification flag      */
    1634             :     const float *hq_generic_fenv,   /* i  : HQ GENERIC envelope             */
    1635             :     int16_t *ynrm,                  /* o  : high band norm indices          */
    1636             :     int16_t *normqlg2,              /* o  : high band norm values           */
    1637             :     const int16_t num_env_bands,    /* i  : Number coded envelope bands     */
    1638             :     const int16_t nb_sfm,           /* i  : Number of envelope bands        */
    1639             :     const int16_t hq_generic_offset /* i  : Freq offset for HQ GENERIC      */
    1640             : );
    1641             : 
    1642             : /*! r: Number of bits consumed for the delta coding */
    1643             : int16_t calc_nor_delta_hf(
    1644             :     BSTR_ENC_HANDLE hBstr,       /* i/o: encoder bitstream handle       */
    1645             :     const float *t_audio,        /* i  : transform-domain coefficients  */
    1646             :     int16_t *ynrm,               /* i/o: norm indices                   */
    1647             :     int16_t *Rsubband,           /* i/o: sub-band bit allocation        */
    1648             :     const int16_t num_env_bands, /* i  : Number coded envelope bands    */
    1649             :     const int16_t nb_sfm,        /* i  : Number of envelope bands       */
    1650             :     const int16_t *sfmsize,      /* i  : band length                    */
    1651             :     const int16_t *sfm_start,    /* i  : Start index of bands           */
    1652             :     const int16_t core_sfm       /* i  : index of the end band for core */
    1653             : );
    1654             : 
    1655             : /*! r: Number of bits consumed for the delta coding */
    1656             : int16_t get_nor_delta_hf(
    1657             :     Decoder_State *st,           /* i/o: Decoder state                  */
    1658             :     int16_t *ynrm,               /* i/o: norm indices                   */
    1659             :     int16_t *Rsubband,           /* i/o: sub-band bit allocation        */
    1660             :     const int16_t num_env_bands, /* i  : Number coded envelope bands    */
    1661             :     const int16_t nb_sfm,        /* i  : Number of envelope bands       */
    1662             :     const int16_t core_sfm );    /* i  : index of the end band for core */
    1663             : 
    1664             : void hq_wb_nf_bwe(
    1665             :     const float *coeff,              /* i  : coded/noisefilled normal. spectrum      */
    1666             :     const int16_t is_transient,      /* i  : is transient flag                       */
    1667             :     const int16_t prev_bfi,          /* i  : previous bad frame indicator            */
    1668             :     const float *normq_v,            /* i  : norms                                   */
    1669             :     const int16_t num_sfm,           /* i  : Number of subbands                      */
    1670             :     const int16_t *sfm_start,        /* i  : Subband start coefficient               */
    1671             :     const int16_t *sfm_end,          /* i  : Subband end coefficient                 */
    1672             :     const int16_t *sfmsize,          /* i  : Subband band width                      */
    1673             :     const int16_t last_sfm,          /* i  : last coded subband                      */
    1674             :     const int16_t *R,                /* i  : bit allocation                          */
    1675             :     const int16_t prev_is_transient, /* i  : previous transient flag                 */
    1676             :     float *prev_normq,               /* i/o: previous norms                          */
    1677             :     float *prev_env,                 /* i/o: previous noise envelopes                */
    1678             :     int16_t *bwe_seed,               /* i/o: random seed for generating BWE input    */
    1679             :     float *prev_coeff_out,           /* i/o: decoded spectrum in previous frame      */
    1680             :     int16_t *prev_R,                 /* i/o: previous frame bit allocation info.     */
    1681             :     float *coeff_out                 /* o  : coded/noisefilled spectrum              */
    1682             : );
    1683             : 
    1684             : /*! r: Number of bits */
    1685             : int16_t encode_envelope_indices(
    1686             :     BSTR_ENC_HANDLE hBstr,     /* i/o: encoder bitstream handle                */
    1687             :     const int16_t num_sfm,     /* i  : Number of subbands                      */
    1688             :     const int16_t numnrmibits, /* i  : Bitrate of fall-back coding mode        */
    1689             :     int16_t *difidx,           /* i/o: Diff indices/encoded diff indices       */
    1690             :     int16_t *LCmode,           /* o  : Coding mode                             */
    1691             :     const int16_t flag_pack,   /* i  : indicator of packing or estimating bits */
    1692             :     const int16_t flag_HQ2,    /* i  : indicator of HQ2 core                   */
    1693             :     const int16_t is_transient /* i  : transient flag                          */
    1694             : );
    1695             : 
    1696             : void diff_envelope_coding(
    1697             :     const int16_t is_transient,  /* i  : transient indicator                     */
    1698             :     const int16_t num_env_bands, /* i  : number of envelope bands to code        */
    1699             :     const int16_t start_norm,    /* i  : start of envelope coding                */
    1700             :     int16_t *ynrm,               /* i/o: quantization indices for norms          */
    1701             :     int16_t *normqlg2,           /* i/o: quantized norms                         */
    1702             :     int16_t *difidx              /* o  : differential code                       */
    1703             : );
    1704             : 
    1705             : /*! r: Number of bits */
    1706             : int16_t decode_envelope_indices(
    1707             :     Decoder_State *st,         /* i/o: decoder state structure                 */
    1708             :     const int16_t start_norm,  /* i  : First SDE encoded norm                  */
    1709             :     const int16_t num_sfm,     /* i  : Number of norms                         */
    1710             :     const int16_t numnrmibits, /* i  : Bitrate of fall-back coding mode        */
    1711             :     int16_t *ynrm,             /* o  : Decoded norm indices                    */
    1712             :     const int16_t flag_HQ2,    /* i  : indicator of HQ2 core                   */
    1713             :     const int16_t is_transient /* i  : transient flag                          */
    1714             : );
    1715             : 
    1716             : /*! r: Number of bits */
    1717             : void dequantize_norms(
    1718             :     Decoder_State *st,          /* i/o: decoder state structure                 */
    1719             :     const int16_t start_norm,   /* i  : First SDE encoded norm                  */
    1720             :     const int16_t num_sfm,      /* i  : Number of norms                         */
    1721             :     const int16_t is_transient, /* i  : Transient flag                          */
    1722             :     int16_t *ynrm,              /* o  : Decoded norm indices                    */
    1723             :     int16_t *normqlg2           /* o  : Log2 of decoded norms                   */
    1724             : );
    1725             : 
    1726             : void hq_configure(
    1727             :     const int16_t length,       /* i  : Frame length                              */
    1728             :     const int16_t hqswb_clas,   /* i  : HQ SWB class                              */
    1729             :     const int32_t core_brate,   /* i  : core bitrate                              */
    1730             :     int16_t *num_sfm,           /* o  : Total number of subbands                  */
    1731             :     int16_t *nb_sfm,            /* o  : Total number of coded bands               */
    1732             :     int16_t *start_norm,        /* o  : First norm to be SDE encoded              */
    1733             :     int16_t *num_sde_norm,      /* o  : Number of norms for SDE encoding          */
    1734             :     int16_t *numnrmibits,       /* o  : Number of bits in fall-back norm encoding */
    1735             :     int16_t *hq_generic_offset, /* o  : Freq offset for HQ GENERIC                */
    1736             :     int16_t *sfmsize,           /* o  : Subband bandwidths                        */
    1737             :     int16_t *sfm_start,         /* o  : Subband start coefficients                */
    1738             :     int16_t *sfm_end            /* o  : Subband end coefficients                  */
    1739             : );
    1740             : 
    1741             : /*! r: Consumed bits */
    1742             : int16_t hvq_enc(
    1743             :     BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle                */
    1744             :     const int16_t bwidth,  /* i  : audio bandwidth                         */
    1745             : #ifdef DEBUGGING
    1746             :     const int16_t idchan, /* i  : channel ID                              */
    1747             : #endif
    1748             :     const int32_t core_brate, /* i  : core bitrate                            */
    1749             :     const int16_t hvq_bits,   /* i  : HVQ bit budget                          */
    1750             :     const int16_t Npeaks,     /* i  : Number of peaks                         */
    1751             :     const int16_t *ynrm,      /* i  : Envelope coefficients                   */
    1752             :     int16_t *R,               /* i/o: Bit allocation/updated bit allocation   */
    1753             :     int16_t *peaks,           /* i/o: Peak pos. / Encoded peak pos.           */
    1754             :     float *nf_gains,          /* i/o: Noise fill gains / Quant. nf gains      */
    1755             :     float *noise_level,       /* o  : Quantized noise level                   */
    1756             :     const float *pe_gains,    /* i  : Peak gains                              */
    1757             :     const float *coefs,       /* i  : spectrum coefficients                   */
    1758             :     float *coefs_out          /* o  : encoded spectrum coefficients           */
    1759             : );
    1760             : 
    1761             : /*! r: Consumed bits */
    1762             : int16_t hq_classifier_enc(
    1763             :     Encoder_State *st,          /* i/o: encoder state structure                 */
    1764             :     const int16_t length,       /* i  : Frame length                            */
    1765             :     const float *coefs,         /* i  : Spectral coefficients                   */
    1766             :     const int16_t is_transient, /* i  : Transient flag                          */
    1767             :     int16_t *Npeaks,            /* o  : Number of identified peaks              */
    1768             :     int16_t *peaks,             /* o  : Peak indices                            */
    1769             :     float *pe_gains,            /* o  : Peak gains                              */
    1770             :     float *nf_gains,            /* o  : Noise-fill gains                        */
    1771             :     int16_t *hqswb_clas         /* o  : HQ class                                */
    1772             : );
    1773             : 
    1774             : /*! r: Consumed bits */
    1775             : int16_t hq_classifier_dec(
    1776             :     Decoder_State *st,        /* i/o: decoder state structure                 */
    1777             :     const int32_t core_brate, /* i  : Core bitrate                            */
    1778             :     const int16_t length,     /* i  : Frame length                            */
    1779             :     int16_t *is_transient,    /* o  : Transient flag                          */
    1780             :     int16_t *hqswb_clas       /* o  : HQ class                                */
    1781             : );
    1782             : 
    1783             : void hq_bit_allocation(
    1784             :     const int32_t core_brate,   /* i  : Core bitrate                                   */
    1785             :     const int16_t length,       /* i  : Frame length                                   */
    1786             :     const int16_t hqswb_clas,   /* i  : HQ class                                       */
    1787             :     int16_t *num_bits,          /* i/o: Remaining bit budget                           */
    1788             :     const int16_t *normqlg2,    /* i  : Quantized norms                                */
    1789             :     const int16_t nb_sfm,       /* i  : Number sub bands to be encoded                 */
    1790             :     const int16_t *sfmsize,     /* i  : Sub band bandwidths                            */
    1791             :     float *noise_level,         /* o  : HVQ noise level                                */
    1792             :     int16_t *R,                 /* o  : Bit allocation per sub band                    */
    1793             :     int16_t *Rsubband,          /* o  : Fractional bit allocation (Q3)                 */
    1794             :     int16_t *sum,               /* o  : Sum of allocated shape bits                    */
    1795             :     int16_t *core_sfm,          /* o  : Last coded band in core                        */
    1796             :     const int16_t num_env_bands /* i  : Number sub bands to be encoded for HQ_SWB_BWE  */
    1797             : );
    1798             : 
    1799             : void enforce_zero_for_min_envelope(
    1800             :     const int16_t hqswb_clas, /* i  : HQ coding class                         */
    1801             :     const int16_t *ynrm,      /* i  : Envelope indices                        */
    1802             :     float *coefsq,            /* i/o: Quantized spectrum/zeroed spectrum      */
    1803             :     int16_t nb_sfm,           /* i  : Number of coded sub bands               */
    1804             :     const int16_t *sfm_start, /* i  : Sub band start indices                  */
    1805             :     const int16_t *sfm_end    /* i  : Sub band end indices                    */
    1806             : );
    1807             : 
    1808             : /*! r: Number of assigned gain bits */
    1809             : int16_t assign_gain_bits(
    1810             :     const int16_t core,        /* i  : HQ core                                 */
    1811             :     const int16_t BANDS,       /* i  : Number of bands                         */
    1812             :     const int16_t *band_width, /* i  : Sub band bandwidth                      */
    1813             :     int16_t *Rk,               /* i/o: Bit allocation/Adjusted bit alloc. (Q3) */
    1814             :     int16_t *gain_bits_array,  /* o  : Assigned gain bits                      */
    1815             :     int16_t *Rcalc             /* o  : Bit budget for shape quantizer (Q3)     */
    1816             : );
    1817             : 
    1818             : void apply_envelope(
    1819             :     const float *coeff,       /* i/o: Coded/noisefilled normalized spectrum   */
    1820             :     const int16_t *norm,      /* i  : Envelope                                */
    1821             :     const float *norm_adj,    /* i  : Envelope adjustment                     */
    1822             :     const int16_t num_sfm,    /* i  : Total number of bands                   */
    1823             :     const int16_t last_sfm,   /* i  : Last coded band                         */
    1824             :     const int16_t HQ_mode,    /* i  : HQ mode                                 */
    1825             :     const int16_t length,     /* i  : Frame length                            */
    1826             :     const int16_t *sfm_start, /* i  : Sub band start indices                  */
    1827             :     const int16_t *sfm_end,   /* i  : Sub band end indices                    */
    1828             :     float *normq_v,           /* o  : Envelope with adjustment                */
    1829             :     float *coeff_out,         /* o  : coded/noisefilled spectrum              */
    1830             :     float *coeff_out1         /* o  : noisefilled spectrum for HQ SWB BWE     */
    1831             : );
    1832             : 
    1833             : void apply_envelope_enc(
    1834             :     float *coeff,             /* i/o: Normalized/scaled normalized spectrum   */
    1835             :     const int16_t *norm,      /* i  : Envelope                                */
    1836             :     const int16_t num_sfm,    /* i  : Total number of 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: Leading_sign_index, index, size, k_val */
    1842             : PvqEntry mpvq_encode_vec(
    1843             :     const int16_t *vec_in, /* i  : Signed pulse train                       */
    1844             :     const int16_t dim_in,  /* i  : Dimension                                */
    1845             :     int16_t k_val_local    /* i/o: Num unit pulses                          */
    1846             : );
    1847             : 
    1848             : /*! r: Size, dim, k_val */
    1849             : PvqEntry get_size_mpvq_calc_offset(
    1850             :     const int16_t dim_in,   /* i  : Dimension                                */
    1851             :     const int16_t k_val_in, /* i  : Num unit pulses                          */
    1852             :     uint32_t *h_mem         /* o  : Offsets                                  */
    1853             : );
    1854             : 
    1855             : void mpvq_decode_vec(
    1856             :     const PvqEntry *entry, /* i  :  Sign_ind, index, dim, k_val             */
    1857             :     uint32_t *h_mem,       /* i  :  A/U offsets                             */
    1858             :     int16_t *vec_out       /* o  :  Pulse train                             */
    1859             : );
    1860             : 
    1861             : /*! r: Multiplication result */
    1862             : uint32_t UMult_32_32(
    1863             :     const uint32_t UL_var1, /* i  : factor 1 */
    1864             :     const uint32_t UL_var2  /* i  : factor 2 */
    1865             : );
    1866             : 
    1867             : /*! r: inverse */
    1868             : uint32_t UL_inverse(
    1869             :     const uint32_t UL_val, /* i  : input value Q_exp      */
    1870             :     int16_t *exp           /* i/o: input exp / result exp */
    1871             : );
    1872             : 
    1873             : /*! r: ratio */
    1874             : Word16 ratio(
    1875             :     const Word32 numer, /* i  : numerator              */
    1876             :     const Word32 denom, /* i  : denominator            */
    1877             :     Word16 *expo        /* i/o: input exp / result exp */
    1878             : );
    1879             : 
    1880             : /*! r: Angle between 0 and EVS_PI/2 radian (Q14) */
    1881             : Word16 atan2_fx(
    1882             :     const Word32 y, /* i  : near side (Argument must be positive) (Q15) */
    1883             :     const Word32 x  /* i  : opposite side (Q15)                         */
    1884             : );
    1885             : 
    1886             : void pvq_encode_frame(
    1887             :     BSTR_ENC_HANDLE hBstr,    /* i/o: encoder bitstream handle                    */
    1888             :     const float *coefs_norm,  /* i  : normalized coefficients to encode           */
    1889             :     float *coefs_quant,       /* o  : quantized coefficients                      */
    1890             :     float *gopt,              /* o  : optimal shape gains                         */
    1891             :     int16_t *npulses,         /* o  : number of pulses per band                   */
    1892             :     int16_t *pulse_vector,    /* o  : non-normalized pulse shapes                 */
    1893             :     const int16_t *sfm_start, /* i  : indices of first coefficients in the bands  */
    1894             :     const int16_t *sfm_end,   /* i  : indices of last coefficients in the bands   */
    1895             :     const int16_t *sfmsize,   /* i  : band sizes                                  */
    1896             :     const int16_t nb_sfm,     /* i  : total number of bands                       */
    1897             :     const int16_t *R,         /* i  : bitallocation per band (Q3)                 */
    1898             :     const int16_t pvq_bits,   /* i  : number of bits avaiable                     */
    1899             :     const int16_t core        /* i  : core                                        */
    1900             : );
    1901             : 
    1902             : void pvq_decode_frame(
    1903             :     Decoder_State *st,        /* i/o: Decoder state                        */
    1904             :     float *coefs_quant,       /* o  : quantized coefficients               */
    1905             :     int16_t *npulses,         /* o  : number of pulses per band            */
    1906             :     int16_t *pulse_vector,    /* o  : non-normalized pulse shapes          */
    1907             :     const int16_t *sfm_start, /* i  : indices of first coeffs in the bands */
    1908             :     const int16_t *sfm_end,   /* i  : indices of last coeffs in the bands  */
    1909             :     const int16_t *sfmsize,   /* i  : band sizes                           */
    1910             :     const int16_t nb_sfm,     /* i  : total number of bands                */
    1911             :     const int16_t *R,         /* i  : bitallocation per band (Q3)          */
    1912             :     const int16_t pvq_bits,   /* i  : number of bits avaiable              */
    1913             :     const int16_t core        /* i  : core                                 */
    1914             : );
    1915             : 
    1916             : void srt_vec_ind(
    1917             :     const int16_t *linear, /* linear input                                     */
    1918             :     int16_t *srt,          /* sorted output                                    */
    1919             :     int16_t *I,            /* index for sorted output                          */
    1920             :     const int16_t length );
    1921             : 
    1922             : void srt_vec_ind_f(
    1923             :     const float *linear, /* linear input                                     */
    1924             :     float *srt,          /* sorted output                                    */
    1925             :     int16_t *I,          /* index for sorted output                          */
    1926             :     const int16_t length /* length of vector                                 */
    1927             : );
    1928             : 
    1929             : /*! r: floor(sqrt(input)) */
    1930             : uint32_t floor_sqrt_exact(
    1931             :     const uint32_t input /* i  : unsigned input  [0.. UINT_MAX/4]     */
    1932             : );
    1933             : 
    1934             : void fine_gain_quant(
    1935             :     BSTR_ENC_HANDLE hBstr,    /* i/o: encoder bitstream handle                    */
    1936             :     const int16_t *ord,       /* i  : Indices for energy order                    */
    1937             :     const int16_t num_sfm,    /* i  : Number of bands                             */
    1938             :     const int16_t *gain_bits, /* i  : Gain adjustment bits per sub band           */
    1939             :     float *fg_pred,           /* i/o: Predicted gains / Corrected gains           */
    1940             :     const float *gopt         /* i  : Optimal gains                               */
    1941             : );
    1942             : 
    1943             : void apply_gain(
    1944             :     const int16_t *ord,        /* i  : Indices for energy order                    */
    1945             :     const int16_t *band_start, /* i  : Sub band start indices                      */
    1946             :     const int16_t *band_end,   /* i  : Sub band end indices                        */
    1947             :     const int16_t num_sfm,     /* i  : Number of bands                             */
    1948             :     const float *gains,        /* i  : Band gain vector                            */
    1949             :     float *xq                  /* i/o: float synthesis / gain adjusted synth       */
    1950             : );
    1951             : 
    1952             : void fine_gain_pred(
    1953             :     const int16_t *sfm_start, /* i  : Sub band start indices                      */
    1954             :     const int16_t *sfm_end,   /* i  : Sub band end indices                        */
    1955             :     const int16_t *sfm_size,  /* i  : Sub band bandwidths                         */
    1956             :     const int16_t *i_sort,    /* i  : Energy sorting indices                      */
    1957             :     const int16_t *K,         /* i  : Number of pulses per band                   */
    1958             :     const int16_t *maxpulse,  /* i  : Maximum pulse per band                      */
    1959             :     const int16_t *R,         /* i  : Bits per sub band (Q3)                      */
    1960             :     const int16_t num_sfm,    /* i  : Number of sub bands                         */
    1961             :     float *xq,                /* i/o: Quantized vector /quantized vector with finegain adj */
    1962             :     int16_t *y,               /* i/o: Quantized vector                            */
    1963             :     float *fg_pred,           /* o  : Predicted fine gains                        */
    1964             :     const int16_t core        /* i  : Core                                        */
    1965             : );
    1966             : 
    1967             : void fine_gain_dec(
    1968             :     Decoder_State *st,        /* i/o: Decoder state struct                        */
    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             : );
    1974             : 
    1975             : void get_max_pulses(
    1976             :     const int16_t *band_start, /* i  : Sub band start indices                      */
    1977             :     const int16_t *band_end,   /* i  : Sub band end indices                        */
    1978             :     const int16_t *k_sort,     /* i  : Indices for sorting by energy               */
    1979             :     const int16_t *npulses,    /* i  : Pulses per sub band                         */
    1980             :     const int16_t BANDS,       /* i  : Number of bands                             */
    1981             :     int16_t *inp_vector,       /* i/o: Encoded shape vectors                       */
    1982             :     int16_t *maxpulse          /* o  : Maximum pulse height per band               */
    1983             : );
    1984             : 
    1985             : Word32 ar_div(
    1986             :     Word32 num,
    1987             :     Word32 denum );
    1988             : 
    1989             : void ar_encoder_start(
    1990             :     PARCODEC arInst,
    1991             :     TCQ_PBITSTREAM bsInst,
    1992             :     int16_t max_bits );
    1993             : 
    1994             : void ar_decoder_start(
    1995             :     PARCODEC arInst,
    1996             :     TCQ_PBITSTREAM bsInst );
    1997             : 
    1998             : void ar_encoder_done(
    1999             :     PARCODEC arInst );
    2000             : 
    2001             : void ar_decoder_done(
    2002             :     PARCODEC arInst );
    2003             : 
    2004             : float GetISCScale(
    2005             :     float *quants,
    2006             :     int16_t size,
    2007             :     Word32 bits_fx,
    2008             :     float *magn,
    2009             :     float *qscale,
    2010             :     Word32 *surplus_fx,
    2011             :     float *pulses,
    2012             :     int32_t *savedstates,
    2013             :     int16_t noTCQ,
    2014             :     int32_t *nzpout,
    2015             :     int16_t *bcount,
    2016             :     float *abuffer,
    2017             :     float *mbuffer,
    2018             :     float *sbuffer );
    2019             : 
    2020             : Word32 Mult_32_16(
    2021             :     Word32 a,
    2022             :     Word16 b );
    2023             : 
    2024             : Word32 Mult_32_32(
    2025             :     Word32 a,
    2026             :     Word32 b );
    2027             : 
    2028             : void decode_position_ari_fx(
    2029             :     PARCODEC pardec,
    2030             :     Word16 size,
    2031             :     Word16 npulses,
    2032             :     Word16 *nz,
    2033             :     Word32 *position );
    2034             : 
    2035             : void decode_magnitude_usq_fx(
    2036             :     ARCODEC *pardec,
    2037             :     Word16 size,
    2038             :     Word16 npulses,
    2039             :     Word16 nzpos,
    2040             :     Word32 *positions,
    2041             :     Word32 *out );
    2042             : 
    2043             : void decode_mangitude_tcq_fx(
    2044             :     ARCODEC *pardec,
    2045             :     Word16 size,
    2046             :     Word16 npulses,
    2047             :     Word16 nzpos,
    2048             :     Word32 *positions,
    2049             :     Word32 *out,
    2050             :     Word32 *surplus_fx );
    2051             : 
    2052             : void decode_signs_fx(
    2053             :     ARCODEC *pardec,
    2054             :     Word16 size,
    2055             :     Word32 *out );
    2056             : 
    2057             : void srt_vec_ind_fx(
    2058             :     const Word32 *linear,
    2059             :     Word32 *srt,
    2060             :     Word16 *I,
    2061             :     Word16 length );
    2062             : 
    2063             : Word16 GetScale_fx(
    2064             :     Word16 blen,
    2065             :     Word32 bits_fx /*Q16*/,
    2066             :     Word32 *surplus_fx /*Q16*/
    2067             : );
    2068             : 
    2069             : void bit_allocation_second_fx(
    2070             :     Word32 *Rk,
    2071             :     Word32 *Rk_sort,
    2072             :     Word16 BANDS,
    2073             :     const Word16 *band_width,
    2074             :     Word16 *k_sort,
    2075             :     Word16 *k_num,
    2076             :     const Word16 *p2a_flags,
    2077             :     const Word16 p2a_bands,
    2078             :     const Word16 *last_bitalloc,
    2079             :     const Word16 input_frame );
    2080             : 
    2081             : Word32 encode_position_ari_fx(
    2082             :     PARCODEC parenc,
    2083             :     float *quants,
    2084             :     Word16 size,
    2085             :     Word32 *est_bits_frame_fx );
    2086             : 
    2087             : Word32 encode_magnitude_tcq_fx(
    2088             :     ARCODEC *parenc,
    2089             :     float *magn_fx,
    2090             :     Word16 size,
    2091             :     Word16 npulses,
    2092             :     Word16 nzpos,
    2093             :     Word32 *savedstates,
    2094             :     Word32 *est_frame_bits_fx );
    2095             : 
    2096             : Word32 encode_signs_fx(
    2097             :     ARCODEC *parenc,
    2098             :     float *magn,
    2099             :     Word16 size,
    2100             :     Word16 npos,
    2101             :     Word32 *est_frame_bits_fx );
    2102             : 
    2103             : Word32 encode_magnitude_usq_fx(
    2104             :     ARCODEC *parenc,
    2105             :     float *magn_fx,
    2106             :     Word16 size,
    2107             :     Word16 npulses,
    2108             :     Word16 nzpos,
    2109             :     Word32 *est_frame_bits_fx );
    2110             : 
    2111             : ivas_error tcq_core_LR_enc(
    2112             :     BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle                    */
    2113             : #ifdef DEBUGGING
    2114             :     const int16_t idchan,
    2115             : #endif
    2116             :     int32_t inp_vector[],
    2117             :     const float coefs_norm[],
    2118             :     float coefs_quant[],
    2119             :     const int16_t bit_budget, /* number of bits */
    2120             :     const int16_t nb_sfm,
    2121             :     const int16_t *sfm_start,
    2122             :     const int16_t *sfm_end,
    2123             :     const int16_t *sfmsize,
    2124             :     Word32 *Rk_fx,
    2125             :     int16_t *npulses,
    2126             :     int16_t *k_sort,
    2127             :     const int16_t *p2a_flags,
    2128             :     const int16_t p2a_bands,
    2129             :     const int16_t *last_bitalloc,
    2130             :     const int16_t input_frame,
    2131             :     const int16_t adjustFlag,
    2132             :     const int16_t is_transient );
    2133             : 
    2134             : void tcq_core_LR_dec(
    2135             :     Decoder_State *st,
    2136             :     int32_t *inp_vector,
    2137             :     const int16_t bit_budget,
    2138             :     const int16_t bands,
    2139             :     const int16_t *band_start,
    2140             :     const int16_t *band_width,
    2141             :     Word32 *Rk_fx,
    2142             :     int16_t npulses[],
    2143             :     int16_t *k_sort,
    2144             :     const int16_t *p2a_flags,
    2145             :     const int16_t p2a_bands,
    2146             :     const int16_t *last_bitalloc,
    2147             :     const int16_t input_frame,
    2148             :     const int16_t adjustFlag,
    2149             :     const int16_t *is_transient );
    2150             : 
    2151             : void InitLSBTCQ(
    2152             :     int16_t *bcount );
    2153             : 
    2154             : void TCQLSB(
    2155             :     int16_t bcount,
    2156             :     float *abuffer,
    2157             :     float *mbuffer,
    2158             :     float *sbuffer,
    2159             :     int16_t *dpath );
    2160             : 
    2161             : void RestoreTCQ(
    2162             :     float *magn,
    2163             :     int16_t size,
    2164             :     int16_t *bcount,
    2165             :     float *mbuffer );
    2166             : 
    2167             : void SaveTCQdata(
    2168             :     PARCODEC arInst,
    2169             :     int16_t *dpath,
    2170             :     int16_t bcount );
    2171             : 
    2172             : void LoadTCQdata(
    2173             :     PARCODEC arInst,
    2174             :     int16_t *dpath,
    2175             :     int16_t bcount );
    2176             : 
    2177             : void RestoreTCQdec(
    2178             :     int32_t *magn,
    2179             :     int16_t size,
    2180             :     int16_t *bcount,
    2181             :     float *mbuffer );
    2182             : 
    2183             : void TCQLSBdec(
    2184             :     int16_t *dpath,
    2185             :     float *mbuffer,
    2186             :     int16_t bcount );
    2187             : 
    2188             : void bit_allocation_second_fx(
    2189             :     Word32 *Rk,
    2190             :     Word32 *Rk_sort,
    2191             :     Word16 BANDS,
    2192             :     const Word16 *band_width,
    2193             :     Word16 *k_sort,
    2194             :     Word16 *k_num,
    2195             :     const Word16 *p2a_flags,
    2196             :     const Word16 p2a_bands,
    2197             :     const Word16 *last_bitalloc,
    2198             :     const Word16 input_frame );
    2199             : 
    2200             : void io_ini_enc(
    2201             :     const int32_t argc, /* i  : command line arguments number           */
    2202             :     char *argv[],       /* i  : command line arguments                  */
    2203             :     FILE **f_input,     /* o  : input signal file                       */
    2204             :     FILE **f_stream,    /* o  : output bitstream file                   */
    2205             :     FILE **f_rate,      /* o  : bitrate switching profile (0 if N/A)    */
    2206             :     FILE **f_bwidth,    /* o  : bandwidth switching profile (0 if N/A)  */
    2207             :     FILE **f_metadata,  /* o  : metadata files (NULL if N/A)            */
    2208             : #ifdef DEBUGGING
    2209             :     FILE **f_force, /* o  : force switching profile (0 if N/A)      */
    2210             : #endif
    2211             :     FILE **f_rf,         /* o  : channel aware configuration file        */
    2212             :     int16_t *quietMode,  /* o  : limit printouts                         */
    2213             :     int16_t *noDelayCmp, /* o  : turn off delay compensation             */
    2214             :     Encoder_Struct *st   /* o  : IVAS encoder structure                  */
    2215             : );
    2216             : 
    2217             : void read_next_rfparam(
    2218             :     int16_t *rf_fec_offset,    /* o  : RF offset                               */
    2219             :     int16_t *rf_fec_indicator, /* o  : RF FEC indicator                        */
    2220             :     FILE *f_rf                 /* i  : file pointer to read parameters         */
    2221             : );
    2222             : 
    2223             : void read_next_brate(
    2224             :     int32_t *total_brate,           /* i/o: total bitrate                           */
    2225             :     const int32_t last_total_brate, /* i  : last total bitrate                      */
    2226             :     FILE *f_rate,                   /* i  : bitrate switching profile (0 if N/A)    */
    2227             :     const int16_t element_mode,     /* i  : IVAS element mode                       */
    2228             :     int32_t input_Fs,               /* i  : input sampling frequency                */
    2229             :     int16_t *Opt_AMR_WB,            /* i  : flag indicating AMR-WB IO mode          */
    2230             :     int16_t *Opt_SC_VBR,            /* i/o: SC-VBR flag                             */
    2231             :     int16_t *codec_mode             /* i/o: Mode 1 or 2                             */
    2232             : );
    2233             : 
    2234             : void read_next_bwidth(
    2235             :     int16_t *max_bwidth,         /* i/o: maximum encoded bandwidth               */
    2236             :     FILE *f_bwidth,              /* i  : bandwidth switching profile (0 if N/A)  */
    2237             :     int32_t *bwidth_profile_cnt, /* i/o: counter of frames for bandwidth switching profile file */
    2238             :     int32_t input_Fs             /* i  : input sampling rate                     */
    2239             : );
    2240             : 
    2241             : #ifdef DEBUGGING
    2242             : void read_next_force(
    2243             :     int16_t *force,            /* i/o: force value (0/1, 0 = speech, 1 = music)*/
    2244             :     FILE *f_force,             /* i  : force switching profile (0 if N/A)      */
    2245             :     int32_t *force_profile_cnt /* i/o: counter of frames for force switching profile file */
    2246             : );
    2247             : #endif
    2248             : 
    2249             : ivas_error init_encoder(
    2250             :     Encoder_State *st,               /* i/o: state structure                        */
    2251             :     Encoder_Struct *st_ivas,         /* i/o: encoder state structure                */
    2252             :     const int16_t idchan,            /* i  : channel ID                             */
    2253             :     const int16_t var_SID_rate_flag, /* i  : flag for variable SID update rate      */
    2254             :     const int16_t interval_SID,      /* i  : interval for SID update                */
    2255             :     const int16_t vad_only_flag,     /* i  : flag to indicate front-VAD structure   */
    2256             :     const ISM_MODE ism_mode,         /* i  : ISM mode                               */
    2257             :     const int32_t element_brate      /* element bitrate                             */
    2258             : );
    2259             : 
    2260             : void LPDmem_enc_init(
    2261             :     LPD_state_HANDLE hLPDmem /* i/o: LP memories                             */
    2262             : );
    2263             : 
    2264             : void destroy_cldfb_encoder(
    2265             :     Encoder_State *st /* i/o: state structure                         */
    2266             : );
    2267             : ivas_error evs_enc(
    2268             :     Encoder_State *st,      /* i/o: state structure                         */
    2269             :     const int16_t *data,    /* i  : input signal                            */
    2270             :     float *mem_hp20_in,     /* i/o: hp20 filter memory                      */
    2271             :     const int16_t n_samples /* i  : number of input samples                 */
    2272             : );
    2273             : void amr_wb_enc(
    2274             :     Encoder_State *st,      /* i/o: encoder state structure                 */
    2275             :     const int16_t *data,    /* i  : input signal                            */
    2276             :     float *mem_hp20_in,     /* i/o: hp20 filter memory                      */
    2277             :     const int16_t n_samples /* i  : number of input samples                 */
    2278             : );
    2279             : 
    2280             : void sc_vbr_enc_init(
    2281             :     SC_VBR_ENC_HANDLE hSC_VBR /* i/o: SC-VBR encoder handle                   */
    2282             : );
    2283             : 
    2284             : void amr_wb_enc_init(
    2285             :     AMRWB_IO_ENC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO encoder handle                */
    2286             : );
    2287             : 
    2288             : void pre_proc(
    2289             :     Encoder_State *st,            /* i/o: encoder state structure                 */
    2290             :     const int16_t input_frame,    /* i  : frame length                            */
    2291             :     float old_inp_12k8[],         /* i/o: buffer of old input signal              */
    2292             :     float old_inp_16k[],          /* i/o: buffer of old input signal @ 16kHz      */
    2293             :     float **inp,                  /* o  : ptr. to inp. signal in the current frame*/
    2294             :     float fr_bands[2 * NB_BANDS], /* i  : energy in frequency bands               */
    2295             :     float *ener,                  /* o  : residual energy from Levinson-Durbin    */
    2296             : #ifndef FIX_I4_OL_PITCH
    2297             :     int16_t pitch_orig[3], /* o  : open-loop pitch values for quantization */
    2298             : #endif
    2299             :     float A[NB_SUBFR16k * ( M + 1 )],                          /* i/o: A(z) unquantized for the 4 subframes    */
    2300             :     float Aw[NB_SUBFR16k * ( M + 1 )],                         /* i/o: weighted A(z) unquantized for subframes */
    2301             :     float epsP[M + 1],                                         /* i/o: LP prediction errors                    */
    2302             :     float lsp_new[M],                                          /* i/o: LSPs at the end of the frame            */
    2303             :     float lsp_mid[M],                                          /* i/o: LSPs in the middle of the frame         */
    2304             :     int16_t *vad_hover_flag,                                   /* i  : VAD hangover flag                       */
    2305             :     int16_t *attack_flag,                                      /* o  : attack flag                             */
    2306             :     float *new_inp_resamp16k,                                  /* o  : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */
    2307             :     int16_t *Voicing_flag,                                     /* o  : voicing flag for HQ FEC                 */
    2308             :     float realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer                             */
    2309             :     float imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer                             */
    2310             :     int16_t *hq_core_type                                      /* o  : HQ core type                            */
    2311             : );
    2312             : #endif
    2313             : 
    2314             : /*! r: HQ_CORE/TCX_20_CORE decision */
    2315             : int16_t mdct_classifier(
    2316             :     Encoder_State *st,        /* i/o: Encoder state variable                  */
    2317             :     const float *fft_buff,    /* i  : FFT spectrum from fft_rel               */
    2318             :     const float enerBuffer[], /* i  : energy buffer                           */
    2319             :     const int32_t brate       /* i  : current brate, IVAS: nominal bitrate, EVS: st->total_brate */
    2320             : );
    2321             : 
    2322             : void MDCT_selector(
    2323             :     Encoder_State *st,       /* i/o: Encoder State                           */
    2324             :     const float sp_floor,    /* i  : Noise floor estimate                    */
    2325             :     const float Etot,        /* i  : Total energy                            */
    2326             :     const float cor_map_sum, /* i  : sum of correlation map                  */
    2327             :     const float enerBuffer[] /* i  : energy buffer                           */
    2328             : );
    2329             : 
    2330             : void MDCT_selector_reset(
    2331             :     TCX_ENC_HANDLE hTcxEnc /* i/o: TCX Encoder Handle                      */
    2332             : );
    2333             : 
    2334             : void MDCT_classifier_reset(
    2335             :     TCX_ENC_HANDLE hTcxEnc /* i/o: TCX Encoder Handle                      */
    2336             : );
    2337             : 
    2338             : ivas_error acelp_core_enc(
    2339             :     Encoder_State *st,                   /* i/o: encoder state structure                 */
    2340             :     const float inp[],                   /* i  : input signal of the current frame       */
    2341             :     const float ener,                    /* i  : residual energy from Levinson-Durbin    */
    2342             :     float A[NB_SUBFR16k * ( M + 1 )],    /* i  : A(z) unquantized for the 4 subframes    */
    2343             :     float Aw[NB_SUBFR16k * ( M + 1 )],   /* i  : weighted A(z) unquant. for subframes    */
    2344             :     const float epsP[M + 1],             /* i  : LP prediction errors                    */
    2345             :     float lsp_new[M],                    /* i  : LSPs at the end of the frame            */
    2346             :     float lsp_mid[M],                    /* i  : LSPs in the middle of the frame         */
    2347             :     const int16_t vad_hover_flag,        /* i  : VAD hangover flag                       */
    2348             :     const int16_t attack_flag,           /* i  : attack flag (GSC or TC)                 */
    2349             :     float bwe_exc_extended[],            /* i/o: bandwidth extended excitation           */
    2350             :     float *voice_factors,                /* o  : voicing factors                         */
    2351             :     float old_syn_12k8_16k[],            /* o  : ACELP core synthesis at 12.8kHz or 16kHz to be used by SWB BWE */
    2352             :     float pitch_buf[NB_SUBFR16k],        /* o  : floating pitch for each subframe        */
    2353             :     int16_t *unbits,                     /* o  : number of unused bits                   */
    2354             :     STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle                */
    2355             :     const float tdm_lsfQ_PCh[M]          /* i  : Q LSFs for primary channel              */
    2356             : );
    2357             : 
    2358             : ivas_error acelp_core_switch_dec_bfi(
    2359             :     Decoder_State *st /* i/o: decoder state structure                 */
    2360             : );
    2361             : 
    2362             : void acelp_core_switch_enc(
    2363             :     Encoder_State *st,                     /* i/o: encoder state structure                 */
    2364             :     const float inp12k8[],                 /* i  : input signal @12.8 kHz                  */
    2365             :     const float inp16k[],                  /* i  : input signal @16 kHz                    */
    2366             :     const float A[NB_SUBFR16k * ( M + 1 )] /* i  : A(z) unquantized for the 4 subframes    */
    2367             : );
    2368             : 
    2369             : /*! r: length of output */
    2370             : int16_t modify_Fs_intcub3m_sup(
    2371             :     const float sigIn[], /* i  : signal to decimate with memory of 2 samples (indexes -2 & -1) */
    2372             :     const int16_t lg,    /* i  : length of input                         */
    2373             :     const int32_t fin,   /* i  : frequency of input                      */
    2374             :     float sigOut[],      /* o  : decimated signal                        */
    2375             :     const int32_t fout,  /* i  : frequency of output                     */
    2376             :     int16_t *delayout    /* o  : delay of output                         */
    2377             : );
    2378             : 
    2379             : void core_switching_OLA(
    2380             :     const float *mem_over_hp,     /* i  : upsampling filter memory                */
    2381             :     const int16_t last_L_frame,   /* i  : last L_frame lengthture                 */
    2382             :     const int32_t output_Fs,      /* i  : output sampling rate                    */
    2383             :     float *synth,                 /* i/o: synthesized signal from HQ core         */
    2384             :     const float *synth_subfr_out, /* i  : synthesized signal from ACELP core      */
    2385             :     float *synth_subfr_bwe,       /* i  : synthesized BWE from ACELP core         */
    2386             :     const int16_t output_frame,   /* i  : output frame length                     */
    2387             :     const int16_t bwidth          /* i  : output bandwidth                        */
    2388             : );
    2389             : 
    2390             : void retro_interp4_5(
    2391             :     const float *syn,
    2392             :     float *pst_old_syn );
    2393             : 
    2394             : void retro_interp5_4(
    2395             :     float *pst_old_syn );
    2396             : 
    2397             : void core_switching_hq_prepare_enc(
    2398             :     Encoder_State *st,         /* i/o: encoder state structure                 */
    2399             :     int16_t *num_bits,         /* i/o: bit budget update                       */
    2400             :     const int16_t input_frame, /* i  : input frame length                      */
    2401             :     float *wtda_audio,
    2402             :     const float *audio );
    2403             : 
    2404             : void core_switching_hq_prepare_dec(
    2405             :     Decoder_State *st,        /* i/o: decoder state structure                 */
    2406             :     int16_t *num_bits,        /* i/o: bit budget update                       */
    2407             :     const int16_t input_frame /* i  : input frame length                      */
    2408             : );
    2409             : 
    2410             : ivas_error acelp_core_switch_dec(
    2411             :     Decoder_State *st,                 /* i/o: decoder structure              */
    2412             :     float *synth_subfr_out,            /* o  : synthesized ACELP subframe     */
    2413             :     float *tmp_synth_bwe,              /* o  : synthesized ACELP subframe BWE */
    2414             :     const int16_t output_frame,        /* i  : input frame length             */
    2415             :     const int16_t core_switching_flag, /* i  : core switching flag            */
    2416             :     float *mem_synth,                  /* o  : synthesis to overlap           */
    2417             :     const int16_t nchan_out            /* i  : number of output channels      */
    2418             : );
    2419             : 
    2420             : void space_lsfs(
    2421             :     float *lsfs,
    2422             :     const int16_t order );
    2423             : 
    2424             : void lsp2a(
    2425             :     float *pc_in,
    2426             :     float *freq,
    2427             :     const int16_t order );
    2428             : 
    2429             : void lsp_weights(
    2430             :     const float *lsps,
    2431             :     float *weight,
    2432             :     const int16_t order );
    2433             : 
    2434             : void a2lsp_stab(
    2435             :     const float *a,      /* i  : LP filter coefficients              */
    2436             :     float *lsp,          /* o  : Line spectral pairs                 */
    2437             :     const float *old_lsp /* i  : LSP vector from past frame          */
    2438             : );
    2439             : 
    2440             : void lsp2a_stab(
    2441             :     const float *lsp, /* i  : LSF vector (in the cosine domain)   */
    2442             :     float *a,         /* o  : LP filter coefficients              */
    2443             :     const int16_t m   /* i  : order of LP analysis                */
    2444             : );
    2445             : 
    2446             : void isf2lsf(
    2447             :     const float *isf,  /* i  : ISF vector                          */
    2448             :     float *lsf,        /* o  : LSF vector                          */
    2449             :     float *stable_lsp, /* i/o: LSF vector                          */
    2450             :     const int16_t m,   /* i  : order of LP analysis                */
    2451             :     const int32_t Fs );
    2452             : 
    2453             : void lsf2isf(
    2454             :     const float *lsf,  /* i  : LSF vector                          */
    2455             :     float *isf,        /* o  : ISF vector                          */
    2456             :     float *stable_isp, /* i/o: ISP vector                          */
    2457             :     const int16_t m,   /* i  : order of LP analysis                */
    2458             :     const int32_t Fs );
    2459             : 
    2460             : int16_t a2lsp(
    2461             :     float *freq,        /* o  : LSP vector                              */
    2462             :     const float *a,     /* i  : predictor coefficients                  */
    2463             :     const int16_t order /* i  : order of LP analysis                    */
    2464             : );
    2465             : 
    2466             : void ResetSHBbuffer_Enc(
    2467             :     TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle                      */
    2468             : );
    2469             : 
    2470             : void ResetSHBbuffer_Dec(
    2471             :     TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle                      */
    2472             :     const int16_t extl         /* i  : BWE extension layer                     */
    2473             : );
    2474             : 
    2475             : void calc_st_filt(
    2476             :     const float *apond2,   /* i  : coefficients of numerator               */
    2477             :     const float *apond1,   /* i  : coefficients of denominator             */
    2478             :     float *parcor0,        /* o  : 1st parcor calcul. on composed filter   */
    2479             :     float *sig_ltp_ptr,    /* i/o: input of 1/A(gamma1) : scaled by 1/g0   */
    2480             :     float *mem_zero,       /* i/o: All zero memory                         */
    2481             :     const int16_t L_subfr, /* i  : the length of subframe                  */
    2482             :     const int16_t extl     /* i  : extension layer info                    */
    2483             : );
    2484             : 
    2485             : void scale_st(
    2486             :     const float *sig_in,   /* i  : postfilter input signal                 */
    2487             :     float *sig_out,        /* i/o: postfilter output signal                */
    2488             :     float *gain_prec,      /* i/o: last value of gain for subframe         */
    2489             :     const int16_t L_subfr, /* i  : the length of subframe                  */
    2490             :     const int16_t extl     /* i  : extension layer info                    */
    2491             : );
    2492             : 
    2493             : void filt_mu(
    2494             :     const float *sig_in,   /* i  : signal (beginning at sample -1)         */
    2495             :     float *sig_out,        /* o  : output signal                           */
    2496             :     const float parcor0,   /* i  : parcor0 (mu = parcor0 * gamma3)         */
    2497             :     const int16_t L_subfr, /* i  : the length of subframe                  */
    2498             :     const int16_t extl     /* i  : extension layer info                    */
    2499             : );
    2500             : 
    2501             : void PostShortTerm(
    2502             :     float *sig_in,          /* i  : input signal (ptr. to current subframe  */
    2503             :     float *lpccoeff,        /* i  : LPC coefficients for current subframe   */
    2504             :     float *sig_out,         /* o  : postfiltered output                     */
    2505             :     float *mem_stp,         /* i/o: postfilter memory                       */
    2506             :     float *ptr_mem_stp,     /* i/o: pointer to postfilter memory            */
    2507             :     float *ptr_gain_prec,   /* i/o: for gain adjustment                     */
    2508             :     float *mem_zero,        /* i/o: null memory to compute h_st             */
    2509             :     const float formant_fac /* i  : Strength of post-filter [0,1]           */
    2510             : );
    2511             : 
    2512             : /*! r: Formant filter strength [0,1] */
    2513             : float swb_formant_fac(
    2514             :     const float lpc_shb2, /* i  : 2nd HB LPC coefficient                  */
    2515             :     float *tilt_mem       /* i/o: Tilt smoothing memory                   */
    2516             : );
    2517             : 
    2518             : void GenShapedSHBExcitation(
    2519             :     float *excSHB,                      /* o  : synthesized shaped shb exctiation       */
    2520             :     const float *lpc_shb,               /* i  : lpc coefficients                        */
    2521             :     float *exc16kWhtnd,                 /* o  : whitened synthesized shb excitation     */
    2522             :     float *mem_csfilt,                  /* i/o: memory                                  */
    2523             :     float *mem_genSHBexc_filt_down_shb, /* i/o: memory                                  */
    2524             :     float *state_lpc_syn,               /* i/o: memory                                  */
    2525             :     const int16_t coder_type,           /* i  : coding type                             */
    2526             :     const float *bwe_exc_extended,      /* i  : bandwidth extended excitation           */
    2527             :     int16_t bwe_seed[],                 /* i/o: random number generator seed            */
    2528             :     float voice_factors[],              /* i  : voicing factor                          */
    2529             :     const int16_t extl,                 /* i  : extension layer                         */
    2530             :     float *tbe_demph,                   /* i/o: de-emphasis memory                      */
    2531             :     float *tbe_premph,                  /* i/o: pre-emphasis memory                     */
    2532             :     float *lpc_shb_sf,                  /* i  : LP coefficients                         */
    2533             :     float *shb_ener_sf,                 /* i  : SHB subframe energies                   */
    2534             :     float *shb_res_gshape,              /* i  : SHB LP residual gain shape              */
    2535             :     float *shb_res,                     /* i  : SHB residual used in encoder only       */
    2536             :     int16_t *vf_ind,                    /* i/o: Mixing factor index                     */
    2537             :     const float formant_fac,            /* i  : Formant sharpening factor [0..1]        */
    2538             :     float fb_state_lpc_syn[],           /* i/o: memory                                  */
    2539             :     float *fb_tbe_demph,                /* i/o: fb de-emphasis memory                   */
    2540             :     const int32_t total_brate,          /* i  : overall bitrate                         */
    2541             :     const int16_t prev_bfi,             /* i  : previous frame was lost flag            */
    2542             :     const int16_t element_mode,         /* i  : element mode                            */
    2543             :     const int16_t flag_ACELP16k,        /* i  : ACELP@16kHz flag                        */
    2544             :     float *nlExc16k,                    /* i/o: NL exc for IC-BWE                       */
    2545             :     float *mixExc16k,                   /* i/o: exc spreading for IC-BWE                */
    2546             :     const int32_t extl_brate,           /* i  : TD BWE bitrate                          */
    2547             :     const int16_t MSFlag,               /* i  : Multi-source flag                       */
    2548             :     float EnvSHBres_4k[],               /* i/o: TD envelope of the SHB residual signal  */
    2549             :     float *prev_pow_exc16kWhtnd,        /* i/o: power of the LB excitation signal in the previous frame */
    2550             :     float *prev_mix_factor,             /* i/o: mixing factor in the previous frame     */
    2551             :     float *Env_error,                   /* o  : error in SHB residual envelope modelling*/
    2552             :     float Env_error_part[]              /* o  : per-segment error in SHB residual envelope modelling */
    2553             : );
    2554             : 
    2555             : void GenSHBSynth(
    2556             :     const float *shb_target_speech,    /* i  : input synthesized speech                */
    2557             :     float *shb_syn_speech_32k,         /* o  : output highband component               */
    2558             :     float Hilbert_Mem[],               /* i/o: memory                                  */
    2559             :     float state_lsyn_filt_shb_local[], /* i/o: memory                                  */
    2560             :     const int16_t L_frame,             /* i  : ACELP Frame length                      */
    2561             :     int16_t *syn_dm_phase );
    2562             : 
    2563             : void ScaleShapedSHB(
    2564             :     const int16_t length,   /* i  : SHB overlap length                      */
    2565             :     float *synSHB,          /* i/o: synthesized shb signal                  */
    2566             :     float *overlap,         /* i/o: buffer for overlap-add                  */
    2567             :     const float *subgain,   /* i  : subframe gain                           */
    2568             :     const float frame_gain, /* i  : frame gain                              */
    2569             :     const float *win,       /* i  : window                                  */
    2570             :     const float *subwin     /* i  : subframes window                        */
    2571             : );
    2572             : 
    2573             : void Interpolate_allpass_steep(
    2574             :     const float *in, /* i  : input array of size N                   */
    2575             :     float *mem,      /* i/o: memory                                  */
    2576             :     const int16_t N, /* i  : number of input samples                 */
    2577             :     float *out       /* o  : output array of size 2*N                */
    2578             : );
    2579             : 
    2580             : void Decimate_allpass_steep(
    2581             :     const float *in, /* i  : input array of size N                   */
    2582             :     float *mem,      /* i/o: memory                                  */
    2583             :     const int16_t N, /* i  : number of input samples                 */
    2584             :     float *out       /* o  : output array of size N/2                */
    2585             : );
    2586             : 
    2587             : void interpolate_3_over_2_allpass(
    2588             :     const float *input, /* i  : input signal                            */
    2589             :     const int16_t len,  /* i  : number of input samples                 */
    2590             :     float *out,         /* o  : output signal                           */
    2591             :     float *mem          /* i/o: memory                                  */
    2592             : );
    2593             : 
    2594             : void decimate_2_over_3_allpass(
    2595             :     const float *input, /* i  : input signal                            */
    2596             :     const int16_t len,  /* i  : number of input samples                 */
    2597             :     float *out,         /* o  : output signal                           */
    2598             :     float *mem,         /* i/o: memory                                  */
    2599             :     float *lp_mem );
    2600             : 
    2601             : void interpolate_3_over_1_allpass(
    2602             :     const float *input, /* i  : input signal                            */
    2603             :     const int16_t len,  /* i  : number of input samples                 */
    2604             :     float *out,         /* o  : output signal                           */
    2605             :     float *mem          /* i/o: memory                                  */
    2606             : );
    2607             : 
    2608             : void InitSWBencBuffer(
    2609             :     TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle                      */
    2610             : );
    2611             : 
    2612             : void InitSWBencBufferStates(
    2613             :     TD_BWE_ENC_HANDLE hBWE_TD, /* i/o: TD BWE data handle                   */
    2614             :     float *shb_speech          /* o  : SHB target signal (6-14kHz) at 16kHz */
    2615             : );
    2616             : 
    2617             : void swb_tbe_enc(
    2618             :     Encoder_State *st,                    /* i/o: encoder state structure                 */
    2619             :     STEREO_ICBWE_ENC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure                  */
    2620             :     const float *new_speech,              /* i  : original input signal                   */
    2621             :     const float *bwe_exc_extended,        /* i  : bandwidth extended exciatation          */
    2622             :     const float voice_factors[],          /* i  : voicing factors                         */
    2623             :     float *White_exc16k,                  /* o  : shaped white excitation for the FB TBE  */
    2624             :     const float pitch_buf[]               /* i  : pitch for each subframe                 */
    2625             : );
    2626             : 
    2627             : void swb_tbe_dec(
    2628             :     Decoder_State *st,                    /* i/o: decoder state structure                 */
    2629             :     STEREO_ICBWE_DEC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure                  */
    2630             :     const float *bwe_exc_extended,        /* i  : bandwidth extended exciatation          */
    2631             :     const float voice_factors[],          /* i  : voicing factors                         */
    2632             :     const float old_syn_12k8_16k[],       /* i  : low band synthesis at 12.8kHz or 16kHz  */
    2633             :     float *White_exc16k,                  /* o  : shaped white excitation for the FB TBE  */
    2634             :     float *synth,                         /* i/o: ACELP core synthesis/final synthesis    */
    2635             :     float *pitch_buf );
    2636             : 
    2637             : void flip_and_downmix_generic(
    2638             :     float input[],                      /* i  : input spectrum                          */
    2639             :     float output[],                     /* o  : output  spectrum                        */
    2640             :     const int16_t length,               /* i  : length of spectra                       */
    2641             :     float mem1_ext[HILBERT_ORDER1],     /* i/o: Hilbert filter memory                   */
    2642             :     float mem2_ext[2 * HILBERT_ORDER2], /* i/o: memory                                  */
    2643             :     float mem3_ext[2 * HILBERT_ORDER2], /* i/o: memory                                  */
    2644             :     int16_t *phase_state                /* i/o: Phase state in case frequency isn't multiple of 50 Hz */
    2645             : );
    2646             : 
    2647             : void non_linearity(
    2648             :     const float input[],          /* i  : input signal                            */
    2649             :     float output[],               /* i  : output signal                           */
    2650             :     float old_bwe_exc_extended[], /* i/o: memory bugffer                          */
    2651             :     const int16_t length,         /* i  : input length                            */
    2652             :     float *prev_scale,            /* i/o: memory                                  */
    2653             :     const int16_t coder_type,     /* i  : Coder Type                              */
    2654             :     const float *voice_factors,   /* i  : Voice Factors                           */
    2655             :     const int16_t L_frame         /* i  : ACELP frame length                      */
    2656             : #ifdef NONBE_1328_FIX_NON_LINEARITY
    2657             :     ,
    2658             :     const int16_t element_mode /* i  : element_mode to differentiate EVS and IVAS */
    2659             : #endif
    2660             : );
    2661             : 
    2662             : void interp_code_5over2(
    2663             :     const float inp_code[],  /* i  :  input vector                           */
    2664             :     float interp_code[],     /* o  :  output vector                          */
    2665             :     const int16_t inp_length /* i  :  length of the input vector             */
    2666             : );
    2667             : 
    2668             : void interp_code_4over2(
    2669             :     const float inp_code[],  /* i  :  input vector                           */
    2670             :     float interp_code[],     /* o  :  output vector                          */
    2671             :     const int16_t inp_length /* i  :  length of the input vector             */
    2672             : );
    2673             : 
    2674             : void flip_spectrum_and_decimby4(
    2675             :     const float input[],    /* i  : input spectrum                          */
    2676             :     float output[],         /* o  : output  spectrum                        */
    2677             :     const int16_t length,   /* i  : vector length                           */
    2678             :     float mem1[],           /* i/o: memory                                  */
    2679             :     float mem2[],           /* i/o: memory                                  */
    2680             :     const int16_t ramp_flag /* i  : flag to trigger slow ramp-up of output  */
    2681             : );
    2682             : 
    2683             : void GenShapedWBExcitation(
    2684             :     float *excSHB,                   /* o  : synthesized shaped shb exctiation      */
    2685             :     const float *lpc_shb,            /* i  : lpc coefficients                       */
    2686             :     float *exc4kWhtnd,               /* o  : whitened synthesized shb excitation    */
    2687             :     float *mem_csfilt,               /* i/o: memory                                 */
    2688             :     float *mem_genSHBexc_filt_down1, /* i/o: memory                                 */
    2689             :     float *mem_genSHBexc_filt_down2, /* i/o: memory                                 */
    2690             :     float *mem_genSHBexc_filt_down3, /* i/o: memory                                 */
    2691             :     float *state_lpc_syn,            /* i/o: memory                                 */
    2692             :     const int16_t coder_type,        /* i  : coding type                            */
    2693             :     const float *bwe_exc_extended,   /* i  : bandwidth extended exciatation         */
    2694             :     int16_t bwe_seed[],              /* i/o: random number generator seed           */
    2695             :     const float voice_factors[],     /* i  : voicing factor                         */
    2696             :     const int16_t uv_flag,           /* i  : unvoiced flag                          */
    2697             :     const int16_t igf_flag );
    2698             : 
    2699             : void GenWBSynth(
    2700             :     const float *input_synspeech, /* i  : input synthesized speech                */
    2701             :     float *shb_syn_speech_16k,    /* o  : output highband compnent                */
    2702             :     float *state_lsyn_filt_shb1,  /* i/o: memory                                  */
    2703             :     float *state_lsyn_filt_shb2   /* i/o: memory                                  */
    2704             : );
    2705             : 
    2706             : void wb_tbe_enc(
    2707             :     Encoder_State *st,             /* i/o: encoder state structure                */
    2708             :     const float *hb_speech,        /* i  : HB target signal (6-8kHz) at 16kHz     */
    2709             :     const float *bwe_exc_extended, /* i  : bandwidth extended exciatation         */
    2710             :     const float pitch_buf[],       /* i  : pitch for each subframe                */
    2711             :     const float voicing[]          /* o  : OL maximum normalized correlation      */
    2712             : );
    2713             : 
    2714             : void wb_tbe_dec(
    2715             :     Decoder_State *st,             /* i/o: decoder state structure                 */
    2716             :     const float *bwe_exc_extended, /* i  : bandwidth extended exciatation          */
    2717             :     const float voice_factors[],   /* i  : voicing factors                         */
    2718             :     float *synth                   /* i/o: ACELP core synthesis/final synthesis    */
    2719             : );
    2720             : 
    2721             : void tbe_write_bitstream(
    2722             :     Encoder_State *st /* i/o: encoder state structure                 */
    2723             : );
    2724             : 
    2725             : void tbe_read_bitstream(
    2726             :     Decoder_State *st /* i/o: decoder state structure                 */
    2727             : );
    2728             : 
    2729             : void GenTransition(
    2730             :     TD_BWE_DEC_HANDLE hBWE_TD,  /* i/o: TD BWE data handle                      */
    2731             :     float *outputHB,            /* o  : synthesized HB transitions signal       */
    2732             :     const int32_t output_Fs,    /* i  : output sampling rate                    */
    2733             :     const int16_t element_mode, /* i  : element mode                            */
    2734             :     const int16_t L_frame,      /* i  : ACELP frame length                      */
    2735             :     const int16_t rf_flag,      /* i  : RF flag                                 */
    2736             :     const int32_t total_brate   /* i  : total bitrate                           */
    2737             : );
    2738             : 
    2739             : void GenTransition_WB(
    2740             :     TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle                      */
    2741             :     float *outputHB,           /* o  : synthesized HB transitions signal       */
    2742             :     const int32_t output_Fs    /* i  : output sampling rate                    */
    2743             : );
    2744             : 
    2745             : void td_bwe_dec_init(
    2746             :     TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle                      */
    2747             :     const int16_t extl,        /* i  : BWE extension layer                     */
    2748             :     const int32_t output_Fs    /* i  : output sampling rate                    */
    2749             : );
    2750             : 
    2751             : void TBEreset_enc(
    2752             :     TD_BWE_ENC_HANDLE hBWE_TD, /* i/o: TD BWE data handle                      */
    2753             :     const int16_t last_core,   /* i  : last core                               */
    2754             :     const int16_t bwidth       /* i  : audio bandwidth                         */
    2755             : );
    2756             : 
    2757             : void TBEreset_dec(
    2758             :     Decoder_State *st /* i/o: decoder state structure                 */
    2759             : );
    2760             : 
    2761             : /*! r: TBE bit consumption per frame */
    2762             : int16_t get_tbe_bits(
    2763             :     const int32_t total_brate, /* i  : overall bitrate                         */
    2764             :     const int16_t bwidth,      /* i  : audio bandwidth                         */
    2765             :     const int16_t rf_mode      /* i  : channel aware mode                      */
    2766             : );
    2767             : 
    2768             : void fb_tbe_enc(
    2769             :     Encoder_State *st,       /* i/o: encoder state structure                 */
    2770             :     const float new_input[], /* i  : input speech at 48 kHz sample rate      */
    2771             :     const float fb_exc[]     /* i  : FB excitation from the SWB part         */
    2772             : );
    2773             : 
    2774             : void fb_tbe_dec(
    2775             :     Decoder_State *st,         /* i/o: decoder state structure                 */
    2776             :     const float fb_exc[],      /* i  : FB excitation from the SWB part         */
    2777             :     float *hb_synth,           /* i/o: high-band synthesis                     */
    2778             :     float *fb_synth_ref,       /* o  : high-band synthesis 16-20 kHz           */
    2779             :     const int16_t output_frame /* i  : output frame length                     */
    2780             : );
    2781             : 
    2782             : void calc_tilt_bwe(
    2783             :     const float *sp, /* i  : input signal                            */
    2784             :     float *tilt,     /* o  : signal tilt                             */
    2785             :     const int16_t N  /* i  : signal length                           */
    2786             : );
    2787             : 
    2788             : void fd_bwe_enc_init(
    2789             :     FD_BWE_ENC_HANDLE hBWE_FD /* i/o: FD BWE data handle                      */
    2790             : );
    2791             : 
    2792             : void swb_pre_proc(
    2793             :     Encoder_State *st,                                         /* i/o: encoder state structure                 */
    2794             :     float *new_swb_speech,                                     /* o  : original input signal at 32kHz          */
    2795             :     float *shb_speech,                                         /* o  : SHB target signal (6-14kHz) at 16kHz    */
    2796             :     float realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i  : real buffer                             */
    2797             :     float imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i  : imag buffer                             */
    2798             :     CPE_ENC_HANDLE hCPE                                        /* i/o: CPE encoder structure                   */
    2799             : );
    2800             : 
    2801             : void wb_pre_proc(
    2802             :     Encoder_State *st,               /* i/o: encoder state structure                 */
    2803             :     const int16_t last_element_mode, /* i  : last element mode                       */
    2804             :     const float *new_inp_resamp16k,  /* i  : original input signal                   */
    2805             :     float *hb_speech                 /* o  : HB target signal (6-8kHz) at 16kHz      */
    2806             : );
    2807             : 
    2808             : void wb_bwe_enc(
    2809             :     Encoder_State *st,         /* i/o: encoder state structure                 */
    2810             :     const float *new_wb_speech /* i  : original input signal at 16kHz          */
    2811             : );
    2812             : 
    2813             : void wb_bwe_dec(
    2814             :     Decoder_State *st,               /* i/o: decoder state structure                 */
    2815             :     const float output[],            /* i  : synthesis @internal Fs                  */
    2816             :     float *synth,                    /* i/o: ACELP core synthesis/final synthesis    */
    2817             :     float *hb_synth,                 /* o  : SHB synthesis/final synthesis           */
    2818             :     const int16_t use_cldfb_for_dft, /* i  : flag to use of CLDFB for DFT Stereo     */
    2819             :     const int16_t output_frame,      /* i  : frame length                            */
    2820             :     const float voice_factors[],     /* i  : voicing factors                         */
    2821             :     const float pitch_buf[]          /* i  : pitch buffer                            */
    2822             : );
    2823             : 
    2824             : void swb_bwe_enc(
    2825             :     Encoder_State *st,               /* i/o: encoder state structure                 */
    2826             :     const int16_t last_element_mode, /* i  : last element mode                       */
    2827             :     const float *old_input_12k8,     /* i  : input signal @12.8kHz for SWB BWE       */
    2828             :     const float *old_input_16k,      /* i  : input signal @16kHz for SWB BWE         */
    2829             :     const float *old_syn_12k8_16k,   /* i  : ACELP core synthesis at 12.8kHz or 16kHz*/
    2830             :     const float *new_swb_speech,     /* i  : original input signal at 32kHz          */
    2831             :     const float *shb_speech          /* i  : SHB target signal (6-14kHz) at 16kHz    */
    2832             : );
    2833             : 
    2834             : void swb_bwe_enc_hr(
    2835             :     Encoder_State *st,         /* i/o: encoder state structure                 */
    2836             :     const float *new_input,    /* i  : input signal                            */
    2837             :     const int16_t input_frame, /* i  : frame length                            */
    2838             :     const int16_t unbits       /* i  : number of core unused bits              */
    2839             : );
    2840             : 
    2841             : void fd_bwe_dec_init(
    2842             :     FD_BWE_DEC_HANDLE hBWE_FD /* i/o: FD BWE data handle                      */
    2843             : );
    2844             : 
    2845             : void swb_bwe_dec(
    2846             :     Decoder_State *st,               /* i/o: decoder state structure                 */
    2847             :     const float output[],            /* i  : synthesis @internal Fs                  */
    2848             :     const float *synth,              /* i  : ACELP core synthesis/final synthesis    */
    2849             :     float *hb_synth,                 /* o  : SHB synthesis/final synthesis           */
    2850             :     const int16_t use_cldfb_for_dft, /* i  : flag to use of CLDFB for DFT Stereo     */
    2851             :     const int16_t output_frame       /* i  : frame length                            */
    2852             : );
    2853             : 
    2854             : void hr_bwe_dec_init(
    2855             :     HR_BWE_DEC_HANDLE hBWE_FD_HR /* i/o: HR BWE data handle                      */
    2856             : );
    2857             : 
    2858             : void swb_bwe_dec_hr(
    2859             :     Decoder_State *st,          /* i/o: decoder state structure                 */
    2860             :     const float *syn_12k8_16k,  /* i  : ACELP core synthesis @16kHz             */
    2861             :     float *hb_synth,            /* o  : SHB synthesis                           */
    2862             :     const int16_t output_frame, /* i  : frame length                            */
    2863             :     const int16_t unbits,       /* i  : number of core unused bits              */
    2864             :     const float pitch_buf[]     /* i  : pitch buffer                            */
    2865             : );
    2866             : 
    2867             : void swb_hr_noise_fill(
    2868             :     const int16_t is_transient, /* i  : transient flag                          */
    2869             :     const int16_t spect_start,  /* i  : spectrum start point                    */
    2870             :     const int16_t spect_end,    /* i  : spectrum end point                      */
    2871             :     const float tilt_wb,        /* i  : tilt of wideband signal                 */
    2872             :     const float pitch,          /* i  : pitch value                             */
    2873             :     const int16_t nq[],         /* i  : AVQ nq index                            */
    2874             :     int16_t Nsv,                /* i  : number of subband                       */
    2875             :     int16_t *bwe_highrate_seed, /* i/o: seed of random noise                    */
    2876             :     float *t_audio              /* i/o: mdct spectrum                           */
    2877             : );
    2878             : 
    2879             : /*! r: gain */
    2880             : float td_postprocess(
    2881             :     float hb_synth[],          /* i/o: high-band synthesis                     */
    2882             :     const int16_t input_frame, /* i  : frame length                            */
    2883             :     const int16_t last_extl    /* i  : last extension layer                    */
    2884             : );
    2885             : 
    2886             : void calc_normal_length(
    2887             :     const int16_t core,      /* i  : core                                    */
    2888             :     const float *sp,         /* i  : input signal                            */
    2889             :     const int16_t mode,      /* i  : input mode                              */
    2890             :     const int16_t extl,      /* i  : extension layer                         */
    2891             :     int16_t *L_swb_norm,     /* o  : normalize length                        */
    2892             :     int16_t *prev_L_swb_norm /* i/o: last normalize length                   */
    2893             : );
    2894             : 
    2895             : void calc_norm_envelop(
    2896             :     const float SWB_signal[],  /* i  : SWB spectrum                            */
    2897             :     float *envelope,           /* o  : normalized envelope                     */
    2898             :     const int16_t L_swb_norm,  /* i  : length of envelope                      */
    2899             :     const int16_t SWB_flength, /* i  : Length of input/output                  */
    2900             :     const int16_t st_offset    /* i  : offset                                  */
    2901             : );
    2902             : 
    2903             : void time_envelop_shaping(
    2904             :     float werr[],     /* i/o: SHB synthesis                           */
    2905             :     float SWB_tenv[], /* i/o: frequency envelope                      */
    2906             :     const int16_t L   /* i  : frame length                            */
    2907             : );
    2908             : 
    2909             : void time_reduce_pre_echo(
    2910             :     const float *synth,   /* i  : ACELP core synthesis                    */
    2911             :     float *error,         /* o  : SHB BWE synthesis                       */
    2912             :     float prev_td_energy, /* o  : last td energy                          */
    2913             :     const int16_t L       /* i  : subframe length                         */
    2914             : );
    2915             : 
    2916             : int16_t WB_BWE_gain_pred(
    2917             :     float *WB_fenv,                /* o  : WB frequency envelopes                  */
    2918             :     const float *core_dec_freq,    /* i  : Frequency domain core decoded signal    */
    2919             :     const int16_t coder_type,      /* i  : coding type                             */
    2920             :     const int16_t prev_code_type,  /* i  : coding type of last frame               */
    2921             :     const float prev_WB_fenv,      /* i  : envelope for last frame                 */
    2922             :     const float voice_factors[],   /* i  : voicing factors                         */
    2923             :     const float pitch_buf[],       /* i  : pitch buffer                            */
    2924             :     const int32_t last_core_brate, /* i  : previous frame core bitrate             */
    2925             :     const float last_wb_bwe_ener,  /* i  : previous frame wb bwe signal energy     */
    2926             :     const int16_t last_extl,       /* i  : extl. layer for last frame              */
    2927             :     const float tilt );
    2928             : 
    2929             : void WB_BWE_decoding(
    2930             :     const float *core_dec_freq, /* i  : Frequency domain core decoded signal    */
    2931             :     float *WB_fenv,             /* i  : WB frequency envelopes                  */
    2932             :     float *WB_signal,           /* o  : WB signal in MDCT domain                */
    2933             :     const int16_t WB_flength,   /* i  : Length of input/output                  */
    2934             :     const int16_t mode,         /* i  : classification for WB signal            */
    2935             :     const int16_t last_extl,    /* i  : extl. layer for last frame              */
    2936             :     float *prev_Energy,         /* i/o: energy for last frame                   */
    2937             :     float *prev_WB_fenv,        /* i/o: envelope for last frame                 */
    2938             :     int16_t *prev_L_wb_norm,    /* i/o: length for last frame wb norm           */
    2939             :     const int16_t extl,         /* i  : extension layer                         */
    2940             :     const int16_t coder_type,   /* i  : coding type                             */
    2941             :     const int32_t total_brate,  /* i  : core layer bitrate                      */
    2942             :     int16_t *Seed,              /* i/o: random generator seed                   */
    2943             :     int16_t *prev_flag,         /* i/o: attenu flag of last frame               */
    2944             :     int16_t prev_coder_type     /* i  : coding type of last frame               */
    2945             : );
    2946             : 
    2947             : void SWB_BWE_decoding(
    2948             :     const float *core_dec_freq, /* i  : Frequency domain core decoded signal    */
    2949             :     float *SWB_fenv,            /* i/o: SWB frequency envelopes                 */
    2950             :     float *SWB_signal,          /* o  : SWB signal in MDCT domain               */
    2951             :     const int16_t SWB_flength,  /* i  : Length of input/output                  */
    2952             :     const int16_t mode,         /* i  : classification for SWB signal           */
    2953             :     int16_t *frica_flag,        /* o  : fricative signal flag                   */
    2954             :     float *prev_Energy,         /* i/o: energy for last frame                   */
    2955             :     float *prev_SWB_fenv,       /* i/o: envelope for last frame                 */
    2956             :     int16_t *prev_L_swb_norm,   /* i/o: length for last frame wb norm           */
    2957             :     const float tilt_nb,        /* i  : tilt of synthesis wb signal             */
    2958             :     int16_t *Seed,              /* i/o: random generator seed                   */
    2959             :     const int16_t st_offset,    /* i  : offset value due to different core      */
    2960             :     float *prev_weight,         /* i/o: excitation weight value of last frame   */
    2961             :     const int16_t extl,         /* i  : extension layer                         */
    2962             :     const int16_t last_extl     /* i  : extension layer of last frame           */
    2963             : );
    2964             : 
    2965             : void CNG_reset_enc(
    2966             :     Encoder_State *st,    /* i/o: encoder state structure                 */
    2967             :     float *pitch_buf,     /* o  : floating pitch for each subframe        */
    2968             :     float *voice_factors, /* o  : voicing factors                         */
    2969             :     int16_t VBR_cng_reset_flag );
    2970             : 
    2971             : void a2isp(
    2972             :     const float *a,      /* i  : LP filter coefficients                  */
    2973             :     float *isp,          /* o  : Immittance spectral pairs               */
    2974             :     const float *old_isp /* i  : ISP vector from past frame              */
    2975             : );
    2976             : 
    2977             : void a2isf(
    2978             :     float *a,
    2979             :     float *isf,
    2980             :     const float *old_isf,
    2981             :     const int16_t lpcOrder );
    2982             : 
    2983             : /*! r: stability flag */
    2984             : uint16_t a2rc(
    2985             :     const float *a,        /* i  : LPC coefficients                                */
    2986             :     float *refl,           /* o  : Reflection co-efficients                        */
    2987             :     const int16_t lpcorder /* i  : LPC order                                       */
    2988             : );
    2989             : 
    2990             : int16_t lp_filt_exc_enc(
    2991             :     const int16_t codec_mode, /* i  : codec mode                                      */
    2992             :     const int16_t coder_type, /* i  : coding type                                     */
    2993             :     const int16_t i_subfr,    /* i  : subframe index                                  */
    2994             :     float *exc,               /* i/o: pointer to excitation signal frame              */
    2995             :     const float *h1,          /* i  : weighted filter input response                  */
    2996             :     const float *xn,          /* i  : target vector                                   */
    2997             :     float *y1,                /* o  : zero-memory filtered adaptive excitation        */
    2998             :     float *xn2,               /* o  : target vector for innovation search             */
    2999             :     const int16_t L_subfr,    /* i  : length of vectors for gain quantization         */
    3000             :     const int16_t L_frame,    /* i  : frame size                                      */
    3001             :     float *g_corr,            /* o  : ACELP correlation values                        */
    3002             :     const int16_t clip_gain,  /* i  : adaptive gain clipping flag                     */
    3003             :     float *gain_pit,          /* o  : adaptive excitation gain                        */
    3004             :     int16_t *lp_flag          /* i/o: mode selection                                  */
    3005             : );
    3006             : 
    3007             : void updt_tar(
    3008             :     const float *x,   /* i  : old target (for pitch search)                   */
    3009             :     float *x2,        /* o  : new target (for codebook search)                */
    3010             :     const float *y,   /* i  : filtered adaptive codebook vector               */
    3011             :     const float gain, /* i  : adaptive codebook gain                          */
    3012             :     const int16_t L   /* i  : subframe size                                   */
    3013             : );
    3014             : 
    3015             : void analy_sp(
    3016             :     const int16_t element_mode, /* i  : element mode                                     */
    3017             :     CPE_ENC_HANDLE hCPE,        /* i/o: CPE encoder structure                            */
    3018             :     const int32_t input_Fs,     /* i  : input sampling rate                              */
    3019             :     float *speech,              /* i  : speech buffer                                    */
    3020             :     float *Bin_E,               /* o  : per bin log energy spectrum                      */
    3021             :     float *Bin_E_old,           /* o  : per bin log energy spectrum for mid-frame        */
    3022             :     float *fr_bands,            /* o  : per band energy spectrum (2 analyses)            */
    3023             :     float lf_E[],               /* o  : per bin E for first VOIC_BINS bins (without DC)  */
    3024             :     float *Etot,                /* o  : total input energy                               */
    3025             :     const int16_t min_band,     /* i  : minimum critical band                            */
    3026             :     const int16_t max_band,     /* i  : maximum critical band                            */
    3027             :     float *band_ener,           /* o  : energy in critical frequency bands without minimum noise floor E_MIN */
    3028             :     float *PS,                  /* o  : Per bin energy spectrum                          */
    3029             :     float *fft_buff             /* o  : FFT coefficients                                 */
    3030             : );
    3031             : 
    3032             : void CNG_enc(
    3033             :     Encoder_State *st,      /* i/o: State structure                                     */
    3034             :     float Aq[],             /* o  : LP coefficients                                     */
    3035             :     const float *speech,    /* i  : pointer to current frame input speech buffer        */
    3036             :     float enr,              /* i  : frame energy output from Levinson recursion         */
    3037             :     const float *lsp_mid,   /* i  : mid frame LSPs                                      */
    3038             :     float *lsp_new,         /* i/o: current frame LSPs                                  */
    3039             :     float *lsf_new,         /* i/o: current frame LSFs                                  */
    3040             :     int16_t *allow_cn_step, /* o  : allow CN step                                       */
    3041             :     float *q_env,
    3042             :     int16_t *sid_bw );
    3043             : 
    3044             : void swb_CNG_enc(
    3045             :     Encoder_State *st,        /* i/o: State structure                                     */
    3046             :     const float *shb_speech,  /* i  : SHB target signal (6-14kHz) at 16kHz                */
    3047             :     const float *syn_12k8_16k /* i  : ACELP core synthesis at 12.8kHz or 16kHz            */
    3048             : );
    3049             : 
    3050             : void lsf_enc(
    3051             :     Encoder_State *st,               /* i/o: state structure                            */
    3052             :     float *lsf_new,                  /* o  : quantized LSF vector                       */
    3053             :     float *lsp_new,                  /* i/o: LSP vector to quantize/quantized           */
    3054             :     float *lsp_mid,                  /* i  : mid-frame LSP vector                       */
    3055             :     float *Aq,                       /* o  : quantized A(z) for 4 subframes             */
    3056             :     const int16_t tdm_low_rate_mode, /* i  : secondary channel low rate mode flag       */
    3057             :     const int16_t GSC_IVAS_mode,     /* i  : GSC IVAS mode                              */
    3058             :     const float tdm_lsfQ_PCh[M]      /* i  : Q LSFs for primary channel                 */
    3059             : );
    3060             : 
    3061             : void isf_enc_amr_wb(
    3062             :     Encoder_State *st, /* i/o: state structure                                     */
    3063             :     float *isf_new,    /* o  : quantized ISF vector                                */
    3064             :     float *isp_new,    /* i/o: ISP vector to quantize/quantized                    */
    3065             :     float *Aq          /* o  : quantized A(z) for 4 subframes                      */
    3066             : );
    3067             : 
    3068             : void find_targets(
    3069             :     const float *speech,   /* i  : pointer to the speech frame                         */
    3070             :     const float *mem_syn,  /* i  : memory of the synthesis filter                      */
    3071             :     const int16_t i_subfr, /* i  : subframe index                                      */
    3072             :     float *mem_w0,         /* i/o: weighting filter denominator memory                 */
    3073             :     const float *p_Aq,     /* i  : interpolated quantized A(z) filter                  */
    3074             :     const float *res,      /* i  : residual signal                                     */
    3075             :     const int16_t L_subfr, /* i  : length of vectors for gain quantization             */
    3076             :     const float *Ap,       /* i  : unquantized A(z) filter with bandwidth expansion    */
    3077             :     const float tilt_fac,  /* i  : tilt factor                                         */
    3078             :     float *xn,             /* o  : Close-loop Pitch search target vector               */
    3079             :     float *cn,             /* o  : target vector in residual domain                    */
    3080             :     float *h1              /* o  : impulse response of weighted synthesis filter       */
    3081             : );
    3082             : 
    3083             : void inov_encode(
    3084             :     Encoder_State *st,          /* i/o: encoder state structure                             */
    3085             :     const int32_t core_brate,   /* i  : core bitrate                                        */
    3086             :     const int16_t Opt_AMR_WB,   /* i  : flag indicating AMR-WB IO mode                      */
    3087             :     const int16_t L_frame,      /* i  : length of the frame                                 */
    3088             :     const int16_t last_L_frame, /* i  : length of the last frame                            */
    3089             :     const int16_t coder_type,   /* i  : coding type                                         */
    3090             :     const int16_t bwidth,       /* i  : input signal bandwidth                              */
    3091             :     const int16_t sharpFlag,    /* i  : formant sharpening flag                             */
    3092             :     const int16_t i_subfr,      /* i  : subframe index                                      */
    3093             :     const int16_t tc_subfr,     /* i  : TC subframe index                                   */
    3094             :     const float *p_Aq,          /* i  : LP filter coefficients                              */
    3095             :     const float gain_pit,       /* i  : adaptive excitation gain                            */
    3096             :     float *cn,                  /* i/o: target vector in residual domain                    */
    3097             :     const float *exc,           /* i  : pointer to excitation signal frame                  */
    3098             :     float *h1,                  /* i/o: weighted filter input response                      */
    3099             :     const float tilt_code,      /* i  : tilt of of the excitation of previous subframe      */
    3100             :     const float pt_pitch,       /* i  : pointer to current subframe fractional pitch        */
    3101             :     const float *xn2,           /* i  : target vector for innovation search                 */
    3102             :     float *code,                /* o  : algebraic excitation                                */
    3103             :     float *y2,                  /* o  : zero-memory filtered algebraic excitation           */
    3104             :     int16_t *unbits,            /* o  : number of unused bits for  EVS_PI                   */
    3105             :     const int16_t L_subfr       /* i  : subframe length                                     */
    3106             : );
    3107             : 
    3108             : void acelp_1t64(
    3109             :     BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle                            */
    3110             :     const float dn[],      /* i  : corr. between target and h[].                       */
    3111             :     const float h[],       /* i  : impulse response of weighted synthesis filter       */
    3112             :     float code[],          /* o  : algebraic (fixed) codebook excitation               */
    3113             :     float y[],             /* o  : filtered fixed codebook excitation                  */
    3114             :     const int16_t L_subfr  /* i  : subframe length                                     */
    3115             : );
    3116             : 
    3117             : void acelp_2t32(
    3118             :     BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle                            */
    3119             :     const float dn[],      /* i  : corr. between target and h[].                       */
    3120             :     const float h[],       /* i  : impulse response of weighted synthesis filter       */
    3121             :     float code[],          /* o  : algebraic (fixed) codebook excitation               */
    3122             :     float y[]              /* o  : filtered fixed codebook excitation                  */
    3123             : );
    3124             : 
    3125             : int16_t acelp_4t64(
    3126             :     BSTR_ENC_HANDLE hBstr,    /* i/o: encoder bitstream handle                            */
    3127             :     float dn[],               /* i  : corr. between target and h[].                       */
    3128             :     const float cn[],         /* i  : residual after long term prediction                 */
    3129             :     const float H[],          /* i  : impulse response of weighted synthesis filter       */
    3130             :     float R[],                /* i  : autocorrelation values                              */
    3131             :     const int16_t acelpautoc, /* i  : autocorrealtion flag                                */
    3132             :     float code[],             /* o  : algebraic (fixed) codebook excitation               */
    3133             :     float y[],                /* o  : filtered fixed codebook excitation                  */
    3134             :     int16_t nbbits,           /* i  : number of bits per codebook                         */
    3135             :     const int16_t cmpl_flag,  /* i  : coomplexity reduction flag                          */
    3136             :     const int16_t Opt_AMR_WB  /* i  : flag indicating AMR-WB IO mode                      */
    3137             : );
    3138             : 
    3139             : /*! r: return (2*N)+1 bits */
    3140             : int16_t quant_2p_2N1(
    3141             :     const int16_t pos1, /* i  : position of the pulse 1                             */
    3142             :     const int16_t pos2, /* i  : position of the pulse 2                             */
    3143             :     const int16_t N     /* i  : number of bits for position                         */
    3144             : );
    3145             : 
    3146             : void corr_xh(
    3147             :     const float *x,       /* i  : target signal                                       */
    3148             :     float *y,             /* o  : correlation between x[] and h[]                     */
    3149             :     const float *h,       /* i  : impulse response of weighted synthesis filter       */
    3150             :     const int16_t L_subfr /* i  : length of the subframe                              */
    3151             : );
    3152             : 
    3153             : void find_tilt(
    3154             :     const float fr_bands[],   /* i  : energy in frequency bands                           */
    3155             :     const float bckr[],       /* i  : per band background noise energy estimate           */
    3156             :     float ee[2],              /* o  : lf/hf E ration for present frame                    */
    3157             :     const int16_t pitch[3],   /* i  : open loop pitch values for 3 half-frames            */
    3158             :     const float voicing[3],   /* i  : normalized correlation for 3 half-frames            */
    3159             :     const float *lf_E,        /* i  : per bin energy  for low frequencies                 */
    3160             :     const float corr_shift,   /* i  : normalized correlation correction                   */
    3161             :     const int16_t bwidth,     /* i  : input signal bandwidth                              */
    3162             :     const int16_t max_band,   /* i  : maximum critical band                               */
    3163             :     float hp_E[],             /* o  : energy in HF                                        */
    3164             :     const int16_t codec_mode, /* i  : Mode 1 or 2                                         */
    3165             :     float *bckr_tilt_lt,      /* i/o: lf/hf E ratio of background noise                   */
    3166             :     int16_t Opt_vbr_mode );
    3167             : 
    3168             : void init_gp_clip(
    3169             :     float mem[] /* o  : memory of gain of pitch clipping algorithm          */
    3170             : );
    3171             : 
    3172             : int16_t gp_clip(
    3173             :     const int16_t element_mode, /* i  : element mode                                        */
    3174             :     const int32_t core_brate,   /* i  : core bitrate                                        */
    3175             :     const float *voicing,       /* i  : normalized correlations (from OL pitch)             */
    3176             :     const int16_t i_subfr,      /* i  : subframe index                                      */
    3177             :     const int16_t coder_type,   /* i  : coding type                                         */
    3178             :     const float xn[],           /* i  : target vector                                       */
    3179             :     float mem[]                 /* i/o: memory of gain of pitch clipping algorithm          */
    3180             : );
    3181             : 
    3182             : void gp_clip_test_lsf(
    3183             :     const int16_t element_mode, /* i  : element mode                                        */
    3184             :     const int32_t core_brate,   /* i  : core bitrate                                        */
    3185             :     const float lsf[],          /* i  : LSF vector                                          */
    3186             :     float mem[],                /* i/o: memory of gain of pitch clipping algorithm          */
    3187             :     const int16_t Opt_AMR_WB    /* i  : flag indicating AMR-WB IO mode                      */
    3188             : );
    3189             : 
    3190             : void gp_clip_test_gain_pit(
    3191             :     const int16_t element_mode, /* i  : element mode                                        */
    3192             :     const int32_t core_brate,   /* i  : core bitrate                                        */
    3193             :     const float gain_pit,       /* i  :   gain of quantized pitch                           */
    3194             :     float mem[]                 /* i/o: memory of gain of pitch clipping algorithm          */
    3195             : );
    3196             : 
    3197             : void analy_lp(
    3198             :     const float speech[],           /* i  : pointer to the denoised speech frame                */
    3199             :     const int16_t L_frame,          /* i  : length of the frame                                 */
    3200             :     const int16_t L_look,           /* i  : look-ahead length                                   */
    3201             :     float *ener,                    /* o  : residual signal energy                              */
    3202             :     float A[],                      /* o  : A(z) filter coefficients                            */
    3203             :     float epsP[],                   /* o  : LP analysis residual energies for each iteration    */
    3204             :     float lsp_new[],                /* o  : current frame ISPs                                  */
    3205             :     float lsp_mid[],                /* o  : current mid-frame ISPs                              */
    3206             :     float lsp_old[],                /* i/o: previous frame unquantized ISPs                     */
    3207             :     const int16_t Top[2],           /* i  : open loop pitch lag                                 */
    3208             :     const float Tnc[2],             /* i  : open loop pitch gain                                */
    3209             :     const int32_t sr_core,          /* i  : internal sampling rate                              */
    3210             :     const int16_t sec_chan_low_rate /* i  : TD secondary channel flag                           */
    3211             : );
    3212             : 
    3213             : void analy_lp_AMR_WB(
    3214             :     const float speech[], /* i  : pointer to the speech frame                         */
    3215             :     float *ener,          /* o  : residual energy from Levinson-Durbin                */
    3216             :     float A[],            /* o  : A(z) filter coefficients                            */
    3217             :     float epsP[],         /* o  : LP analysis residual energies for each iteration    */
    3218             :     float isp_new[],      /* o  : current frame ISPs                                  */
    3219             :     float isp_old[],      /* i/o: previous frame unquantized ISPs                     */
    3220             :     float isf_new[],      /* o  : current frame ISFs                                  */
    3221             :     const int16_t Top,    /* i  : open loop pitch lag                                 */
    3222             :     const float Tnc       /* i  : open loop pitch gain                                */
    3223             : );
    3224             : 
    3225             : void noise_est_init(
    3226             :     NOISE_EST_HANDLE hNoiseEst /* i/o: Noise estimation handle                             */
    3227             : );
    3228             : 
    3229             : void speech_music_clas_init(
    3230             :     SP_MUS_CLAS_HANDLE hSpMusClas /* i/o: speech/music classifier handle                      */
    3231             : );
    3232             : 
    3233             : void long_enr(
    3234             :     Encoder_State *st,                  /* i/o: encoder state structure                  */
    3235             :     const float Etot,                   /* i  : total channel energy                     */
    3236             :     const int16_t localVAD_HE_SAD,      /* i  : HE-SAD flag without hangover             */
    3237             :     const int16_t high_lpn_flag,        /* i  : sp/mus LPN flag                          */
    3238             :     FRONT_VAD_ENC_HANDLE hFrontVad[],   /* i/o: front-VAD handles                        */
    3239             :     const int16_t n_chan,               /* i  : number of channels                       */
    3240             :     const int16_t localVAD_HE_SAD_LR[], /* i  : HE-SAD flag without hangover LR channels */
    3241             :     const float Etot_LR[]               /* i  : total channel energy LR channels         */
    3242             : );
    3243             : 
    3244             : void noise_est_pre(
    3245             :     const float Etot,               /* i  : Energy of current frame                             */
    3246             :     const int16_t ini_frame,        /* i  : Frame number (init)                                 */
    3247             :     NOISE_EST_HANDLE hNoiseEst,     /* i/o: Noise estimation data handle                        */
    3248             :     const int16_t idchan,           /* i  : channel ID                                          */
    3249             :     const int16_t element_mode,     /* i  : element mode                                        */
    3250             :     const int16_t last_element_mode /* i  : last element mode                                   */
    3251             : );
    3252             : 
    3253             : void noise_est_down(
    3254             :     const float fr_bands[], /* i  : per band input energy (contains 2 vectors)          */
    3255             :     float bckr[],           /* i/o: per band background noise energy estimate           */
    3256             :     float tmpN[],           /* o  : temporary noise update                              */
    3257             :     float enr[],            /* o  : averaged energy over both subframes                 */
    3258             :     const int16_t min_band, /* i  : minimum critical band                               */
    3259             :     const int16_t max_band, /* i  : maximum critical band                               */
    3260             :     float *totalNoise,      /* o  : noise estimate over all critical bands              */
    3261             :     const float Etot,       /* i  : Energy of current frame                             */
    3262             :     float *Etot_last,       /* i/o: Energy of last frame                                */
    3263             :     float *Etot_v_h2        /* i/o: Energy variaions of noise frames                    */
    3264             : );
    3265             : 
    3266             : void noise_est(
    3267             :     Encoder_State *st,                    /* i/o: encoder state structure                             */
    3268             :     const int16_t old_pitch1,             /* i  : previous frame OL pitch[1]                          */
    3269             :     const float tmpN[],                   /* i  : temporary noise update                              */
    3270             :     const float *epsP,                    /* i  : LP prediction error energies                        */
    3271             :     const float Etot,                     /* i  : total channel E                                     */
    3272             :     const float relE,                     /* i  : relative frame energy                               */
    3273             :     const float corr_shift,               /* i  : normalized correlation correction                   */
    3274             :     const float enr[],                    /* i  : averaged energy over both subframes                 */
    3275             :     float fr_bands[],                     /* i  : spectrum per critical bands of the current frame    */
    3276             :     float *cor_map_sum,                   /* o  : sum of correlation map from mult-harm analysis      */
    3277             :     float *ncharX,                        /* o  : noise character for sp/mus classifier               */
    3278             :     float *sp_div,                        /* o  : soectral diversity feature                          */
    3279             :     float *non_staX,                      /* o  : non-stationarity for sp/mus classifier              */
    3280             :     int16_t *loc_harm,                    /* o  : multi-harmonicity flag for UV classifier            */
    3281             :     const float *lf_E,                    /* i  : per bin energy  for low frequencies                 */
    3282             :     int16_t *st_harm_cor_cnt,             /* i  : 1st harm correlation timer                          */
    3283             :     const float Etot_l_lp,                /* i  : Smoothed low energy                                 */
    3284             :     float *sp_floor,                      /* o  : noise floor estimate                                */
    3285             :     float S_map[],                        /* o  : short-term correlation map                          */
    3286             :     STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure                         */
    3287             :     FRONT_VAD_ENC_HANDLE hFrontVad,       /* i/o: front-VAD handle                                    */
    3288             :     const int16_t ini_frame               /* i  : Frame number (init)                                 */
    3289             : );
    3290             : 
    3291             : void vad_param_updt(
    3292             :     Encoder_State *st,                /* i/o: encoder state structure                             */
    3293             :     const float corr_shift,           /* i  : correlation shift                                   */
    3294             :     const float corr_shiftR,          /* i  : correlation shift right channel                     */
    3295             :     const float A[],                  /* i  : A(z) unquantized for the 4 subframes                */
    3296             :     const int16_t old_pitch1,         /* i  : previous frame OL pitch[1]                          */
    3297             :     FRONT_VAD_ENC_HANDLE hFrontVad[], /* i/o: front-VAD handles                                   */
    3298             :     const int16_t n_channels          /* i  : number of channels                                  */
    3299             : );
    3300             : 
    3301             : /*! r: frame multi-harmonicity (1-harmonic, 0-not) */
    3302             : int16_t multi_harm(
    3303             :     const float Bin_E[],       /* i  : log energy spectrum of the current frame        */
    3304             :     float old_S[],             /* i/o: prev. log-energy spectrum w. subtracted floor   */
    3305             :     float cor_map_LT[],        /* i/o: LT correlation map                              */
    3306             :     float *multi_harm_limit,   /* i/o: multi harminic threshold                        */
    3307             :     const int32_t total_brate, /* i  : total bitrate                                   */
    3308             :     const int16_t bwidth,      /* i  : input signal bandwidth                          */
    3309             :     int16_t *cor_strong_limit, /* i/o: HF correlation indicator                        */
    3310             :     float *st_mean_avr_dyn,    /* i/o: long term average dynamic                       */
    3311             :     float *st_last_sw_dyn,     /* i/o: last dynamic                                    */
    3312             :     float *cor_map_sum,        /* i  : sum of correlation map                          */
    3313             :     float *sp_floor,           /* o  : noise floor estimate                            */
    3314             :     float S_map[]              /* o  : short-term correlation map                      */
    3315             : );
    3316             : 
    3317             : void lp_gain_updt(
    3318             :     const int16_t i_subfr,      /* i  :  subframe number                                */
    3319             :     const float gain_pit,       /* i  : Decoded gain pitch                              */
    3320             :     const float norm_gain_code, /* i  : Normalised gain code                            */
    3321             :     float *lp_gainp,            /* i/o: LP-filtered pitch gain(FEC)                     */
    3322             :     float *lp_gainc,            /* i/o: LP-filtered code gain (FEC)                     */
    3323             :     const int16_t L_frame       /* i  : length of the frame                             */
    3324             : );
    3325             : 
    3326             : void enc_pit_exc(
    3327             :     Encoder_State *st,                  /* i/o: state structure                                 */
    3328             :     const float *speech,                /* i  : Input speech                                    */
    3329             :     const float Aw[],                   /* i  : weighted A(z) unquantized for subframes         */
    3330             :     const float *Aq,                    /* i  : 12k8 Lp coefficient                             */
    3331             :     const float Es_pred,                /* i  : predicted scaled innov. energy                  */
    3332             :     const float *res,                   /* i  : residual signal                                 */
    3333             :     float *synth,                       /* i/o: core synthesis                                  */
    3334             :     float *exc,                         /* i/o: current non-enhanced excitation                 */
    3335             :     int16_t *T0,                        /* i/o: close loop integer pitch                        */
    3336             :     int16_t *T0_frac,                   /* i/o: close-loop pitch period - fractional part       */
    3337             :     float *pitch_buf,                   /* i/o: Fractionnal per subframe pitch                  */
    3338             :     const int16_t nb_subfr,             /* i  : Number of subframe considered                   */
    3339             :     float *gpit,                        /* o  : pitch gain per subframe                         */
    3340             :     const int16_t tdm_Pitch_reuse_flag, /* i  : primary channel pitch reuse flag                */
    3341             :     const float tdm_Pri_pitch_buf[]     /* i  : primary channel pitch buffer                    */
    3342             : );
    3343             : 
    3344             : void GSC_enc_init(
    3345             :     GSC_ENC_HANDLE hGSCEnc /* i/o: GSC data handle                                  */
    3346             : );
    3347             : 
    3348             : void encod_audio(
    3349             :     Encoder_State *st,                  /* i/o: state structure                                  */
    3350             :     const float speech[],               /* i  : input speech                                     */
    3351             :     const float Aw[],                   /* i  : weighted A(z) unquantized for subframes          */
    3352             :     const float Aq[],                   /* i  : 12k8 Lp coefficient                              */
    3353             :     const float *res,                   /* i  : residual signal                                  */
    3354             :     float *synth,                       /* i/o: core synthesis                                   */
    3355             :     float *exc,                         /* i/o: current non-enhanced excitation                  */
    3356             :     float *pitch_buf,                   /* i/o: floating pitch values for each subframe          */
    3357             :     float *voice_factors,               /* o  : voicing factors                                  */
    3358             :     float *bwe_exc,                     /* o  : excitation for SWB TBE                           */
    3359             :     const int16_t attack_flag,          /* i  : attack flag (GSC or TC)                          */
    3360             :     float *lsf_new,                     /* i  : current frame ISF vector                         */
    3361             :     float *tmp_noise,                   /* o  : long-term noise energy                           */
    3362             :     const int16_t tdm_Pitch_reuse_flag, /* i  : primary channel pitch reuse flag                 */
    3363             :     const float tdm_Pri_pitch_buf[]     /* i  : primary channel pitch buffer                     */
    3364             : );
    3365             : 
    3366             : /*! r: index of the last band where pitch contribution is significant */
    3367             : int16_t Pit_exc_contribution_len(
    3368             :     Encoder_State *st,    /* i/o: state structure                                 */
    3369             :     const float *dct_res, /* i  : DCT of residual                                 */
    3370             :     float *dct_pitex,     /* i/o: DCT of pitch contribution                       */
    3371             :     float *pitch_buf,     /* i/o: Pitch per subframe                              */
    3372             :     int16_t *hangover     /* i  : Hangover for the time contribution switching    */
    3373             : );
    3374             : 
    3375             : int16_t stab_est(
    3376             :     float etot,               /* i  : Total energy of the current frame                   */
    3377             :     float *lt_diff_etot,      /* i/o: Long term total energy variation                    */
    3378             :     float *mem_etot,          /* i/o: Total energy memory                                 */
    3379             :     int16_t *nb_thr_3,        /* i/o: Number of consecutives frames of level 3            */
    3380             :     int16_t *nb_thr_1,        /* i/o: Number of consecutives frames of level 1            */
    3381             :     float *thresh,            /* i/o: Detection thresold                                  */
    3382             :     int16_t *last_music_flag, /* i/o: Previous music detection ouptut                     */
    3383             :     const int16_t vad_flag    /* i  : VAD flag                                            */
    3384             : );
    3385             : 
    3386             : float gsc_gainQ(
    3387             :     BSTR_ENC_HANDLE hBstr,       /* i/o: encoder bitstream handle                            */
    3388             :     const int16_t element_mode,  /* i  : element mode                                        */
    3389             :     const int16_t idchan,        /* i  : channel ID                                          */
    3390             :     const float y_gain4[],       /* i  : gain per band                                       */
    3391             :     float y_gainQ[],             /* o  : quantized gain per band                             */
    3392             :     const int32_t core_brate,    /* i  : Core rate                                           */
    3393             :     const int16_t coder_type,    /* i  : coding type                                         */
    3394             :     const int16_t bwidth,        /* i  : input signal bandwidth                              */
    3395             :     const int16_t L_frame,       /* i  : frame length                                        */
    3396             :     const int16_t tdm_LRTD_flag, /* i  : LRTD stereo mode flag                               */
    3397             :     const int32_t core_brate_inp /* i  : true core brate                                     */
    3398             : );
    3399             : 
    3400             : void Ener_per_band_comp(
    3401             :     const float exc_diff[], /* i  : gain per band                                       */
    3402             :     float y_gain4[],        /* o  : gain per band to quantize                           */
    3403             :     const int16_t Mband,    /* i  : Max band                                            */
    3404             :     const int16_t Eflag,    /* i  : flag of highest band                                */
    3405             :     const int16_t L_frame   /* i  : frame length                                        */
    3406             : );
    3407             : 
    3408             : void Comp_and_apply_gain(
    3409             :     float exc_diffQ[],      /* i/o: gain per band                                       */
    3410             :     float Ener_per_bd_iQ[], /* o  : Quant Ener per band                                 */
    3411             :     float Ener_per_bd_yQ[], /* o  : Ener per band for quantize y                        */
    3412             :     int16_t Mbands_gn,      /* i  : number of bands                                     */
    3413             :     const int16_t ReUseGain /* i  : Reuse the gain in Ener_per_bd_yQ                    */
    3414             : );
    3415             : 
    3416             : void bands_and_bit_alloc(
    3417             :     const int16_t cor_strong_limit, /* i  : HF correlation                                        */
    3418             :     const int16_t noise_lev,        /* i  : dwn scaling factor                                    */
    3419             :     const int32_t core_brate,       /* i  : core bitrate                                          */
    3420             :     const int16_t Diff_len,         /* i  : Lenght of the difference signal (before pure spectral)*/
    3421             :     const int16_t bits_used,        /* i  : Number of bit used before frequency Q                 */
    3422             :     int16_t *bit,                   /* i/o: Number of bit allowed for frequency quantization      */
    3423             :     float *ener_vec,                /* i/o: Quantized energy vector                               */
    3424             :     int16_t *max_ener_band,         /* o  : Sorted order                                          */
    3425             :     int16_t *bits_per_bands_s,      /* i/o: Number of bit allowed per allowed subband (Q3)        */
    3426             :     int16_t *nb_subbands,           /* o  : Number of subband allowed                             */
    3427             :     const float *exc_diff,          /* i  : Difference signal to quantize (encoder side only)     */
    3428             :     float *concat_in,               /* o  : Concatened PVQ's input vector (encoder side only)     */
    3429             :     int16_t *pvq_len,               /* o  : Number of bin covered with the PVQ                    */
    3430             :     const int16_t coder_type,       /* i  : coding type                                           */
    3431             :     const int16_t bwidth,           /* i  : input signal bandwidth                                */
    3432             :     const int16_t GSC_noisy_speech, /* i  : GSC noisy speech flag                                 */
    3433             :     const int16_t L_frame,          /* i  : frame length                                          */
    3434             :     const int16_t element_mode,     /* i  : element mode                                          */
    3435             :     const int16_t GSC_IVAS_mode     /* i  : GSC IVAS mode                                         */
    3436             : );
    3437             : 
    3438             : /*! r: average frequency gain */
    3439             : float gsc_gaindec(
    3440             :     Decoder_State *st,        /* i/o: decoder state structure                 */
    3441             :     float y_gainQ[],          /* o  : quantized gain per band                 */
    3442             :     const int32_t core_brate, /* i  : core used                               */
    3443             :     float old_y_gain[],       /* i/o: AR gain quantizer for low rate          */
    3444             :     const int16_t coder_type, /* i  : coding type                             */
    3445             :     const int16_t bwidth      /* i  : input signal bandwidth                  */
    3446             : );
    3447             : 
    3448             : void freq_dnw_scaling(
    3449             :     const int16_t cor_strong_limit, /* i  : HF correlation                          */
    3450             :     const int16_t coder_type,       /* i  : coder type                              */
    3451             :     const int16_t noise_lev,        /* i  : Noise level                             */
    3452             :     const int32_t core_brate,       /* i  : Core bitrate                            */
    3453             :     float fy_norm[],                /* i/o: Frequency quantized parameter           */
    3454             :     const int16_t L_frame           /* i  : frame length                            */
    3455             : );
    3456             : 
    3457             : void GSC_dec_init(
    3458             :     GSC_DEC_HANDLE hGSCDec /* i/o: GSC data handle                         */
    3459             : );
    3460             : 
    3461             : void decod_audio(
    3462             :     Decoder_State *st,                  /* i/o: decoder static memory                     */
    3463             :     float dct_epit[],                   /* o  : GSC excitation in DCT domain              */
    3464             :     const float *Aq,                    /* i  : LP filter coefficient                     */
    3465             :     float *tmp_noise,                   /* o  : long term temporary noise energy          */
    3466             :     float *pitch_buf,                   /* o  : floating pitch values for each subframe   */
    3467             :     float *voice_factors,               /* o  : voicing factors                           */
    3468             :     float *exc_dct_in,                  /* i/o: adapt. excitation exc                     */
    3469             :     float *exc2,                        /* i/o: adapt. excitation/total exc               */
    3470             :     float *bwe_exc,                     /* o  : excitation for SWB TBE                    */
    3471             :     float *lsf_new,                     /* i  : current frame ISF vector                  */
    3472             :     float *gain_buf,                    /* o  : floating pitch gain for each subframe     */
    3473             :     const int16_t tdm_lp_reuse_flag,    /* i  : LPC reuse flag                            */
    3474             :     const int16_t tdm_low_rate_mode,    /* i  : secondary channel low rate mode flag      */
    3475             :     const int16_t tdm_Pitch_reuse_flag, /* i  : primary channel pitch reuse flag          */
    3476             :     const float tdm_Pri_pitch_buf[]     /* i  : primary channel pitch buffer              */
    3477             : );
    3478             : 
    3479             : void gsc_dec(
    3480             :     Decoder_State *st,          /* i/o: State structure                           */
    3481             :     float exc_dct_in[],         /* i/o: dct of pitch-only/total excitation        */
    3482             :     const int16_t pit_band_idx, /* i  : pitch band index                          */
    3483             :     const int16_t Diff_len,     /* i  :  */
    3484             :     const int16_t bits_used,    /* i  : total number of bits used                 */
    3485             :     const int16_t nb_subfr,     /* i  : Number of subframe considered             */
    3486             :     const int16_t coder_type,   /* i  : coding type                               */
    3487             :     int16_t *last_bin,          /* i  : last bin of bit allocation                */
    3488             :     const float *lsf_new,       /* i  : ISFs at the end of the frame              */
    3489             :     float *exc_wo_nf,           /* o  : excitation (in f domain) without noisefill*/
    3490             :     float *tmp_noise            /* o  : long-term noise energy                    */
    3491             : );
    3492             : 
    3493             : void dec_pit_exc(
    3494             :     Decoder_State *st,                  /* i/o: decoder static memory                     */
    3495             :     const int16_t L_frame,              /* i  : length of the frame                       */
    3496             :     const float *Aq,                    /* i  : LP filter coefficient                     */
    3497             :     const float Es_pred,                /* i  : predicted scaled innov. energy            */
    3498             :     float *pitch_buf,                   /* o  : floating pitch values for each subframe   */
    3499             :     float *code,                        /* o  : innovation                                */
    3500             :     float *exc,                         /* i/o: adapt. excitation exc                     */
    3501             :     const int16_t nb_subfr,             /* i  : Number of subframe considered             */
    3502             :     float *gain_buf,                    /* o  : floating pitch gain for each subframe     */
    3503             :     const int16_t tdm_Pitch_reuse_flag, /* i  : primary channel pitch reuse flag          */
    3504             :     const float tdm_Pri_pitch_buf[]     /* i  : primary channel pitch buffer              */
    3505             : );
    3506             : 
    3507             : void highband_exc_dct_in(
    3508             :     const int32_t core_brate,         /* i  : core bitrate                                    */
    3509             :     const int16_t *mfreq_bindiv_loc,  /* i  : bin per bands tables                            */
    3510             :     int16_t last_bin,                 /* i  : last bin of bit allocation                      */
    3511             :     int16_t Diff_len,                 /* i  : number of bin before cut-off frequency          */
    3512             :     int16_t noise_lev,                /* i  : pulses dynamic                                  */
    3513             :     int16_t pit_band_idx,             /* i  : bin position of the cut-off frequency           */
    3514             :     float *exc_diffQ,                 /* i  : frequency coefficients of per band              */
    3515             :     int16_t *seed_tcx,                /* i  : Seed for noise                                  */
    3516             :     float *Ener_per_bd_iQ,            /* i  : Quantized energy of targeted vector             */
    3517             :     int16_t nb_subfr,                 /* i  : Number of subframe considered                   */
    3518             :     float *exc_dct_in,                /* o  : dct of residual signal                          */
    3519             :     int16_t last_coder_type,          /* i  : coding type of last frame                       */
    3520             :     int16_t *bitallocation_band,      /* i  : bit allocation flag of each band                */
    3521             :     const float *lsf_new,             /* i  : ISFs at the end of the frame                    */
    3522             :     float *last_exc_dct_in,           /* i  : dct of residual signal of last frame            */
    3523             :     float *last_ener,                 /* i  : frequency energy  of last frame                 */
    3524             :     int16_t *last_bitallocation_band, /* i  : bit allocation flag of each band  of last frame */
    3525             :     int16_t *bitallocation_exc,       /* i  : flag of decoded coefficients                    */
    3526             :     const int16_t bfi,                /* i  : bad frame indicator                             */
    3527             :     const int16_t coder_type,         /* i  : coder type                                      */
    3528             :     const int16_t bwidth,             /* i  : audio bandwidth                                 */
    3529             :     float *exc_wo_nf,                 /* o  : excitation (in f domain) without noisefill      */
    3530             :     const int16_t GSC_noisy_speech,   /* i  : GSC noisy speech flag                           */
    3531             :     float *lt_ener_per_band_fx,       /* i/o: Average per band energy                         */
    3532             :     const int16_t L_frame,            /* i  : frame length                                    */
    3533             :     const int16_t element_mode,       /* i  : IVAS element moden                              */
    3534             :     const int16_t GSC_IVAS_mode       /* i  : GSC IVAS mode                                   */
    3535             : );
    3536             : 
    3537             : void inact_switch_ematch(
    3538             :     float exc2[],                           /* i/o: CELP/GSC excitation buffer                  */
    3539             :     float dct_exc_tmp[],                    /* i  : GSC excitation in DCT domain                */
    3540             :     float lt_ener_per_band[],               /* i/o: long-term energy per band                   */
    3541             :     const int16_t coder_type,               /* i  : coder type                                  */
    3542             :     const int16_t inactive_coder_type_flag, /* i  : AVQ (0) or GSC (1) IC flag                  */
    3543             :     const int16_t L_frame,                  /* i  : frame length                                */
    3544             :     const int16_t bfi,                      /* i  : frame lost indicator                        */
    3545             :     const int16_t last_core,                /* i  : Last core used                              */
    3546             :     const int16_t last_codec_mode,          /* i  : Last codec mode                             */
    3547             :     const int16_t tdm_low_rate_mode,        /* i  : secondary channel low rate mode flag        */
    3548             :     const int16_t element_mode              /* i  : element mode                                */
    3549             : );
    3550             : 
    3551             : void music_postfilt_init(
    3552             :     MUSIC_POSTFILT_HANDLE hMusicPF /* i/o: LD music postfilter handle                  */
    3553             : );
    3554             : 
    3555             : void LD_music_post_filter(
    3556             :     MUSIC_POSTFILT_HANDLE hMusicPF, /* i/o: LD music postfilter handle                  */
    3557             :     const float dtc_in[],           /* i  : input synthesis                             */
    3558             :     float dtc_out[],                /* o  : output synthesis                            */
    3559             :     const int32_t core_brate,       /* i  : core bitrate                                */
    3560             :     const int16_t coder_type,       /* i  : Coder type : -1 in case of IO               */
    3561             :     const int16_t Last_coder_type   /* i  : last Coder type                             */
    3562             : );
    3563             : 
    3564             : void Post_music_postP(
    3565             :     float dct_buffer_in[],  /* i/o: excitation buffer                           */
    3566             :     float exc_buffer_out[], /* o  : DCT output buffer                           */
    3567             :     float *exc2,            /* i/o: Current excitation to be overwriten         */
    3568             :     const float *mem_tmp,   /* i  : previous frame synthesis memory             */
    3569             :     float *st_mem_syn2,     /* i/o: current frame synthesis memory              */
    3570             :     const float *Aq,        /* i  : LPC filter coefficients                     */
    3571             :     float *syn              /* i/o: 12k8 synthesis                              */
    3572             : );
    3573             : 
    3574             : void Prep_music_postP(
    3575             :     float exc_buffer_in[],   /* i/o: excitation buffer                           */
    3576             :     float dct_buffer_out[],  /* o  : DCT output buffer                           */
    3577             :     float filt_lfE[],        /* i/o: long term spectrum energy                   */
    3578             :     const int16_t last_core, /* i  : last core                                   */
    3579             :     const float *pitch_buf,  /* i  : current frame pitch information             */
    3580             :     float *LDm_enh_lp_gbin   /* o  : smoothed suppression gain, per bin FFT      */
    3581             : );
    3582             : 
    3583             : void speech_music_classif(
    3584             :     Encoder_State *st,             /* i/o: encoder state structure                         */
    3585             :     const float *new_inp,          /* i  : new input signal                                */
    3586             :     const float *inp,              /* i  : input signal to locate attach position          */
    3587             :     const int16_t localVAD_HE_SAD, /* i  : HE-SAD flag without hangover                    */
    3588             :     const float lsp_new[M],        /* i  : LSPs in current frame                           */
    3589             :     const float cor_map_sum,       /* i  : correlation map sum (from multi-harmonic anal.) */
    3590             :     const float epsP[M + 1],       /* i  : LP prediciton error                             */
    3591             :     const float PS[],              /* i  : energy spectrum                                 */
    3592             :     const float Etot,              /* i  : total frame energy                              */
    3593             :     const float old_cor,           /* i  : max correlation from previous frame             */
    3594             :     int16_t *attack_flag,          /* o  : attack flag (GSC or TC)                         */
    3595             :     const float non_staX,          /* i  : unbound non-stationarity for sp/mus classifier  */
    3596             :     const float relE,              /* i  : relative frame energy                           */
    3597             :     int16_t *high_lpn_flag,        /* o  : sp/mus LPN flag                                 */
    3598             :     const int16_t flag_spitch      /* i  : flag to indicate very short stable pitch        */
    3599             : );
    3600             : 
    3601             : void find_wsp(
    3602             :     const int16_t L_frame,  /* i  : length of the frame                         */
    3603             :     const int16_t L_subfr,  /* i  : length of subframe                          */
    3604             :     const int16_t nb_subfr, /* i  : number of subframes                         */
    3605             :     const float *A,         /* i  : A(z) filter coefficients                    */
    3606             :     float *Aw,              /* o  : weighted A(z) filter coefficients           */
    3607             :     const float *speech,    /* i  : pointer to the denoised speech frame        */
    3608             :     const float tilt_fact,  /* i  : tilt factor                                 */
    3609             :     float *wsp,             /* o  : poitnter to the weighted speech frame       */
    3610             :     float *mem_wsp,         /* i/o: W(Z) denominator memory                     */
    3611             :     const float gamma,      /* i  : weighting factor                            */
    3612             :     const int16_t L_look    /* i  : look-ahead                                  */
    3613             : );
    3614             : 
    3615             : void pitch_ol_init(
    3616             :     float *old_thres,   /* o  : threshold for reinforcement of past pitch influence */
    3617             :     int16_t *old_pitch, /* o  : pitch  of the 2nd half-frame of previous frame      */
    3618             :     int16_t *delta_pit, /* o  : pitch evolution extrapolation                       */
    3619             :     float *old_corr     /* o  : correlation                                         */
    3620             : );
    3621             : 
    3622             : void pitch_ol(
    3623             :     int16_t pitch[3],         /* o  : open loop pitch lag for each half-frame                        */
    3624             :     float voicing[3],         /* o  : maximum normalized correlation for each half-frame             */
    3625             :     int16_t *old_pitch,       /* i/o: OL pitch of the 2nd half-frame of the last frame               */
    3626             :     float *old_corr,          /* i/o: correlation                                                    */
    3627             :     float corr_shift,         /* i  : normalized correlation correction                              */
    3628             :     float *old_thres,         /* i/o: maximum correlation weighting with respect to past frame pitch */
    3629             :     int16_t *delta_pit,       /* i/o: old pitch extrapolation correction (added to old pitch)        */
    3630             :     float *st_old_wsp2,       /* i/o: weighted speech memory                                         */
    3631             :     const float *wsp,         /* i  : weighted speech for current frame and look-ahead               */
    3632             :     float mem_decim2[3],      /* i/o: wsp decimation filter memory                                   */
    3633             :     const float relE,         /* i  : relative frame energy                                          */
    3634             :     const int16_t L_look,     /* i  : look-ahead length                                              */
    3635             :     const int16_t last_class, /* i  : frame classification of last frame                             */
    3636             :     const int16_t bwidth,     /* i  : audio bandwidth                                                */
    3637             :     const int16_t Opt_SC_VBR  /* i  : SC-VBR flag                                                    */
    3638             : );
    3639             : 
    3640             : void pitch_ol2(
    3641             :     const int16_t pit_min,  /* i  : pit_min value                                                   */
    3642             :     const int16_t pitch_ol, /* i  : pitch to be improved                                            */
    3643             :     float *pitch_fr,        /* o  : adjusted 1/4 fractional pitch                                   */
    3644             :     float *voicing_fr,      /* o  : adjusted 1/4 fractional voicing                                 */
    3645             :     const int16_t pos,      /* i  : position in frame where to calculate the improv.                */
    3646             :     const float *wsp,       /* i  : weighted speech for current frame and look-ahead                */
    3647             :     const int16_t delta     /* i  : delta for pitch search                                          */
    3648             : );
    3649             : 
    3650             : void StableHighPitchDetect(
    3651             :     int16_t *flag_spitch,      /* o  : flag to indicate very short stable pitch                        */
    3652             :     int16_t pitch[],           /* i/o: OL pitch buffer                                                 */
    3653             :     const float voicing[],     /* i  : OL pitch gains                                                  */
    3654             :     const float Bin_E[],       /* i  : per bin log energy spectrum                                     */
    3655             :     const float wsp[],         /* i  : weighted speech                                                 */
    3656             :     const int16_t localVAD,    /* i  : local VAD flag                                                  */
    3657             :     float *voicing_sm,         /* i/o: smoothed open-loop pitch gains                                  */
    3658             :     float *voicing0_sm,        /* i/o: smoothed high pitch gains                                       */
    3659             :     float *LF_EnergyRatio_sm,  /* i/o: smoothed [0, 300Hz] relative peak energy                        */
    3660             :     int16_t *predecision_flag, /* i/o: predecision flag                                                */
    3661             :     float *diff_sm,            /* i/o: smoothed pitch frequency difference                             */
    3662             :     float *energy_sm           /* i/o: smoothed energy around pitch frequency                          */
    3663             : );
    3664             : 
    3665             : void pitchDoubling_det(
    3666             :     const float *wspeech,
    3667             :     int16_t *pitch_ol,
    3668             :     float *pitch_fr,
    3669             :     float *voicing_fr );
    3670             : 
    3671             : void gain_enc_amr_wb(
    3672             :     BSTR_ENC_HANDLE hBstr,    /* i/o: encoder bitstream handle                                        */
    3673             :     const float *xn,          /* i  : target vector                                                   */
    3674             :     const float *y1,          /* i  : zero-memory filtered adaptive excitation                        */
    3675             :     const float *y2,          /* i  : zero-memory filtered algebraic codebook excitation              */
    3676             :     const float *code,        /* i  : algebraic excitation                                            */
    3677             :     const int32_t core_brate, /* i  : core bitrate                                                    */
    3678             :     float *gain_pit,          /* i/o: Pitch gain / Quantized pitch gain                               */
    3679             :     float *gain_code,         /* o  : Quantized codebook gain                                         */
    3680             :     float *gain_inov,         /* o  : innovation gain                                                 */
    3681             :     float *norm_gain_code,    /* o  : norm. gain of the codebook excitation                           */
    3682             :     float *coeff,             /* i/o: correlations <y1,y1>, -2<xn,y1>,<y2,y2>, -2<xn,y2> and 2<y1,y2> */
    3683             :     const int16_t clip_gain,  /* i  : gain pitch clipping flag (1 = clipping)                         */
    3684             :     float *past_qua_en        /* i/o: gain quantization memory (4 words)                              */
    3685             : );
    3686             : 
    3687             : void gain_enc_lbr(
    3688             :     BSTR_ENC_HANDLE hBstr,      /* i/o: encoder bitstream handle                                        */
    3689             :     const int16_t gains_mode[], /* i  : gain bits                                                       */
    3690             :     const int16_t coder_type,   /* i  : coding type                                                     */
    3691             :     const int16_t i_subfr,      /* i  : subframe index                                                  */
    3692             :     const float *xn,            /* i  : target vector                                                   */
    3693             :     const float *y1,            /* i  : zero-memory filtered adaptive excitation                        */
    3694             :     const float *y2,            /* i  : zero-memory filtered algebraic codebook excitation              */
    3695             :     const float *code,          /* i  : algebraic excitation                                            */
    3696             :     float *gain_pit,            /* o  : quantized pitch gain                                            */
    3697             :     float *gain_code,           /* o  : quantized codebook gain                                         */
    3698             :     float *gain_inov,           /* o  : gain of the innovation (used for normalization)                 */
    3699             :     float *norm_gain_code,      /* o  : norm. gain of the codebook excitation                           */
    3700             :     float *g_corr,              /* i/o: correlations <y1,y1>, -2<xn,y1>,<y2,y2>, -2<xn,y2> and 2<y1,y2> */
    3701             :     float gains_mem[],          /* i/o: pitch gain and code gain from previous subframes                */
    3702             :     const int16_t clip_gain,    /* i  : gain pitch clipping flag (1 = clipping)                         */
    3703             :     const int16_t L_subfr       /* i  : subfr Lenght                                                    */
    3704             : );
    3705             : 
    3706             : void gain_enc_mless(
    3707             :     BSTR_ENC_HANDLE hBstr,      /* i/o: encoder bitstream handle                                        */
    3708             :     const int16_t gains_mode[], /* i  : gain bits                                                       */
    3709             :     const int16_t element_mode, /* i  : element mode                                                    */
    3710             :     const int16_t L_frame,      /* i  : length of the frame                                             */
    3711             :     const int16_t i_subfr,      /* i  : subframe index                                                  */
    3712             :     const int16_t tc_subfr,     /* i  : TC subframe index                                               */
    3713             :     const float *xn,            /* i  : target vector                                                   */
    3714             :     const float *y1,            /* i  : zero-memory filtered adaptive excitation                        */
    3715             :     const float *y2,            /* i  : zero-memory filtered algebraic codebook excitation              */
    3716             :     const float *code,          /* i  : algebraic excitation                                            */
    3717             :     const float Es_pred,        /* i  : predicted scaled innovation energy                              */
    3718             :     float *gain_pit,            /* o  : quantized pitch gain                                            */
    3719             :     float *gain_code,           /* o  : quantized codebook gain                                         */
    3720             :     float *gain_inov,           /* o  : innovation gain                                                 */
    3721             :     float *norm_gain_code,      /* o  : norm. gain of the codebook excitation                           */
    3722             :     float *coeff,               /* i/o: correlations <y1,y1>, -2<xn,y1>,<y2,y2>, -2<xn,y2> and 2<y1,y2> */
    3723             :     const int16_t clip_gain     /* i  : gain pitch clipping flag (1 = clipping)                         */
    3724             : );
    3725             : 
    3726             : void gain_enc_SQ(
    3727             :     BSTR_ENC_HANDLE hBstr,      /* i/o: encoder bitstream handle                                        */
    3728             :     const int16_t gains_mode[], /* i  : gain bits                                                       */
    3729             :     const int16_t i_subfr,      /* i  : subframe index                                                  */
    3730             :     const float *xn,            /* i  : target vector                                                   */
    3731             :     const float *yy1,           /* i  : zero-memory filtered adaptive excitation                        */
    3732             :     const float *y2,            /* i  : zero-memory filtered algebraic codebook excitation              */
    3733             :     const float *code,          /* i  : algebraic excitation                                            */
    3734             :     const float Es_pred,        /* i  : predicted scaled innovation energy                              */
    3735             :     float *gain_pit,            /* o  : quantized pitch gain                                            */
    3736             :     float *gain_code,           /* o  : quantized codebook gain                                         */
    3737             :     float *gain_inov,           /* o  : gain of the innovation (used for normalization)                 */
    3738             :     float *norm_gain_code,      /* o  : norm. gain of the codebook excitation                           */
    3739             :     float *g_corr,              /* i/o: correlations <y1,y1>, -2<xn,y1>,<y2,y2>, -2<xn,y2> and 2<y1,y2> */
    3740             :     const int16_t clip_gain     /* i  : gain pitch clipping flag (1 = clipping)                         */
    3741             : );
    3742             : 
    3743             : /*! r: Return index of quantization */
    3744             : int16_t gain_enc_gaus(
    3745             :     float *gain,          /* i/o: Code gain to quantize                       */
    3746             :     const int16_t bits,   /* i  : number of bits to quantize                  */
    3747             :     const float lowBound, /* i  : lower bound of quantizer (dB)               */
    3748             :     const float topBound  /* i  : upper bound of quantizer (dB)               */
    3749             : );
    3750             : 
    3751             : void E_corr_xy2(
    3752             :     const float xn[],     /* i  : target vector                               */
    3753             :     const float y1[],     /* i  : filtered excitation components 1            */
    3754             :     const float y2[],     /* i  : filtered excitation components 2            */
    3755             :     float g_corr[],       /* o  : correlations between x, y1, y2, y3, y4      */
    3756             :     const int16_t L_subfr /* i  : subframe size                               */
    3757             : );
    3758             : 
    3759             : /*! r: Floating pitch for each subframe */
    3760             : float pit_encode(
    3761             :     BSTR_ENC_HANDLE hBstr,              /* i/o: encoder bitstream handle                    */
    3762             :     const int16_t pitch_bits[],         /* i  : pitch bits                                  */
    3763             :     const int32_t core_brate,           /* i  : core bitrate                                */
    3764             :     const int16_t Opt_AMR_WB,           /* i  : flag indicating AMR-WB IO mode              */
    3765             :     const int16_t L_frame,              /* i  : length of the frame                         */
    3766             :     const int16_t coder_type,           /* i  : coding type                                 */
    3767             :     int16_t *limit_flag,                /* i/o: restrained(0) or extended(1) Q limits       */
    3768             :     const int16_t i_subfr,              /* i  : subframe index                              */
    3769             :     float *exc,                         /* i/o: pointer to excitation signal frame          */
    3770             :     const int16_t L_subfr,              /* i  : subframe length                             */
    3771             :     const int16_t *pitch,               /* i  : open loop pitch estimates in current frame  */
    3772             :     int16_t *T0_min,                    /* i/o: lower limit for close-loop search           */
    3773             :     int16_t *T0_max,                    /* i/o: higher limit for close-loop search          */
    3774             :     int16_t *T0,                        /* i/o: close loop integer pitch                    */
    3775             :     int16_t *T0_frac,                   /* i/o: close loop fractional part of the pitch     */
    3776             :     const float *h1,                    /* i  : weighted filter input response              */
    3777             :     const float *xn,                    /* i  : target vector                               */
    3778             :     const int16_t tdm_Pitch_reuse_flag, /* i  : primary channel pitch reuse flag            */
    3779             :     const float tdm_Pri_pitch_buf[]     /* i  : primary channel pitch buffer                */
    3780             : );
    3781             : 
    3782             : /*! r: coding type */
    3783             : int16_t find_uv(
    3784             :     Encoder_State *st,               /* i/o: encoder state structure                       */
    3785             :     const float *pitch_fr,           /* i  : pointer to adjusted fractional pitch (4 val.) */
    3786             :     const float *voicing_fr,         /* i  : refined correlation for each subframes        */
    3787             :     const float *speech,             /* i  : pointer to speech signal for E computation    */
    3788             :     const float *ee,                 /* i  : lf/hf Energy ratio for present frame          */
    3789             :     float *dE1X,                     /* o  : sudden energy increase for S/M classifier     */
    3790             :     const float corr_shift,          /* i  : normalized correlation correction in noise    */
    3791             :     const float relE,                /* i  : relative frame energy                         */
    3792             :     const float Etot,                /* i  : total energy                                  */
    3793             :     const float hp_E[],              /* i  : energy in HF                                  */
    3794             :     int16_t *flag_spitch,            /* i/o: flag to indicate very short stable pitch and high correlation */
    3795             :     const int16_t last_core_orig,    /* i  : original last core                            */
    3796             :     STEREO_CLASSIF_HANDLE hStereoClf /* i/o: stereo classifier structure                   */
    3797             : );
    3798             : 
    3799             : /*! r: classification for current frames */
    3800             : int16_t signal_clas(
    3801             :     Encoder_State *st,    /* i/o: encoder state structure                           */
    3802             :     const float *speech,  /* i  : pointer to speech signal for E computation        */
    3803             :     const float *ee,      /* i  : lf/hf E ration for 2 half-frames                  */
    3804             :     const float relE,     /* i  : frame relative E to the long term average         */
    3805             :     const int16_t L_look, /* i  : look-ahead                                        */
    3806             :     int16_t *clas_mod     /* o  : class flag for NOOP detection                     */
    3807             : );
    3808             : 
    3809             : void select_TC(
    3810             :     const int16_t codec_mode, /* i  : codec mode                                        */
    3811             :     const int16_t tc_cnt,     /* i  : TC frame counter                                  */
    3812             :     int16_t *coder_type,      /* i/o: coder type                                        */
    3813             :     const int16_t localVAD    /* i  : VAD without hangover                              */
    3814             : );
    3815             : 
    3816             : void coder_type_modif(
    3817             :     Encoder_State *st, /* i/o: encoder state structure                           */
    3818             :     const float relE   /* i  : frame relative E to the long term average         */
    3819             : );
    3820             : 
    3821             : void wb_vad_init(
    3822             :     VAD_HANDLE hVAD /* i/o: VAD data handle                            */
    3823             : );
    3824             : 
    3825             : int16_t dtx_hangover_addition(
    3826             :     Encoder_State *st,               /* i/o: encoder state structure                    */
    3827             :     const int16_t vad_flag,          /* i  : VAD flag                                   */
    3828             :     const float snr,                 /* i  : input single SNR estimate                  */
    3829             :     const int16_t cldfb_subtraction, /* i  :                                            */
    3830             :     int16_t *vad_hover_flag,         /* o  : VAD hangover flag                          */
    3831             :     VAD_HANDLE hVAD,                 /* i/o: VAD handle for L or R channel              */
    3832             :     NOISE_EST_HANDLE hNoiseEst,      /* i  : Noise estimation handle                    */
    3833             :     int16_t *rem_dtx_ho              /* o  : Expected remaining hangover frames         */
    3834             : );
    3835             : 
    3836             : int16_t wb_vad(
    3837             :     Encoder_State *st,              /* i/o: encoder state structure                    */
    3838             :     const float fr_bands[],         /* i  : per band input energy (contains 2 vectors) */
    3839             :     int16_t *noisy_speech_HO,       /* o  : SC-VBR noisy speech HO flag                */
    3840             :     int16_t *clean_speech_HO,       /* o  : SC-VBR clean speech HO flag                */
    3841             :     int16_t *NB_speech_HO,          /* o  : SC-VBR NB speech HO flag                   */
    3842             :     float *snr_sum_he,              /* i  : voicing metric from SAD                    */
    3843             :     int16_t *localVAD_HE_SAD,       /* o  : HE_SAD decision without hangovers          */
    3844             :     int16_t *flag_noisy_speech_snr, /* o  :                                            */
    3845             :     VAD_HANDLE hVAD,                /* i/o: VAD handle                                 */
    3846             :     NOISE_EST_HANDLE hNoiseEst,     /* i/o: Noise estimation handle                    */
    3847             :     float lp_speech,                /* i  : long term active speech energy average     */
    3848             :     float lp_noise                  /* i  : long term noise energy                     */
    3849             : );
    3850             : 
    3851             : void bw_detect(
    3852             :     Encoder_State *st,             /* i/o: Encoder State                               */
    3853             :     const float signal_in[],       /* i  : input signal                                */
    3854             :     float *spectrum,               /* i  : MDCT spectrum                               */
    3855             :     const float *enerBuffer,       /* i  : energy buffer                               */
    3856             :     const IVAS_FORMAT ivas_format, /* i  : IVAS format                                 */
    3857             :     const int16_t mct_on           /* i  : flag MCT mode                               */
    3858             : );
    3859             : 
    3860             : void set_bw(
    3861             :     const int16_t element_mode,  /* i  : element mode                                */
    3862             :     const int32_t element_brate, /* i  : element bitrate                             */
    3863             :     Encoder_State *st,           /* i/o: Encoder State                               */
    3864             :     const int16_t codec_mode     /* i  : codec mode                                  */
    3865             : );
    3866             : 
    3867             : float gaus_encode(
    3868             :     Encoder_State *st,     /* i/o: encoder state structure                     */
    3869             :     const int16_t i_subfr, /* i  : subframe index                              */
    3870             :     const float *h1,       /* i  : weighted filter input response              */
    3871             :     const float *xn,       /* i  : target vector                               */
    3872             :     float *exc,            /* o  : pointer to excitation signal frame          */
    3873             :     float *mem_w0,         /* o  : weighting filter denominator memory         */
    3874             :     float *gp_clip_mem,    /* o  : memory of gain of pitch clipping algorithm  */
    3875             :     float *tilt_code,      /* o  : synthesis excitation spectrum tilt          */
    3876             :     float *code,           /* o  : algebraic excitation                        */
    3877             :     float *gain_code,      /* o  : Code gain.                                  */
    3878             :     float *y2,             /* o  : zero-memory filtered adaptive excitation    */
    3879             :     float *gain_inov,      /* o  : innovation gain                             */
    3880             :     float *voice_fac,      /* o  : voicing factor                              */
    3881             :     float *gain_pit,       /* o  : adaptive excitation gain                    */
    3882             :     float *norm_gain_code  /* o  : normalized innovative cb. gain              */
    3883             : );
    3884             : 
    3885             : void td_cng_enc_init(
    3886             :     TD_CNG_ENC_HANDLE hTdCngEnc, /* i/o: DTX/TD CNG data handle                      */
    3887             :     const int16_t Opt_DTX_ON,    /* i  : flag indicating DTX operation               */
    3888             :     const int16_t max_bwidth     /* i  : maximum encoded bandwidth                   */
    3889             : );
    3890             : 
    3891             : void dtx(
    3892             :     Encoder_State *st,                   /* i/o: encoder state structure                     */
    3893             :     const int32_t last_ivas_total_brate, /* i  : last IVAS total bitrate                */
    3894             :     const int32_t ivas_total_brate,      /* i  : IVAS total bitrate                          */
    3895             :     const int16_t vad,                   /* i  : VAD flag for DTX                            */
    3896             :     const float speech[]                 /* i  : Pointer to the speech frame                 */
    3897             : );
    3898             : 
    3899             : void dtx_hangover_control(
    3900             :     Encoder_State *st,     /* i/o: encoder state structure                     */
    3901             :     const float lsp_new[M] /* i  : current frame LSPs                          */
    3902             : );
    3903             : 
    3904             : void updt_enc(
    3905             :     Encoder_State *st,       /* i/o: state structure                             */
    3906             :     const float *old_exc,    /* i  : buffer of excitation                        */
    3907             :     const float *pitch_buf,  /* i  : Floating pitch   for each subframe          */
    3908             :     const float Es_pred,     /* i  : predicited scaled innovation energy         */
    3909             :     const float *Aq,         /* i  : A(z) quantized for all subframes            */
    3910             :     const float *lsf_new,    /* i  : current frame LSF vector                    */
    3911             :     const float *lsp_new,    /* i  : current frame LSP vector                    */
    3912             :     const float *old_bwe_exc /* o  : buffer of excitation for SWB TBE            */
    3913             : );
    3914             : 
    3915             : void updt_enc_common(
    3916             :     Encoder_State *st /* i/o: encoder state structure                     */
    3917             : );
    3918             : 
    3919             : void updt_IO_switch_enc(
    3920             :     Encoder_State *st,        /* i/o: state structure                             */
    3921             :     const int16_t input_frame /* i  : input frame length                          */
    3922             : );
    3923             : 
    3924             : void transition_enc(
    3925             :     Encoder_State *st,     /* i/o: encoder state structure                     */
    3926             :     const int16_t i_subfr, /* i  : subframe index                              */
    3927             :     int16_t *tc_subfr,     /* i/o: TC subframe index                           */
    3928             :     int16_t *Jopt_flag,    /* i  : joint optimization flag                     */
    3929             :     int16_t *position,     /* i/o: maximum of residual signal index            */
    3930             :     int16_t *T0,           /* i/o: close loop integer pitch                    */
    3931             :     int16_t *T0_frac,      /* i/o: close loop fractional part of the pitch     */
    3932             :     int16_t *T0_min,       /* i/o: lower limit for close-loop search           */
    3933             :     int16_t *T0_max,       /* i/o: higher limit for close-loop search          */
    3934             :     float *exc,            /* i/o: pointer to excitation signal frame          */
    3935             :     float *y1,             /* o  : zero-memory filtered adaptive excitation    */
    3936             :     const float *h1,       /* i  : weighted filter input response              */
    3937             :     const float *xn,       /* i  : target vector                               */
    3938             :     float *xn2,            /* o  : target vector for innovation search         */
    3939             :     float *gp_cl,          /* i/o: memory of gain of pitch clipping algorithm  */
    3940             :     float *gain_pit,       /* o  : adaptive excitation gain                    */
    3941             :     float *g_corr,         /* o  : ACELP correlation values                    */
    3942             :     int16_t *clip_gain,    /* i/o: adaptive gain clipping flag                 */
    3943             :     float **pt_pitch,      /* o  : floating pitch values                       */
    3944             :     float *bwe_exc,        /* i/o: excitation for SWB TBE                      */
    3945             :     int16_t *unbits        /* i/o: unused bits                                 */
    3946             : );
    3947             : 
    3948             : void tc_classif_enc(
    3949             :     const int16_t L_frame,     /* i  : length of the frame                           */
    3950             :     int16_t *tc_subfr,         /* i/o: TC subframe index                             */
    3951             :     int16_t *position,         /* i/o: maximum of residual signal index              */
    3952             :     const int16_t attack_flag, /* i  : attack flag                                   */
    3953             :     const int16_t pitch,       /* i  : open loop pitch estimates for first halfframe */
    3954             :     const float *res           /* i  : pointer to the LP residual signal frame       */
    3955             : );
    3956             : 
    3957             : void set_impulse(
    3958             :     const float xn[],     /* i  : target signal                                   */
    3959             :     const float h_orig[], /* i  : impulse response of weighted synthesis filter   */
    3960             :     float exc[],          /* o  : adaptive codebook excitation                    */
    3961             :     float y1[],           /* o  : filtered adaptive codebook excitation           */
    3962             :     int16_t *imp_shape,   /* o  : adaptive codebook index                         */
    3963             :     int16_t *imp_pos,     /* o  : position of the glottal impulse center index    */
    3964             :     float *gain_trans     /* o  : transition gain                                 */
    3965             : );
    3966             : 
    3967             : void gain_enc_tc(
    3968             :     BSTR_ENC_HANDLE hBstr,      /* i/o: encoder bitstream handle                                */
    3969             :     const int16_t gains_mode[], /* i  : gain bits                                               */
    3970             :     const int16_t i_subfr,      /* i  : subframe index                                          */
    3971             :     const float xn[],           /* i  : target vector                                           */
    3972             :     const float y2[],           /* i  : zero-memory filtered algebraic codebook excitation      */
    3973             :     const float code[],         /* i  : algebraic excitation                                    */
    3974             :     const float Es_pred,        /* i  : predicted scaled innovation energy                      */
    3975             :     float *gain_pit,            /* o  : pitch gain / Quantized pitch gain                       */
    3976             :     float *gain_code,           /* o  : quantized codebook gain                                 */
    3977             :     float *gain_inov,           /* o  : innovation gain                                         */
    3978             :     float *norm_gain_code       /* o  : norm. gain of the codebook excitation                   */
    3979             : );
    3980             : 
    3981             : /*! r: pitch gain  (0..GAIN_PIT_MAX) */
    3982             : float corr_xy1(
    3983             :     const float xn[],       /* i  : target signal                               */
    3984             :     const float y1[],       /* i  : filtered adaptive codebook excitation       */
    3985             :     float g_corr[],         /* o  : correlations <y1,y1>  and -2<xn,y1>         */
    3986             :     const int16_t L_subfr,  /* i  : subframe length                             */
    3987             :     const int16_t norm_flag /* i  : flag for constraining pitch contribution    */
    3988             : );
    3989             : 
    3990             : void norm_corr(
    3991             :     const float exc[],    /* i  : excitation buffer                          */
    3992             :     const float xn[],     /* i  : target signal                              */
    3993             :     const float h[],      /* i  : weighted synthesis filter impulse response */
    3994             :     const int16_t t_min,  /* i  : minimum value of searched range            */
    3995             :     const int16_t t_max,  /* i  : maximum value of searched range            */
    3996             :     float corr_norm[],    /* o  : normalized correlation                     */
    3997             :     const int16_t L_subfr /* i  : subframe size                              */
    3998             : );
    3999             : 
    4000             : /*! r: chosen integer pitch lag */
    4001             : int16_t pitch_fr4(
    4002             :     const float exc[],        /* i  : excitation buffer                          */
    4003             :     const float xn[],         /* i  : target signal                              */
    4004             :     const float h[],          /* i  : weighted synthesis filter impulse response */
    4005             :     const int16_t t0_min,     /* i  : minimum value in the searched range.       */
    4006             :     const int16_t t0_max,     /* i  : maximum value in the searched range.       */
    4007             :     int16_t *pit_frac,        /* o  : chosen fraction (0, 1, 2 or 3)             */
    4008             :     const int16_t i_subfr,    /* i  : flag to first subframe                     */
    4009             :     const int16_t limit_flag, /* i  : flag for limits (0=restrained, 1=extended) */
    4010             :     const int16_t t0_fr2,     /* i  : minimum value for resolution 1/2           */
    4011             :     const int16_t t0_fr1,     /* i  : minimum value for resolution 1             */
    4012             :     const int16_t L_frame,    /* i  : length of the frame                        */
    4013             :     const int16_t L_subfr     /* i  : size of subframe                           */
    4014             : );
    4015             : 
    4016             : void pit_Q_enc(
    4017             :     BSTR_ENC_HANDLE hBstr,    /* i/o: encoder bitstream handle                */
    4018             :     const int16_t Opt_AMR_WB, /* i  : flag indicating AMR-WB IO mode          */
    4019             :     const int16_t nBits,      /* i  : # of Q bits                             */
    4020             :     const int16_t delta,      /* i  : Half the CL searched interval           */
    4021             :     const int16_t pit_flag,   /* i  : absolute(0) or delta(1) pitch Q         */
    4022             :     const int16_t limit_flag, /* i  : restrained(0) or extended(1) Q limits   */
    4023             :     const int16_t T0,         /* i  : integer pitch lag                       */
    4024             :     const int16_t T0_frac,    /* i  : pitch fraction                          */
    4025             :     int16_t *T0_min,          /* i/o: delta search min                        */
    4026             :     int16_t *T0_max           /* o  : delta search max                        */
    4027             : );
    4028             : 
    4029             : void pit16k_Q_enc(
    4030             :     BSTR_ENC_HANDLE hBstr,    /* i/o: encoder bitstream handle                */
    4031             :     const int16_t nBits,      /* i  : # of Q bits                             */
    4032             :     const int16_t limit_flag, /* i  : restrained(0) or extended(1) Q limits   */
    4033             :     const int16_t T0,         /* i  : integer pitch lag                       */
    4034             :     const int16_t T0_frac,    /* i  : pitch fraction                          */
    4035             :     int16_t *T0_min,          /* i/o: delta search min                        */
    4036             :     int16_t *T0_max           /* o  : delta search max                        */
    4037             : );
    4038             : 
    4039             : /*! r: pitch index */
    4040             : int16_t abs_pit_enc(
    4041             :     const int16_t fr_steps,   /* i  : fractional resolution step              */
    4042             :     const int16_t limit_flag, /* i  : restrained(0) or extended(1) limits     */
    4043             :     const int16_t T0,         /* i  : integer pitch lag                       */
    4044             :     const int16_t T0_frac     /* i  : pitch fraction                          */
    4045             : );
    4046             : 
    4047             : /*! r: pitch index */
    4048             : int16_t delta_pit_enc(
    4049             :     const int16_t fr_steps, /* i  : fractional resolution steps (2 or 4)    */
    4050             :     const int16_t T0,       /* i  : integer pitch lag                       */
    4051             :     const int16_t T0_frac,  /* i  : pitch fraction                          */
    4052             :     const int16_t T0_min    /* i  : delta search min                        */
    4053             : );
    4054             : 
    4055             : /*! r: comfort noise gain factor */
    4056             : float AVQ_cod(
    4057             :     const float xri[],     /* i  : vector to quantize                      */
    4058             :     int16_t xriq[],        /* o  : quantized normalized vector (assuming the bit budget is enough) */
    4059             :     const int16_t nb_bits, /* i  : number of allocated bits                */
    4060             :     const int16_t Nsv      /* i  : number of subvectors (lg=Nsv*8)         */
    4061             : );
    4062             : 
    4063             : void AVQ_encmux(
    4064             :     BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle                        */
    4065             :     const int16_t extl,    /* i  : extension layer                                 */
    4066             :     int16_t xriq[],        /* i/o: rounded subvectors [0..8*Nsv-1] followed by rounded bit allocations [8*Nsv..8*Nsv+Nsv-1] */
    4067             :     int16_t *nb_bits,      /* i/o: number of allocated bits                        */
    4068             :     const int16_t Nsv,     /* i  : number of subvectors                            */
    4069             :     int16_t nq[],          /* o  : AVQ nq index                                    */
    4070             :     int16_t avq_bit_sFlag, /* i  : flag indicating AVQ bit savings                 */
    4071             :     int16_t trgtSvPos      /* i  : target SV for AVQ bit savings                   */
    4072             : );
    4073             : 
    4074             : void ordr_esti(
    4075             :     const int16_t k,   /* i  : sub-vector index                         */
    4076             :     int16_t *Mpos,     /* i/o: dominant sub-vector position from ACV    */
    4077             :     int16_t svOrder[], /* i/o: AVQ sub-vector order                     */
    4078             :     const int16_t Nsv  /* i  : total sub-vectors in a sub-frames        */
    4079             : );
    4080             : 
    4081             : void re8_cod(
    4082             :     int16_t x[], /* i  : point in RE8 (8-dimensional integer vector)                         */
    4083             :     int16_t *n,  /* i  : codebook number (*n is an integer defined in {0,2,3,4,..,n_max})    */
    4084             :     uint16_t *I, /* o  : index of c (pointer to unsigned 16-bit word)                        */
    4085             :     int16_t k[]  /* o  : index of v (8-dimensional vector of binary indices) = Voronoi index */
    4086             : );
    4087             : 
    4088             : void pre_exc(
    4089             :     const int16_t Opt_AMR_WB, /* i  : flag indicating AMR-WB IO mode                       */
    4090             :     const int16_t L_frame,    /* i  : frame length                                         */
    4091             :     const float *speech,      /* i  : input speech                                         */
    4092             :     const float *p_Aq,        /* i  : 12k8 Lp coefficient                                  */
    4093             :     const float *p_A,         /* i  : unquantized A(q) filter with bandwidth expansion     */
    4094             :     const int16_t coder_type, /* i  : coding type                                          */
    4095             :     const int16_t i_subfr,    /* i  : current sub frame indicator                          */
    4096             :     float *Ap,                /* o  : weighted LP filter coefficients                      */
    4097             :     const float *res,         /* i  : residual signal                                      */
    4098             :     float *h1,                /* o  : impulse response of weighted synthesis filter        */
    4099             :     float *xn,                /* o  : close-loop Pitch search target vector                */
    4100             :     float *cn,                /* o  : target vector in residual domain                     */
    4101             :     float *mem_syn,           /* i/o: memory of the synthesis filter                       */
    4102             :     float *mem_w0,            /* i/o: weighting filter denominator memory                  */
    4103             :     const int16_t L_subfr     /* i  : subframe length                                      */
    4104             : );
    4105             : 
    4106             : void encod_unvoiced(
    4107             :     Encoder_State *st,               /* i/o: state structure                                 */
    4108             :     const float *speech,             /* i  : input speech                                    */
    4109             :     const float Aw[],                /* i  : weighted A(z) unquantized for subframes         */
    4110             :     const float *Aq,                 /* i  : LP coefficients                                 */
    4111             :     const float Es_pred,             /* i  : predicted scaled innov. energy                  */
    4112             :     const int16_t uc_two_stage_flag, /* i  : flag indicating two-stage UC                    */
    4113             :     const float *res,                /* i  : residual signal                                 */
    4114             :     float *syn,                      /* o  : core synthesis                                  */
    4115             :     float *tmp_noise,                /* o  : long-term noise energy                          */
    4116             :     float *exc,                      /* i/o: current non-enhanced excitation                 */
    4117             :     float *pitch_buf,                /* o  : floating pitch values for each subframe         */
    4118             :     float *voice_factors,            /* o  : voicing factors                                 */
    4119             :     float *bwe_exc                   /* i/o: excitation for SWB TBE                          */
    4120             : );
    4121             : 
    4122             : void encod_gen_voic(
    4123             :     Encoder_State *st,                  /* i/o: state structure                                 */
    4124             :     const float speech[],               /* i  : input speech                                    */
    4125             :     const float Aw[],                   /* i  : weighted A(z) unquantized for subframes         */
    4126             :     const float Aq[],                   /* i  : LP coefficients                                 */
    4127             :     const float Es_pred,                /* i  : predicted scaled innov. energy                  */
    4128             :     const float *res,                   /* i  : residual signal                                 */
    4129             :     float *syn,                         /* o  : core synthesis                                  */
    4130             :     float *exc,                         /* i/o: current non-enhanced excitation                 */
    4131             :     float *exc2,                        /* i/o: current enhanced excitation                     */
    4132             :     float *pitch_buf,                   /* o  : floating pitch values for each subframe         */
    4133             :     float *voice_factors,               /* o  : voicing factors                                 */
    4134             :     float *bwe_exc,                     /* i/o: excitation for SWB TBE                          */
    4135             :     int16_t *unbits,                    /* i/o: number of unused bits                           */
    4136             :     const int16_t tdm_Pitch_reuse_flag, /* i  : primary channel pitch reuse flag                */
    4137             :     const float tdm_Pri_pitch_buf[]     /* i  : primary channel pitch buffer                    */
    4138             : );
    4139             : 
    4140             : int16_t encod_tran(
    4141             :     Encoder_State *st,    /* i/o: state structure                                 */
    4142             :     const float speech[], /* i  : input speech                                    */
    4143             :     const float Aw[],     /* i  : weighted A(z) unquantized for subframes         */
    4144             :     const float Aq[],     /* i  : LP coefficients                                 */
    4145             :     const float Es_pred,  /* i  : predicted scaled innov. energy                  */
    4146             :     const float *res,     /* i  : residual signal                                 */
    4147             :     float *syn,           /* o  : synthesis                                       */
    4148             :     float *exc,           /* i/o: current non-enhanced excitation                 */
    4149             :     float *exc2,          /* i/o: current enhanced excitation                     */
    4150             :     float *pitch_buf,     /* o  : floating pitch values for each subframe         */
    4151             :     float *voice_factors, /* o  : voicing factors                                 */
    4152             :     float *bwe_exc,       /* i/o: excitation for SWB TBE                          */
    4153             :     int16_t tc_subfr,     /* i/o: TC subframe classification                      */
    4154             :     int16_t position,     /* i  : maximum of residual signal index                */
    4155             :     int16_t *unbits       /* i/o: number of unused bits                           */
    4156             : );
    4157             : 
    4158             : void encod_amr_wb(
    4159             :     Encoder_State *st,         /* i/o: state structure                                 */
    4160             :     const float speech[],      /* i  : input speech                                    */
    4161             :     const float Aw[],          /* i  : weighted A(z) unquantized for subframes         */
    4162             :     const float Aq[],          /* i  : 12k8 Lp coefficient                             */
    4163             :     const float *res,          /* i  : residual signal                                 */
    4164             :     float *syn,                /* i/o: core synthesis                                  */
    4165             :     float *exc,                /* i/o: current non-enhanced excitation                 */
    4166             :     float *exc2,               /* i/o: current enhanced excitation                     */
    4167             :     float *pitch_buf,          /* i/o: floating pitch values for each subframe         */
    4168             :     int16_t hf_gain[NB_SUBFR], /* o  : decoded HF gain                                 */
    4169             :     const float *speech16k     /* i  : input speech @16kHz                             */
    4170             : );
    4171             : 
    4172             : void stat_noise_uv_enc(
    4173             :     Encoder_State *st,              /* i/o: state structure                      */
    4174             :     const float *epsP,              /* i  : LP prediction errors                 */
    4175             :     const float *isp_new,           /* i  : immittance spectral pairs at 4th sfr */
    4176             :     const float *isp_mid,           /* i  : immittance spectral pairs at 2nd sfr */
    4177             :     float *Aq,                      /* i/o: A(z) quantized for the 4 subframes   */
    4178             :     float *exc2,                    /* i/o: excitation buffer                    */
    4179             :     const int16_t uc_two_stage_flag /* o  : flag undicating two-stage UC         */
    4180             : );
    4181             : 
    4182             : void re8_compute_base_index(
    4183             :     const int16_t *x, /* i  : Elemen of Q2, Q3 or Q4                          */
    4184             :     const int16_t ka, /* i  : Identifier of the absolute leader related to x  */
    4185             :     uint16_t *I       /* o  : index                                           */
    4186             : );
    4187             : 
    4188             : void transf_cdbk_enc(
    4189             :     Encoder_State *st,             /* i/o: encoder state structure                     */
    4190             :     const int16_t harm_flag_acelp, /* i  : harmonic flag for higher rates ACELP        */
    4191             :     const int16_t i_subfr,         /* i  : subframe index                              */
    4192             :     float cn[],                    /* i/o: target vector in residual domain            */
    4193             :     float exc[],                   /* i/o: pointer to excitation signal frame          */
    4194             :     const float *p_Aq,             /* i  : 12k8 Lp coefficient                         */
    4195             :     const float Ap[],              /* i  : weighted LP filter coefficients             */
    4196             :     const float h1[],              /* i  : weighted filter input response              */
    4197             :     float xn[],                    /* i/o: target vector                               */
    4198             :     float xn2[],                   /* i/o: target vector for innovation search         */
    4199             :     float y1[],                    /* i/o: zero-memory filtered adaptive excitation    */
    4200             :     const float y2[],              /* i  : zero-memory filtered innovative excitation  */
    4201             :     const float Es_pred,           /* i  : predicited scaled innovation energy         */
    4202             :     float *gain_pit,               /* i/o: adaptive excitation gain                    */
    4203             :     const float gain_code,         /* i  : innovative excitation gain                  */
    4204             :     float g_corr[],                /* o  : ACELP correlation values                    */
    4205             :     const int16_t clip_gain,       /* i  : adaptive gain clipping flag                 */
    4206             :     float *gain_preQ,              /* o  : prequantizer excitation gain                */
    4207             :     float code_preQ[],             /* o  : prequantizer excitation                     */
    4208             :     int16_t *unbits                /* i/o: number of AVQ unused bits                   */
    4209             : );
    4210             : 
    4211             : /*! r: quantization index */
    4212             : int16_t gain_quant(
    4213             :     float *gain,         /* i/o: quantized gain                              */
    4214             :     const float min_val, /* i  : value of lower limit                        */
    4215             :     const float max_val, /* i  : value of upper limit                        */
    4216             :     const int16_t bits   /* i  : number of bits to quantize                  */
    4217             : );
    4218             : 
    4219             : void deemph_lpc(
    4220             :     float *p_Aq_cuerr,  /* i  : LP coefficients current frame               */
    4221             :     float *p_Aq_old,    /* i  : LP coefficients previous frame              */
    4222             :     float *LPC_de_curr, /* o  : De-emphasized LP coefficients current frame */
    4223             :     float *LPC_de_old,  /* o  : De-emphasized LP coefficients previous frame*/
    4224             :     const int16_t deemph_old );
    4225             : 
    4226             : void Interpol_delay(
    4227             :     float *out,       /* o  : pitch interpolation output                  */
    4228             :     float *last,      /* i  : last frame pitch lag                        */
    4229             :     float *current,   /* i  : current frame pitch lag                     */
    4230             :     int16_t SubNum,   /* i  : subframe number                             */
    4231             :     const float *frac /* i  : interpolation constant                      */
    4232             : );
    4233             : 
    4234             : void dequantize_uvg(
    4235             :     int16_t iG1,         /* i  : gain 1 index                                */
    4236             :     int16_t *iG2,        /* i  : gain 2 index                                */
    4237             :     float *G,            /* o  : quantized gain                              */
    4238             :     const int16_t bwidth /* i  : audio bandwidth                             */
    4239             : );
    4240             : 
    4241             : void generate_nelp_excitation(
    4242             :     int16_t *seed, /* i/o: random number seed                          */
    4243             :     float *Gains,  /* i  : excitation gains                            */
    4244             :     float *output, /* o  : excitation output                           */
    4245             :     float gain_fac /* i  : gain factor                                 */
    4246             : );
    4247             : 
    4248             : void nelp_encoder(
    4249             :     Encoder_State *st, /* i/o: encoder state                               */
    4250             :     float *in,         /* i  : residual signal                             */
    4251             :     float *exc,        /* o  : NELP quantized excitation signal            */
    4252             :     const int16_t reduce_gains );
    4253             : 
    4254             : void encod_nelp(
    4255             :     Encoder_State *st,    /* i/o: state structure                             */
    4256             :     const float *speech,  /* i  : input speech                                */
    4257             :     const float Aw[],     /* i  : weighted A(z) unquantized for subframes     */
    4258             :     const float *Aq,      /* i  : 12k8 Lp coefficient                         */
    4259             :     float *res,           /* o  : residual signal                             */
    4260             :     float *synth,         /* o  : core synthesis                              */
    4261             :     float *tmp_noise,     /* o  : long-term noise energy                      */
    4262             :     float *exc,           /* i/o: current non-enhanced excitation             */
    4263             :     float *exc2,          /* i/o: current enhanced excitation                 */
    4264             :     float *pitch_buf,     /* o  : floating pitch values for each subframe     */
    4265             :     float *voice_factors, /* o  : voicing factors                             */
    4266             :     float *bwe_exc        /* o  : excitation for SWB TBE                      */
    4267             : );
    4268             : 
    4269             : void realft(
    4270             :     float *data,  /* i/o: data array                                  */
    4271             :     int16_t n,    /* i  : length of data array                        */
    4272             :     int16_t isign /* i  : sign +1 or -1                               */
    4273             : );
    4274             : 
    4275             : ivas_error DTFS_new(
    4276             :     DTFS_STRUCTURE **dtfs_out );
    4277             : 
    4278             : void DTFS_copy(
    4279             :     DTFS_STRUCTURE *Xout, /* o  : DTFS                                        */
    4280             :     DTFS_STRUCTURE Xinp   /* i  : DTFS                                        */
    4281             : );
    4282             : 
    4283             : void DTFS_sub(
    4284             :     DTFS_STRUCTURE *tmp, /* o  : output DFTS                                 */
    4285             :     DTFS_STRUCTURE X1,   /* i  : DTFS input 1                                */
    4286             :     DTFS_STRUCTURE X2    /* i  : DTFS input 2                                */
    4287             : );
    4288             : 
    4289             : void DTFS_to_fs(
    4290             :     const float *x,    /* i  : Time domain signal                          */
    4291             :     const int16_t N,   /* i  : Length of input vector                      */
    4292             :     DTFS_STRUCTURE *X, /* o  : DTFS structure with a, b, lag               */
    4293             :     const int32_t sampling_rate,
    4294             :     const int16_t FR_flag /* i  : FR flag                                     */
    4295             : );
    4296             : 
    4297             : void DTFS_fs_inv(
    4298             :     DTFS_STRUCTURE *X, /* i  : DTFS                                         */
    4299             :     float *x,          /* o  : time domain sig                              */
    4300             :     const int16_t N,   /* i  : Output length                                */
    4301             :     float ph0          /* i  : Input phase                                  */
    4302             : );
    4303             : 
    4304             : void DTFS_car2pol(
    4305             :     DTFS_STRUCTURE *X /* i/o: DTFS structure a, b, lag                    */
    4306             :                       /* input in Cartesion, output in Polar              */
    4307             : );
    4308             : 
    4309             : void DTFS_pol2car(
    4310             :     DTFS_STRUCTURE *X /* i/o: DTFS structure a, b, lag                   */
    4311             :                       /* input in Polar, output in Cartesian             */
    4312             : );
    4313             : 
    4314             : /*! r: Return Input RMS between f1/f2 b4 scaling */
    4315             : float DTFS_setEngyHarm(
    4316             :     float f1,         /* i  : lower band freq of input to control energy  */
    4317             :     float f2,         /* i  : upper band freq of input to control energy  */
    4318             :     float g1,         /* i  : lower band freq of output to control energy */
    4319             :     float g2,         /* i  : upper band freq of output to control energy */
    4320             :     float en2,        /* i  : Target Energy to set the DTFS to            */
    4321             :     DTFS_STRUCTURE *X /* i/o: DTFS to adjust the energy of                */
    4322             : );
    4323             : 
    4324             : void DTFS_to_erb(
    4325             :     DTFS_STRUCTURE X, /* i  : DTFS input                             */
    4326             :     float *out        /* o  : ERB output                             */
    4327             : );
    4328             : 
    4329             : void DTFS_zeroPadd(
    4330             :     const int16_t N,  /* i  : Target lag                            */
    4331             :     DTFS_STRUCTURE *X /* i/o: DTFS                                  */
    4332             : );
    4333             : 
    4334             : /*! r: Energy */
    4335             : float DTFS_getEngy(
    4336             :     DTFS_STRUCTURE X /* i  : DTFS to compute energy of              */
    4337             : );
    4338             : 
    4339             : void DTFS_adjustLag(
    4340             :     DTFS_STRUCTURE *X_DTFS, /* i/o: DTFS to adjust lag for                */
    4341             :     const int16_t N         /* i  : Target lag                            */
    4342             : );
    4343             : 
    4344             : void DTFS_poleFilter(
    4345             :     DTFS_STRUCTURE *X, /* i/o: DTFS to poleFilter inplace            */
    4346             :     const float *LPC,  /* i  : LPCs                                  */
    4347             :     const int16_t N    /* i  : LPCORDER                              */
    4348             : );
    4349             : 
    4350             : void DTFS_zeroFilter(
    4351             :     DTFS_STRUCTURE *X, /* i/o: DTFS to zeroFilter inplace            */
    4352             :     const float *LPC,  /* i  : LPCs                                  */
    4353             :     const int16_t N    /* i  : LPCORDER                              */
    4354             : );
    4355             : 
    4356             : float DTFS_alignment_full(
    4357             :     DTFS_STRUCTURE X1_DTFS, /* i  : reference DTFS                         */
    4358             :     DTFS_STRUCTURE X2_DTFS, /* i  : DTFS to shift                          */
    4359             :     const int16_t num_steps /* i  : resolution                             */
    4360             : );
    4361             : 
    4362             : void DTFS_phaseShift(
    4363             :     DTFS_STRUCTURE *X, /* i  : DTFS to shift                          */
    4364             :     float ph           /* i  : phase to shift                         */
    4365             : );
    4366             : 
    4367             : void erb_add(
    4368             :     float *curr_erb,       /* i/o:  current ERB                          */
    4369             :     const int16_t l,       /* i  :  current lag                          */
    4370             :     const float *prev_erb, /* i  :  previous ERB                         */
    4371             :     const int16_t pl,      /* i  :  previous lag                         */
    4372             :     const int16_t *index,  /* i  :  ERB index                            */
    4373             :     const int16_t num_erb  /* i  :  number of ERBs                       */
    4374             : );
    4375             : 
    4376             : void erb_slot(
    4377             :     int16_t lag,    /* i  : input lag                             */
    4378             :     int16_t *out,   /* o  : ERB slots                             */
    4379             :     float *mfreq,   /* i  : ERB frequencies                       */
    4380             :     int16_t num_erb /* i  : number of ERBs                        */
    4381             : );
    4382             : 
    4383             : void erb_diff(
    4384             :     const float *prev_erb, /* i  : previous ERB                          */
    4385             :     const int16_t pl,      /* i  : previous lag                          */
    4386             :     const float *curr_erb, /* i  : current ERB                           */
    4387             :     const int16_t l,       /* i  : current lag                           */
    4388             :     const float *curr_lsp, /* i  : current LSP coefficients              */
    4389             :     float *out,            /* o  : ERB difference                        */
    4390             :     int16_t *index,        /* i  : ERB index                             */
    4391             :     const int16_t num_erb  /* i  : Number of ERBs                        */
    4392             : );
    4393             : 
    4394             : void DTFS_erb_inv(
    4395             :     float *in,            /* i  : ERB inpt                               */
    4396             :     int16_t *slot,        /* i  : ERB slots filled based on lag          */
    4397             :     float *mfreq,         /* i  : erb frequence edges                    */
    4398             :     DTFS_STRUCTURE *X,    /* o  : DTFS after erb-inv                     */
    4399             :     const int16_t num_erb /* i  : Number of ERB bands                    */
    4400             : );
    4401             : 
    4402             : ivas_error ppp_quarter_encoder(
    4403             :     int16_t *returnFlag,       /* o  : return value                            */
    4404             :     BSTR_ENC_HANDLE hBstr,     /* i/o: encoder bitstream handle                 */
    4405             :     DTFS_STRUCTURE *CURRCW_Q,  /* o  : Quantized (amp/phase) DTFS               */
    4406             :     DTFS_STRUCTURE *TARGETCW,  /* o  : DTFS with quant phase but unquant Amp    */
    4407             :     const int16_t prevCW_lag,  /* i  : previous lag                             */
    4408             :     DTFS_STRUCTURE vCURRCW_NQ, /* i  : Unquantized DTFS                         */
    4409             :     const float *curr_lpc,     /* i  : LPCS                                     */
    4410             :     float *lastLgainE,         /* i/o: last low band gain                       */
    4411             :     float *lastHgainE,         /* i/o: last high band gain                      */
    4412             :     float *lasterbE,           /* i/o: last ERB vector                          */
    4413             :     DTFS_STRUCTURE PREV_CW_E   /* i  : past DTFS                                */
    4414             : );
    4415             : 
    4416             : ivas_error WIsyn(
    4417             :     DTFS_STRUCTURE PREVCW,        /* i  : Prev frame DTFS                          */
    4418             :     DTFS_STRUCTURE *CURR_CW_DTFS, /* i/o: Curr frame DTFS                          */
    4419             :     const float *curr_lpc,        /* i  : LPC                                      */
    4420             :     float *ph_offset,             /* i/o: Phase offset to line up at end of frame  */
    4421             :     float *out,                   /* o  : Waveform Interpolated time domain signal */
    4422             :     const int16_t N,              /* i  : Number of samples of output to generate  */
    4423             :     const int16_t FR_flag         /* i  : called for post-smoothing in FR          */
    4424             : );
    4425             : 
    4426             : void set_ppp_mode(
    4427             :     Encoder_State *st,             /* i/o: encoder state structure                 */
    4428             :     const int16_t noisy_speech_HO, /* i  : SC-VBR noisy speech HO flag             */
    4429             :     const int16_t clean_speech_HO, /* i  : SC-VBR clean speech HO flag             */
    4430             :     const int16_t NB_speech_HO,    /* i  : SC-VBR NB speech HO flag                */
    4431             :     const int16_t localVAD_he      /* i  : HE-SAD flag without hangover            */
    4432             : );
    4433             : 
    4434             : void lsf_syn_mem_backup(
    4435             :     Encoder_State *st,          /* i  : state structure                                       */
    4436             :     float *btilt_code,          /* i  : tilt code                                             */
    4437             :     float *bgc_threshold,       /* i  :                                                       */
    4438             :     float *clip_var_bck,        /* o  :                                                       */
    4439             :     int16_t *next_force_sf_bck, /* o  :                                                       */
    4440             :     float *lsp_new,             /* i  : LSP vector to quantize                                */
    4441             :     float *lsp_mid,             /* i  : mid-frame LSP vector                                  */
    4442             :     float *clip_var,            /* o  : pitch clipping state var                              */
    4443             :     float *mem_AR,              /* o  : quantizer memory for AR model                         */
    4444             :     float *mem_MA,              /* o  : quantizer memory for AR model                         */
    4445             :     float *lsp_new_bck,         /* o  : LSP vector to quantize- backup                        */
    4446             :     float *lsp_mid_bck,         /* o  : mid-frame LSP vector - backup                         */
    4447             :     float *Bin_E,               /* o  : FFT Bin energy 128 *2 sets                            */
    4448             :     float *Bin_E_old,           /* o  : FFT Bin energy 128 sets                               */
    4449             :     float *mem_syn_bck,         /* o  : synthesis filter memory                               */
    4450             :     float *mem_w0_bck,          /* o  : memory of the weighting filter                        */
    4451             :     float *streaklimit,
    4452             :     int16_t *pstreaklen );
    4453             : 
    4454             : void lsf_syn_mem_restore(
    4455             :     Encoder_State *st,         /* o  : state structure                                        */
    4456             :     float btilt_code,          /* i  :                                                        */
    4457             :     float gc_threshold,        /* i  :                                                        */
    4458             :     float *clip_var_bck,       /* i  :                                                        */
    4459             :     int16_t next_force_sf_bck, /* i  :                                                        */
    4460             :     float *lsp_new,            /* o  : LSP vector to quantize                                 */
    4461             :     float *lsp_mid,            /* o  : mid-frame LSP vector                                   */
    4462             :     float clip_var,            /* i  : pitch clipping state var                               */
    4463             :     float *mem_AR,             /* i  : quantizer memory for AR model                          */
    4464             :     float *mem_MA,             /* i  : quantizer memory for AR model                          */
    4465             :     float *lsp_new_bck,        /* i  : LSP vector to quantize- backup                         */
    4466             :     float *lsp_mid_bck,        /* i  : mid-frame LSP vector - backup                          */
    4467             :     float *Bin_E,              /* i  : FFT Bin energy 128 *2 sets                             */
    4468             :     float *Bin_E_old,          /* i  : FFT Bin energy 128 sets                                */
    4469             :     float *mem_syn_bck,        /* i  : synthesis filter memory                                */
    4470             :     float mem_w0_bck,          /* i  : memory of the weighting filter                         */
    4471             :     const float streaklimit,
    4472             :     const int16_t pstreaklen );
    4473             : 
    4474             : ivas_error ppp_voiced_encoder(
    4475             :     BSTR_ENC_HANDLE hBstr,             /* i/o: encoder bitstream handle                    */
    4476             :     SC_VBR_ENC_HANDLE hSC_VBR,         /* i/o: SC-VBR state structure                      */
    4477             :     const int16_t bwidth,              /* i  : audio bandwidth                             */
    4478             :     const int16_t last_coder_type_raw, /* i  : raw last_coder_type                         */
    4479             :     const float old_pitch_buf[],       /* i  : buffer of old subframe pitch values         */
    4480             :     float *in,                         /* i  : residual signal                             */
    4481             :     float *out,                        /* o  : Quantized residual signal                   */
    4482             :     const int16_t delay,               /* i  : open loop pitch                             */
    4483             :     float *lpc1,                       /* i  : prev frame de-emphasized LPC                */
    4484             :     float *lpc2,                       /* i  : current frame de-emphasized LPC             */
    4485             :     float *exc,                        /* i  : previous frame quantized excitation         */
    4486             :     float *pitch                       /* o  : floating pitch values for each subframe     */
    4487             : );
    4488             : 
    4489             : ivas_error encod_ppp(
    4490             :     Encoder_State *st,    /* i/o: state structure                                 */
    4491             :     const float speech[], /* i  : input speech                                    */
    4492             :     const float Aw[],     /* i  : weighted A(z) unquantized for subframes         */
    4493             :     const float Aq[],     /* i  : 12k8 Lp coefficient                             */
    4494             :     float *res,           /* i/o: residual signal                                 */
    4495             :     float *synth,         /* i/o: core synthesis                                  */
    4496             :     float *exc,           /* i/o: current non-enhanced excitation                 */
    4497             :     float *exc2,          /* i/o: current enhanced excitation                     */
    4498             :     float *pitch_buf,     /* i/o: floating pitch values for each subframe         */
    4499             :     float *voice_factors, /* o  : voicing factors                                 */
    4500             :     float *bwe_exc        /* o  : excitation for SWB TBE                          */
    4501             : );
    4502             : 
    4503             : void reset_rf_indices(
    4504             :     RF_ENC_HANDLE hRF,     /* i/o: RF state structure                  */
    4505             :     const int16_t L_frame, /* i  : frame length                        */
    4506             :     int16_t *rf_target_bits_write );
    4507             : 
    4508             : void signaling_enc_rf(
    4509             :     Encoder_State *st /* i/o: encoder state structure             */
    4510             : );
    4511             : 
    4512             : ivas_error acelp_core_dec(
    4513             :     Decoder_State *st,                   /* i/o: Decoder state structure             */
    4514             :     float output[],                      /* o  : synthesis @internal Fs              */
    4515             :     float synth[],                       /* o  : synthesis                           */
    4516             :     float save_hb_synth[],               /* o  : HB synthesis                        */
    4517             :     float bwe_exc_extended[],            /* i/o: bandwidth extended excitation       */
    4518             :     float *voice_factors,                /* o  : voicing factors                     */
    4519             :     float old_syn_12k8_16k[],            /* o  : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE */
    4520             :     const int16_t sharpFlag,             /* i  : formant sharpening flag             */
    4521             :     float pitch_buf[NB_SUBFR16k],        /* o  : floating pitch for each subframe    */
    4522             :     int16_t *unbits,                     /* o  : number of unused bits               */
    4523             :     int16_t *sid_bw,                     /* o  : 0-NB/WB, 1-SWB SID                  */
    4524             :     STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle            */
    4525             :     const float tdm_lsfQ_PCh[M],         /* i  : Q LSFs for primary channel          */
    4526             :     const int16_t use_cldfb_for_dft,     /* i  : flag to use of CLDFB for DFT Stereo */
    4527             :     const int16_t last_element_mode,     /* i  : last element mode                   */
    4528             :     const int32_t last_element_brate,    /* i  : last element bitrate                */
    4529             :     const int16_t flag_sec_CNA,          /* i  : CNA flag for secondary channel      */
    4530             :     const int16_t nchan_out,             /* i  : number of output channels           */
    4531             :     STEREO_CNG_DEC_HANDLE hStereoCng,    /* i  :  stereo CNG handle                  */
    4532             :     const int16_t read_sid_info          /* i  : read SID info flag                  */
    4533             : );
    4534             : 
    4535             : void bass_psfilter_init(
    4536             :     BPF_DEC_HANDLE hBPF /* o  : BPF data handle                     */
    4537             : );
    4538             : 
    4539             : void bass_psfilter(
    4540             :     BPF_DEC_HANDLE hBPF,      /* o  : BPF data handle                     */
    4541             :     const int16_t Opt_AMR_WB, /* i  : AMR-WB IO flag                      */
    4542             :     const float synth_in[],   /* i  : synthesis (at 16kHz)                */
    4543             :     const int16_t L_frame,    /* i  : length of the last frame            */
    4544             :     const float pitch_buf[],  /* i  : pitch for every subfr [0,1,2,3]     */
    4545             :     const int16_t bpf_off,    /* i  : do not use BPF when set to 1        */
    4546             :     float v_stab,             /* i  : stability factor                    */
    4547             :     float *v_stab_smooth,     /* i  : smoothed stability factor           */
    4548             :     const int16_t coder_type, /* i  : coder_type                          */
    4549             :     float bpf_noise_buf[]     /* o  : BPF error signal (at int_fs)        */
    4550             : );
    4551             : 
    4552             : void CNG_reset_dec(
    4553             :     Decoder_State *st,   /* i/o: decoder state structure            */
    4554             :     float *pitch_buf,    /* o  : floating pitch for each subframe   */
    4555             :     float *voice_factors /* o  : voicing factors                    */
    4556             : );
    4557             : 
    4558             : void updt_dec(
    4559             :     Decoder_State *st,           /* i/o: state structure                         */
    4560             :     const float *old_exc,        /* i  : buffer of excitation                    */
    4561             :     const float *pitch_buf,      /* i  : floating pitch values for each subframe */
    4562             :     const float Es_pred,         /* i  : predicited scaled innovation energy     */
    4563             :     const float *Aq,             /* i  : A(z) quantized for all subframes        */
    4564             :     const float *lsf_new,        /* i  : current frame LSF vector                */
    4565             :     const float *lsp_new,        /* i  : current frame LSP vector                */
    4566             :     const float voice_factors[], /* i  : voicing factors                         */
    4567             :     const float *old_bwe_exc,    /* i  : buffer of excitation                    */
    4568             :     const float *gain_buf        /* o  : floating pitch gain for each subframe   */
    4569             : );
    4570             : 
    4571             : void updt_IO_switch_dec(
    4572             :     const int16_t output_frame, /* i  : output frame length                     */
    4573             :     Decoder_State *st           /* i/o: state structure                         */
    4574             : );
    4575             : 
    4576             : void updt_dec_common(
    4577             :     Decoder_State *st,                  /* i/o: decoder state structure     */
    4578             :     const int16_t hq_core_type,         /* i  : HQ core type                */
    4579             :     const int16_t concealWholeFrameTmp, /* i  : concealWholeFrameTmp flag   */
    4580             :     const float *synth                  /* i  : decoded synthesis           */
    4581             : );
    4582             : 
    4583             : void td_cng_dec_init(
    4584             :     DEC_CORE_HANDLE st /* i/o: decoder state structure     */
    4585             : );
    4586             : 
    4587             : void CNG_dec(
    4588             :     Decoder_State *st,               /* i/o: State structure                         */
    4589             :     const int16_t last_element_mode, /* i  : last element mode                       */
    4590             :     float Aq[],                      /* o  : LP coefficients                         */
    4591             :     float *lsp_new,                  /* i/o: current frame LSPs                      */
    4592             :     float *lsf_new,                  /* i/o: current frame LSFs                      */
    4593             :     int16_t *allow_cn_step,          /* o  : allow cn step                           */
    4594             :     int16_t *sid_bw,                 /* o  : 0-NB/WB, 1-SWB SID                      */
    4595             :     float *q_env );
    4596             : 
    4597             : void swb_CNG_dec(
    4598             :     Decoder_State *st,   /* i/o: State structure                         */
    4599             :     const float *synth,  /* i  : ACELP core synthesis at 32kHz           */
    4600             :     float *shb_synth,    /* o  : high-band CNG synthesis                 */
    4601             :     const int16_t sid_bw /* i  : 0-NB/WB, 1-SWB SID                      */
    4602             : );
    4603             : 
    4604             : void lsf_dec(
    4605             :     Decoder_State *st,               /* i/o: State structure                             */
    4606             :     const int16_t tc_subfr,          /* i  : TC subframe index                           */
    4607             :     float *Aq,                       /* o  : quantized A(z) for 4 subframes              */
    4608             :     int16_t *LSF_Q_prediction,       /* o  : LSF prediction mode                         */
    4609             :     float *lsf_new,                  /* o  : de-quantized LSF vector                     */
    4610             :     float *lsp_new,                  /* o  : de-quantized LSP vector                     */
    4611             :     float *lsp_mid,                  /* o  : de-quantized mid-frame LSP vector           */
    4612             :     const int16_t tdm_low_rate_mode, /* i  : secondary channel low rate mode flag        */
    4613             :     const float tdm_lsfQ_PCh[M]      /* i  : Q LSFs for primary channel                  */
    4614             : );
    4615             : 
    4616             : void isf_dec_amr_wb(
    4617             :     Decoder_State *st, /* i/o: State structure                             */
    4618             :     float *Aq,         /* o  : quantized A(z) for 4 subframes              */
    4619             :     float *isf_new,    /* o  : de-quantized ISF vector                     */
    4620             :     float *isp_new     /* o  : de-quantized ISP vector                     */
    4621             : );
    4622             : 
    4623             : void Es_pred_dec(
    4624             :     float *Es_pred,        /* o  : predicted scaled innovation energy          */
    4625             :     const int16_t enr_idx, /* i  : indice                                      */
    4626             :     const int16_t nb_bits, /* i  : number of bits                              */
    4627             :     const int16_t no_ltp   /* i  : no LTP flag                                 */
    4628             : );
    4629             : 
    4630             : void gaus_dec(
    4631             :     Decoder_State *st,     /* i/o: decoder state structure                     */
    4632             :     const int16_t i_subfr, /* i  : subframe index                              */
    4633             :     float *code,           /* o  : gaussian excitation                         */
    4634             :     float *norm_gain_code, /* o  : gain of the normalized gaussian excitation  */
    4635             :     float *lp_gainp,       /* i/o: lp filtered pitch gain(FER)                 */
    4636             :     float *lp_gainc,       /* i/o: lp filtered code gain (FER)                 */
    4637             :     float *gain_inov,      /* o  : unscaled innovation gain                    */
    4638             :     float *tilt_code,      /* o  : synthesis excitation spectrum tilt          */
    4639             :     float *voice_fac,      /* o  : estimated voicing factor                    */
    4640             :     float *gain_pit,       /* o  : reset pitch gain                            */
    4641             :     float *pt_pitch,       /* o  : reset floating pitch buffer                 */
    4642             :     float *exc,            /* o  : excitation signal frame                     */
    4643             :     float *gain_code,      /* o  : gain of the gaussian excitation             */
    4644             :     float *exc2            /* o  : scaled excitation signal frame              */
    4645             : );
    4646             : 
    4647             : void gain_dec_amr_wb(
    4648             :     Decoder_State *st,        /* i/o: decoder state structure               */
    4649             :     const int32_t core_brate, /* i  : core bitrate                          */
    4650             :     float *gain_pit,          /* o  : Quantized pitch gain                  */
    4651             :     float *gain_code,         /* o  : Quantized codeebook gain              */
    4652             :     float *past_qua_en,       /* i/o: gain quantization memory (4 words)    */
    4653             :     float *gain_inov,         /* o  : unscaled innovation gain              */
    4654             :     const float *code,        /* i  : algebraic code excitation             */
    4655             :     float *norm_gain_code     /* o  : norm. gain of the codebook excitation */
    4656             : );
    4657             : 
    4658             : void gain_dec_lbr(
    4659             :     Decoder_State *st,        /* i/o: decoder state structure                          */
    4660             :     const int16_t coder_type, /* i  : coding type                                      */
    4661             :     const int16_t i_subfr,    /* i  : subframe index                                   */
    4662             :     const float *code,        /* i  : algebraic excitation                             */
    4663             :     float *gain_pit,          /* o  : quantized pitch gain                             */
    4664             :     float *gain_code,         /* o  : quantized codebook gain                          */
    4665             :     float *gain_inov,         /* o  : gain of the innovation (used for normalization)  */
    4666             :     float *norm_gain_code,    /* o  : norm. gain of the codebook excitation            */
    4667             :     float gains_mem[],        /* i/o: pitch gain and code gain from previous subframes */
    4668             :     const int16_t L_subfr     /* i  : subframe length                                  */
    4669             : );
    4670             : 
    4671             : void gain_dec_mless(
    4672             :     Decoder_State *st,        /* i/o: decoder state structure               */
    4673             :     const int16_t L_frame,    /* i  : length of the frame                   */
    4674             :     const int16_t coder_type, /* i  : coding type                           */
    4675             :     const int16_t i_subfr,    /* i  : subframe number                       */
    4676             :     const int16_t tc_subfr,   /* i  : TC subframe index                     */
    4677             :     const float *code,        /* i  : algebraic code excitation             */
    4678             :     const float Es_pred,      /* i  : predicted scaled innov. energy        */
    4679             :     float *gain_pit,          /* o  : Quantized pitch gain                  */
    4680             :     float *gain_code,         /* o  : Quantized codeebook gain              */
    4681             :     float *gain_inov,         /* o  : unscaled innovation gain              */
    4682             :     float *norm_gain_code     /* o  : norm. gain of the codebook excitation */
    4683             : );
    4684             : 
    4685             : void gain_dec_SQ(
    4686             :     Decoder_State *st,     /* i/o: decoder state structure               */
    4687             :     const int16_t i_subfr, /* i  : subframe number                       */
    4688             :     const float *code,     /* i  : algebraic code excitation             */
    4689             :     const float Es_pred,   /* i  : predicted scaled innov. energy        */
    4690             :     float *gain_pit,       /* o  : Quantized pitch gain                  */
    4691             :     float *gain_code,      /* o  : Quantized codeebook gain              */
    4692             :     float *gain_inov,      /* o  : unscaled innovation gain              */
    4693             :     float *norm_gain_code  /* o  : norm. gain of the codebook excitation */
    4694             : );
    4695             : 
    4696             : /*! r: quantized codebook gain */
    4697             : float gain_dec_gaus(
    4698             :     const int16_t index,   /* i  : quantization index                      */
    4699             :     const int16_t bits,    /* i  : number of bits to quantize              */
    4700             :     const float lowBound,  /* i  : lower bound of quantizer (dB)           */
    4701             :     const float topBound,  /* i  : upper bound of quantizer (dB)           */
    4702             :     const float gain_inov, /* i  : unscaled innovation gain                */
    4703             :     float *norm_gain_code  /* o  : gain of normalized gaus. excit.         */
    4704             : );
    4705             : 
    4706             : /*! r: floating pitch value */
    4707             : float pit_decode(
    4708             :     Decoder_State *st,                  /* i/o: decoder state structure                 */
    4709             :     const int32_t core_brate,           /* i  : core bitrate                            */
    4710             :     const int16_t Opt_AMR_WB,           /* i  : flag indicating AMR-WB IO mode          */
    4711             :     const int16_t L_frame,              /* i  : length of the frame                     */
    4712             :     int16_t i_subfr,                    /* i  : subframe index                          */
    4713             :     const int16_t coder_type,           /* i  : coding type                             */
    4714             :     int16_t *limit_flag,                /* i/o: restrained(0) or extended(1) Q limits   */
    4715             :     int16_t *T0,                        /* o  : close loop integer pitch                */
    4716             :     int16_t *T0_frac,                   /* o  : close loop fractional part of the pitch */
    4717             :     int16_t *T0_min,                    /* i/o: delta search min for sf 2 & 4           */
    4718             :     int16_t *T0_max,                    /* i/o: delta search max for sf 2 & 4           */
    4719             :     const int16_t L_subfr,              /* i  : subframe length                         */
    4720             :     const int16_t tdm_Pitch_reuse_flag, /* i  : primary channel pitch reuse flag        */
    4721             :     const float tdm_Pri_pitch_buf[]     /* i  : primary channel pitch buffer            */
    4722             : );
    4723             : 
    4724             : void abs_pit_dec(
    4725             :     const int16_t fr_steps,   /* i  : fractional resolution steps (0, 2, 4)   */
    4726             :     int16_t pitch_index,      /* i  : pitch index                             */
    4727             :     const int16_t limit_flag, /* i  : restrained(0) or extended(1) Q limits   */
    4728             :     int16_t *T0,              /* o  : integer pitch lag                       */
    4729             :     int16_t *T0_frac          /* o  : pitch fraction                          */
    4730             : );
    4731             : 
    4732             : void delta_pit_dec(
    4733             :     const int16_t fr_steps,    /* i  : fractional resolution steps (0, 2, 4)   */
    4734             :     const int16_t pitch_index, /* i  : pitch index                             */
    4735             :     int16_t *T0,               /* o  : integer pitch lag                       */
    4736             :     int16_t *T0_frac,          /* o  : pitch fraction                          */
    4737             :     const int16_t T0_min       /* i  : delta search min                        */
    4738             : );
    4739             : 
    4740             : void pit_Q_dec(
    4741             :     const int16_t Opt_AMR_WB,  /* i  : flag indicating AMR-WB IO mode          */
    4742             :     const int16_t pitch_index, /* i  : pitch index                             */
    4743             :     const int16_t nBits,       /* i  : # of Q bits                             */
    4744             :     const int16_t delta,       /* i  : Half the CL searched interval           */
    4745             :     const int16_t pit_flag,    /* i  : absolute(0) or delta(1) pitch Q         */
    4746             :     const int16_t limit_flag,  /* i  : restrained(0) or extended(1) Q limits   */
    4747             :     int16_t *T0,               /* o  : integer pitch lag                       */
    4748             :     int16_t *T0_frac,          /* o  : pitch fraction                          */
    4749             :     int16_t *T0_min,           /* i/o: delta search min                        */
    4750             :     int16_t *T0_max,           /* i/o: delta search max                        */
    4751             :     int16_t *BER_detect        /* o  : BER detect flag                         */
    4752             : );
    4753             : 
    4754             : void pit16k_Q_dec(
    4755             :     const int16_t pitch_index, /* i  : pitch index                             */
    4756             :     const int16_t nBits,       /* i  : # of Q bits                             */
    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             :     int16_t *T0_min,           /* i/o: delta search min                        */
    4761             :     int16_t *T0_max,           /* i/o: delta search max                        */
    4762             :     int16_t *BER_detect        /* o  : BER detect flag                         */
    4763             : );
    4764             : 
    4765             : void lp_filt_exc_dec(
    4766             :     Decoder_State *st,        /* i/o: decoder state structure                         */
    4767             :     const int16_t codec_mode, /* i  : codec mode                                      */
    4768             :     const int16_t i_subfr,    /* i  : subframe index                                  */
    4769             :     const int16_t L_subfr,    /* i  : subframe size                                   */
    4770             :     const int16_t L_Frame,    /* i  : frame size                                      */
    4771             :     int16_t lp_flag,          /* i  : operation mode signaling                        */
    4772             :     float *exc                /* i/o: pointer to the excitation signal frame          */
    4773             : );
    4774             : 
    4775             : void inov_decode(
    4776             :     Decoder_State *st,        /* i/o: decoder state structure                         */
    4777             :     const int32_t core_brate, /* i  : core bitrate                                    */
    4778             :     const int16_t Opt_AMR_WB, /* i  : flag indicating AMR-WB IO mode                  */
    4779             :     const int16_t L_frame,    /* i  : length of the frame                             */
    4780             :     const int16_t sharpFlag,  /* i  : formant sharpening flag                         */
    4781             :     const int16_t i_subfr,    /* i  : subframe index                                  */
    4782             :     const float *p_Aq,        /* i  : LP filter coefficients                          */
    4783             :     const float tilt_code,    /* i  : tilt of of the excitation of previous subframe  */
    4784             :     const float pt_pitch,     /* i  : pointer to current subframe fractional pitch    */
    4785             :     float *code,              /* o  : algebraic excitation                            */
    4786             :     const int16_t L_subfr     /* i  : subframe length                                 */
    4787             : );
    4788             : 
    4789             : void dec_acelp_1t64(
    4790             :     Decoder_State *st,    /* i/o: decoder state structure                         */
    4791             :     float code[],         /* o  : algebraic (fixed) codebook excitation           */
    4792             :     const int16_t L_subfr /* i  : subframe length                                 */
    4793             : );
    4794             : 
    4795             : void dec_acelp_2t32(
    4796             :     Decoder_State *st, /* i/o: decoder state structure                         */
    4797             :     float code[]       /* o  : algebraic (fixed) codebook excitation           */
    4798             : );
    4799             : 
    4800             : void dec_acelp_4t64(
    4801             :     Decoder_State *st,       /* i/o: decoder state structure                         */
    4802             :     int16_t nbbits,          /* i  : number of bits per codebook                     */
    4803             :     float code[],            /* o  : algebraic (fixed) codebook excitation           */
    4804             :     const int16_t Opt_AMR_WB /* i  : flag indicating AMR-WB IO mode                  */
    4805             : );
    4806             : 
    4807             : void FEC_exc_estim(
    4808             :     Decoder_State *st,     /* i/o: Decoder static memory                           */
    4809             :     const int16_t L_frame, /* i  : length of the frame                             */
    4810             :     float *old_exc,        /* i/o: excitation buffer                               */
    4811             :     float *exc2,           /* o  : excitation buffer (for synthesis)               */
    4812             :     float *exc_dct_in,     /* o  : GSC excitation in DCT domain                    */
    4813             :     float *pitch_buf,      /* o  : Floating pitch   for each subframe              */
    4814             :     float *tmp_tc,         /* o  : FEC pitch                                       */
    4815             :     float *voice_factors,  /* o  : voicing factors                                 */
    4816             :     float *bwe_exc,        /* i/o: excitation for SWB TBE                          */
    4817             :     float *lsf_new,        /* i  : ISFs at the end of the frame                    */
    4818             :     float *tmp_noise       /* o  : long-term noise energy                          */
    4819             : );
    4820             : 
    4821             : void FEC_lsf2lsp_interp(
    4822             :     Decoder_State *st,     /* i/o: Decoder static memory                           */
    4823             :     const int16_t L_frame, /* i  : length of the frame                             */
    4824             :     float *Aq,             /* o  : calculated A(z) for 4 subframes                 */
    4825             :     float *lsf,            /* o  : estimated LSF vector                            */
    4826             :     float *lsp             /* o  : estimated LSP vector                            */
    4827             : );
    4828             : 
    4829             : void FEC_lsf_estim_enc(
    4830             :     Encoder_State *st, /* i  : Encoder static memory                           */
    4831             :     float *lsf         /* o  : estimated LSF vector                            */
    4832             : );
    4833             : 
    4834             : float frame_energy(
    4835             :     const int16_t L_frame, /* i  : length of the frame                             */
    4836             :     const float *pitch,    /* i  : pitch values for each subframe                  */
    4837             :     const float *speech,   /* i  : pointer to speech signal for E computation      */
    4838             :     const float lp_speech, /* i  : long term active speech energy average          */
    4839             :     float *frame_ener      /* o  : pitch-synchronous energy at frame end           */
    4840             : );
    4841             : 
    4842             : void FEC_SinOnset(
    4843             :     float *exc,           /* i/o: exc vector to modify                           */
    4844             :     int16_t puls_pos,     /* i  : Last pulse position desired                    */
    4845             :     int16_t T0,           /* i  : decoded first frame pitch                      */
    4846             :     float enr_q,          /* i  : energy provided by the encoder                 */
    4847             :     float *Aq,            /* i  : Lsp coefficient                                */
    4848             :     const int16_t L_frame /* i  : Frame length                                   */
    4849             : );
    4850             : 
    4851             : int16_t FEC_enhACB(
    4852             :     const int16_t L_frame,      /* i  : Frame length                                                              */
    4853             :     const int16_t last_L_frame, /* i  : frame length of last frame                                                */
    4854             :     float *exc_io,              /* i/o: Adaptive codebook memory                                                  */
    4855             :     const int16_t new_pit,      /* i  : decoded first frame pitch                                                 */
    4856             :     const int16_t puls_pos,     /* i  : decoder position of the last glottal pulses decoded in the previous frame */
    4857             :     const float bfi_pitch       /* i  : Pitch used for concealment                                                */
    4858             : );
    4859             : 
    4860             : void FEC_scale_syn(
    4861             :     const int16_t L_frame,                     /* i  : length of the frame                     */
    4862             :     int16_t clas,                              /* i/o: frame classification                    */
    4863             :     const int16_t last_good,                   /* i  : last good frame classification          */
    4864             :     float *synth,                              /* i/o: synthesized speech at Fs = 12k8 Hz      */
    4865             :     const float *pitch,                        /* i  : pitch values for each subframe          */
    4866             :     float enr_old,                             /* i  : energy at the end of prvious frame      */
    4867             :     float enr_q,                               /* i  : transmitted energy for current frame    */
    4868             :     const int16_t coder_type,                  /* i  : coding type                             */
    4869             :     const int16_t LSF_Q_prediction,            /* i  : LSF prediction mode                     */
    4870             :     int16_t *scaling_flag,                     /* i/o: flag to indicate energy control of syn  */
    4871             :     float *lp_ener_FEC_av,                     /* i/o: averaged voiced signal energy           */
    4872             :     float *lp_ener_FEC_max,                    /* i/o: averaged voiced signal energy           */
    4873             :     const int16_t bfi,                         /* i  : current  frame BFI                      */
    4874             :     const int32_t total_brate,                 /* i  : total bitrate                           */
    4875             :     const int16_t prev_bfi,                    /* i  : previous frame BFI                      */
    4876             :     const int32_t last_core_brate,             /* i  : previous frame core bitrate             */
    4877             :     float *exc,                                /* i/o: excitation signal without enhancement   */
    4878             :     float *exc2,                               /* i/o: excitation signal with enhancement      */
    4879             :     const float Aq[],                          /* i  : LP filter coefs                         */
    4880             :     float *old_enr_LP,                         /* i/o: LP filter E of last good voiced frame   */
    4881             :     const float *mem_tmp,                      /* i  : temp. initial synthesis filter states   */
    4882             :     float *mem_syn,                            /* o  : initial synthesis filter states         */
    4883             :     const int16_t avoid_lpc_burst_on_recovery, /* i  : if true the excitation energy is limited if LP has big gain */
    4884             :     const int16_t force_scaling                /* i  : force scaling                           */
    4885             : );
    4886             : 
    4887             : void FEC_pitch_estim(
    4888             :     const int16_t Opt_AMR_WB,    /* i  : flag indicating AMR-WB IO mode          */
    4889             :     const int16_t last_core,     /* i  : last core                               */
    4890             :     const int16_t L_frame,       /* i  : length of the frame                     */
    4891             :     const int16_t clas,          /* i  : current frame classification            */
    4892             :     const int16_t last_good,     /* i  : last good clas information              */
    4893             :     const float pitch_buf[],     /* i  : Floating pitch   for each subframe      */
    4894             :     const float old_pitch_buf[], /* i  : buffer of old subframe pitch values     */
    4895             :     float *bfi_pitch,            /* i/o: update of the estimated pitch for FEC   */
    4896             :     int16_t *bfi_pitch_frame,    /* o  : frame length when pitch was updated     */
    4897             :     int16_t *upd_cnt,            /* i/o: update counter                          */
    4898             :     const int16_t coder_type );
    4899             : 
    4900             : void FEC_encode(
    4901             :     BSTR_ENC_HANDLE hBstr,        /* i/o: encoder bitstream handle                        */
    4902             :     const ACELP_config acelp_cfg, /* i  : configuration of the ACELP                      */
    4903             :     const float *synth,           /* i  : pointer to synthesized speech for E computation */
    4904             :     const int16_t coder_type,     /* i  : type of coder                                   */
    4905             :     int16_t clas,                 /* i  : signal clas for current frame                   */
    4906             :     const float *fpit,            /* i  : close loop fractional pitch buffer              */
    4907             :     const float *res,             /* i  : LP residual signal frame                        */
    4908             :     int16_t *last_pulse_pos,      /* i/o: Position of the last pulse                      */
    4909             :     const int16_t L_frame,        /* i  : Frame length                                    */
    4910             :     const int32_t total_brate     /* i  : total codec bitrate                             */
    4911             : );
    4912             : 
    4913             : int16_t FEC_pos_dec(
    4914             :     Decoder_State *st,          /* i/o: decoder state structure                     */
    4915             :     int16_t *last_pulse_pos,    /* o  : Last glottal pulse position in the lost ACB */
    4916             :     float *enr_q,               /* o  : Decoded energy                              */
    4917             :     const int16_t nBits_es_Pred /* i  : number of bits for Es_pred Q                */
    4918             : );
    4919             : 
    4920             : void improv_amr_wb_gs(
    4921             :     const int16_t clas,                 /* i  : bitrate allocated to the core           */
    4922             :     const int16_t coder_type,           /* i  : coder_type                              */
    4923             :     const int32_t core_brate,           /* i  : bitrate allocated to the core           */
    4924             :     int16_t *seed_tcx,                  /* i/o: Seed used for noise generation          */
    4925             :     float *old_Aq,                      /* i/o: old LPC filter coefficient              */
    4926             :     float *mem_syn2,                    /* i/o: synthesis memory                        */
    4927             :     const float lt_voice_fac,           /* i/o: long term voice factor                  */
    4928             :     const int16_t locattack,            /* i  : Flag for a detected attack              */
    4929             :     float *Aq,                          /* i/o: Decoded LP filter coefficient           */
    4930             :     float *exc2,                        /* i/o: Decoded complete excitation             */
    4931             :     float *mem_tmp,                     /* i/o: synthesis temporary memory              */
    4932             :     float *syn,                         /* i/o: Decoded synthesis to be updated         */
    4933             :     const float *pitch_buf,             /* i  : Decoded pitch buffer                    */
    4934             :     const float Last_ener,              /* i  : Last energy                             */
    4935             :     const int16_t rate_switching_reset, /* i  : rate switching reset flag               */
    4936             :     const int16_t last_coder_type,      /* i  : Last coder_type                         */
    4937             :     const int16_t VeryLowRateSTflag     /* i  : Enable the noise enhancement for very low rate stereo generic mode */
    4938             : );
    4939             : 
    4940             : int16_t tc_classif(
    4941             :     Decoder_State *st /* i/o: decoder state structure                 */
    4942             : );
    4943             : 
    4944             : void transition_dec(
    4945             :     Decoder_State *st,      /* i/o: decoder state structure                 */
    4946             :     const int16_t L_frame,  /* i  : length of the frame                     */
    4947             :     const int16_t i_subfr,  /* i  : subframe index                          */
    4948             :     const int16_t tc_subfr, /* i  : TC subframe index                       */
    4949             :     int16_t *Jopt_flag,     /* i  : joint optimization flag                 */
    4950             :     float *exc,             /* i/o: current frame excitation signal         */
    4951             :     int16_t *T0,            /* o  : close loop integer pitch                */
    4952             :     int16_t *T0_frac,       /* o  : close loop fractional part of the pitch */
    4953             :     int16_t *T0_min,        /* i/o: delta search min for sf 2 & 4           */
    4954             :     int16_t *T0_max,        /* i/o: delta search max for sf 2 & 4           */
    4955             :     float **pt_pitch,       /* o  : floating pitch values                   */
    4956             :     int16_t *position,      /* i/o: first glottal impulse position in frame */
    4957             :     float *bwe_exc          /* i/o: excitation for SWB TBE                  */
    4958             : );
    4959             : 
    4960             : void gain_dec_tc(
    4961             :     Decoder_State *st,     /* i/o: decoder state structure              */
    4962             :     const int16_t i_subfr, /* i  : subframe number                      */
    4963             :     const float Es_pred,   /* i  : predicted scaled innov. energy       */
    4964             :     const float *code,     /* i  : algebraic code excitation            */
    4965             :     float *gain_pit,       /* o  : pitch gain                           */
    4966             :     float *gain_code,      /* o  : Quantized codeebook gain             */
    4967             :     float *gain_inov,      /* o  : unscaled innovation gain             */
    4968             :     float *norm_gain_code  /* o  : norm. gain of the codebook excit.    */
    4969             : );
    4970             : 
    4971             : void stat_noise_uv_dec(
    4972             :     Decoder_State *st,              /* i/o: decoder static memory               */
    4973             :     const float *lsp_new,           /* i  : end-frame LSP vector                */
    4974             :     const float *lsp_mid,           /* i  : mid-frame LSP vector                */
    4975             :     float *Aq,                      /* o  : A(z) quantized for the 4 subframes  */
    4976             :     float *exc2,                    /* i/o: excitation buffer                   */
    4977             :     const int16_t uc_two_stage_flag /* 1  : flag undicating two-stage UC        */
    4978             : );
    4979             : 
    4980             : void sc_vbr_dec_init(
    4981             :     SC_VBR_DEC_HANDLE hSC_VBR /* i/o: SC-VBR decoder handle                */
    4982             : );
    4983             : 
    4984             : void decod_nelp(
    4985             :     Decoder_State *st,    /* i/o: decoder static memory                   */
    4986             :     float *tmp_noise,     /* o  : long term temporary noise energy        */
    4987             :     float *pitch_buf,     /* o  : floating pitch values for each subframe */
    4988             :     float *exc,           /* o  : adapt. excitation exc                   */
    4989             :     float *exc2,          /* o  : adapt. excitation/total exc             */
    4990             :     float *voice_factors, /* o  : voicing factors                         */
    4991             :     float *bwe_exc,       /* o  : excitation for SWB TBE                  */
    4992             :     const int16_t bfi,    /* i  : bad frame indicator                     */
    4993             :     float *gain_buf       /* o  : floating pitch gain for each subframe   */
    4994             : );
    4995             : 
    4996             : void nelp_decoder(
    4997             :     Decoder_State *st,        /* i/o: decoder static memory                     */
    4998             :     float *exc_nelp,          /* o  : adapt. excitation/total exc               */
    4999             :     float *exc,               /* o  : adapt. excitation exc                     */
    5000             :     int16_t bfi,              /* i  : frame error rate                          */
    5001             :     const int16_t coder_type, /* i  : coding type                               */
    5002             :     float *gain_buf           /* o  : floating pitch gain for each subframe     */
    5003             : );
    5004             : 
    5005             : ivas_error decod_ppp(
    5006             :     Decoder_State *st,    /* i/o: state structure                           */
    5007             :     const float Aq[],     /* i  : 12k8 Lp coefficient                       */
    5008             :     float *pitch_buf,     /* i/o: floating pitch values for each subframe   */
    5009             :     float *exc,           /* i/o: current non-enhanced excitation           */
    5010             :     float *exc2,          /* i/o: current enhanced excitation               */
    5011             :     float *voice_factors, /* o  : voicing factors                           */
    5012             :     float *bwe_exc,       /* o  : excitation for SWB TBE                    */
    5013             :     float *gain_buf,      /* o  : floating pitch gain for each subframe     */
    5014             :     const int16_t bfi     /* i  : BFI flag                                  */
    5015             : );
    5016             : 
    5017             : ivas_error ppp_quarter_decoder(
    5018             :     Decoder_State *st,             /* i/o: decoder state structure                 */
    5019             :     DTFS_STRUCTURE *CURRCW_Q_DTFS, /* i/o: Current CW DTFS                         */
    5020             :     int16_t prevCW_lag,            /* i  : Previous lag                            */
    5021             :     float *lastLgainD,             /* i/o: Last gain lowband                       */
    5022             :     float *lastHgainD,             /* i/o: Last gain highwband                     */
    5023             :     float *lasterbD,               /* i/o: Last ERB vector                         */
    5024             :     int16_t bfi,                   /* i  : FER flag                                */
    5025             :     DTFS_STRUCTURE PREV_CW_D       /* i  : Previous DTFS                           */
    5026             : );
    5027             : 
    5028             : ivas_error ppp_voiced_decoder(
    5029             :     Decoder_State *st, /* i/o: state structure                         */
    5030             :     float *out,        /* o  : residual signal                         */
    5031             :     const float *lpc2, /* i  : current frame LPC                       */
    5032             :     float *exc,        /* i  : previous frame excitation               */
    5033             :     float *pitch,      /* o  : floating pitch values for each subframe */
    5034             :     const int16_t bfi  /* i  : BFI flag                                */
    5035             : );
    5036             : 
    5037             : void AVQ_demuxdec(
    5038             :     Decoder_State *st,     /* i/o: decoder state structure         */
    5039             :     int16_t xriq[],        /* o  : decoded subvectors [0..8*Nsv-1] */
    5040             :     int16_t *nb_bits,      /* i/o: number of allocated bits        */
    5041             :     const int16_t Nsv,     /* i  : number of subvectors            */
    5042             :     int16_t nq[],          /* i/o: AVQ nq index                    */
    5043             :     int16_t avq_bit_sFlag, /* i  : flag for AVQ bit saving solution*/
    5044             :     int16_t trgtSvPos      /* i  : target SV for AVQ bit savings   */
    5045             : );
    5046             : 
    5047             : void re8_dec(
    5048             :     int16_t nq,         /* i  : codebook number (*n is an integer defined in {0,2,3,4,..,n_max})    */
    5049             :     const uint16_t I,   /* i  : index of c (pointer to unsigned 16-bit word)                        */
    5050             :     const int16_t kv[], /* i  : index of v (8-dimensional vector of binary indices) = Voronoi index */
    5051             :     int16_t y[]         /* o  : point in RE8 (8-dimensional integer vector)                         */
    5052             : );
    5053             : 
    5054             : void re8_decode_base_index(
    5055             :     const int16_t n, /* i  : codebook number (*n is an integer defined in {0,2,3,4,..,n_max}) */
    5056             :     uint16_t I,      /* i  : index of c (pointer to unsigned 16-bit word)                     */
    5057             :     int16_t *x       /* o  : point in RE8 (8-dimensional integer vector)                      */
    5058             : );
    5059             : 
    5060             : void Init_post_filter(
    5061             :     PFSTAT_HANDLE hPFstat /* i  : post-filter state memories              */
    5062             : );
    5063             : 
    5064             : void nb_post_filt(
    5065             :     const int16_t L_frame,    /* i  : frame length                            */
    5066             :     const int16_t L_subfr,    /* i  : sub-frame length                        */
    5067             :     PFSTAT_HANDLE hPFstat,    /* i/o: Post filter related memories            */
    5068             :     float *lp_noise,          /* i/o: long term noise energy                  */
    5069             :     const float tmp_noise,    /* i  : noise energy                            */
    5070             :     float *synth,             /* i/o: synthesis                               */
    5071             :     const float *Aq,          /* i  : LP filter coefficient                   */
    5072             :     const float *pitch_buf,   /* i  : Floating pitch   for each subframe      */
    5073             :     const int16_t coder_type, /* i  : coder_type -> deactivated in AUDIO      */
    5074             :     const int16_t BER_detect, /* i  : BER detect flag                         */
    5075             :     const int16_t disable_hpf /* i  : flag to diabled HPF                     */
    5076             : );
    5077             : 
    5078             : void decod_unvoiced(
    5079             :     Decoder_State *st,               /* i/o: decoder static memory                   */
    5080             :     const float *Aq,                 /* i  : LP filter coefficient                   */
    5081             :     const float Es_pred,             /* i  : predicted scaled innov. energy          */
    5082             :     const int16_t uc_two_stage_flag, /* i  : flag indicating two-stage UC            */
    5083             :     float *tmp_noise,                /* o  : long term temporary noise energy        */
    5084             :     float *pitch_buf,                /* o  : floating pitch values for each subframe */
    5085             :     float *voice_factors,            /* o  : voicing factors                         */
    5086             :     float *exc,                      /* o  : adapt. excitation exc                   */
    5087             :     float *exc2,                     /* o  : adapt. excitation/total exc             */
    5088             :     float *bwe_exc,                  /* i/o: excitation for SWB TBE                  */
    5089             :     float *gain_buf                  /* o  : floating pitch gain for each subfram    */
    5090             : );
    5091             : 
    5092             : void decod_tran(
    5093             :     Decoder_State *st,       /* i/o: decoder static memory                   */
    5094             :     const int16_t L_frame,   /* i  : length of the frame                     */
    5095             :     const int16_t tc_subfr,  /* i  : TC subframe index                       */
    5096             :     const float *Aq,         /* i  : LP filter coefficient                   */
    5097             :     const float Es_pred,     /* i  : predicted scaled innov. energy          */
    5098             :     float *pitch_buf,        /* o  : floating pitch values for each subframe */
    5099             :     float *voice_factors,    /* o  : voicing factors                         */
    5100             :     float *exc,              /* i/o: adapt. excitation exc                   */
    5101             :     float *exc2,             /* i/o: adapt. excitation/total exc             */
    5102             :     float *bwe_exc,          /* i/o: excitation for SWB TBE                  */
    5103             :     int16_t *unbits,         /* i/o: number of unused bits                   */
    5104             :     const int16_t sharpFlag, /* i  : formant sharpening flag                 */
    5105             :     float *gain_buf          /* o  : floating pitch gain for each subframe   */
    5106             : );
    5107             : 
    5108             : ivas_error decod_gen_voic(
    5109             :     Decoder_State *st,                  /* i/o: decoder static memory                   */
    5110             :     const int16_t L_frame,              /* i  : length of the frame                     */
    5111             :     const int16_t sharpFlag,            /* i  : formant sharpening flag                 */
    5112             :     const float *Aq,                    /* i  : LP filter coefficient                   */
    5113             :     const float Es_pred,                /* i  : predicted scaled innov. energy          */
    5114             :     const int16_t do_WI,                /* i  : FEC fast recovery flag                  */
    5115             :     float *pitch_buf,                   /* o  : floating pitch   for each subframe      */
    5116             :     float *voice_factors,               /* o  : voicing factors                         */
    5117             :     float *exc,                         /* i/o: adapt. excitation exc                   */
    5118             :     float *exc2,                        /* i/o: adapt. excitation/total exc             */
    5119             :     float *bwe_exc,                     /* i/o: excitation for SWB TBE                  */
    5120             :     int16_t *unbits,                    /* i/o: number of unused bits                   */
    5121             :     float *gain_buf,                    /* o  : floating pitch gain for each subframe   */
    5122             :     const int16_t tdm_Pitch_reuse_flag, /* i  : primary channel pitch reuse flag        */
    5123             :     const float tdm_Pri_pitch_buf[]     /* i  : primary channel pitch buffer            */
    5124             : );
    5125             : 
    5126             : void decod_amr_wb(
    5127             :     Decoder_State *st,         /* i/o: decoder static memory                     */
    5128             :     const float *Aq,           /* i  : LP filter coefficients                    */
    5129             :     float *pitch_buf,          /* o  : floating pitch values for each subframe   */
    5130             :     float *exc,                /* i/o: adapt. excitation exc                     */
    5131             :     float *exc2,               /* i/o: adapt. excitation/total exc               */
    5132             :     int16_t hf_gain[NB_SUBFR], /* o  : decoded HF gain                           */
    5133             :     float *voice_factors,      /* o  : voicing factors                           */
    5134             :     float *gain_buf            /* o  : floating pitch gain for each subframe     */
    5135             : );
    5136             : 
    5137             : ivas_error init_decoder(
    5138             :     Decoder_State *st,    /* o  : Decoder static variables structure        */
    5139             :     const int16_t idchan, /* i  : channel ID                                */
    5140             :     const MC_MODE mc_mode /* i  : MC mode                                   */
    5141             : );
    5142             : 
    5143             : void destroy_cldfb_decoder(
    5144             :     Decoder_State *st /* o  : Decoder static variables structure        */
    5145             : );
    5146             : 
    5147             : void HQ_core_dec_init(
    5148             :     HQ_DEC_HANDLE hHQ_core /* i/o: HQ core data handle                       */
    5149             : );
    5150             : 
    5151             : void HQ_nbfec_init(
    5152             :     HQ_NBFEC_HANDLE hHQ_nbfec /* i/o: HQ NB FEC data handle                    */
    5153             : );
    5154             : 
    5155             : ivas_error evs_dec(
    5156             :     Decoder_State *st,              /* i/o: Decoder state structure                   */
    5157             :     float mem_hp20_out[L_HP20_MEM], /* i/o: HP filter memory for synthesis            */
    5158             :     float *output,                  /* o  : output synthesis signal                   */
    5159             :     FRAME_MODE frameMode            /* i  : Decoder frame mode                        */
    5160             : );
    5161             : 
    5162             : void get_next_frame_parameters(
    5163             :     Decoder_State *st /* i/o: Decoder state structure                   */
    5164             : );
    5165             : 
    5166             : ivas_error amr_wb_dec(
    5167             :     Decoder_State *st,              /* i/o: decoder state structure                   */
    5168             :     float mem_hp20_out[L_HP20_MEM], /* i/o: HP filter memory for synthesis            */
    5169             :     float *output                   /* o  : synthesis output                          */
    5170             : );
    5171             : 
    5172             : void transf_cdbk_dec(
    5173             :     Decoder_State *st,             /* i/o: decoder state structure                   */
    5174             :     const int16_t harm_flag_acelp, /* i  : harmonic flag for higher rates ACELP      */
    5175             :     const int16_t i_subfr,         /* i  : subframe index                            */
    5176             :     const float Es_pred,           /* i  : predicited scaled innovation energy       */
    5177             :     const float gain_code,         /* i  : innovative excitation gain                */
    5178             :     float *gain_preQ,              /* o  : prequantizer excitation gain              */
    5179             :     float *norm_gain_preQ,         /* o  : normalized prequantizer excitation gain   */
    5180             :     float code_preQ[],             /* o  : prequantizer excitation                   */
    5181             :     int16_t *unbits                /* o  : number of AVQ unused bits                 */
    5182             : );
    5183             : 
    5184             : /*! r: decoded gain */
    5185             : float gain_dequant(
    5186             :     int16_t index,       /* i  : quantization index                        */
    5187             :     const float min_val, /* i  : value of lower limit                      */
    5188             :     const float max_val, /* i  : value of upper limit                      */
    5189             :     const int16_t bits   /* i  : number of bits to dequantize              */
    5190             : );
    5191             : 
    5192             : void HQ_core_enc_init(
    5193             :     HQ_ENC_HANDLE hHQ_core /* i/o: HQ core data handle                       */
    5194             : );
    5195             : 
    5196             : void hq_core_enc(
    5197             :     Encoder_State *st,           /* i/o: encoder state structure                   */
    5198             :     const float *audio,          /* i  : input audio signal                        */
    5199             :     const int16_t input_frame,   /* i  : frame length                              */
    5200             :     const int16_t hq_core_type,  /* i  : HQ core type                              */
    5201             :     const int16_t Voicing_flag,  /* i  : Voicing flag for FER method selection     */
    5202             :     const int16_t vad_hover_flag /* i  : VAD hangover flag                         */
    5203             : );
    5204             : 
    5205             : int16_t detect_transient(
    5206             :     Encoder_State *st, /* i/o: encoder state structure             */
    5207             :     const float *in,   /* i  : input signal                        */
    5208             :     const int16_t L    /* i  : length                              */
    5209             : );
    5210             : 
    5211             : void wtda(
    5212             :     const float *new_audio,   /* i  : input audio                         */
    5213             :     float *wtda_audio,        /* o  : windowed audio                      */
    5214             :     float *old_wtda,          /* i/o: windowed audio from previous frame  */
    5215             :     const int16_t left_mode,  /* i  : window overlap of previous frame (0: full, 2: none, or 3: half) */
    5216             :     const int16_t right_mode, /* i  : window overlap of current frame (0: full, 2: none, or 3: half) */
    5217             :     const int16_t L           /* i  : length                              */
    5218             : );
    5219             : 
    5220             : void wtda_ext(
    5221             :     const float *new_audio,    /* i  : input audio                         */
    5222             :     float *wtda_audio,         /* o  : windowed audio                      */
    5223             :     const int16_t left_mode,   /* i  : window overlap of previous frame (0: full, 2: none, or 3: half) */
    5224             :     const int16_t right_mode,  /* i  : window overlap of current frame (0: full, 2: none, or 3: half) */
    5225             :     const int16_t L,           /* i  : length                              */
    5226             :     const uint16_t kernel_type /* i  : transform kernel type (0 - 3)       */
    5227             : );
    5228             : 
    5229             : void tcx_get_windows_mode1(
    5230             :     const int16_t left_mode,  /* i  : overlap mode of left window half    */
    5231             :     const int16_t right_mode, /* i  : overlap mode of right window half   */
    5232             :     float *left_win,          /* o  : left overlap window                 */
    5233             :     float *right_win,         /* o  : right overlap window                */
    5234             :     float *left_win_int,      /* o  : left overlap window                 */
    5235             :     float *right_win_int,     /* o  : right overlap window                */
    5236             :     const int16_t L           /* i  : length                              */
    5237             : );
    5238             : 
    5239             : void direct_transform(
    5240             :     const float *in32,          /* i  : input signal                        */
    5241             :     float *out32,               /* o  : output transformation               */
    5242             :     const int16_t is_transient, /* i  : transient flag                      */
    5243             :     const int16_t L,            /* i  : length                              */
    5244             :     const int16_t element_mode  /* i  : IVAS element mode   */
    5245             : );
    5246             : 
    5247             : /*! r: index of noise attenuation */
    5248             : int16_t noise_adjust(
    5249             :     const float *coeffs_norm, /* i  : normalized coefficients             */
    5250             :     const int16_t *bitalloc,  /* i  : bit allocation                      */
    5251             :     const int16_t *sfm_start, /* i  : Start of bands                      */
    5252             :     const int16_t *sfm_end,   /* i  : End of bands                        */
    5253             :     const int16_t core_sfm    /* i  : index of the end band for core      */
    5254             : );
    5255             : 
    5256             : void interleave_spectrum(
    5257             :     float *coefs,        /* i/o: input and output coefficients       */
    5258             :     const int16_t length /* i  : length of spectrum                  */
    5259             : );
    5260             : 
    5261             : void hq_hr_enc(
    5262             :     Encoder_State *st,           /* i/o: encoder state structure             */
    5263             :     float *coefs,                /* i/o: transform-domain coefficients       */
    5264             :     const int16_t length,        /* i  : length of spectrum                  */
    5265             :     int16_t *num_bits,           /* i/o: number of available bits            */
    5266             :     const int16_t is_transient,  /* i  : transient flag                      */
    5267             :     const int16_t vad_hover_flag /* i  : VAD hangover flag                   */
    5268             : );
    5269             : 
    5270             : void logqnorm(
    5271             :     const float *x,  /* i  : coefficient vector                  */
    5272             :     int16_t *k,      /* o  : index                               */
    5273             :     const int16_t L, /* i  : codebook length                     */
    5274             :     const int16_t N, /* i  : sub-vector size                     */
    5275             :     const float *thren );
    5276             : 
    5277             : void huff_dec(
    5278             :     Decoder_State *st,         /* i/o: decoder state structure                         */
    5279             :     const int16_t N,           /* i  : Number of codewords to decode                   */
    5280             :     const int16_t buffer_len,  /* i  : Number of bits to read                          */
    5281             :     const int16_t num_lengths, /* i  : Number of different huffman codeword lengths    */
    5282             :     const int16_t *thres,      /* i  : Threshold of first codeword of each length      */
    5283             :     const int16_t *offset,     /* i  : Offset for first codeword                       */
    5284             :     const int16_t *huff_tab,   /* i  : Huffman table order by codeword lengths         */
    5285             :     int16_t *index             /* o  : Decoded index                                   */
    5286             : );
    5287             : 
    5288             : void calc_norm(
    5289             :     const float *x,           /* i  : Input vector.                       */
    5290             :     int16_t *norm,            /* o  : Quantization indices for norms      */
    5291             :     int16_t *normlg,          /* o  : Quantized norms in log2             */
    5292             :     const int16_t start_band, /* i  : Indice of band to start coding      */
    5293             :     const int16_t num_bands,  /* i  : Number of bands                     */
    5294             :     const int16_t *band_len,  /* i  : Length of bands                     */
    5295             :     const int16_t *band_start /* i  : Start of bands                      */
    5296             : );
    5297             : 
    5298             : void reordernorm(
    5299             :     const int16_t *ynrm,     /* i  : quantization indices for norms      */
    5300             :     const int16_t *normqlg2, /* i  : quantized norms                     */
    5301             :     int16_t *idxbuf,         /* o  : reordered quantization indices      */
    5302             :     int16_t *normbuf,        /* o  : reordered quantized norms           */
    5303             :     const int16_t nb_sfm     /* i  : number of bands                     */
    5304             : );
    5305             : 
    5306             : void diffcod(
    5307             :     const int16_t N, /* i  : number of sub-vectors               */
    5308             :     int16_t *y,      /* i/o: indices of quantized norms          */
    5309             :     int16_t *difidx  /* o  : differential code                   */
    5310             : );
    5311             : 
    5312             : void diffcod_lrmdct(
    5313             :     const int16_t N,           /* i  : number of sub-vectors       */
    5314             :     const int16_t be_ref,      /* i  : band energy reference       */
    5315             :     int16_t *y,                /* i/o: indices of quantized norms  */
    5316             :     int16_t *difidx,           /* o  : differential code           */
    5317             :     const int16_t is_transient /* i  : transient flag              */
    5318             : );
    5319             : 
    5320             : void normalizecoefs(
    5321             :     float *coefs,              /* i/o: MDCT coefficients                   */
    5322             :     const int16_t *ynrm,       /* i  : quantization indices for norms      */
    5323             :     const int16_t num_bands,   /* i  : Number of bands                     */
    5324             :     const int16_t *band_start, /* i  : Start of bands                      */
    5325             :     const int16_t *band_end    /* i  : End of bands                        */
    5326             : );
    5327             : 
    5328             : void bitallocsum(
    5329             :     int16_t *R,             /* i  : bit-allocation vector               */
    5330             :     const int16_t nb_sfm,   /* i  : number of sub-vectors               */
    5331             :     int16_t *sum,           /* o  : total number of bits allocated      */
    5332             :     int16_t *Rsubband,      /* o  : rate per subband (Q3)               */
    5333             :     const int16_t num_bits, /* i  : number of bits                      */
    5334             :     const int16_t length,   /* i  : length of spectrum                  */
    5335             :     const int16_t *sfmsize  /* i  : Length of bands                     */
    5336             : );
    5337             : 
    5338             : void hq_generic_hf_encoding(
    5339             :     const float *coefs,              /* i  : MDCT coefficients of weighted original      */
    5340             :     float *hq_generic_fenv,          /* i/o: energy of SWB envelope                      */
    5341             :     const int16_t hq_generic_offset, /* i  : frequency offset for extracting energy      */
    5342             :     Encoder_State *st,               /* i/o: encoder state structure                     */
    5343             :     int16_t *hq_generic_exc_clas,    /* o  : HF excitation class                         */
    5344             :     const int16_t length             /* i  : Length of spectrum                          */
    5345             : );
    5346             : 
    5347             : /*! r: BWE class */
    5348             : int16_t swb_bwe_gain_deq(
    5349             :     Decoder_State *st,       /* i/o: decoder state structure                     */
    5350             :     const int16_t core,      /* i  : core                                        */
    5351             :     float *SWB_tenv,         /* o  : time-domain BWE envelope                    */
    5352             :     float *SWB_fenv,         /* o  : frequency-domain BWE envelope               */
    5353             :     const int16_t hr_flag,   /* i  : high rate flag                              */
    5354             :     const int16_t hqswb_clas /* i  : HQ BWE class                                */
    5355             : );
    5356             : 
    5357             : void save_old_syn(
    5358             :     const int16_t L_frame,    /* i  : frame length                                */
    5359             :     const float syn[],        /* i  : ACELP synthesis                             */
    5360             :     float old_syn[],          /* o  : old synthesis buffer                        */
    5361             :     float old_syn_12k8_16k[], /* i/o: old synthesis buffer                        */
    5362             :     const float preemph_fac,  /* i  : preemphasis factor                          */
    5363             :     float *mem_deemph         /* i/o: deemphasis filter memory                    */
    5364             : );
    5365             : 
    5366             : void hq_generic_hf_decoding(
    5367             :     const int16_t HQ_mode,             /* i  : HQ mode                                     */
    5368             :     float *coeff_out1,                 /* i/o: BWE input & temporary buffer                */
    5369             :     const float *hq_generic_fenv,      /* i  : SWB frequency envelopes                     */
    5370             :     float *coeff_out,                  /* o  : SWB signal in MDCT domain                   */
    5371             :     const int16_t hq_generic_offset,   /* i  : frequency offset for representing hq swb bwe*/
    5372             :     int16_t *prev_L_swb_norm,          /* i/o: last normalize length                       */
    5373             :     const int16_t hq_swb_bwe_exc_clas, /* i  : bwe excitation class                        */
    5374             :     const int16_t *R );
    5375             : 
    5376             : void hq_core_dec(
    5377             :     Decoder_State *st,                 /* i/o: decoder state structure                 */
    5378             :     float out[],                       /* o  : output synthesis                        */
    5379             :     const int16_t output_frame,        /* i  : output frame length                     */
    5380             :     const int16_t hq_core_type,        /* i  : HQ core type                            */
    5381             :     const int16_t core_switching_flag, /* i  : ACELP->HQ switching frame flag          */
    5382             :     float *output                      /* o  : LB synthesis in case of ACELP-HQ switch */
    5383             : );
    5384             : 
    5385             : void IMDCT(
    5386             :     float *x,
    5387             :     float *old_syn_overl,
    5388             :     float *syn_Overl_TDAC,
    5389             :     float *xn_buf,
    5390             :     const float *tcx_aldo_window_1_trunc,
    5391             :     const float *tcx_aldo_window_2,
    5392             :     const float *tcx_mdct_window_half,
    5393             :     const float *tcx_mdct_window_minimum,
    5394             :     const float *tcx_mdct_window_trans,
    5395             :     const int16_t tcx_mdct_window_half_length,
    5396             :     const int16_t tcx_mdct_window_min_length,
    5397             :     int16_t index,
    5398             :     const uint16_t kernel_type, /* i  : TCX transform kernel type               */
    5399             :     const int16_t left_rect,
    5400             :     const int16_t tcx_offset,
    5401             :     const int16_t overlap,
    5402             :     const int16_t L_frame,
    5403             :     const int16_t L_frameTCX,
    5404             :     const int16_t L_spec_TCX5,
    5405             :     const int16_t L_frame_glob,
    5406             :     const int16_t frame_cnt,
    5407             :     const int16_t bfi,
    5408             :     float *old_out,
    5409             :     const int16_t FB_flag,
    5410             :     Decoder_State *st,
    5411             :     const int16_t fullband,
    5412             :     float *acelp_zir );
    5413             : 
    5414             : void hq_hr_dec(
    5415             :     Decoder_State *st,                /* i/o: decoder state structure         */
    5416             :     float *t_audio_q,                 /* o  : transform-domain coefficients   */
    5417             :     const int16_t length,             /* i  : frame length                    */
    5418             :     const int16_t num_bits,           /* i  : number of available bits        */
    5419             :     int16_t *ynrm,                    /* o  : norm quantization index vector  */
    5420             :     int16_t *is_transient,            /* o  : transient flag                  */
    5421             :     int16_t *hqswb_clas,              /* o  : HQ SWB class                    */
    5422             :     float *SWB_fenv,                  /* o  : SWB frequency envelopes         */
    5423             :     const int16_t core_switching_flag /* i  : Core switching flag             */
    5424             : 
    5425             : );
    5426             : 
    5427             : void hdecnrm_context(
    5428             :     Decoder_State *st, /* i/o: decoder state structure                 */
    5429             :     const int16_t N,   /* i  : number of norms                         */
    5430             :     int16_t *index,    /* o  : indices of quantized norms              */
    5431             :     int16_t *n_length  /* o  : decoded stream length                   */
    5432             : );
    5433             : 
    5434             : void hdecnrm_tran(
    5435             :     Decoder_State *st, /* i/o: decoder state structure     */
    5436             :     const int16_t N,   /* i  : number of norms             */
    5437             :     int16_t *index     /* o  : indices of quantized norms  */
    5438             : );
    5439             : 
    5440             : void hdecnrm_resize(
    5441             :     Decoder_State *st, /* i/o: decoder state structure                 */
    5442             :     const int16_t N,   /* i  : number of SFMs                          */
    5443             :     int16_t *index     /* o  : norm quantization index vector          */
    5444             : );
    5445             : 
    5446             : void hdecnrm(
    5447             :     Decoder_State *st, /* i/o: decoder state structure                 */
    5448             :     const int16_t N,   /* i  : number of norms                         */
    5449             :     int16_t *index     /* o  : indices of quantized norms              */
    5450             : );
    5451             : 
    5452             : /*! r: index of last band */
    5453             : int16_t find_last_band(
    5454             :     const int16_t *bitalloc, /* i  : bit allocation                          */
    5455             :     const int16_t nb_sfm     /* i  : number of possibly coded bands          */
    5456             : );
    5457             : 
    5458             : void fill_spectrum(
    5459             :     float *coeff,                      /* i/o: normalized MLT spectrum / nf spectrum                 */
    5460             :     int16_t *R,                        /* i  : number of pulses per band                             */
    5461             :     const int16_t is_transient,        /* i  : transient flag                                        */
    5462             :     int16_t norm[],                    /* i  : quantization indices for norms                        */
    5463             :     const float *hq_generic_fenv,      /* i  : HQ GENERIC envelope                                   */
    5464             :     const int16_t hq_generic_offset,   /* i  : HQ GENERIC offset                                     */
    5465             :     const int16_t nf_idx,              /* i  : noise fill index                                      */
    5466             :     const int16_t length,              /* i  : Length of spectrum (32 or 48 kHz)                     */
    5467             :     const float env_stab,              /* i  : Envelope stability measure [0..1]                     */
    5468             :     int16_t *no_att_hangover,          /* i/o: Frame counter for attenuation hangover                */
    5469             :     float *energy_lt,                  /* i/o: Long-term energy measure for transient detection      */
    5470             :     int16_t *bwe_seed,                 /* i/o: random seed for generating BWE input                  */
    5471             :     const int16_t hq_generic_exc_clas, /* i  : HF excitation class                                   */
    5472             :     const int16_t core_sfm,            /* i  : index of the end band for core                        */
    5473             :     int16_t HQ_mode,                   /* i  : HQ mode                                               */
    5474             :     float noise_level[],               /* i  : noise level for harmonic modes                        */
    5475             :     int32_t core_brate,                /* i  : target bitrate                                        */
    5476             :     float prev_noise_level[],          /* i/o: noise factor in previous frame                        */
    5477             :     int16_t *prev_R,                   /* i/o: bit allocation info. in previous frame                */
    5478             :     float *prev_coeff_out,             /* i/o: decoded spectrum in previous frame                    */
    5479             :     const int16_t *peak_idx,           /* i  : peak positions                                        */
    5480             :     const int16_t Npeaks,              /* i  : number of peaks                                       */
    5481             :     const int16_t *npulses,            /* i  : Number of assigned pulses per band                    */
    5482             :     int16_t prev_is_transient,         /* i  : previous transient flag                               */
    5483             :     float *prev_normq,                 /* i  : previous norms                                        */
    5484             :     float *prev_env,                   /* i  : previous noise envelopes                              */
    5485             :     int16_t prev_bfi,                  /* i  : previous bad frame indicator                          */
    5486             :     const int16_t *sfmsize,            /* i  : Length of bands                                       */
    5487             :     const int16_t *sfm_start,          /* i  : Start of bands                                        */
    5488             :     const int16_t *sfm_end,            /* i  : End of bands                                          */
    5489             :     int16_t *prev_L_swb_norm,          /* i/o: last normalize length for harmonic mode               */
    5490             :     int16_t prev_hq_mode,              /* i  : previous HQ mode                                      */
    5491             :     const int16_t num_sfm,             /* i  : Number of bands                                       */
    5492             :     const int16_t num_env_bands,       /* i  : Number of envelope bands                              */
    5493             :     const int16_t element_mode         /* i  : element mode                                          */
    5494             : );
    5495             : 
    5496             : void env_stab_transient_detect(
    5497             :     const int16_t is_transient, /* i  : Transient flag                                        */
    5498             :     const int16_t length,       /* i  : Length of spectrum (32 or 48 kHz)                     */
    5499             :     const int16_t norm[],       /* i  : quantization indices for norms                        */
    5500             :     int16_t *no_att_hangover,   /* i/o: Frame counter for attenuation hangover                */
    5501             :     float *energy_lt,           /* i/o: Long-term energy measure for transient detection      */
    5502             :     const int16_t HQ_mode,      /* i  : HQ coding mode                                        */
    5503             :     const int16_t bin_th,       /* i  : HVQ cross-over frequency bin                          */
    5504             :     const float *coeff          /* i  : Coded spectral coefficients                           */
    5505             : );
    5506             : 
    5507             : void de_interleave_spectrum(
    5508             :     float *coefs,  /* i/o: input and output coefficients   */
    5509             :     int16_t length /* i  : length of spectrum              */
    5510             : );
    5511             : 
    5512             : void inverse_transform(
    5513             :     const float *InMDCT,       /* i  : input MDCT vector               */
    5514             :     float *Out,                /* o  : output vector                   */
    5515             :     const int16_t IsTransient, /* i  : transient flag                  */
    5516             :     const int16_t L,           /* i  : output frame length             */
    5517             :     const int16_t L_inner,     /* i  : length of the transform         */
    5518             :     const int16_t element_mode /* i  : IVAS element mode   */
    5519             : );
    5520             : 
    5521             : void window_ola(
    5522             :     const float *ImdctOut, /* i  : input                           */
    5523             :     float *auOut,          /* o  : output audio                    */
    5524             :     float *OldauOut,       /* i/o: audio from previous frame       */
    5525             :     const int16_t L,       /* i  : length                          */
    5526             :     const int16_t right_mode,
    5527             :     const int16_t left_mode,    /* i  : window overlap of current frame (0: full, 2: none, or 3: half) */
    5528             :     const int16_t use_bfi_win,  /* i  : use BFI windowing               */
    5529             :     const int16_t oldHqVoicing, /* i  : previous HqVoicing              */
    5530             :     float *oldgapsynth          /* i  : previous gapsynth               */
    5531             : );
    5532             : 
    5533             : void window_ola_ext(
    5534             :     const float *ImdstOut, /* i  : input                       */
    5535             :     float *auOut,          /* o  : output audio                */
    5536             :     float *OldauOut,       /* i/o: audio from previous frame   */
    5537             :     const int16_t L,       /* i  : length                      */
    5538             :     const int16_t right_mode,
    5539             :     const int16_t left_mode,   /* i  : window overlap of current frame (0: full, 2: none, or 3: half) */
    5540             :     const uint16_t kernel_type /* i  : transform kernel type  */
    5541             : );
    5542             : 
    5543             : void map_quant_weight(
    5544             :     const int16_t normqlg2[],  /* i  : quantized norms                 */
    5545             :     int16_t wnorm[],           /* o  : weighted norm                   */
    5546             :     const int16_t is_transient /* i  : transient flag                  */
    5547             : );
    5548             : 
    5549             : void recovernorm(
    5550             :     const int16_t *const idxbuf, /* i  : reordered quantization indices */
    5551             :     int16_t *ynrm,               /* o  : recovered quantization indices */
    5552             :     int16_t *normqlg2,           /* o  : recovered quantized norms      */
    5553             :     const int16_t nb_sfm         /* i  : number of subbands             */
    5554             : );
    5555             : 
    5556             : void reordvct(
    5557             :     int16_t *y,      /* i/o: vector to rearrange    */
    5558             :     const int16_t N, /* i  : dimensions             */
    5559             :     int16_t *idx     /* o  : reordered vector index */
    5560             : );
    5561             : 
    5562             : void bitalloc(
    5563             :     int16_t *y,              /* i  : reordered norm of sub-vectors           */
    5564             :     int16_t *idx,            /* i  : reordered sub-vector indices            */
    5565             :     int16_t sum,             /* i  : number of available bits                */
    5566             :     int16_t N,               /* i  : number of norms                         */
    5567             :     int16_t K,               /* i  : maximum number of bits per dimension    */
    5568             :     int16_t *r,              /* o  : bit-allacation vector                   */
    5569             :     const int16_t *sfmsize,  /* i  : Length of bands                         */
    5570             :     const int16_t hqswb_clas /* i  : signal classification flag              */
    5571             : );
    5572             : 
    5573             : /*! r: Integer (truncated) number of allocated bits */
    5574             : int16_t BitAllocF(
    5575             :     int16_t *y,                 /* i  : norm of sub-vectors                     */
    5576             :     int32_t bit_rate,           /* i  : bitrate                                 */
    5577             :     int16_t B,                  /* i  : number of available bits                */
    5578             :     int16_t N,                  /* i  : number of sub-vectors                   */
    5579             :     int16_t *R,                 /* o  : bit-allocation indicator                */
    5580             :     int16_t *Rsubband,          /* o  : sub-band bit-allocation vector (Q3)     */
    5581             :     const int16_t hqswb_clas,   /* i  : hq swb class                            */
    5582             :     const int16_t num_env_bands /* i  : Number sub bands to be encoded for HQ_SWB_BWE  */
    5583             : );
    5584             : 
    5585             : /*! r: Integer (truncated) number of allocated bits */
    5586             : int16_t BitAllocWB(
    5587             :     int16_t *y,          /* i  : norm of sub-vectors                     */
    5588             :     int16_t B,           /* i  : number of available bits                */
    5589             :     int16_t N,           /* i  : number of sub-vectors                   */
    5590             :     int16_t *R,          /* o  : bit-allocation indicator                */
    5591             :     int16_t *Rsubband ); /* o  : sub-band bit-allocation vector (Q3)     */
    5592             : 
    5593             : /*! r: Number of low frequency bands */
    5594             : int16_t hvq_pvq_bitalloc(
    5595             :     int16_t num_bits,         /* i/o: Number of available bits (including gain bits) */
    5596             :     const int32_t core_brate, /* i  : bitrate                     */
    5597             :     const int16_t bwidth,     /* i  : Encoded bandwidth           */
    5598             :     const int16_t *ynrm,      /* i  : Envelope coefficients       */
    5599             :     const int32_t manE_peak,  /* i  : Peak energy mantissa        */
    5600             :     const int16_t expE_peak,  /* i  : Peak energy exponent        */
    5601             :     int16_t *Rk,              /* o  : bit allocation for concatenated vector */
    5602             :     int16_t *R,               /* i/o: Global bit allocation       */
    5603             :     int16_t *sel_bands,       /* o  : Selected bands for encoding */
    5604             :     int16_t *n_sel_bands      /* o  : No. of selected bands for encoding */
    5605             : );
    5606             : 
    5607             : void floating_point_add(
    5608             :     int32_t *mx,      /* i/o: mantissa of the addend Q31    */
    5609             :     int16_t *ex,      /* i/o: exponent of the addend Q0     */
    5610             :     const int32_t my, /* i  :  mantissa of the adder Q31    */
    5611             :     const int16_t ey  /* i  :  exponent of the adder Q0     */
    5612             : );
    5613             : 
    5614             : /*! r: Number of bits needed */
    5615             : int16_t rc_get_bits2(
    5616             :     const int16_t N,     /* i  : Number of bits currently used */
    5617             :     const uint32_t range /* i  : Range of range coder          */
    5618             : );
    5619             : 
    5620             : void rc_enc_init(
    5621             :     PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle            */
    5622             :     int16_t tot_bits     /* i  : Total bit budget              */
    5623             : );
    5624             : 
    5625             : void rc_encode(
    5626             :     BSTR_ENC_HANDLE hBstr,   /* i/o: encoder bitstream handle            */
    5627             :     PVQ_ENC_HANDLE hPVQ,     /* i/o: PVQ encoder handle                  */
    5628             :     const uint32_t cum_freq, /* i  : Cumulative frequency up to symbol   */
    5629             :     const uint32_t sym_freq, /* i  : Symbol probability                  */
    5630             :     const uint32_t tot       /* i  : Total cumulative frequency          */
    5631             : );
    5632             : 
    5633             : void rc_enc_finish(
    5634             :     BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle  */
    5635             :     PVQ_ENC_HANDLE hPVQ    /* i/o: PVQ encoder handle        */
    5636             : );
    5637             : 
    5638             : void rc_enc_bits(
    5639             :     BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle  */
    5640             :     PVQ_ENC_HANDLE hPVQ,   /* i/o: PVQ encoder handle        */
    5641             :     const uint32_t value,  /* i  : Value to encode           */
    5642             :     const int16_t bits     /* i  : Number of bits used       */
    5643             : );
    5644             : 
    5645             : void rc_enc_uniform(
    5646             :     BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle  */
    5647             :     PVQ_ENC_HANDLE hPVQ,   /* i/o: PVQ encoder handle        */
    5648             :     uint32_t value,        /* i  : Value to encode           */
    5649             :     uint32_t tot           /* i  : Maximum value             */
    5650             : );
    5651             : 
    5652             : void rc_dec_init(
    5653             :     Decoder_State *st,   /* i/o: Decoder State       */
    5654             :     PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle  */
    5655             :     int16_t tot_bits     /* i  : Total bit budget    */
    5656             : );
    5657             : 
    5658             : /*! r: Decoded value */
    5659             : uint32_t rc_decode(
    5660             :     int16_t *BER_detect, /* o  : Bit error detection flag        */
    5661             :     PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle              */
    5662             :     uint32_t tot         /* i  : Total cumulative frequency      */
    5663             : );
    5664             : 
    5665             : void rc_dec_update(
    5666             :     Decoder_State *st,       /* i/o: Decoder State           */
    5667             :     PVQ_DEC_HANDLE hPVQ,     /* i/o: PVQ decoder handle      */
    5668             :     const uint32_t cum_freq, /* i  : Cumulative frequency    */
    5669             :     const uint32_t sym_freq  /* i  : Symbol frequency        */
    5670             : );
    5671             : 
    5672             : /*! r: Decoded value   */
    5673             : uint32_t rc_dec_bits(
    5674             :     Decoder_State *st,   /* i/o: Decoder State          */
    5675             :     PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle     */
    5676             :     const int16_t bits   /* i  : Number of bits         */
    5677             : );
    5678             : 
    5679             : /*! r: Decoded value   */
    5680             : uint32_t rc_dec_uniform(
    5681             :     Decoder_State *st,   /* i/o: Decoder State          */
    5682             :     PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle     */
    5683             :     const uint32_t tot   /* i  : Maximum value          */
    5684             : );
    5685             : 
    5686             : void rc_dec_finish(
    5687             :     Decoder_State *st,  /* i/o: decoder state structure */
    5688             :     PVQ_DEC_HANDLE hPVQ /* i/o: PVQ decoder handle      */
    5689             : );
    5690             : 
    5691             : /*! r: number of bits encoded */
    5692             : int16_t pvq_core_enc(
    5693             :     BSTR_ENC_HANDLE hBstr,    /* i/o: encoder bitstream handle          */
    5694             :     float coefs_norm[],       /* i/o: normalized coefficients to encode */
    5695             :     float coefs_quant[],      /* o  : quantized coefficients            */
    5696             :     const int16_t bits_tot,   /* i  : total number of bits              */
    5697             :     const int16_t nb_sfm,     /* i  : number of bands                   */
    5698             :     const int16_t *sfm_start, /* i  : Subband start coefficient         */
    5699             :     const int16_t *sfm_end,   /* i  : Subband end coefficient           */
    5700             :     const int16_t *sfmsize,   /* i  : subband width                     */
    5701             :     int16_t *R,               /* i/o: Bit allocation/Adjusted bit alloc. (Q3) */
    5702             :     int16_t *Rs,              /* i/o: Integer bit allocation            */
    5703             :     int16_t *npulses,         /* o  : number of pulses                  */
    5704             :     int16_t *maxpulse,        /* i  : maximum pulse per band            */
    5705             :     const int16_t core        /* i  : number of bands                   */
    5706             : );
    5707             : 
    5708             : /*! r: number of bits decoded  */
    5709             : int16_t pvq_core_dec(
    5710             :     Decoder_State *st,        /* i/o: Decoder state                        */
    5711             :     const int16_t *sfm_start, /* i  : indices of first coeffs in the bands */
    5712             :     const int16_t *sfm_end,   /* i  : indices of last coeffs in the bands  */
    5713             :     const int16_t *sfmsize,   /* i  : band sizes                           */
    5714             :     float coefs_quant[],      /* o  : output MDCT                          */
    5715             :     const int16_t bits_tot,   /* i  : bit budget                           */
    5716             :     const int16_t nb_sfm,     /* i  : number of bands                      */
    5717             :     int16_t *R,               /* i/o: Bit allocation/Adjusted bit alloc.(Q3) */
    5718             :     int16_t *Rs,              /* i/o: Integer bit allocation               */
    5719             :     int16_t *npulses,         /* o  : number of pulses per band            */
    5720             :     int16_t *maxpulse,        /* o  : maximum pulse per band               */
    5721             :     const int16_t core        /* i  : core                                 */
    5722             : );
    5723             : 
    5724             : void pvq_encode(
    5725             :     BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle             */
    5726             :     PVQ_ENC_HANDLE hPVQ,   /* i/o: PVQ encoder handle                   */
    5727             :     const float *x,        /* i  : vector to quantize                   */
    5728             :     int16_t *y,            /* o  : quantized vector (non-scaled integer)*/
    5729             :     float *xq,             /* o  : quantized vector (scaled float)      */
    5730             :     const int16_t pulses,  /* i  : number of allocated pulses           */
    5731             :     const int16_t N,       /* i  : Length of vector                     */
    5732             :     const float gain       /* i  : Gain                                 */
    5733             : );
    5734             : 
    5735             : void pvq_decode(
    5736             :     Decoder_State *st,   /* i/o: Decoder State                    */
    5737             :     PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle               */
    5738             :     float *xq,           /* o  : decoded vector (scaled float)    */
    5739             :     int16_t *y,          /* o  : decoded vector (non-scaled short)*/
    5740             :     const int16_t K,     /* i  : number of allocated pulses       */
    5741             :     const int16_t N,     /* i  : Length of vector                 */
    5742             :     const float gain     /* i  : Gain                             */
    5743             : );
    5744             : 
    5745             : void rangeCoderFinalizationFBits(
    5746             :     const int16_t Brc,    /*  i  : Current number of decoded bits */
    5747             :     const uint32_t INTrc, /*  i  : Range coder state              */
    5748             :     int16_t *FBits        /*  i  : Fractional finalization bits   */
    5749             : );
    5750             : 
    5751             : void bandBitsAdjustment(
    5752             :     const int16_t Brc,     /* i  : Current number of read quanta in range coder */
    5753             :     const uint32_t INTrc,  /* i  : Range coder state                            */
    5754             :     const int16_t Bavail,  /* i  : Available number of quanta                   */
    5755             :     const int16_t Nbands,  /* i  : Number of bands                              */
    5756             :     const int16_t D,       /* i  : Remaining number of bands to encode          */
    5757             :     const int16_t L,       /* i  : Size of current band                         */
    5758             :     const int16_t Bband,   /* i  : Quanta allocation for current band           */
    5759             :     const int16_t Breserv, /* i  : Quanta reservoir                             */
    5760             :     int16_t *Bband_adj,    /* o  : Actual used number of quanta                 */
    5761             :     int16_t *Brem,         /* o  : Quanta remaining                             */
    5762             :     int16_t *Breservplus   /* o  : Quanta pool size                             */
    5763             : );
    5764             : 
    5765             : void conservativeL1Norm(
    5766             :     const int16_t L,       /* i  : Length of vector segment      */
    5767             :     const int16_t Qvec,    /* i  : Assigned number of quanta     */
    5768             :     const int16_t Fcons,   /* i  : Conservative rounding flag    */
    5769             :     const int16_t Qavail,  /* i  : Input quanta remaining        */
    5770             :     const int16_t Qreserv, /* i  : Input quanta in reservoir     */
    5771             :     const int16_t Dspec,   /* i  : assigned diracs from bitalloc */
    5772             :     int16_t *Dvec,         /* o  : actual number of diracs       */
    5773             :     int16_t *Qspare,       /* o  : Output quanta remaining       */
    5774             :     int16_t *Qreservplus,  /* o  : Output quanta in reservoir    */
    5775             :     int16_t *Dspecplus     /* o  : Output number of diracs       */
    5776             : );
    5777             : 
    5778             : void NearOppSplitAdjustment(
    5779             :     const int16_t qband,    /* i  : quanta for current band         */
    5780             :     const int16_t qzero,    /* i  : range coder finalization quanta */
    5781             :     const int16_t Qac,      /* i  : range coder current quanta      */
    5782             :     const uint32_t INTac,   /* i  : range coder state               */
    5783             :     const int16_t qglobal,  /* i  : quanta input                    */
    5784             :     const int16_t FlagCons, /* i  : conservative rounding flag      */
    5785             :     const int16_t Np,       /* i  : number of parts                 */
    5786             :     const int16_t Nhead,    /* i  : first part                      */
    5787             :     const int16_t Ntail,    /* i  : remaining parts                 */
    5788             :     const int16_t Nnear,    /* i  : length of near component        */
    5789             :     const int16_t Nopp,     /* i  : length of opposite component    */
    5790             :     int16_t oppRQ3,         /* i  : ratio                           */
    5791             :     int16_t *qnear,         /* o  : quantized near                  */
    5792             :     int16_t *qopp,          /* o  : quantized opposite              */
    5793             :     int16_t *qglobalupd     /* o  : quanta remaining                */
    5794             : );
    5795             : 
    5796             : /*! r: Approximate integer division for positive input */
    5797             : int32_t intLimCDivPos(
    5798             :     const int32_t NUM, /* i  : numerator   */
    5799             :     const int16_t DEN  /* i  : denominator */
    5800             : );
    5801             : 
    5802             : /*! r: Approximate integer division */
    5803             : int16_t shrtCDivSignedApprox(
    5804             :     const int16_t num, /* i  : numerator   */
    5805             :     const int16_t den  /* i  : denominator */
    5806             : );
    5807             : 
    5808             : void QuantaPerDsDirac(
    5809             :     const int16_t td,                  /* i  : Length of vector segment   */
    5810             :     const int16_t dsDiracIndex,        /* i  : Quanta table index         */
    5811             :     const uint8_t *const *dimFrQuanta, /* i  : Quanta lookup table        */
    5812             :     int16_t *Quanta                    /* i  : Quanta                     */
    5813             : );
    5814             : 
    5815             : void obtainEnergyQuantizerDensity(
    5816             :     const int16_t L_in, /* i  : left vector energy  */
    5817             :     const int16_t R_in, /* i  : right vector energy */
    5818             :     int16_t *Density    /* o  : quantizer density   */
    5819             : );
    5820             : 
    5821             : void densityAngle2RmsProjDec(
    5822             :     const int16_t D,        /* i  : density                   */
    5823             :     const int16_t indexphi, /* i  : decoded index from AR dec */
    5824             :     int16_t *oppQ15,        /* o  : opposite                  */
    5825             :     int16_t *nearQ15,       /* o  : near                      */
    5826             :     int16_t *oppRatioQ3     /* o  : ratio                     */
    5827             : );
    5828             : 
    5829             : void densityAngle2RmsProjEnc(
    5830             :     const int16_t D,        /* i  : density  */
    5831             :     const int16_t phiQ14uq, /* i  : angle    */
    5832             :     int16_t *indexphi,      /* o  : index    */
    5833             :     int16_t *oppQ15,        /* o  : opposite */
    5834             :     int16_t *nearQ15,       /* o  : near     */
    5835             :     int16_t *oppRatioQ3     /* o  : ratio    */
    5836             : );
    5837             : 
    5838             : void env_adj(
    5839             :     const int16_t *pulses,  /* i  : number of pulses per band             */
    5840             :     const int16_t length,   /* i  : length of spectrum                    */
    5841             :     const int16_t last_sfm, /* i  : Index of last band                    */
    5842             :     float *adj,             /* o  : Adjustment factors for the envelope   */
    5843             :     const float env_stab,   /* i  : Envelope stability parameter          */
    5844             :     const int16_t *sfmsize  /* i  : Length of bands                       */
    5845             : );
    5846             : 
    5847             : float env_stability(
    5848             :     const int16_t *ynrm,              /* i  : Norm vector for current frame          */
    5849             :     const int16_t nb_sfm,             /* i  : Number of sub-bands                    */
    5850             :     int16_t *mem_norm,                /* i/o: Norm vector memory from past frame     */
    5851             :     int16_t *mem_env_delta,           /* i/o: Envelope stability memory for smoothing*/
    5852             :     const int16_t core_switching_flag /* i  : Core switching flag             */
    5853             : );
    5854             : 
    5855             : /*! r: New speech/music state */
    5856             : float env_stab_smo(
    5857             :     float env_stab,          /* i  : env_stab value                         */
    5858             :     float *env_stab_state_p, /* i/o: env_stab state probabilities           */
    5859             :     int16_t *ho_cnt          /* i/o: hangover counter for speech state      */
    5860             : );
    5861             : 
    5862             : void core_switching_pre_enc(
    5863             :     Encoder_State *st,              /* i/o: encoder state structure                 */
    5864             :     const float *old_inp_12k8,      /* i  : old input signal @12.8kHz               */
    5865             :     const float *old_inp_16k,       /* i  : old input signal @16kHz                 */
    5866             :     const int16_t active_cnt,       /* i  : Active frame counter                    */
    5867             :     const int16_t last_element_mode /* i  : last_element_mode                       */
    5868             : );
    5869             : 
    5870             : void core_switching_post_enc(
    5871             :     Encoder_State *st,         /* i/o: encoder state structure                 */
    5872             :     const float *old_inp_12k8, /* i  : old input signal @12.8kHz               */
    5873             :     const float *old_inp_16k,  /* i  : old input signal @16kHz                 */
    5874             :     const float A[]            /* i  : unquant LP filter coefs.                */
    5875             : );
    5876             : 
    5877             : ivas_error core_switching_post_dec(
    5878             :     Decoder_State *st,                   /* i/o: decoder state structure                 */
    5879             :     float *synth,                        /* i/o: output synthesis                        */
    5880             :     float *output,                       /* i/o: LB synth/upsampled LB synth             */
    5881             :     float output_mem[],                  /* i  : OLA memory from last TCX/HQ frame       */
    5882             :     const int16_t use_cldfb_for_dft,     /* i  : flag to use of CLDFB for DFT Stereo     */
    5883             :     const int16_t output_frame,          /* i  : frame length                            */
    5884             :     const int16_t core_switching_flag,   /* i  : ACELP->HQ switching frame flag          */
    5885             :     const int16_t sba_dirac_stereo_flag, /* i  : signal stereo output for SBA DirAC      */
    5886             :     const int16_t nchan_out,             /* i  : number of output channels               */
    5887             :     const int16_t last_element_mode      /* i  : element mode of previous frame          */
    5888             : );
    5889             : 
    5890             : ivas_error core_switching_pre_dec(
    5891             :     Decoder_State *st,                 /* i/o: decoder state structure              */
    5892             :     const int16_t output_frame,        /* i  : frame length                         */
    5893             :     const int32_t last_core_brate_st0, /* i  : channel 0 last core bitrate          */
    5894             :     const int16_t nchan_out,           /* i  : number of output channels            */
    5895             :     const int16_t last_element_mode,   /* i  : last_element_mode                    */
    5896             :     const int32_t last_element_brate   /* i  : last element bitrate                 */
    5897             : );
    5898             : 
    5899             : void bandwidth_switching_detect(
    5900             :     Decoder_State *st /* i/o: decoder state structure                 */
    5901             : );
    5902             : 
    5903             : void bw_switching_pre_proc(
    5904             :     Decoder_State *st,                /* i/o: decoder state structure                 */
    5905             :     const float *old_syn_12k8_16k,    /* i  : ACELP core synthesis @ 12.8kHz or 16kHz */
    5906             :     const int32_t last_element_brate, /* i  : last element bitrate                     */
    5907             :     const int16_t nchan_out           /* i  : number of output channels               */
    5908             : );
    5909             : 
    5910             : void updt_bw_switching(
    5911             :     Decoder_State *st, /* i/o: decoder state structure                 */
    5912             :     const float *synth /* i  : float synthesis signal                  */
    5913             : );
    5914             : 
    5915             : void swb_tbe_reset(
    5916             :     float mem_csfilt[],
    5917             :     float mem_genSHBexc_filt_down_shb[],
    5918             :     float state_lpc_syn[],
    5919             :     float syn_overlap[],
    5920             :     float state_syn_shbexc[],
    5921             :     float *tbe_demph,
    5922             :     float *tbe_premph,
    5923             :     float mem_stp_swb[],
    5924             :     float *gain_prec_swb );
    5925             : 
    5926             : void swb_tbe_reset_synth(
    5927             :     float genSHBsynth_Hilbert_Mem[],
    5928             :     float genSHBsynth_state_lsyn_filt_shb_local[] );
    5929             : 
    5930             : void find_td_envelope(
    5931             :     const float inp[],
    5932             :     const int16_t len,
    5933             :     const int16_t len_h,
    5934             :     float mem_h[],
    5935             :     float out[] );
    5936             : 
    5937             : void fb_tbe_reset_enc(
    5938             :     float elliptic_bpf_2_48k_mem[][4],
    5939             :     float *prev_fb_energy );
    5940             : 
    5941             : void fb_tbe_reset_synth(
    5942             :     float fbbwe_hpf_mem[][4],
    5943             :     float *prev_fbbwe_ratio );
    5944             : 
    5945             : void wb_tbe_extras_reset(
    5946             :     float mem_genSHBexc_filt_down_wb2[],
    5947             :     float mem_genSHBexc_filt_down_wb3[] );
    5948             : 
    5949             : void wb_tbe_extras_reset_synth(
    5950             :     float state_lsyn_filt_shb[],
    5951             :     float state_lsyn_filt_dwn_shb[],
    5952             :     float mem_resamp_HB[] );
    5953             : 
    5954             : void tbe_celp_exc(
    5955             :     const int16_t element_mode, /* i  : element mode                            */
    5956             :     const int16_t idchan,       /* i  : channel ID                              */
    5957             :     float *bwe_exc,             /* i/o: BWE excitation                          */
    5958             :     const int16_t L_frame,      /* i  : frame length                            */
    5959             :     const int16_t L_subfr,      /* i  : subframe length                         */
    5960             :     const int16_t i_subfr,      /* i  : subframe index                          */
    5961             :     const int16_t T0,           /* i  : integer pitch lag                       */
    5962             :     const int16_t T0_frac,      /* i  : fraction of lag                         */
    5963             :     float *error,               /* i/o: error                                   */
    5964             :     const int16_t tdm_LRTD_flag /* i  : LRTD stereo mode flag                   */
    5965             : );
    5966             : 
    5967             : void prep_tbe_exc(
    5968             :     const int16_t L_frame,      /* i  : length of the frame                     */
    5969             :     const int16_t L_subfr,      /* i  : subframe length                         */
    5970             :     const int16_t i_subfr,      /* i  : subframe index                          */
    5971             :     const float gain_pit,       /* i  : Pitch gain                              */
    5972             :     const float gain_code,      /* i  : algebraic codebook gain                 */
    5973             :     const float code[],         /* i  : algebraic excitation                    */
    5974             :     const float voice_fac,      /* i  : voicing factor                          */
    5975             :     float *voice_factors,       /* o  : TBE voicing factor                      */
    5976             :     float bwe_exc[],            /* i/o: excitation for TBE                      */
    5977             :     const float gain_preQ,      /* i  : prequantizer excitation gain            */
    5978             :     const float code_preQ[],    /* i  : prequantizer excitation                 */
    5979             :     const int16_t T0,           /* i  : integer pitch variables                 */
    5980             :     const int16_t coder_type,   /* i  : coding type                             */
    5981             :     const int32_t core_brate,   /* i  : core bitrate                            */
    5982             :     const int16_t element_mode, /* i  : element mode                            */
    5983             :     const int16_t idchan,       /* i  : channel ID                              */
    5984             :     const int16_t flag_TD_BWE,  /* i  : flag indicating whether hTD_BWE exists  */
    5985             :     const int16_t tdm_LRTD_flag /* i  : LRTD stereo mode flag                   */
    5986             : );
    5987             : 
    5988             : void synthesise_fb_high_band(
    5989             :     const float excitation_in[], /* i  : full band excitation                    */
    5990             :     float output[],              /* o  : high band speech - 14.0 to 20 kHz       */
    5991             :     const float fb_exc_energy,   /* i  : full band excitation energy             */
    5992             :     const float ratio,           /* i  : energy ratio                            */
    5993             :     const int16_t L_frame,       /* i  : ACELP frame length                      */
    5994             :     const int16_t bfi,           /* i  : BFI flag                                */
    5995             :     float *prev_fbbwe_ratio,     /* o  : previous frame energy for FEC           */
    5996             :     float bpf_memory[][4]        /* i/o: memory for elliptic bpf 48k             */
    5997             : );
    5998             : 
    5999             : void elliptic_bpf_48k_generic(
    6000             :     const float input[],           /* i  : input signal                            */
    6001             :     float output[],                /* o  : output signal                           */
    6002             :     float memory[][4],             /* i/o: 4 arrays for memory                     */
    6003             :     const float full_band_bpf[][5] /* i  : filter coefficients b0,b1,b2,a0,a1,a2   */
    6004             : );
    6005             : 
    6006             : void HQ_FEC_processing(
    6007             :     Decoder_State *st,            /* i/o: decoder state structure                          */
    6008             :     float *t_audio_q,             /* o  : MDCT coeffs. (for synthesis)                     */
    6009             :     int16_t is_transient,         /* i  : Old flag for transient                           */
    6010             :     float ynrm_values[][MAX_PGF], /* i  : Old average Norm values for each group of bands  */
    6011             :     float r_p_values[][MAX_ROW],  /* i  : Computed y-intercept and slope by Regression     */
    6012             :     int16_t num_Sb,               /* i  : Number of sub-band group                         */
    6013             :     int16_t nb_sfm,               /* i  : Number of sub-band                               */
    6014             :     int16_t *Num_bands_p,         /* i  : Number of coeffs. for each sub-band              */
    6015             :     int16_t output_frame,         /* i  : Frame size                                       */
    6016             :     const int16_t *sfm_start,     /* i  : Start of bands                                   */
    6017             :     const int16_t *sfm_end        /* i  : End of bands                                     */
    6018             : );
    6019             : 
    6020             : void HQ_FEC_Mem_update(
    6021             :     Decoder_State *st, /* i/o: decoder state structure            */
    6022             :     const float *t_audio_q,
    6023             :     float *normq,
    6024             :     int16_t *ynrm,
    6025             :     const int16_t *Num_bands_p,
    6026             :     const int16_t is_transient,
    6027             :     const int16_t hqswb_clas,
    6028             :     const int16_t c_switching_flag,
    6029             :     const int16_t nb_sfm,
    6030             :     const int16_t num_Sb,
    6031             :     float *mean_en_high,
    6032             :     const int16_t hq_core_type, /* i  : normal or low-rate MDCT(HQ) core */
    6033             :     const int16_t output_frame  /* i  : Frame size                       */
    6034             : );
    6035             : 
    6036             : void time_domain_FEC_HQ(
    6037             :     Decoder_State *st,         /* i  : Decoder State                           */
    6038             :     float *wtda_audio,         /* i  : input                                   */
    6039             :     float *out,                /* o  : output audio                            */
    6040             :     const float mean_en_high,  /* i  : transient flag                          */
    6041             :     const int16_t output_frame /* i  : Frame size                               */
    6042             : );
    6043             : 
    6044             : void save_synthesis_hq_fec(
    6045             :     Decoder_State *st,          /* i/o: decoder state structure                 */
    6046             :     const float *output,        /* i  : decoded synthesis                       */
    6047             :     const int16_t output_frame, /* i  : decoded synthesis                       */
    6048             :     CPE_DEC_HANDLE hCPE         /* i  : CPE decoder structure                   */
    6049             : );
    6050             : 
    6051             : void Next_good_after_burst_erasures(
    6052             :     const float *ImdctOut, /* i  : input                                   */
    6053             :     float *auOut,          /* o  : output audio                            */
    6054             :     float *OldauOut,       /* i/o: audio from previous frame               */
    6055             :     const int16_t ol_size  /* i  : overlap size                            */
    6056             : );
    6057             : 
    6058             : void update_average_rate(
    6059             :     SC_VBR_ENC_HANDLE hSC_VBR, /* i/o: SC-VBR state structure                  */
    6060             :     const int32_t core_brate   /* i  : core bitrate                            */
    6061             : );
    6062             : 
    6063             : void reset_preecho_dec(
    6064             :     HQ_DEC_HANDLE hHQ_core /* i/o: HQ decoder handle                       */
    6065             : );
    6066             : 
    6067             : void preecho_sb(
    6068             :     const int32_t core_brate,  /* i  : core bitrate                                            */
    6069             :     const float wtda_audio[],  /* i  : imdct signal                                            */
    6070             :     float *rec_sig,            /* i  : reconstructed signal, output of the imdct transform     */
    6071             :     const int16_t framelength, /* i  : frame length                                            */
    6072             :     float *memfilt_lb,         /* i/o: memory                                                  */
    6073             :     float *mean_prev_hb,       /* i/o: memory                                                  */
    6074             :     float *smoothmem,          /* i/o: memory                                                  */
    6075             :     float *mean_prev,          /* i/o: memory                                                  */
    6076             :     float *mean_prev_nc,       /* i/o: memory                                                  */
    6077             :     float *wmold_hb,           /* i/o: memory                                                  */
    6078             :     int16_t *prevflag,         /* i/o: flag                                                    */
    6079             :     int16_t *pastpre,          /* i/o: flag                                                    */
    6080             :     const int16_t bwidth       /* i  : audio bandwidth                                         */
    6081             : );
    6082             : 
    6083             : void hq2_core_configure(
    6084             :     const int16_t frame_length, /* i  : frame length                            */
    6085             :     const int16_t num_bits,     /* i  : number of bits                          */
    6086             :     const int16_t is_transient, /* i  : transient flag                          */
    6087             :     int16_t *bands,
    6088             :     int16_t *length,
    6089             :     int16_t band_width[],
    6090             :     int16_t band_start[],
    6091             :     int16_t band_end[],
    6092             :     Word32 *L_qint,              /* o  : Q29 */
    6093             :     Word16 *eref_fx,             /* o  : Q10 */
    6094             :     Word16 *bit_alloc_weight_fx, /* o  : Q13 */
    6095             :     int16_t *gqlevs,
    6096             :     int16_t *Ngq,
    6097             :     int16_t *p2a_bands,
    6098             :     float *p2a_th,
    6099             :     float *pd_thresh,
    6100             :     float *ld_slope,
    6101             :     float *ni_coef,
    6102             :     float *ni_pd_th,
    6103             :     int32_t bwe_br );
    6104             : 
    6105             : void hq_lr_enc(
    6106             :     Encoder_State *st,         /* i/o: encoder state structure                 */
    6107             :     float t_audio[],           /* i/o: transform-domain coefs.                 */
    6108             :     const int16_t inner_frame, /* i  : inner frame length                      */
    6109             :     int16_t *num_bits,         /* i/o: number of available bits                */
    6110             :     const int16_t is_transient /* i  : transient flag                          */
    6111             : );
    6112             : 
    6113             : void hq_lr_dec(
    6114             :     Decoder_State *st,         /* i/o: decoder state structure                 */
    6115             :     float yout[],              /* o  : transform-domain output coefs.          */
    6116             :     const int16_t inner_frame, /* i  : inner frame length                      */
    6117             :     int16_t num_bits,          /* i  : number of available bits                */
    6118             :     int16_t *is_transient      /* o  : transient flag                          */
    6119             : );
    6120             : 
    6121             : void hq2_bit_alloc(
    6122             :     const float band_energy[],  /* i  : band energy of each subband                 */
    6123             :     const int16_t bands,        /* i  : total number of subbands in a frame         */
    6124             :     Word32 L_Rk[],              /* i/o: Bit allocation/Adjusted bit alloc.          */
    6125             :     int16_t *bit_budget,        /* i/o: bit bugdet                                  */
    6126             :     int16_t *p2a_flags,         /* i  : HF tonal indicator                          */
    6127             :     const Word16 weight_fx,     /* i  : weight (Q13)                                */
    6128             :     const int16_t band_width[], /* i  : Sub band bandwidth                          */
    6129             :     const int16_t num_bits,     /* i  : available bits                              */
    6130             :     const int16_t hqswb_clas,   /* i  : HQ2 class information                       */
    6131             :     const int16_t bwidth,       /* i  : input bandwidth                             */
    6132             :     const int16_t is_transient  /* i  : indicator HQ_TRANSIENT or not               */
    6133             : );
    6134             : 
    6135             : void hq2_noise_inject(
    6136             :     float y2hat[],
    6137             :     const int16_t band_start[],
    6138             :     const int16_t band_end[],
    6139             :     const int16_t band_width[],
    6140             :     float Ep[],
    6141             :     float Rk[],
    6142             :     const int16_t npulses[],
    6143             :     int16_t ni_seed,
    6144             :     const int16_t bands,
    6145             :     const int16_t ni_start_band,
    6146             :     const int16_t bw_low,
    6147             :     const int16_t bw_high,
    6148             :     const float enerL,
    6149             :     const float enerH,
    6150             :     float last_ni_gain[],
    6151             :     float last_env[],
    6152             :     int16_t *last_max_pos_pulse,
    6153             :     int16_t *p2a_flags,
    6154             :     int16_t p2a_bands,
    6155             :     const int16_t hqswb_clas,
    6156             :     const int16_t bwidth,
    6157             :     const int32_t bwe_br );
    6158             : 
    6159             : void mdct_spectrum_denorm(
    6160             :     const int32_t inp_vector[],
    6161             :     float y2[],
    6162             :     const int16_t band_start[],
    6163             :     const int16_t band_end[],
    6164             :     const int16_t band_width[],
    6165             :     const float band_energy[],
    6166             :     const int16_t npulses[],
    6167             :     const int16_t bands,
    6168             :     const float ld_slope,
    6169             :     const float pd_thresh );
    6170             : 
    6171             : void reverse_transient_frame_energies(
    6172             :     float band_energy[], /* o  : band energies                           */
    6173             :     const int16_t bands  /* i  : number of bands                         */
    6174             : );
    6175             : 
    6176             : int16_t peak_vq_enc(
    6177             :     BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle    */
    6178             :     const int16_t bwidth,  /* i  : audio bandwidth             */
    6179             : #ifdef DEBUGGING
    6180             :     const int16_t idchan, /* i  : channel ID                  */
    6181             : #endif
    6182             :     const float *coefs,       /* i  : Input coefficient vector    */
    6183             :     float *coefs_out,         /* o  : Quantized output vector     */
    6184             :     const int32_t core_brate, /* i  : Core bitrate                */
    6185             :     const int16_t num_bits,   /* i  : Number of bits for HVQ      */
    6186             :     const int16_t vq_peaks,   /* i  : Number of identified peaks  */
    6187             :     const int16_t *ynrm,      /* i  : Envelope coefficients       */
    6188             :     int16_t *R,               /* i/o: Bit allocation/updated bit allocation */
    6189             :     int16_t *vq_peak_idx,     /* i  : Peak index vector           */
    6190             :     float *nf_gains           /* i  : Estimated noise floor gains */
    6191             : );
    6192             : 
    6193             : void hvq_dec(
    6194             :     Decoder_State *st,        /* i/o: decoder state structure                */
    6195             :     const int16_t num_bits,   /* i  : Number of available bits               */
    6196             :     const int32_t core_brate, /* i  : Core bitrate                           */
    6197             :     const int16_t *ynrm,      /* i  : Envelope coefficients                  */
    6198             :     int16_t *R,               /* i/o: Bit allocation/updated bit allocation  */
    6199             :     float *noise_level,       /* o  : Noise level                            */
    6200             :     int16_t *peak_idx,        /* o  : Peak position vector                   */
    6201             :     int16_t *Npeaks,          /* o  : Total number of peaks                  */
    6202             :     float *coefsq_norm,       /* o  : Output vector                          */
    6203             :     const int16_t core        /* i  : Core                                   */
    6204             : );
    6205             : 
    6206             : void hq_configure_bfi(
    6207             :     int16_t *nb_sfm,           /* o  : Number of sub bands               */
    6208             :     int16_t *num_Sb,           /* o  : Number of FEC sub bands ?         */
    6209             :     int16_t *num_bands_p,      /* o  : FEC sub bands                     */
    6210             :     const int16_t **sfmsize,   /* o  : Subband bandwidths                */
    6211             :     const int16_t **sfm_start, /* o  : Subband start coefficients        */
    6212             :     const int16_t **sfm_end    /* o  : Subband end coefficients          */
    6213             : );
    6214             : 
    6215             : void swb_bwe_enc_lr(
    6216             :     Encoder_State *st,         /* i/o: encoder state structure     */
    6217             :     const float m_core[],      /* i  : core synthesis (MDCT)       */
    6218             :     const float m_orig[],      /* i/o: scaled orig signal (MDCT)   */
    6219             :     float m[],                 /* o  : output, SWB part (MDCT)     */
    6220             :     const int32_t total_brate, /* i  : total bitrate for selecting subband pattern */
    6221             :     int16_t BANDS,
    6222             :     int16_t *band_start,
    6223             :     int16_t *band_end,
    6224             :     float *band_energy,
    6225             :     int16_t *p2a_flags,
    6226             :     const int16_t hqswb_clas,
    6227             :     int16_t lowlength,
    6228             :     int16_t highlength,
    6229             :     int16_t *prev_frm_index,
    6230             :     const int16_t har_bands,
    6231             :     int16_t *prev_frm_hfe2,
    6232             :     int16_t *prev_stab_hfe2,
    6233             :     int16_t band_width[],
    6234             :     const float y2_ni[],
    6235             :     int16_t *ni_seed );
    6236             : 
    6237             : void swb_bwe_dec_lr(
    6238             :     Decoder_State *st,         /* i/o: decoder state structure                     */
    6239             :     const float m_core[],      /* i  : lowband synthesis                           */
    6240             :     float m[],                 /* o  : highband synthesis with lowband zeroed      */
    6241             :     const int32_t total_brate, /* i  : total bitrate for selecting subband pattern */
    6242             :     int16_t BANDS,
    6243             :     int16_t *band_start,
    6244             :     int16_t *band_end,
    6245             :     float *band_energy,
    6246             :     int16_t *p2a_flags,
    6247             :     const int16_t hqswb_clas,
    6248             :     int16_t lowlength,
    6249             :     int16_t highlength,
    6250             :     const int16_t har_bands,
    6251             :     int16_t *prev_frm_hfe2,
    6252             :     int16_t *prev_stab_hfe2,
    6253             :     int16_t band_width[],
    6254             :     const float y2_ni[],
    6255             :     int16_t *ni_seed );
    6256             : 
    6257             : int16_t get_usebit_npswb(
    6258             :     const int16_t hqswb_clas );
    6259             : 
    6260             : void GetPredictedSignal(
    6261             :     const float *predBuf, /* i  : prediction buffer        */
    6262             :     float *outBuf,        /* o  : output buffer            */
    6263             :     const int16_t lag,    /* i  : prediction buffer offset */
    6264             :     const int16_t fLen,   /* i  : length of loop (output)  */
    6265             :     const float gain      /* i  : gain to be applied       */
    6266             : );
    6267             : 
    6268             : void convert_lagIndices_pls2smp(
    6269             :     int16_t lagIndices_in[],
    6270             :     int16_t nBands_search,
    6271             :     int16_t lagIndices_out[],
    6272             :     const float sspectra[],
    6273             :     const int16_t sbWidth[],
    6274             :     const int16_t fLenLow );
    6275             : 
    6276             : void FindNBiggest2_simple(
    6277             :     const float *inBuf, /* i  : input buffer (searched)                     */
    6278             :     GainItem *g,        /* o  : N biggest components found                  */
    6279             :     const int16_t nIdx, /* i  : search length                               */
    6280             :     int16_t *n,         /* i  : number of components searched (N biggest)   */
    6281             :     const int16_t N_NBIGGESTSEARCH );
    6282             : 
    6283             : void updat_prev_frm(
    6284             :     float y2[],
    6285             :     float t_audio[],
    6286             :     const int32_t bwe_br,
    6287             :     const int16_t length,
    6288             :     const int16_t inner_frame,
    6289             :     const int16_t bands,
    6290             :     const int16_t bwidth,
    6291             :     const int16_t is_transient,
    6292             :     const int16_t hqswb_clas,
    6293             :     int16_t *prev_hqswb_clas,
    6294             :     int16_t *prev_SWB_peak_pos,
    6295             :     int16_t prev_SWB_peak_pos_tmp[],
    6296             :     int16_t *prev_frm_hfe2,
    6297             :     int16_t *prev_stab_hfe2,
    6298             :     const int16_t bws_cnt );
    6299             : 
    6300             : void hf_parinitiz(
    6301             :     const int32_t total_brate,
    6302             :     const int16_t hqswb_clas,
    6303             :     int16_t lowlength,
    6304             :     int16_t highlength,
    6305             :     int16_t wBands[],
    6306             :     const int16_t **subband_search_offset,
    6307             :     const int16_t **subband_offsets,
    6308             :     int16_t *nBands,
    6309             :     int16_t *nBands_search,
    6310             :     int16_t *swb_lowband,
    6311             :     int16_t *swb_highband );
    6312             : 
    6313             : float spectrumsmooth_noiseton(
    6314             :     float spectra[],
    6315             :     const float spectra_ni[],
    6316             :     float sspectra[],
    6317             :     float sspectra_diff[],
    6318             :     float sspectra_ni[],
    6319             :     const int16_t fLenLow,
    6320             :     int16_t *ni_seed );
    6321             : 
    6322             : void noiseinj_hf(
    6323             :     float xSynth_har[],
    6324             :     const float th_g[],
    6325             :     const float band_energy[],
    6326             :     float *prev_En_sb,
    6327             :     const int16_t p2a_flags[],
    6328             :     const int16_t BANDS,
    6329             :     const int16_t band_start[],
    6330             :     const int16_t band_end[],
    6331             :     const int16_t fLenLow );
    6332             : 
    6333             : void noise_extr_corcod(
    6334             :     float spectra[],
    6335             :     const float spectra_ni[],
    6336             :     float sspectra[],
    6337             :     float sspectra_diff[],
    6338             :     float sspectra_ni[],
    6339             :     const int16_t fLenLow,
    6340             :     int16_t prev_hqswb_clas,
    6341             :     float *prev_ni_ratio );
    6342             : 
    6343             : void genhf_noise(
    6344             :     float noise_flr[],
    6345             :     float xSynth_har[],
    6346             :     float *predBuf,
    6347             :     int16_t bands,         /* i  : total number of subbands in a frame         */
    6348             :     int16_t harmonic_band, /* i  : Number of LF harmonic frames                */
    6349             :     int16_t har_freq_est2,
    6350             :     int16_t pos_max_hfe2,
    6351             :     int16_t *pul_res,
    6352             :     GainItem pk_sf[],
    6353             :     const int16_t fLenLow,
    6354             :     const int16_t fLenHigh,
    6355             :     const int16_t sbWidth[],
    6356             :     const int16_t lagIndices[],
    6357             :     const int16_t subband_offsets[],
    6358             :     const int16_t subband_search_offset[] );
    6359             : 
    6360             : void ton_ene_est(
    6361             :     float xSynth_har[],
    6362             :     float be_tonal[],
    6363             :     float band_energy[],
    6364             :     int16_t band_start[],
    6365             :     int16_t band_end[],
    6366             :     int16_t band_width[],
    6367             :     const int16_t fLenLow,
    6368             :     const int16_t fLenHigh,
    6369             :     int16_t bands,
    6370             :     int16_t har_bands,
    6371             :     float ni_lvl,
    6372             :     GainItem pk_sf[],
    6373             :     int16_t *pul_res );
    6374             : 
    6375             : void Gettonl_scalfact(
    6376             :     float *outBuf,          /* o  : synthesized spectrum                        */
    6377             :     const float *codbuf,    /* i  : core coder                                  */
    6378             :     const int16_t fLenLow,  /* i  : lowband length                              */
    6379             :     const int16_t fLenHigh, /* i  : highband length                             */
    6380             :     int16_t harmonic_band,  /* i  : Number of LF harmonic frames                */
    6381             :     int16_t bands,          /* i  : total number of subbands in a frame         */
    6382             :     float *band_energy,     /* i  : band energy of each subband                 */
    6383             :     int16_t *band_start,    /* i  : subband start indices                       */
    6384             :     int16_t *band_end,      /* i  : subband end indices                         */
    6385             :     const int16_t p2aflags[],
    6386             :     float be_tonal[],
    6387             :     GainItem *pk_sf,
    6388             :     int16_t *pul_res );
    6389             : 
    6390             : void SpectrumSmoothing(
    6391             :     float *inBuf,
    6392             :     float *outBuf,
    6393             :     const int16_t fLen,
    6394             :     const float th_cut );
    6395             : 
    6396             : void hq2_bit_alloc_har(
    6397             :     float *y,  /* i  : band energy of sub-vectors                    */
    6398             :     int16_t B, /* i  : number of available bits                      */
    6399             :     int16_t N, /* i  : number of sub-vectors                         */
    6400             :     Word32 *L_Rsubband,
    6401             :     int16_t p2a_bands,
    6402             :     int32_t core_brate, /* i  : core bitrate                                 */
    6403             :     int16_t p2a_flags[],
    6404             :     int16_t band_width[] );
    6405             : 
    6406             : void GetSynthesizedSpecThinOut(
    6407             :     const float *predBuf,
    6408             :     float *outBuf,
    6409             :     const int16_t nBands,
    6410             :     const int16_t *sbWidth,
    6411             :     const int16_t *lagIndices,
    6412             :     const float *lagGains,
    6413             :     const int16_t predBufLen );
    6414             : 
    6415             : void return_bits_normal2(
    6416             :     int16_t *bit_budget,
    6417             :     const int16_t p2a_flags[],
    6418             :     const int16_t bands,
    6419             :     const int16_t bits_lagIndices[] );
    6420             : 
    6421             : void GetlagGains(
    6422             :     const float *predBuf,
    6423             :     const float *band_energy,
    6424             :     const int16_t nBands,
    6425             :     const int16_t *sbWidth,
    6426             :     const int16_t *lagIndices,
    6427             :     const int16_t predBufLen,
    6428             :     float *lagGains );
    6429             : 
    6430             : void preset_hq2_swb(
    6431             :     const int16_t hqswb_clas,
    6432             :     const int16_t band_end[],
    6433             :     int16_t *har_bands,
    6434             :     int16_t p2a_bands,
    6435             :     const int16_t length,
    6436             :     const int16_t bands,
    6437             :     int16_t *lowlength,
    6438             :     int16_t *highlength,
    6439             :     float m[] );
    6440             : 
    6441             : void post_hq2_swb(
    6442             :     const float m[],
    6443             :     const int16_t lowlength,
    6444             :     const int16_t highlength,
    6445             :     const int16_t hqswb_clas,
    6446             :     const int16_t har_bands,
    6447             :     const int16_t bands,
    6448             :     const int16_t p2a_flags[],
    6449             :     const int16_t band_start[],
    6450             :     const int16_t band_end[],
    6451             :     float y2[],
    6452             :     int16_t npulses[] );
    6453             : 
    6454             : void har_denorm_pulcnt(
    6455             :     float spectra[],            /* i/o: MDCT domain spectrum                        */
    6456             :     const int16_t band_start[], /* i  : Number subbands/Frame                       */
    6457             :     const int16_t band_end[],   /* i  : Band Start of each SB                       */
    6458             :     const float band_energy[],  /* i  : Band end of each SB                         */
    6459             :     const int16_t band_width[],
    6460             :     const int16_t npulses[],
    6461             :     const int16_t har_bands /* i  : No. of harmonic bands                       */
    6462             : );
    6463             : 
    6464             : int16_t har_est(
    6465             :     float spectra[],
    6466             :     const int16_t N,
    6467             :     int16_t *har_freq_est1,
    6468             :     int16_t *har_freq_est2,
    6469             :     int16_t *flag_dis,
    6470             :     int16_t *prev_frm_hfe2,
    6471             :     const int16_t subband_search_offset[],
    6472             :     const int16_t sbWidth[],
    6473             :     int16_t *prev_stab_hfe2 );
    6474             : 
    6475             : void spt_shorten_domain_pre(
    6476             :     const int16_t band_start[],
    6477             :     const int16_t band_end[],
    6478             :     const int16_t prev_SWB_peak_pos[],
    6479             :     const int16_t BANDS,
    6480             :     const int32_t bwe_br,
    6481             :     int16_t new_band_start[],
    6482             :     int16_t new_band_end[],
    6483             :     int16_t new_band_width[] );
    6484             : 
    6485             : void spt_shorten_domain_band_save(
    6486             :     const int16_t bands,
    6487             :     const int16_t band_start[],
    6488             :     const int16_t band_end[],
    6489             :     const int16_t band_width[],
    6490             :     int16_t org_band_start[],
    6491             :     int16_t org_band_end[],
    6492             :     int16_t org_band_width[] );
    6493             : 
    6494             : void spt_shorten_domain_band_restore(
    6495             :     const int16_t bands,
    6496             :     int16_t band_start[],
    6497             :     int16_t band_end[],
    6498             :     int16_t band_width[],
    6499             :     const int16_t org_band_start[],
    6500             :     const int16_t org_band_end[],
    6501             :     const int16_t org_band_width[] );
    6502             : 
    6503             : void spt_swb_peakpos_tmp_save(
    6504             :     const float y2[],
    6505             :     const int16_t bands,
    6506             :     const int16_t band_start[],
    6507             :     const int16_t band_end[],
    6508             :     int16_t prev_SWB_peak_pos_tmp[] );
    6509             : 
    6510             : void hq_ecu(
    6511             :     const float *prevsynth,            /* i  : buffer of previously synthesized signal   */
    6512             :     float *ecu_rec,                    /* o  : reconstructed frame in tda domain         */
    6513             :     int16_t *time_offs,                /* i/o: Sample offset for consecutive frame losses*/
    6514             :     float *X_sav,                      /* i/o: Stored spectrum of prototype frame        */
    6515             :     int16_t *num_p,                    /* i/o: Number of identified peaks                */
    6516             :     int16_t *plocs,                    /* i/o: Peak locations                            */
    6517             :     float *plocsi,                     /* i/o: Interpolated peak locations               */
    6518             :     const float env_stab,              /* i  : Envelope stability parameter              */
    6519             :     int16_t *last_fec,                 /* i/o: Flag for usage of pitch dependent ECU     */
    6520             :     const int16_t ph_ecu_HqVoicing,    /* i  : HQ Voicing flag                           */
    6521             :     int16_t *ph_ecu_active,            /* i  : Phase ECU active flag                     */
    6522             :     float *gapsynth,                   /* o  : Gap synthesis                             */
    6523             :     const int16_t prev_bfi,            /* i  : indicating burst frame error              */
    6524             :     const int16_t old_is_transient[2], /* i  : flags indicating previous transient frames*/
    6525             :     float *mag_chg_1st,                /* i/o: per band magnitude modifier for transients*/
    6526             :     float Xavg[LGW_MAX],               /* i/o: Frequency group average gain to fade to   */
    6527             :     float *beta_mute,                  /* o  : Factor for long-term mute                 */
    6528             :     const int16_t output_frame,        /* i  : frame length                              */
    6529             :     Decoder_State *st                  /* i/o: decoder state structure                   */
    6530             : );
    6531             : 
    6532             : void peakfinder(
    6533             :     const float *x0,        /* i  : vector from which the maxima will be found                     */
    6534             :     const int16_t len0,     /* i  : length of input vector                                         */
    6535             :     int16_t *plocs,         /* o  : the indicies of the identified peaks in x0                     */
    6536             :     int16_t *cInd,          /* o  : number of identified peaks                                     */
    6537             :     const float sel,        /* i  : The amount above surrounding data for a peak to be identified  */
    6538             :     const int16_t endpoints /* i  : Flag to include endpoints in peak search                       */
    6539             : );
    6540             : 
    6541             : /*! r: interpolated maximum position */
    6542             : float imax_pos(
    6543             :     const float *y /* i  : Input vector for peak interpolation */
    6544             : );
    6545             : 
    6546             : 
    6547             : void fft3(
    6548             :     const float X[], /* i  : input frame                                */
    6549             :     float Y[],       /* o  : DFT of input frame                         */
    6550             :     const int16_t n  /* i  : block length (must be radix 3)             */
    6551             : );
    6552             : 
    6553             : void ifft3(
    6554             :     const float X[], /* i  : input frame                                */
    6555             :     float Y[],       /* o  : iDFT of input frame                        */
    6556             :     const int16_t n  /* i  : block length (must be radix 3)             */
    6557             : );
    6558             : 
    6559             : /*! r: updated estimate of background noise */
    6560             : void minimumStatistics(
    6561             :     float *noiseLevelMemory,  /* i/o: internal state                            */
    6562             :     int16_t *noiseLevelIndex, /* i/o: internal state                            */
    6563             :     int16_t *currLevelIndex,  /* i/o: internal state (circular buffer)          */
    6564             :     float *noiseEstimate,     /* i/o: previous estimate of background noise     */
    6565             :     float *lastFrameLevel,    /* i/o: level of the last frame                   */
    6566             :     float currentFrameLevel,  /* i  : level of the current frame                */
    6567             :     const float minLev,       /* i  : minimum level                             */
    6568             :     const int16_t buffSize    /* i  : buffer size                               */
    6569             : );
    6570             : 
    6571             : void E_LPC_int_lpc_tcx(
    6572             :     const float lsf_old[], /* i  : LSFs from past frame                      */
    6573             :     const float lsf_new[], /* i  : LSFs from present frame                   */
    6574             :     float a[]              /* o  : interpolated LP coefficients              */
    6575             : );
    6576             : 
    6577             : int16_t E_GAIN_closed_loop_search(
    6578             :     float exc[],
    6579             :     float xn[],
    6580             :     float h[],
    6581             :     int16_t t0_min,
    6582             :     int16_t t0_min_frac,
    6583             :     int16_t t0_max,
    6584             :     int16_t t0_max_frac,
    6585             :     const int16_t t0_min_max_res,
    6586             :     int16_t *pit_frac,
    6587             :     int16_t *pit_res,
    6588             :     const int16_t pit_res_max,
    6589             :     const int16_t i_subfr,
    6590             :     const int16_t pit_min,
    6591             :     const int16_t pit_fr2,
    6592             :     const int16_t pit_fr1,
    6593             :     const int16_t L_subfr );
    6594             : 
    6595             : void E_ACELP_toeplitz_mul(
    6596             :     const float R[],
    6597             :     const float c[],
    6598             :     float d[] );
    6599             : 
    6600             : void acelp_pulsesign(
    6601             :     const float cn[],
    6602             :     float dn[],
    6603             :     float dn2[],
    6604             :     float sign[],
    6605             :     float vec[],
    6606             :     const float alp );
    6607             : 
    6608             : void E_ACELP_4t(
    6609             :     float dn[],
    6610             :     float cn[],
    6611             :     float H[],
    6612             :     float R[],
    6613             :     const int16_t acelpautoc,
    6614             :     float code[],
    6615             :     const int16_t cdk_index,
    6616             :     int16_t _index[],
    6617             :     const int16_t L_frame,
    6618             :     const int16_t last_L_frame,
    6619             :     const int32_t total_brate,
    6620             :     const int16_t i_subfr,
    6621             :     const int16_t cmpl_flag );
    6622             : 
    6623             : void E_ACELP_4tsearch(
    6624             :     float dn[],
    6625             :     const float cn[],
    6626             :     const float H[],
    6627             :     float code[],
    6628             :     PulseConfig *config,
    6629             :     int16_t ind[],
    6630             :     float y[] );
    6631             : 
    6632             : void E_ACELP_4tsearchx(
    6633             :     float dn[],
    6634             :     const float cn[],
    6635             :     float Rw[],
    6636             :     float code[],
    6637             :     PulseConfig *config,
    6638             :     int16_t ind[] );
    6639             : 
    6640             : int16_t E_ACELP_indexing(
    6641             :     float code[],
    6642             :     PulseConfig config,
    6643             :     const int16_t num_tracks,
    6644             :     int16_t prm[] );
    6645             : 
    6646             : void acelp_findcandidates(
    6647             :     float dn2[],
    6648             :     int16_t dn2_pos[],
    6649             :     int16_t pos_max[],
    6650             :     const int16_t L_subfr,
    6651             :     const int16_t tracks );
    6652             : 
    6653             : void E_ACELP_innovative_codebook(
    6654             :     const float *exc,           /* i  : pointer to the excitation frame                  */
    6655             :     const int16_t T0,           /* i  : integer pitch lag                                */
    6656             :     const int16_t T0_frac,      /* i  : fraction of lag                                  */
    6657             :     const int16_t T0_res,       /* i  : pitch resolution                                 */
    6658             :     const float pitch_gain,     /* i  : adaptive codebook gain                           */
    6659             :     const float tilt_code,      /* i  : tilt factor                                      */
    6660             :     ACELP_config *acelp_cfg,    /* i/o: configuration of the ACELP                       */
    6661             :     const int16_t i_subfr,      /* i  : subframe index                                   */
    6662             :     const float *Aq,            /* i  : quantized LPC coefficients                       */
    6663             :     const float *h1,            /* i  : impulse response of weighted synthesis filter    */
    6664             :     const float *xn,            /* i  : Close-loop Pitch search target vector            */
    6665             :     const float *cn,            /* i  : Innovative codebook search target vector         */
    6666             :     const float *y1,            /* i  : zero-memory filtered adaptive excitation         */
    6667             :     float *y2,                  /* o  : zero-memory filtered algebraic excitation        */
    6668             :     const int16_t acelpautoc,   /* i  : autocorrelation mode enabled                     */
    6669             :     int16_t **pt_indice,        /* i/o: quantization indices pointer                     */
    6670             :     float *code,                /* o  : innovative codebook                              */
    6671             :     const int16_t L_frame,      /* i  : length of the frame                              */
    6672             :     const int16_t last_L_frame, /* i  : length of the last frame                         */
    6673             :     const int32_t total_brate   /* i  : total bitrate                                    */
    6674             : );
    6675             : 
    6676             : int16_t E_ACELP_code43bit(
    6677             :     const float code[],
    6678             :     uint32_t *ps,
    6679             :     int16_t *p,
    6680             :     uint16_t idxs[] );
    6681             : 
    6682             : void fcb_pulse_track_joint(
    6683             :     uint16_t *idxs,
    6684             :     const int16_t wordcnt,
    6685             :     uint32_t *index_n,
    6686             :     const int16_t *pulse_num,
    6687             :     const int16_t track_num );
    6688             : 
    6689             : void D_ACELP_indexing(
    6690             :     float code[],
    6691             :     PulseConfig config,
    6692             :     const int16_t num_tracks,
    6693             :     int16_t prm[],
    6694             :     int16_t *BER_detect );
    6695             : 
    6696             : void D_ACELP_decode_43bit(
    6697             :     uint16_t idxs[],
    6698             :     float code[],
    6699             :     int16_t *pulsestrack );
    6700             : 
    6701             : void fcb_pulse_track_joint_decode(
    6702             :     uint16_t *idxs,
    6703             :     const int16_t wordcnt,
    6704             :     uint32_t *index_n,
    6705             :     const int16_t *pulse_num,
    6706             :     const int16_t track_num );
    6707             : 
    6708             : void lag_wind(
    6709             :     float r[],             /* i/o: autocorrelations                                       */
    6710             :     const int16_t m,       /* i  : order of LP filter                                     */
    6711             :     const int32_t sr_core, /* i  : sampling rate                                          */
    6712             :     const int16_t strength /* i  : LAGW_WEAK, LAGW_MEDIUM, or LAGW_STRONG                 */
    6713             : );
    6714             : 
    6715             : void adapt_lag_wind(
    6716             :     float r[],            /* i/o: autocorrelations                                       */
    6717             :     const int16_t m,      /* i  : order of LP filter                                     */
    6718             :     const int16_t Top,    /* i  : open loop pitch lags from curr. frame (or NULL if n/a) */
    6719             :     const float Tnc,      /* i  : open loop pitch gains from curr. frame (NULL if n/a)   */
    6720             :     const int32_t sr_core /* i  : core sampling rate                                     */
    6721             : );
    6722             : 
    6723             : void hp20(
    6724             :     Float32 signal[],
    6725             :     const Word16 lg,
    6726             :     Float32 mem[],
    6727             :     const Word32 Fs );
    6728             : 
    6729             : void ham_cos_window(
    6730             :     float *fh,
    6731             :     const int16_t n1,
    6732             :     const int16_t n2 );
    6733             : 
    6734             : /*! r: noise dependent voicing correction */
    6735             : float correlation_shift(
    6736             :     const float totalNoise /* i  : noise estimate over all critical bands  */
    6737             : );
    6738             : 
    6739             : void init_coder_ace_plus(
    6740             :     Encoder_State *st,              /* i  : Encoder state handle                */
    6741             :     const int32_t last_total_brate, /* i  : last total bitrate                  */
    6742             :     const int32_t igf_brate,        /* i  : IGF configuration bitrate           */
    6743             :     const int16_t MCT_flag          /* i  : hMCT handle allocated (1) or not (0)*/
    6744             : );
    6745             : 
    6746             : void core_coder_reconfig(
    6747             :     Encoder_State *st,             /* i/o: encoder state structure             */
    6748             :     const int32_t last_total_brate /* i  : last total bitrate                  */
    6749             : );
    6750             : 
    6751             : void core_coder_mode_switch(
    6752             :     Encoder_State *st,              /* i/o: encoder state structure             */
    6753             :     const int32_t last_total_brate, /* i  : last bitrate                        */
    6754             :     const int16_t MCT_flag          /* i  : hMCT handle allocated (1) or not (0)*/
    6755             : );
    6756             : 
    6757             : void enc_acelp_tcx_main(
    6758             :     Encoder_State *st,                 /* i/o: encoder state structure             */
    6759             :     const float new_samples[],         /* i  : new samples                         */
    6760             :     float Aw[NB_SUBFR16k * ( M + 1 )], /* i  : weighted A(z) unquant. for subframes*/
    6761             :     const float lsp_new[M],            /* i  : LSPs at the end of the frame        */
    6762             :     const float lsp_mid[M],            /* i  : LSPs at the middle of the frame     */
    6763             :     float bwe_exc_extended[],          /* i/o: bandwidth extended excitation       */
    6764             :     float *voice_factors,              /* o  : voicing factors                     */
    6765             :     float pitch_buf[],                 /* o  : floating pitch for each subframe    */
    6766             :     const int16_t vad_hover_flag       /* i  : VAD hangover flag                   */
    6767             : );
    6768             : 
    6769             : void getTCXMode(
    6770             :     Decoder_State *st,     /* i/o: decoder memory state                */
    6771             :     Decoder_State *st0,    /* i  : bitstream                           */
    6772             :     const int16_t MCT_flag /* i  : hMCT handle allocated (1) or not (0)*/
    6773             : );
    6774             : 
    6775             : void getTCXWindowing(
    6776             :     const int16_t core,         /* i  : current frame mode                  */
    6777             :     const int16_t last_core,    /* i  : last frame mode                     */
    6778             :     const int16_t element_mode, /* i  : element mode                        */
    6779             :     TCX_CONFIG_HANDLE hTcxCfg,  /* i/o: TCX configuration handle            */
    6780             :     Decoder_State *st0          /* i  : bitstream                           */
    6781             : );
    6782             : 
    6783             : void getLPCparam(
    6784             :     Decoder_State *st,            /* i/o: decoder memory state                */
    6785             :     int16_t param_lpc[],          /* o  : LTP parameters                      */
    6786             :     Decoder_State *st0,           /* i  : bitstream                           */
    6787             :     const int16_t ch,             /* i  : channel                             */
    6788             :     const int16_t sns_low_br_mode /* i  : SNS low-bitrate mode                */
    6789             : );
    6790             : 
    6791             : void getTCXparam(
    6792             :     Decoder_State *st,           /* i/o: Decoder State handle                  */
    6793             :     Decoder_State *st0,          /* i  : bitstream                             */
    6794             :     CONTEXT_HM_CONFIG hm_cfg,    /* i/o: HM config                             */
    6795             :     int16_t param[],             /* o  : decoded parameters                    */
    6796             :     const int16_t bits_common,   /* i  : number of common bits                 */
    6797             :     const int16_t start_bit_pos, /* i  : position of the start bit             */
    6798             :     const int16_t *no_param_tns, /* i  : number of TNS parameters per subframe */
    6799             :     int16_t p_param[2],          /* o  : pointer to parameters for next round of bs reading*/
    6800             :     int16_t nTnsBitsTCX10[2],
    6801             :     const int16_t pre_past_flag );
    6802             : 
    6803             : void pitch_pred_linear_fit(
    6804             :     const int16_t nbLostCmpt, /* i  : bfi counter                                     */
    6805             :     const int16_t last_good,  /* i  : last classification type                        */
    6806             :     float *old_pitch_buf,     /* i  : pitch lag buffer                                */
    6807             :     float *old_fpitch,        /* i/o: pitch used for initial ACB generation           */
    6808             :     float *T0_out,            /* o  : estimated close loop pitch                      */
    6809             :     const int16_t pit_min,    /* i  : Minimum pitch lag                               */
    6810             :     const int16_t pit_max,    /* i  : Maximum pitch lag                               */
    6811             :     float *mem_pitch_gain,    /* i  : lag pitch gain [0] is the most recent subfr lag */
    6812             :     const int16_t limitation,
    6813             :     const int16_t plc_use_future_lag, /* i  : number of subframes to predict                  */
    6814             :     int16_t *extrapolationFailed,     /* o  : flag if extrap decides not to change the pitch  */
    6815             :     const int16_t nb_subfr            /* i  : number of ACELP subframes                       */
    6816             : );
    6817             : 
    6818             : void get_subframe_pitch(
    6819             :     const int16_t nSubframes, /* i  : number of subframes                             */
    6820             :     float pitchStart,         /* i  : starting pitch lag (in subframe -1)             */
    6821             :     float pitchEnd,           /* i  : ending pitch lag (in subframe nSubframes-1)     */
    6822             :     float *pitchBuf           /* o  : interpolated pitch lag per subframe             */
    6823             : );
    6824             : 
    6825             : void core_encode_openloop(
    6826             :     Encoder_State *st,                       /* i/o: encoder state structure             */
    6827             :     const float Aw[NB_SUBFR16k * ( M + 1 )], /* i  : weighted A(z) unquant. for subframes*/
    6828             :     const float lsp_new[M],                  /* i  : LSPs at the end of the frame        */
    6829             :     const float lsp_mid[M],                  /* i  : LSPs at the middle of the frame     */
    6830             :     float *pitch_buf,                        /* i/o: floating pitch values for each subfr*/
    6831             :     float *voice_factors,                    /* o  : voicing factors                     */
    6832             :     float *ptr_bwe_exc,                      /* o  : excitation for SWB TBE              */
    6833             :     const int16_t vad_hover_flag             /* i  : VAD hangover flag                   */
    6834             : );
    6835             : 
    6836             : void core_acelp_tcx20_switching(
    6837             :     Encoder_State *st,            /* i/o: encoder state structure                   */
    6838             :     float non_staX,               /* i  : unbound non-stationarity for sp/mu clas   */
    6839             :     float *pitch_fr,              /* i/o: fraction pitch values                     */
    6840             :     float *voicing_fr,            /* i/o: fractional voicing values                 */
    6841             :     const float currTempFlatness, /* i  : flatness                                  */
    6842             :     const float lsp_mid[M],       /* i  : LSPs at the middle of the frame           */
    6843             :     const float stab_fac          /* i  : LP filter stability                       */
    6844             : );
    6845             : 
    6846             : void core_encode_twodiv(
    6847             :     Encoder_State *st,                 /* i/o: coder memory state                  */
    6848             :     const float new_samples[],         /* i  : new samples                         */
    6849             :     float Aw[NB_SUBFR16k * ( M + 1 )], /* i  : weighted A(z) unquant. for subframes*/
    6850             :     const int16_t vad_hover_flag       /* i  : VAD hangover flag                   */
    6851             : );
    6852             : 
    6853             : void core_encode_update(
    6854             :     Encoder_State *st /* i/o: encoder state structure             */
    6855             : );
    6856             : 
    6857             : void core_encode_update_cng(
    6858             :     Encoder_State *st, /* i/o: encoder state structure             */
    6859             :     float *timeDomainBuffer,
    6860             :     float *A,
    6861             :     const float Aw[] /* i  : weighted A(z) unquant. for subframes*/
    6862             : );
    6863             : 
    6864             : void core_signal_analysis_high_bitrate(
    6865             :     const float *new_samples,
    6866             :     const int16_t T_op[3], /* i  : open-loop pitch values for quantiz. */
    6867             :     float lsp_new[],
    6868             :     float lsp_mid[],
    6869             :     Encoder_State *st,
    6870             :     float *mdst_spectrum[2],
    6871             :     int16_t pTnsSize[],
    6872             :     int16_t pTnsBits[],
    6873             :     int16_t param_core[],
    6874             :     int16_t *ltpBits,
    6875             :     float *windowed_samples, /* i/o: backup of windowed time signal */
    6876             :     const int16_t L_frame,
    6877             :     const int16_t L_frameTCX,
    6878             :     const int16_t last_element_mode,
    6879             :     const int16_t vad_hover_flag /* i  : VAD hangover flag                          */
    6880             : );
    6881             : 
    6882             : /*! r: codebook gain (adaptive or fixed) */
    6883             : float get_gain(
    6884             :     const float x[], /* i  : target signal                        */
    6885             :     const float y[], /* i  : filtered codebook excitation         */
    6886             :     const int16_t n, /* i  : segment length                       */
    6887             :     float *en_y      /* o  : energy of y (sum of y[]^2, optional) */
    6888             : );
    6889             : 
    6890             : void encode_acelp_gains(
    6891             :     const float *code,
    6892             :     const int16_t gains_mode,
    6893             :     const float mean_ener_code,
    6894             :     const int16_t clip_gain,
    6895             :     ACELP_CbkCorr *g_corr,
    6896             :     float *gain_pit,
    6897             :     float *gain_code,
    6898             :     int16_t **pt_indice,
    6899             :     float *past_gcode,
    6900             :     float *gain_inov,
    6901             :     const int16_t L_subfr,
    6902             :     float *code2,
    6903             :     float *gain_code2,
    6904             :     const int16_t noisy_speech_flag );
    6905             : 
    6906             : int16_t gain_enc_gacelp_uv(
    6907             :     const float *code,              /* i  : algebraic excitation                                            */
    6908             :     const float *code2,             /* i  : gaussian excitation                                             */
    6909             :     const int16_t lcode,            /* i  : Subframe size                                                   */
    6910             :     const float mean_ener,          /* i  : quantized mean energy of the frame                              */
    6911             :     float *gain_pit,                /* o  : quantized pitch gain                                            */
    6912             :     float *gain_code,               /* o  : quantized codebook gain                                         */
    6913             :     float *gain_code2,              /* o  : quantized codebook gain                                         */
    6914             :     ACELP_CbkCorr *coeff,           /* i/o: correlations <y1,y1>, -2<xn,y1>,<y2,y2>, -2<xn,y2> and 2<y1,y2> */
    6915             :     float *past_gcode,              /* i/o: past gain of code                                               */
    6916             :     float *gain_inov,               /* o  : unscaled innovation gain                                        */
    6917             :     const int16_t noisy_speech_flag /* i  : noisy speech flag                                               */
    6918             : );
    6919             : 
    6920             : int16_t Mode2_gain_enc_mless(
    6921             :     const float *code,       /* i  : algebraic excitation                                            */
    6922             :     const int16_t lcode,     /* i  : Subframe size                                                   */
    6923             :     float *gain_pit,         /* o  : quantized pitch gain                                            */
    6924             :     float *gain_code,        /* o  : quantized codebook gain                                         */
    6925             :     ACELP_CbkCorr *coeff,    /* i/o: correlations <y1,y1>, -2<xn,y1>,<y2,y2>, -2<xn,y2> and 2<y1,y2> */
    6926             :     const float mean_ener,   /* i  : mean_ener defined in open-loop (3 bits)                         */
    6927             :     const int16_t clip_gain, /* i  : gain pitch clipping flag (1 = clipping)                         */
    6928             :     float *past_gcode,       /* i/o: past gain of code                                               */
    6929             :     float *gain_inov,        /* o  : unscaled innovation gain                                        */
    6930             :     const int16_t coder_type /* i  : type of coder                                                   */
    6931             : );
    6932             : 
    6933             : void decode_acelp_gains(
    6934             :     const float *code,
    6935             :     const int16_t gains_mode,
    6936             :     const float mean_ener_code,
    6937             :     float *gain_pit,
    6938             :     float *gain_code,
    6939             :     int16_t **pt_indice,
    6940             :     float *past_gpit,
    6941             :     float *past_gcode,
    6942             :     float *gain_inov,
    6943             :     const int16_t L_subfr,
    6944             :     float *code2,
    6945             :     float *gain_code2 );
    6946             : 
    6947             : void gain_dec_gacelp_uv(
    6948             :     int16_t index,         /* i/o: Quantization index vector             */
    6949             :     const float *code,     /* i  : algebraic code excitation             */
    6950             :     const float *code2,    /* i  : algebraic code excitation             */
    6951             :     const float mean_ener, /* i  : mean energy                           */
    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             :     float *gain_code2,     /* o  : Quantized codebook gain               */
    6956             :     float *past_gpit,      /* i/o: past gain of pitch                    */
    6957             :     float *past_gcode,     /* i/o: past energy of code                   */
    6958             :     float *gain_inov       /* o  : unscaled innovation gain              */
    6959             : );
    6960             : 
    6961             : void Mode2_pit_encode(
    6962             :     const int16_t coder_type, /* i  : coding model                               */
    6963             :     const int16_t i_subfr,    /* i  : subframe index                             */
    6964             :     int16_t **pt_indice,      /* i/o: quantization indices pointer               */
    6965             :     float *exc,               /* i/o: pointer to excitation signal frame         */
    6966             :     const int16_t *T_op,      /* i  : open loop pitch estimates in current frame */
    6967             :     int16_t *T0_min,          /* i/o: lower limit for close-loop search          */
    6968             :     int16_t *T0_min_frac,     /* i/o: lower limit for close-loop search          */
    6969             :     int16_t *T0_max,          /* i/o: higher limit for close-loop search         */
    6970             :     int16_t *T0_max_frac,     /* i/o: higher limit for close-loop search         */
    6971             :     int16_t *T0,              /* i/o: close loop integer pitch                   */
    6972             :     int16_t *T0_frac,         /* i/o: close loop fractional part of the pitch    */
    6973             :     int16_t *T0_res,          /* i/o: close loop pitch resolution                */
    6974             :     float *h1,                /* i  : weighted filter impulse response           */
    6975             :     float *xn,                /* i  : target vector                              */
    6976             :     const int16_t pit_min,
    6977             :     const int16_t pit_fr1,
    6978             :     const int16_t pit_fr1b,
    6979             :     const int16_t pit_fr2,
    6980             :     const int16_t pit_max,
    6981             :     const int16_t pit_res_max );
    6982             : 
    6983             : void limit_T0_voiced(
    6984             :     const int16_t nbits,
    6985             :     const int16_t res,
    6986             :     const int16_t T0,      /* i  : rough pitch estimate around which the search is done */
    6987             :     const int16_t T0_frac, /* i  : pitch estimate fractional part                       */
    6988             :     const int16_t T0_res,  /* i  : pitch resolution                                     */
    6989             :     int16_t *T0_min,       /* o  : lower pitch limit                                    */
    6990             :     int16_t *T0_min_frac,  /* o  : lower pitch limit                                    */
    6991             :     int16_t *T0_max,       /* o  : higher pitch limit                                   */
    6992             :     int16_t *T0_max_frac,  /* o  : higher pitch limit                                   */
    6993             :     const int16_t pit_min, /* i  : Minimum pitch lag                                    */
    6994             :     const int16_t pit_max  /* i  : Maximum pitch lag                                    */
    6995             : );
    6996             : 
    6997             : void Mode2_abs_pit_enc(
    6998             :     const int16_t T0,      /* i  : integer pitch lag              */
    6999             :     const int16_t T0_frac, /* i  : pitch fraction                 */
    7000             :     int16_t **pt_indice,   /* i/o: pointer to Vector of Q indexes */
    7001             :     const int16_t pit_min,
    7002             :     const int16_t pit_fr1,
    7003             :     const int16_t pit_fr2,
    7004             :     const int16_t pit_res_max );
    7005             : 
    7006             : void Mode2_delta_pit_enc(
    7007             :     const int16_t T0,          /* i  : integer pitch lag              */
    7008             :     const int16_t T0_frac,     /* i  : pitch fraction                 */
    7009             :     const int16_t T0_res,      /* i  : pitch resolution               */
    7010             :     const int16_t T0_min,      /* i  : delta search min               */
    7011             :     const int16_t T0_min_frac, /* i  : delta search min               */
    7012             :     int16_t **pt_indice        /* o  : pointer to Vector of Q indexes */
    7013             : );
    7014             : 
    7015             : /*! r: floating pitch value */
    7016             : float Mode2_pit_decode(
    7017             :     const int16_t coder_type, /* i  : coding model                            */
    7018             :     const int16_t i_subfr,    /* i  : subframe index                          */
    7019             :     const int16_t L_subfr,    /* i  : sub-frame length                */
    7020             :     int16_t **pt_indice,      /* i/o: quantization indices pointer            */
    7021             :     int16_t *T0,              /* o  : close loop integer pitch                */
    7022             :     int16_t *T0_frac,         /* o  : close loop fractional part of the pitch */
    7023             :     int16_t *T0_res,          /* i/o: pitch resolution                        */
    7024             :     int16_t *T0_min,          /* i/o: lower limit for close-loop search       */
    7025             :     int16_t *T0_min_frac,     /* i/o: lower limit for close-loop search       */
    7026             :     int16_t *T0_max,          /* i/o: higher limit for close-loop search      */
    7027             :     int16_t *T0_max_frac,     /* i/o: higher limit for close-loop search      */
    7028             :     const int16_t pit_min,
    7029             :     const int16_t pit_fr1,
    7030             :     const int16_t pit_fr1b,
    7031             :     const int16_t pit_fr2,
    7032             :     const int16_t pit_max,
    7033             :     const int16_t pit_res_max );
    7034             : 
    7035             : void Mode2_abs_pit_dec(
    7036             :     int16_t *T0,         /* o  : integer pitch lag              */
    7037             :     int16_t *T0_frac,    /* o  : pitch fraction                 */
    7038             :     int16_t *T0_res,     /* o  : pitch resolution               */
    7039             :     int16_t **pt_indice, /* i/o: pointer to Vector of Q indexes */
    7040             :     const int16_t pit_min,
    7041             :     const int16_t pit_fr1,
    7042             :     const int16_t pit_fr2,
    7043             :     const int16_t pit_res_max );
    7044             : 
    7045             : void Mode2_delta_pit_dec(
    7046             :     int16_t *T0,          /* o  : integer pitch lag              */
    7047             :     int16_t *T0_frac,     /* o  : pitch fraction                 */
    7048             :     int16_t T0_res,       /* i  : pitch resolution               */
    7049             :     int16_t *T0_min,      /* i  : delta search min               */
    7050             :     int16_t *T0_min_frac, /* i  : delta search min               */
    7051             :     int16_t **pt_indice   /* i/o: pointer to Vector of Q indexes */
    7052             : );
    7053             : 
    7054             : void formant_post_filt(
    7055             :     PFSTAT_HANDLE hPFstat, /* i/o: Post filter related memories    */
    7056             :     float *synth_in,       /* i  : 12k8 synthesis                  */
    7057             :     const float *Aq,       /* i  : LP filter coefficient           */
    7058             :     float *synth_out,      /* i/o: input signal                    */
    7059             :     const int16_t L_frame, /* i  : frame length                    */
    7060             :     const int16_t L_subfr, /* i  : sub-frame length                */
    7061             :     const float lp_noise,  /* i  : background noise energy         */
    7062             :     const int32_t brate,   /* i  : bitrate                         */
    7063             :     const int16_t off_flag /* i  : Off flag                        */
    7064             : );
    7065             : 
    7066             : void qlpc_avq(
    7067             :     const float *lsp,     /* i  : Input LSF vectors              */
    7068             :     const float *lspmid,  /* i  : Input mid-LSF vectors          */
    7069             :     float *lsf_q,         /* o  : Quantized LFS vectors          */
    7070             :     float *lsfmid_q,      /* o  : Quantized mid-LFS vectors      */
    7071             :     int16_t *index,       /* o  : Quantization indices           */
    7072             :     int16_t *nb_indices,  /* o  : Number of quantization indices */
    7073             :     int16_t *nbbits,      /* o  : Number of quantization bits    */
    7074             :     const int16_t core,   /* i  : core                           */
    7075             :     const int32_t sr_core /* i  : internal sampling rate         */
    7076             : );
    7077             : 
    7078             : int16_t encode_lpc_avq(
    7079             :     BSTR_ENC_HANDLE hBstr,     /* i/o: bitstream handle                */
    7080             :     const int16_t numlpc,      /* i  : Number of sets of lpc           */
    7081             :     const int16_t *param_lpc,  /* i  : lpc parameters                  */
    7082             :     const int16_t core,        /* i  : core                            */
    7083             :     const int16_t element_mode /* i  : element mode                    */
    7084             : );
    7085             : 
    7086             : int16_t dlpc_avq(
    7087             :     int16_t *index,       /* i  : Quantization indices            */
    7088             :     float *LSF_Q,         /* o  : Quantized LSF vectors           */
    7089             :     const int16_t numlpc, /* i  : Number of sets of lpc           */
    7090             :     const int32_t sr_core /* i  : internal sampling rate          */
    7091             : );
    7092             : 
    7093             : int16_t decode_lpc_avq(
    7094             :     Decoder_State *st,            /* i/o: decoder state structure         */
    7095             :     const int16_t numlpc,         /* i  : Number of sets of lpc           */
    7096             :     int16_t *param_lpc,           /* o  : lpc parameters                  */
    7097             :     const int16_t ch,             /* i  : channel                         */
    7098             :     const int16_t element_mode,   /* i  : element mode                    */
    7099             :     const int16_t sns_low_br_mode /* i  : SNS low-bitrate mode            */
    7100             : );
    7101             : 
    7102             : /*! r: codebook index */
    7103             : int16_t vlpc_1st_cod(
    7104             :     const float *lsf,      /* i  : vector to quantize              */
    7105             :     float *lsfq,           /* i/o: i:prediction   o:quantized lsf  */
    7106             :     const int32_t sr_core, /* i  : internal sampling rate          */
    7107             :     float *w               /* o  : lsf weights                     */
    7108             : );
    7109             : 
    7110             : /*! r: number of allocated bits */
    7111             : int16_t vlpc_2st_cod(
    7112             :     const float *lsf,     /* i  : normalized vector to quantize   */
    7113             :     float *lsfq,          /* i/o: i:1st stage   o:1st+2nd stage   */
    7114             :     int16_t *indx,        /* o  : index[] (4 bits per words)      */
    7115             :     const int16_t mode,   /* i  : 0=abs, >0=rel                   */
    7116             :     const int32_t sr_core /* i  : internal sampling rate          */
    7117             : );
    7118             : 
    7119             : void vlpc_2st_dec(
    7120             :     float *lsfq,          /* i/o: i:1st stage   o:1st+2nd stage   */
    7121             :     int16_t *indx,        /* i  : index[] (4 bits per words)      */
    7122             :     const int16_t mode,   /* i  : 0=abs, >0=rel                   */
    7123             :     const int32_t sr_core /* i  : internal sampling rate          */
    7124             : );
    7125             : 
    7126             : void lsf_weight_2st(
    7127             :     const float *lsfq,
    7128             :     float *w,
    7129             :     const int16_t mode,
    7130             :     const int32_t sr_core );
    7131             : 
    7132             : void mdct_window_sine(
    7133             :     float *window,
    7134             :     const int32_t Fs,
    7135             :     const int16_t n,
    7136             :     const int16_t window_type,
    7137             :     const int16_t element_mode );
    7138             : 
    7139             : void mdct_window_aldo(
    7140             :     float *window1,
    7141             :     float *window2,
    7142             :     const int16_t n );
    7143             : 
    7144             : void AVQ_cod_lpc(
    7145             :     const float nvec[], /* i  : vector to quantize              */
    7146             :     int16_t nvecq[],    /* o  : quantized normalized vector (assuming the bit budget is enough) */
    7147             :     int16_t *indx,      /* o  : index[] (4 bits per words)      */
    7148             :     const int16_t Nsv   /* i  : number of subvectors (lg=Nsv*8) */
    7149             : );
    7150             : 
    7151             : void AVQ_dec_lpc(
    7152             :     const int16_t indx[], /* i  : index[] (4 bits per words)      */
    7153             :     int16_t nvecq[],      /* o  : vector quantized                */
    7154             :     const int16_t Nsv     /* i  : number of subvectors (lg=Nsv*8) */
    7155             : );
    7156             : 
    7157             : void vlpc_1st_dec(
    7158             :     const int16_t index, /* i  : codebook index                  */
    7159             :     float *lsfq,         /* i/o: i:prediction   o:quantized lsf  */
    7160             :     const int32_t sr_core );
    7161             : 
    7162             : void WindowSignal(
    7163             :     TCX_CONFIG_HANDLE hTcxCfg,        /* i  : configuration of TCX                */
    7164             :     int16_t offset,                   /* i  : left folding point offset relative to the input signal pointer */
    7165             :     const int16_t left_overlap_mode,  /* i  : overlap mode of left window half    */
    7166             :     const int16_t right_overlap_mode, /* i  : overlap mode of right window half   */
    7167             :     int16_t *left_overlap_length,     /* o  : TCX window left overlap length      */
    7168             :     int16_t *right_overlap_length,    /* o  : TCX window right overlap length     */
    7169             :     const float in[],                 /* i  : input signal                        */
    7170             :     int16_t *L_frame,                 /* i/o: frame length                        */
    7171             :     float out[],                      /* o  : output windowed signal              */
    7172             :     const int16_t truncate_aldo,      /* i  : nonzero to truncate long ALDO slope */
    7173             :     const int16_t fullband            /* i  : fullband flag                       */
    7174             : );
    7175             : 
    7176             : void HBAutocorrelation(
    7177             :     TCX_CONFIG_HANDLE hTcxCfg, /* i  : configuration of TCX               */
    7178             :     const int16_t left_mode,   /* i  : overlap mode of left window half   */
    7179             :     const int16_t right_mode,  /* i  : overlap mode of right window half  */
    7180             :     float speech[],            /* i  : speech                             */
    7181             :     int16_t L_frame_glob,      /* i/o: frame length                       */
    7182             :     float *r                   /* o  : autocorrelations vector            */
    7183             : );
    7184             : 
    7185             : void TNSAnalysis(
    7186             :     TCX_CONFIG_HANDLE hTcxCfg,    /* i  : configuration of TCX                                                                    */
    7187             :     const int16_t L_frame,        /* i  : frame length                                                                            */
    7188             :     int16_t L_spec,               /* i  : length of the spectrum                                                                  */
    7189             :     const int16_t transform_type, /* i  : transform type for the frame/subframe - TCX20 | TCX10 | TCX 5 (meaning 2 x TCX 5)       */
    7190             :     const int16_t isAfterACELP,   /* i  : Flag indicating if the last frame was ACELP. For the second TCX subframe it should be 0 */
    7191             :     float spectrum[],             /* i  : MDCT spectrum of the subframe                                                           */
    7192             :     TRAN_DET_HANDLE hTranDet,     /* i  : handle transient detection                                                              */
    7193             :     const float ltp_gain,         /* i  : ltp gain                                                                                */
    7194             :     STnsData *pTnsData,           /* o  : TNS data                                                                                */
    7195             :     int16_t *pfUseTns,            /* o  : Flag indicating if TNS is used                                                          */
    7196             :     float *predictionGain         /* o  : TNS prediction gain                                                                     */
    7197             : );
    7198             : 
    7199             : void CalculateTnsFilt(
    7200             :     STnsConfig const *pTnsConfig, /* i  : TNS Configuration struct          */
    7201             :     const float pSpectrum[],      /* i  : MDCT spectrum                     */
    7202             :     STnsData *pTnsData,           /* o  : TNS data struct                   */
    7203             :     float *predictionGain         /* o  : TNS prediction gain               */
    7204             : );
    7205             : 
    7206             : void ShapeSpectrum(
    7207             :     TCX_CONFIG_HANDLE hTcxCfg,  /* i  : configuration of TCX                */
    7208             :     const float A[],            /* i  : quantized coefficients NxAz_q[M+1]  */
    7209             :     float gainlpc[],            /* o  : MDCT gains for the previous frame   */
    7210             :     const int16_t L_frame_glob, /* i  : frame length                        */
    7211             :     int16_t L_spec,             /* i  : length of the spectrum              */
    7212             :     float spectrum[],           /* i/o: MDCT spectrum                       */
    7213             :     const int16_t fUseTns,      /* i  : Flag indicating if TNS is used      */
    7214             :     Encoder_State *st,          /* i/o: encoder state structure             */
    7215             :     float *scf                  /* i  : scale factors                       */
    7216             : );
    7217             : 
    7218             : void QuantizeSpectrum(
    7219             :     Encoder_State *st,           /* i/o: encoder state structure                     */
    7220             :     const float A[],             /* i  : quantized coefficients NxAz_q[M+1]          */
    7221             :     const Word16 Aqind[],        /* i  : frame-independent quantized coeffs (M+1)    */
    7222             :     float gainlpc[],             /* i  : MDCT gains of the previous frame            */
    7223             :     float synth[],               /* o  : synthesis buffer                            */
    7224             :     const int16_t nb_bits,       /* i  : bit budget                                  */
    7225             :     const int16_t tnsSize,       /* i  : number of tns parameters put into prm       */
    7226             :     int16_t prm[],               /* o  : tcx parameters                              */
    7227             :     const int16_t frame_cnt,     /* i  : frame counter in the super_frame            */
    7228             :     CONTEXT_HM_CONFIG *hm_cfg,   /* i  : HM configuration                            */
    7229             :     const int16_t vad_hover_flag /* i  : VAD hangover flag                           */
    7230             : );
    7231             : 
    7232             : /*! r: index of next coefficient */
    7233             : int16_t get_next_coeff_mapped(
    7234             :     int16_t ii[2],            /* i/o: coefficient indexes                         */
    7235             :     int32_t *pp,              /* o  : peak(1)/hole(0) indicator                   */
    7236             :     int16_t *idx,             /* o  : index in unmapped domain                    */
    7237             :     CONTEXT_HM_CONFIG *hm_cfg /* i  : HM configuration                            */
    7238             : );
    7239             : 
    7240             : /*! r: index of next coefficient */
    7241             : int16_t get_next_coeff_unmapped(
    7242             :     int16_t *ii, /* i/o: coefficient index                           */
    7243             :     int16_t *idx /* o  : index in unmapped domain                    */
    7244             : );
    7245             : 
    7246             : int32_t update_mixed_context(
    7247             :     int32_t ctx,
    7248             :     int16_t a );
    7249             : 
    7250             : void ACcontextMapping_encode2_no_mem_s17_LC(
    7251             :     BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle                            */
    7252             :     int16_t *x,
    7253             :     int16_t nt,
    7254             :     int16_t lastnz,
    7255             :     int16_t nbbits,
    7256             :     int16_t resQMaxBits,
    7257             :     CONTEXT_HM_CONFIG *hm_cfg );
    7258             : 
    7259             : int16_t ACcontextMapping_decode2_no_mem_s17_LC(
    7260             :     Decoder_State *st,        /* i/o: decoder state                               */
    7261             :     int16_t *x,               /* o  : decoded spectrum                            */
    7262             :     int16_t nt,               /* i  : size of spectrum                            */
    7263             :     int16_t nbbits,           /* i  : bit budget                                  */
    7264             :     int16_t resQMaxBits,      /* i  : residual coding maximum bits                */
    7265             :     CONTEXT_HM_CONFIG *hm_cfg /* i  : context-based harmonic model configuration  */
    7266             : );
    7267             : 
    7268             : int16_t ACcontextMapping_encode2_estimate_no_mem_s17_LC(
    7269             :     const int16_t *x,
    7270             :     const int16_t nt,
    7271             :     int16_t *lastnz,
    7272             :     int16_t *nEncoded,
    7273             :     const int16_t target,
    7274             :     int16_t *stop,
    7275             :     CONTEXT_HM_CONFIG *hm_cfg );
    7276             : 
    7277             : void RCcontextMapping_encode2_no_mem_s17_LCS(
    7278             :     BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle                        */
    7279             :     int16_t *x,
    7280             :     const int16_t nt,
    7281             :     int16_t lastnz,
    7282             :     const int16_t nbbits,
    7283             :     const int16_t resQMaxBits,
    7284             :     CONTEXT_HM_CONFIG *hm_cfg );
    7285             : 
    7286             : int16_t RCcontextMapping_decode2_no_mem_s17_LCS(
    7287             :     Decoder_State *st,         /* i/o: decoder state                               */
    7288             :     int16_t *x,                /* o  : decoded spectrum                            */
    7289             :     const int16_t nt,          /* i  : size of spectrum                            */
    7290             :     const int16_t nbbits,      /* i  : bit budget                                  */
    7291             :     const int16_t resQMaxBits, /* i  : residual coding maximum bits                */
    7292             :     CONTEXT_HM_CONFIG *hm_cfg  /* i  : context-based harmonic model configuration  */
    7293             : );
    7294             : 
    7295             : int16_t RCcontextMapping_encode2_estimate_no_mem_s17_LCS(
    7296             :     int16_t *x,       /* Spectral coefficients */
    7297             :     const int16_t nt, /* L - size of spectrum (no. of spectral coefficients) */
    7298             :     int16_t *lastnz_out,
    7299             :     int16_t *nEncoded,    /* No. of spectral coefficients that can be coded without an overflow occuring */
    7300             :     const int16_t target, /* Target bits */
    7301             :     int16_t *stop,
    7302             :     int16_t mode,
    7303             :     CONTEXT_HM_CONFIG *hm_cfg /* context-based harmonic model configuration */
    7304             : );
    7305             : 
    7306             : int16_t RCcontextMapping_encode2_estimate_bandWise_start(
    7307             :     int16_t *x,
    7308             :     const int16_t nt,
    7309             :     const int16_t target,
    7310             :     HANDLE_RC_CONTEXT_MEM hContextMem );
    7311             : 
    7312             : int16_t RCcontextMapping_encode2_estimate_bandWise(
    7313             :     int16_t *x,
    7314             :     const int16_t start_line,
    7315             :     const int16_t end_line,
    7316             :     HANDLE_RC_CONTEXT_MEM hContextMem );
    7317             : 
    7318             : void tcx_get_windows(
    7319             :     TCX_CONFIG_HANDLE hTcxCfg, /* i  : TCX configuration                   */
    7320             :     const int16_t left_mode,   /* i  : overlap mode of left window half    */
    7321             :     const int16_t right_mode,  /* i  : overlap mode of right window half   */
    7322             :     int16_t *left_overlap,     /* o  : left overlap length                 */
    7323             :     const float **left_win,    /* o  : left overlap window                 */
    7324             :     int16_t *right_overlap,    /* o  : right overlap length                */
    7325             :     const float **right_win,   /* o  : right overlap window                */
    7326             :     const int16_t fullband     /* i  : fullband flag                       */
    7327             : );
    7328             : 
    7329             : void tcx_windowing_analysis(
    7330             :     const float *signal,         /* i  : signal vector                              */
    7331             :     const int16_t L_frame,       /* i  : frame length                               */
    7332             :     const int16_t left_overlap,  /* i  : left overlap length                        */
    7333             :     const float *left_win,       /* i  : left overlap window                        */
    7334             :     const int16_t right_overlap, /* i  : right overlap length                       */
    7335             :     const float *right_win,      /* i  : right overlap window                       */
    7336             :     float *output                /* o  : windowed signal vector                     */
    7337             : );
    7338             : 
    7339             : void tcx_windowing_synthesis_current_frame(
    7340             :     float *signal,                    /* i/o: signal vector                              */
    7341             :     const float *window,              /* i  : TCX window vector                          */
    7342             :     const float *window_half,         /* i  : TCX window vector for half-overlap window  */
    7343             :     const float *window_min,          /* i  : TCX minimum overlap window                 */
    7344             :     const int16_t window_length,      /* i  : TCX window length                          */
    7345             :     const int16_t window_half_length, /* i  : TCX half window length                     */
    7346             :     const int16_t window_min_length,  /* i  : TCX minimum overlap length                 */
    7347             :     const int16_t left_rect,          /* i  : left part is rectangular                   */
    7348             :     const int16_t left_mode,          /* i  : overlap mode of left window half           */
    7349             :     float *acelp_zir,                 /* i/o: acelp ZIR                                  */
    7350             :     const float *old_syn,             /* i  : old synthesis                              */
    7351             :     const float *syn_overl,           /* i  : overlap synthesis                          */
    7352             :     const float *A_zir,
    7353             :     const float *window_trans, /* i  : window for transition from ACELP           */
    7354             :     int16_t acelp_zir_len,
    7355             :     const int16_t acelp_mem_len,
    7356             :     const int16_t last_core_bfi, /* i  : last mode                                  */
    7357             :     const int16_t last_is_cng,
    7358             :     const int16_t fullbandScale );
    7359             : 
    7360             : void tcx_windowing_synthesis_past_frame(
    7361             :     float *signal,                    /* i/o: signal vector                              */
    7362             :     const float *window,              /* i  : TCX window vector                          */
    7363             :     const float *window_half,         /* i  : TCX window vector for half-overlap window  */
    7364             :     const float *window_min,          /* i  : TCX minimum overlap window                 */
    7365             :     const int16_t window_length,      /* i  : TCX window length                          */
    7366             :     const int16_t window_half_length, /* i  : TCX half window length                     */
    7367             :     const int16_t window_min_length,  /* i  : TCX minimum overlap length                 */
    7368             :     const int16_t right_mode          /* i  : overlap mode (left_mode of current frame)  */
    7369             : );
    7370             : 
    7371             : void ProcessIGF(
    7372             :     Encoder_State *st,              /* i  : Encoder state                               */
    7373             :     float *pMDCTSpectrum,           /* i  : MDCT spectrum                               */
    7374             :     const float *pITFMDCTSpectrum,  /* i  : MDCT spectrum fir ITF                       */
    7375             :     float *pPowerSpectrum,          /* i  : MDCT^2 + MDST^2 spectrum, or estimate       */
    7376             :     const int16_t isTCX20,          /* i  : flag indicating if the input is TCX20 or TCX10/2xTCX5 */
    7377             :     const int16_t frameno,          /* i  : flag indicating index of current subframe   */
    7378             :     const int16_t sp_aud_decision0, /* i  : first stage switching decision             */
    7379             :     const int16_t vad_hover_flag    /* i  : VAD hangover flag                          */
    7380             : );
    7381             : 
    7382             : void ProcessStereoIGF(
    7383             :     STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct,
    7384             :     Encoder_State *sts[CPE_CHANNELS],                 /* i  : Encoder state                           */
    7385             :     int16_t ms_mask[2][MAX_SFB],                      /* i  : bandwise MS mask                        */
    7386             :     float *pITFMDCTSpectrum[CPE_CHANNELS][NB_DIV],    /* i  : MDCT spectrum fir ITF                   */
    7387             :     float *pPowerSpectrum[CPE_CHANNELS],              /* i/o: MDCT^2 + MDST^2 spectrum, or estimate   */
    7388             :     float *pPowerSpectrumMsInv[CPE_CHANNELS][NB_DIV], /* i  : inverse power spectrum                  */
    7389             :     float *inv_spectrum[CPE_CHANNELS][NB_DIV],        /* i  : inverse spectrum                        */
    7390             :     const int16_t frameno,                            /* i  : flag indicating index of current subframe*/
    7391             :     const int16_t sp_aud_decision0,                   /* i  : sp_aud_decision0                        */
    7392             :     const int32_t element_brate,                      /* i  : element bitrate                         */
    7393             :     const int16_t mct_on                              /* i  : flag mct block (1) or stereo (0)        */
    7394             : );
    7395             : 
    7396             : void AnalyzePowerSpectrum(
    7397             :     Encoder_State *st,           /* i/o: encoder states                                */
    7398             :     const int16_t L_frame,       /* i  : frame length                                  */
    7399             :     const int16_t L_frameTCX,    /* i  : full band frame length                        */
    7400             :     const int16_t left_overlap,  /* i  : left overlap length                           */
    7401             :     const int16_t right_overlap, /* i  : right overlap length                          */
    7402             :     const float mdctSpectrum[],  /* i  : MDCT spectrum                                 */
    7403             :     const float signal[],        /* i  : windowed signal corresponding to mdctSpectrum */
    7404             :     float powerSpec[]            /* o  : Power spectrum                                */
    7405             : );
    7406             : 
    7407             : void lpc2mdct(
    7408             :     float *lpcCoeffs,
    7409             :     const int16_t lpcOrder,
    7410             :     float mdct_gains[],
    7411             :     const int16_t length,
    7412             :     const int16_t noInverse );
    7413             : 
    7414             : void mdct_preShaping(
    7415             :     float x[],
    7416             :     const int16_t lg,
    7417             :     const float gains[] );
    7418             : 
    7419             : void mdct_noiseShaping(
    7420             :     float x[],
    7421             :     const int16_t lg,
    7422             :     const float gains[],
    7423             :     const int16_t nBands );
    7424             : 
    7425             : void AdaptLowFreqEmph(
    7426             :     float x[],
    7427             :     int16_t xq[],
    7428             :     float invGain,
    7429             :     const int16_t tcx_lpc_shaped_ari,
    7430             :     const float lpcGains[],
    7431             :     const int16_t lg );
    7432             : 
    7433             : void PsychAdaptLowFreqEmph(
    7434             :     float x[],
    7435             :     const float lpcGains[] );
    7436             : 
    7437             : void PsychAdaptLowFreqDeemph(
    7438             :     float x[],
    7439             :     const float lpcGains[],
    7440             :     float lf_deemph_factors[] );
    7441             : 
    7442             : void AdaptLowFreqDeemph(
    7443             :     float x[],
    7444             :     int16_t tcx_lpc_shaped_ari,
    7445             :     const float lpcGains[],
    7446             :     const int16_t lg,
    7447             :     float lf_deemph_factors[] );
    7448             : 
    7449             : /*! r: SQ gain */
    7450             : float SQ_gain(
    7451             :     const float x[],       /* i  : vector to quantize           */
    7452             :     const int16_t nbitsSQ, /* i  : number of bits targeted      */
    7453             :     const int16_t lg       /* i  : vector size (2048 max)       */
    7454             : );
    7455             : 
    7456             : /*! r: SQ gain */
    7457             : float SQ_gain_estimate(
    7458             :     const float x[],       /* i  :  vector to quantize           */
    7459             :     const int16_t nbitsSQ, /* i  :  number of bits targeted      */
    7460             :     const int16_t lg       /* i  :  vector size (2048 max)       */
    7461             : );
    7462             : 
    7463             : 
    7464             : void tcx_scalar_quantization(
    7465             :     float *x,               /* i  : input coefficients            */
    7466             :     int16_t *xq,            /* o  : quantized coefficients        */
    7467             :     const int16_t L_frame,  /* i  : frame length                  */
    7468             :     const float gain,       /* i  : quantization gain             */
    7469             :     const float offset,     /* i  : rounding offset (deadzone)    */
    7470             :     int16_t *memQuantZeros, /* o  : coefficients set to 0         */
    7471             :     const int16_t tcxonly );
    7472             : 
    7473             : int16_t tcx_scalar_quantization_rateloop(
    7474             :     float *x,                       /* i  : input coefficients            */
    7475             :     int16_t *xq,                    /* o  : quantized coefficients        */
    7476             :     const int16_t L_frame,          /* i  : frame length                  */
    7477             :     float *gain,                    /* i/o: quantization gain             */
    7478             :     float offset,                   /* i  : rounding offset (deadzone)    */
    7479             :     int16_t *memQuantZeros,         /* o  : coefficients set to 0         */
    7480             :     int16_t *lastnz_out,            /* i/o: last nonzero coeff index      */
    7481             :     const int16_t target,           /* i  : target number of bits         */
    7482             :     int16_t *nEncoded,              /* o  : number of encoded coeff       */
    7483             :     int16_t *stop,                  /* i/o: stop param                    */
    7484             :     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) */
    7485             :     const int16_t sqBits_in,        /* i  : number of sqBits as determined in prev. quant. stage, using stop mechanism (ie always <= target bits) */
    7486             :     const int16_t tcxRateLoopOpt,   /* i  : turns on/off rateloop optimization */
    7487             :     const int16_t tcxonly,
    7488             :     CONTEXT_HM_CONFIG *hm_cfg,
    7489             :     const int16_t iter_max,
    7490             :     const int16_t element_mode );
    7491             : 
    7492             : void tcx_QuantizeGain(
    7493             :     const int16_t n,
    7494             :     float *pGain,
    7495             :     int16_t *pQuantizedGain );
    7496             : 
    7497             : void tcx_noise_factor(
    7498             :     const float *x_orig,        /* i  : unquantized mdct coefficients             */
    7499             :     float *sqQ,                 /* i/o: quantized mdct coefficients               */
    7500             :     const int16_t iFirstLine,   /* i  : first coefficient to be considered        */
    7501             :     const int16_t lowpassLine,  /* i  : last nonzero coefficients after low-pass  */
    7502             :     const int16_t nMinHoleSize, /* i  : minimum size of hole to be checked        */
    7503             :     const int16_t L_frame,      /* i  : frame length                              */
    7504             :     const float gain_tcx,       /* i  : tcx gain                                  */
    7505             :     const float tiltCompFactor, /* i  : LPC tilt compensation factor              */
    7506             :     float *fac_ns,              /* o  : noise factor                              */
    7507             :     int16_t *quantized_fac_ns,  /* o  : quantized noise factor                    */
    7508             :     const int16_t element_mode  /* i  : IVAS element mode                         */
    7509             : );
    7510             : 
    7511             : void tcx_noise_filling(
    7512             :     float *Q,
    7513             :     const int16_t noiseFillSeed,
    7514             :     const int16_t iFirstLine,
    7515             :     const int16_t lowpassLine,
    7516             :     const int16_t nTransWidth,
    7517             :     const int16_t L_frame,
    7518             :     const float tiltCompFactor,
    7519             :     float fac_ns,
    7520             :     uint8_t *infoTCXNoise,
    7521             :     const int16_t element_mode /* i  : IVAS element mode                         */
    7522             : );
    7523             : 
    7524             : void tcx_encoder_memory_update(
    7525             :     Encoder_State *st, /* i/o: encoder memory state                        */
    7526             :     float *xn_buf,     /* i/o: mdct output buffer/TD weigthed synthesis    */
    7527             :     const float *Ai,   /* i  : Unquantized (interpolated) LPC coefficients */
    7528             :     const float *A     /* i  : Quantized LPC coefficients                  */
    7529             : );
    7530             : 
    7531             : void tcx_decoder_memory_update(
    7532             :     Decoder_State *st,   /* i/o: decoder memory state                        */
    7533             :     const float *xn_buf, /* i  : mdct output buffer                          */
    7534             :     float *synth,        /* i/o: synth                                       */
    7535             :     const float *A       /* i  : Quantized LPC coefficients                  */
    7536             : );
    7537             : 
    7538             : /*! r: number of bits used (including "bits") */
    7539             : int16_t tcx_ari_res_Q_spec(
    7540             :     const float x_orig[],  /* i  : original spectrum                           */
    7541             :     const int16_t signs[], /* i  : signs (x_orig[.]<0)                         */
    7542             :     float x_Q[],           /* i/o: quantized spectrum                          */
    7543             :     const int16_t L_frame, /* i  : number of lines                             */
    7544             :     const float gain,      /* i  : TCX gain                                    */
    7545             :     int16_t prm[],         /* o  : bitstream                                   */
    7546             :     int16_t target_bits,   /* i  : number of bits available                    */
    7547             :     int16_t bits,          /* i  : number of bits used so far                  */
    7548             :     const float deadzone,  /* i  : quantizer deadzone                          */
    7549             :     const float x_fac[]    /* i  : spectrum post-quantization factors          */
    7550             : );
    7551             : 
    7552             : /*! r: number of bits used (including "bits") */
    7553             : int16_t tcx_ari_res_invQ_spec(
    7554             :     float x_Q[],           /* i/o: quantized spectrum                          */
    7555             :     const int16_t L_frame, /* i  : number of lines                             */
    7556             :     const int16_t prm[],   /* i  : bitstream                                   */
    7557             :     int16_t target_bits,   /* i  : number of bits available                    */
    7558             :     int16_t bits,          /* i  : number of bits used so far                  */
    7559             :     const float deadzone,  /* i  : quantizer deadzone                          */
    7560             :     const float x_fac[]    /* i  : spectrum post-quantization factors          */
    7561             : );
    7562             : 
    7563             : int16_t tcx_res_Q_gain(
    7564             :     float sqGain,
    7565             :     float *gain_tcx,
    7566             :     int16_t *prm,
    7567             :     int16_t sqTargetBits );
    7568             : 
    7569             : int16_t tcx_res_Q_spec(
    7570             :     const float *x_orig,
    7571             :     float *x_Q,
    7572             :     const int16_t L_frame,
    7573             :     const float sqGain,
    7574             :     int16_t *prm,
    7575             :     int16_t sqTargetBits,
    7576             :     int16_t bits,
    7577             :     const float sq_round,
    7578             :     const float lf_deemph_factors[] );
    7579             : 
    7580             : int16_t tcx_res_invQ_gain(
    7581             :     float *gain_tcx,
    7582             :     const int16_t *prm,
    7583             :     const int16_t resQBits );
    7584             : 
    7585             : int16_t tcx_res_invQ_spec(
    7586             :     float *x,
    7587             :     const int16_t L_frame,
    7588             :     const int16_t *prm,
    7589             :     int16_t resQBits,
    7590             :     int16_t bits,
    7591             :     const float sq_round,
    7592             :     const float lf_deemph_factors[] );
    7593             : 
    7594             : void InitTnsConfigs(
    7595             :     const int16_t bwidth,
    7596             :     const int16_t L_frame,
    7597             :     STnsConfig tnsConfig[2][2],
    7598             :     const int16_t igfStopFreq,
    7599             :     const int32_t total_brate,
    7600             :     const int16_t element_mode,
    7601             :     const int16_t MCT_flag );
    7602             : 
    7603             : void SetAllowTnsOnWhite(
    7604             :     STnsConfig tnsConfig[2][2],
    7605             :     const int8_t allowTnsOnWhite );
    7606             : 
    7607             : void SetTnsConfig(
    7608             :     TCX_CONFIG_HANDLE hTcxCfg,
    7609             :     const int16_t isTCX20,
    7610             :     const int16_t isAfterACELP );
    7611             : 
    7612             : void ari_copy_states(
    7613             :     Tastat *source,
    7614             :     Tastat *dest );
    7615             : 
    7616             : int32_t mul_sbc_14bits(
    7617             :     int32_t r,
    7618             :     int32_t c );
    7619             : 
    7620             : void ari_start_encoding_14bits(
    7621             :     Tastat *s );
    7622             : 
    7623             : int16_t ari_encode_14bits_ext(
    7624             :     int16_t *ptr,
    7625             :     int16_t bp,
    7626             :     Tastat *s,
    7627             :     int32_t symbol,
    7628             :     const uint16_t *cum_freq );
    7629             : 
    7630             : int16_t ari_done_encoding_14bits(
    7631             :     int16_t *ptr,
    7632             :     int16_t bp,
    7633             :     Tastat *s );
    7634             : 
    7635             : void ari_start_decoding_14bits(
    7636             :     Decoder_State *st,
    7637             :     Tastat *s );
    7638             : 
    7639             : int16_t ari_start_decoding_14bits_prm(
    7640             :     const int16_t *ptr,
    7641             :     int16_t bp,
    7642             :     Tastat *s );
    7643             : 
    7644             : void ari_decode_14bits_s17_ext(
    7645             :     Decoder_State *st,
    7646             :     uint16_t *res,
    7647             :     Tastat *s,
    7648             :     const uint16_t *cum_freq );
    7649             : 
    7650             : void ari_decode_14bits_s27_ext(
    7651             :     Decoder_State *st,
    7652             :     uint16_t *res,
    7653             :     Tastat *s,
    7654             :     const uint16_t *cum_freq );
    7655             : 
    7656             : void ari_decode_14bits_bit_ext(
    7657             :     Decoder_State *st,
    7658             :     uint16_t *res,
    7659             :     Tastat *s );
    7660             : 
    7661             : /*! r: Q15 */
    7662             : Word16 expfp(
    7663             :     const Word16 x,  /* i  : mantissa  Q15-e                         */
    7664             :     const Word16 x_e /* i  : exponent  Q0                            */
    7665             : );
    7666             : 
    7667             : void powfp_odd2(
    7668             :     const Word16 base, /* Q15 */
    7669             :     const Word16 exp,  /* Q0  */
    7670             :     Word16 *pout1,     /* Q15 */
    7671             :     Word16 *pout2      /* Q15 */
    7672             : );
    7673             : 
    7674             : void tcx_arith_scale_envelope(
    7675             :     const Word16 L_spec_core,    /* i  : number of lines to scale    Q0          */
    7676             :     Word16 L_frame,              /* i  : number of lines             Q0          */
    7677             :     const Word32 env[],          /* i  : unscaled envelope           Q16         */
    7678             :     Word16 target_bits,          /* i  : number of available bits    Q0          */
    7679             :     const Word16 low_complexity, /* i  : low-complexity flag         Q0          */
    7680             :     Word16 s_env[],              /* o  : scaled envelope             Q15-e       */
    7681             :     Word16 *s_env_e              /* o  : scaled envelope exponent    Q0          */
    7682             : );
    7683             : 
    7684             : void tcx_arith_render_envelope(
    7685             :     const Word16 A_ind[],     /* i  : LPC coefficients of signal envelope     */
    7686             :     const Word16 L_frame,     /* i  : number of spectral lines                */
    7687             :     const Word16 L_spec,      /* i  : length of the coded spectrum            */
    7688             :     const Word16 preemph_fac, /* i  : pre-emphasis factor                     */
    7689             :     const Word16 gamma_w,     /* i  : A_ind -> weighted envelope factor       */
    7690             :     const Word16 gamma_uw,    /* i  : A_ind -> non-weighted envelope factor   */
    7691             :     Word32 env[]              /* o  : shaped signal envelope                  */
    7692             : );
    7693             : 
    7694             : int16_t ari_encode_14bits_range(
    7695             :     int16_t *ptr,
    7696             :     int16_t bp,
    7697             :     int32_t bits,
    7698             :     Tastat *s,
    7699             :     uint16_t cum_freq_low,
    7700             :     uint16_t cum_freq_high );
    7701             : 
    7702             : int16_t ari_encode_14bits_sign(
    7703             :     int16_t *ptr,
    7704             :     int16_t bp,
    7705             :     int32_t bits,
    7706             :     Tastat *s,
    7707             :     int32_t sign );
    7708             : 
    7709             : int16_t ari_done_cbr_encoding_14bits(
    7710             :     int16_t *ptr,
    7711             :     int16_t bp,
    7712             :     int32_t bits,
    7713             :     Tastat *s );
    7714             : 
    7715             : int16_t ari_decode_14bits_pow(
    7716             :     const int16_t *ptr,
    7717             :     int16_t bp,
    7718             :     int16_t bits,
    7719             :     int16_t *res,
    7720             :     Tastat *s,
    7721             :     uint16_t base );
    7722             : 
    7723             : int16_t ari_decode_14bits_sign(
    7724             :     const int16_t *ptr,
    7725             :     int16_t bp,
    7726             :     int16_t bits,
    7727             :     uint16_t *res,
    7728             :     Tastat *s );
    7729             : 
    7730             : void tcx_arith_encode_envelope(
    7731             :     float spectrum[],            /* i/o: MDCT coefficients             */
    7732             :     int16_t signs[],             /* o  : signs (spectrum[.]<0)         */
    7733             :     const int16_t L_frame,       /* i  : frame or MDCT length          */
    7734             :     const int16_t L_spec,        /* i  : length w/o BW limitation      */
    7735             :     Encoder_State *st,           /* i/o: coder state                   */
    7736             :     const Word16 A_ind[],        /* i  : quantised LPC coefficients    */
    7737             :     int16_t target_bits,         /* i  : number of available bits      */
    7738             :     int16_t prm[],               /* o  : bitstream parameters          */
    7739             :     const int16_t use_hm,        /* i  : use HM in current frame?      */
    7740             :     int16_t prm_hm[],            /* o  : HM parameter area             */
    7741             :     const int16_t tcxltp_pitch,  /* i  : TCX LTP pitch in FD, -1 if n/a*/
    7742             :     int16_t *arith_bits,         /* o  : bits used for ari. coding     */
    7743             :     int16_t *signaling_bits,     /* o  : bits used for signaling       */
    7744             :     const int16_t low_complexity /* i  : low-complexity flag           */
    7745             : );
    7746             : 
    7747             : void tcx_arith_decode_envelope(
    7748             :     Decoder_State *st,           /* i/o: coder state                   */
    7749             :     float q_spectrum[],          /* o  : quantised MDCT coefficients   */
    7750             :     const int16_t L_frame,       /* i  : frame or MDCT length          */
    7751             :     int16_t L_spec,              /* i  : length w/o BW limitation      */
    7752             :     const Word16 A_ind[],        /* i  : quantised LPC coefficients    */
    7753             :     const int16_t target_bits,   /* i  : number of available bits      */
    7754             :     const int16_t prm[],         /* i  : bitstream parameters          */
    7755             :     const int16_t use_hm,        /* i  : use HM in current frame?      */
    7756             :     const int16_t prm_hm[],      /* i  : HM parameter area             */
    7757             :     int16_t tcxltp_pitch,        /* i  : TCX LTP pitch in FD, -1 if n/a*/
    7758             :     int16_t *arith_bits,         /* o  : bits used for ari. coding     */
    7759             :     int16_t *signaling_bits,     /* o  : bits used for signaling       */
    7760             :     const int16_t low_complexity /* i  : low-complexity flag           */
    7761             : );
    7762             : 
    7763             : void UnmapIndex(
    7764             :     const int16_t PeriodicityIndex,
    7765             :     const int16_t Bandwidth,
    7766             :     const int16_t LtpPitchLag,
    7767             :     const int16_t SmallerLags,
    7768             :     int16_t *FractionalResolution,
    7769             :     int32_t *Lag );
    7770             : 
    7771             : /*! r: PeriodicityIndex */
    7772             : int16_t SearchPeriodicityIndex(
    7773             :     const float Mdct[],            /* i  : Coefficients, Mdct[0..NumCoeffs-1]                      */
    7774             :     const float UnfilteredMdct[],  /* i  : Unfiltered coefficients, UnfilteredMdct[0..NumCoeffs-1] */
    7775             :     const int16_t NumCoeffs,       /* i  : Number of coefficients                                  */
    7776             :     const int16_t shortTargetBits, /* i  : Target bit budget (excl. Done flag)                     */
    7777             :     const int16_t LtpPitchLag,     /* i  : TCX-LTP pitch                                           */
    7778             :     const float LtpGain,           /* i  : LTP gain                                                */
    7779             :     float *RelativeScore           /* o  : Energy concentration factor                             */
    7780             : );
    7781             : 
    7782             : void ConfigureContextHm(
    7783             :     const int16_t NumCoeffs,        /* i  : Number of coefficients                                  */
    7784             :     const int16_t TargetBits,       /* i  : Target bit budget (excl. Done flag)                     */
    7785             :     const int16_t PeriodicityIndex, /* i  : Pitch related index                                     */
    7786             :     const int16_t LtpPitchLag,      /* i  : TCX-LTP pitch in F.D.                                   */
    7787             :     CONTEXT_HM_CONFIG *hm_cfg       /* o  : Context-based harmonic model configuration              */
    7788             : );
    7789             : 
    7790             : int16_t EncodeIndex(
    7791             :     const int16_t Bandwidth, /* o  : NB, 1: (S)WB                                            */
    7792             :     int16_t PeriodicityIndex,
    7793             :     BSTR_ENC_HANDLE hBstr );
    7794             : 
    7795             : int16_t CountIndexBits(
    7796             :     const int16_t Bandwidth, /* o  : NB, 1: (S)WB                                            */
    7797             :     const int16_t PeriodicityIndex );
    7798             : 
    7799             : int16_t DecodeIndex(
    7800             :     Decoder_State *st,
    7801             :     const int16_t Bandwidth, /* o  : NB, 1: (S)WB                                            */
    7802             :     int16_t *PeriodicityIndex );
    7803             : 
    7804             : #define GET_ADJ( T, L )     GET_ADJ2( T, L, *FractionalResolution )
    7805             : #define GET_ADJ2( T, L, F ) ( ( ( L ) << ( F ) ) - ( T ) )
    7806             : 
    7807             : int16_t tcx_hm_render(
    7808             :     const int32_t lag,       /* i  : pitch lag                             */
    7809             :     const int16_t fract_res, /* i  : fractional resolution of the lag      */
    7810             :     Word16 p[]               /* o  : harmonic model (Q13)                  */
    7811             : );
    7812             : 
    7813             : void tcx_hm_modify_envelope(
    7814             :     const Word16 gain, /* i  : HM gain (Q11)                         */
    7815             :     const int32_t lag,
    7816             :     const int16_t fract_res,
    7817             :     const Word16 p[],     /* i  : harmonic model (Q13)                  */
    7818             :     Word32 env[],         /* i/o: envelope (Q16)                        */
    7819             :     const int16_t L_frame /* i  : number of spectral lines              */
    7820             : );
    7821             : 
    7822             : void tcx_hm_analyse(
    7823             :     const float abs_spectrum[], /* i  : absolute spectrum                     */
    7824             :     const int16_t L_frame,      /* i  : number of spectral lines              */
    7825             :     Word32 env[],               /* i/o: envelope shape (Q16)                  */
    7826             :     const int16_t targetBits,   /* i  : target bit budget                     */
    7827             :     const int16_t coder_type,   /* i  : GC/VC coder type                      */
    7828             :     int16_t prm_hm[],           /* o  : HM parameters                         */
    7829             :     int16_t LtpPitchLag,        /* i  : LTP pitch lag or -1 if none           */
    7830             :     const float LtpGain,        /* i  : LTP gain                              */
    7831             :     int16_t *hm_bits            /* o  : bit consumption                       */
    7832             : );
    7833             : 
    7834             : void tcx_hm_decode(
    7835             :     const int16_t L_frame,     /* i  : number of spectral lines              */
    7836             :     Word32 env[],              /* i/o: envelope shape (Q16)                  */
    7837             :     const int16_t targetBits,  /* i  : target bit budget                     */
    7838             :     const int16_t coder_type,  /* i  : GC/VC coder type                      */
    7839             :     const int16_t prm_hm[],    /* i  : HM parameters                         */
    7840             :     const int16_t LtpPitchLag, /* i  : LTP pitch lag or -1 if none           */
    7841             :     int16_t *hm_bits           /* o  : bit consumption                       */
    7842             : );
    7843             : 
    7844             : void coder_tcx(
    7845             :     Encoder_State *st,          /* i/o: encoder state structure               */
    7846             :     TCX_CONFIG_HANDLE hTcxCfg,  /* i  : configuration of TCX                  */
    7847             :     const float A[],            /* i  : quantized coefficients NxAz_q[M+1]    */
    7848             :     const Word16 Aqind[],       /* i  : frame-independent quantized coefficients (M+1) */
    7849             :     float synth[],              /* o  : decoded synthesis                     */
    7850             :     const int16_t L_frame_glob, /* i  : frame length                          */
    7851             :     const int16_t L_frameTCX_glob,
    7852             :     const int16_t L_spec,
    7853             :     int16_t nb_bits,  /* i  : bit budget                            */
    7854             :     float spectrum[], /* i/o: MDCT spectrum                         */
    7855             :     int16_t prm[],    /* o  : tcx parameters                        */
    7856             :     CONTEXT_HM_CONFIG *hm_cfg,
    7857             :     const int16_t vad_hover_flag /* i  : VAD hangover flag */
    7858             : );
    7859             : 
    7860             : void coder_tcx_post(
    7861             :     Encoder_State *st, /* i/o: encoder memory state                        */
    7862             :     float *A,          /* o  : Quantized LPC coefficients                  */
    7863             :     const float *Ai    /* i  : Unquantized (interpolated) LPC coefficients */
    7864             : );
    7865             : 
    7866             : void decoder_tcx(
    7867             :     Decoder_State *st,                  /* i/o: coder memory state                    */
    7868             :     int16_t prm[],                      /* i  : parameters                            */
    7869             :     float A[],                          /* i  : coefficients NxAz[M+1]                */
    7870             :     Word16 Aind[],                      /* i  : frame-independent coefficients Az[M+1]*/
    7871             :     float synth[],                      /* i/o: synth[-M..lg]                         */
    7872             :     float synthFB[],                    /* i/o: encoder memory state                  */
    7873             :     const int16_t bfi,                  /* i  : Bad frame indicator                   */
    7874             :     const int16_t frame_cnt,            /* i  : frame counter in the super_frame      */
    7875             :     const int16_t sba_dirac_stereo_flag /* i  : signal stereo output for SBA DirAC    */
    7876             : );
    7877             : 
    7878             : void decoder_tcx_post(
    7879             :     Decoder_State *st, /* i/o: decoder memory state          */
    7880             :     float *synth,
    7881             :     float *synthFB,
    7882             :     float *A, /* i  : A(z) filter coefficients             */
    7883             :     const int16_t bfi,
    7884             :     const int16_t isMCT );
    7885             : 
    7886             : void coder_acelp(
    7887             :     Encoder_State *st,    /* i/o: coder memory state          */
    7888             :     const float A[],      /* i  : coefficients 4xAz[M+1]      */
    7889             :     const float Aq[],     /* i  : coefficients 4xAz_q[M+1]    */
    7890             :     const float speech[], /* i  : speech[-M..lg]              */
    7891             :     LPD_state *LPDmem,    /* i/o: ACELP memories              */
    7892             :     int16_t *prm,         /* o  : acelp parameters            */
    7893             :     const float stab_fac,
    7894             :     const int16_t target_bits,
    7895             :     float *gain_pitch_buf, /* o  : gain pitch values           */
    7896             :     float *gain_code_buf,  /* o  : gain code values            */
    7897             :     float *pitch_buf,      /* o  : pitch values for each subfr.*/
    7898             :     float *voice_factors,  /* o  : voicing factors             */
    7899             :     float *bwe_exc         /* o  : excitation for SWB TBE      */
    7900             : );
    7901             : 
    7902             : void coder_acelp_rf(
    7903             :     const int16_t target_bits,   /* i  :   target bits               */
    7904             :     const float speech[],        /* i  : speech[-M..lg]              */
    7905             :     const int16_t coder_type,    /* i  : coding type                 */
    7906             :     const int16_t rf_frame_type, /* i  : rf_frame_type               */
    7907             :     const float A[],             /* i  : coefficients 4xAz[M+1]      */
    7908             :     const float Aq[],            /* i  : coefficients 4xAz_q[M+1]    */
    7909             :     const float voicing[],       /* i  : open-loop LTP gain          */
    7910             :     const int16_t T_op[],        /* i  : open-loop LTP lag           */
    7911             :     const float stab_fac,        /* i  : LP stability factor         */
    7912             :     Encoder_State *st,           /* i/o: coder memory state          */
    7913             :     ACELP_config *acelp_cfg,     /* i/o: configuration of the ACELP  */
    7914             :     float *exc_rf,               /* i/o: pointer to RF excitation    */
    7915             :     float *syn_rf                /* i/o: pointer to RF synthesis     */
    7916             : );
    7917             : 
    7918             : void decoder_acelp(
    7919             :     Decoder_State *st,              /* i/o:  coder memory state         */
    7920             :     int16_t prm[],                  /* i  : parameters                  */
    7921             :     const float A[],                /* i  : coefficients NxAz[M+1]      */
    7922             :     ACELP_config acelp_cfg,         /* i  : ACELP config                */
    7923             :     float synth[],                  /* i/o: synthesis                   */
    7924             :     int16_t *pT,                    /* o  : pitch for all subframe      */
    7925             :     float *pgainT,                  /* o  : pitch gain for all subfr    */
    7926             :     const float stab_fac,           /* i  : stability of isf            */
    7927             :     float *pitch_buffer,            /* o  : pitch values for each subfr.*/
    7928             :     float *voice_factors,           /* o  : voicing factors             */
    7929             :     const int16_t LSF_Q_prediction, /* i  : LSF prediction mode         */
    7930             :     float *bwe_exc                  /* o  : excitation for SWB TBE      */
    7931             : );
    7932             : 
    7933             : void writeTCXMode(
    7934             :     Encoder_State *st,      /* i/o: encoder state structure             */
    7935             :     BSTR_ENC_HANDLE hBstr,  /* i/o: bitstream handle                    */
    7936             :     const int16_t MCT_flag, /* i  : hMCT handle allocated (1) or not (0)*/
    7937             :     int16_t *nbits_start    /* o  : nbits start                         */
    7938             : );
    7939             : 
    7940             : void writeTCXWindowing(
    7941             :     BSTR_ENC_HANDLE hBstr,     /* i/o: bitstream handle            */
    7942             :     const int16_t overlap_mode /* i  : overlap mode                */
    7943             : );
    7944             : 
    7945             : void writeLPCparam(
    7946             :     Encoder_State *st,              /* i/o: encoder state structure     */
    7947             :     BSTR_ENC_HANDLE hBstr,          /* i/o: bitstream handle            */
    7948             :     const int16_t param_lpc[],      /* i  : LPC parameters to write     */
    7949             :     const int16_t bits_param_lpc[], /* i  : bits per LPC parameter      */
    7950             :     const int16_t no_param_lpc,     /* i  : number of LPC parameters    */
    7951             :     int16_t *nbits_lpc              /* o  : LPC bits written            */
    7952             : );
    7953             : 
    7954             : void enc_prm(
    7955             :     Encoder_State *st,   /* i/o: encoder state structure     */
    7956             :     int16_t param[],     /* i  : parameters                  */
    7957             :     int16_t param_lpc[], /* i  : LPC parameters              */
    7958             :     CONTEXT_HM_CONFIG hm_cfg[],
    7959             :     const int16_t bits_param_lpc[],
    7960             :     const int16_t no_param_lpc );
    7961             : 
    7962             : void writeTCXparam(
    7963             :     Encoder_State *st,          /* i/o: Encoder State handle        */
    7964             :     BSTR_ENC_HANDLE hBstr,      /* i/o: bitstream handle            */
    7965             :     CONTEXT_HM_CONFIG hm_cfg[], /* i/o: HM config                   */
    7966             :     int16_t param[],            /* i  : parameters                  */
    7967             :     const int16_t nbits_header,
    7968             :     const int16_t nbits_start,
    7969             :     const int16_t nbits_lpc,
    7970             :     const int16_t *no_param_tns, /* i  : number of TNS parameters per subframe          */
    7971             :     int16_t p_param[2],          /* i/o: pointer to parameters from previous bs writing */
    7972             :     const int16_t target_bitsTCX10[2],
    7973             :     const int16_t pre_past_flag );
    7974             : 
    7975             : void enc_prm_rf(
    7976             :     Encoder_State *st, /* i/o: encoder memory state          */
    7977             :     const int16_t rf_frame_type,
    7978             :     const int16_t fec_offset );
    7979             : 
    7980             : void dec_prm_hm(
    7981             :     Decoder_State *st, /* i/o: decoder memory state          */
    7982             :     int16_t *prm_hm,
    7983             :     const int16_t hm_size );
    7984             : 
    7985             : void dec_prm(
    7986             :     Decoder_State *st,     /* i/o: decoder memory state          */
    7987             :     int16_t param[],       /* o  : decoded parameters            */
    7988             :     int16_t param_lpc[],   /* i  : LPC parameters                */
    7989             :     int16_t *total_nbbits, /* i/o: number of bits / decoded bits */
    7990             :     int16_t *bitsRead );
    7991             : 
    7992             : void gauss_L2(
    7993             :     const float h[],       /* i  : weighted LP filter impulse response     */
    7994             :     float code[],          /* o  : gaussian excitation                     */
    7995             :     float y2[],            /* i  : zero-memory filtered code. excitation   */
    7996             :     float y11[],           /* o  : zero-memory filtered gauss. excitation  */
    7997             :     float *gain,           /* o  : excitation gain                         */
    7998             :     float g_corr[],        /* i/o: correlation structure for gain coding   */
    7999             :     float tilt_code,       /* i  : tilt of code                            */
    8000             :     const float *Aq,       /* i  : quantized LPCs                          */
    8001             :     float formant_enh_num, /* i  : formant enhancement factor              */
    8002             :     int16_t *seed_acelp    /* i/o: random seed                             */
    8003             : );
    8004             : 
    8005             : void gaus_L2_dec(
    8006             :     float *code, /* o  : decoded gaussian codevector             */
    8007             :     float tilt_code,
    8008             :     const float *A,
    8009             :     float formant_enh_num,
    8010             :     int16_t *seed_acelp /* i/o: random seed             */
    8011             : );
    8012             : 
    8013             : /*! r: interpolated value */
    8014             : float interpolation(
    8015             :     const float *x,        /* i  : input vector            */
    8016             :     const float *win,      /* i  : interpolation window    */
    8017             :     const int16_t frac,    /* i  : fraction                */
    8018             :     const int16_t up_samp, /* i  : upsampling factor       */
    8019             :     const int16_t nb_coef  /* i  : nb of filter coef       */
    8020             : );
    8021             : 
    8022             : void predict_signal(
    8023             :     const float excI[],     /* i  : input excitation buffer  */
    8024             :     float excO[],           /* o  : output excitation buffer */
    8025             :     const int16_t T0,       /* i  : integer pitch lag        */
    8026             :     int16_t frac,           /* i  : fraction of lag          */
    8027             :     const int16_t frac_max, /* i  : max fraction             */
    8028             :     const int16_t L_subfr   /* i  : subframe size            */
    8029             : );
    8030             : 
    8031             : void tcx_ltp_encode(
    8032             :     Encoder_State *st,
    8033             :     const int16_t tcxMode,
    8034             :     const int16_t L_frame,
    8035             :     const float *speech,
    8036             :     float *speech_ltp,
    8037             :     const float *wsp,
    8038             :     const int16_t Top[],
    8039             :     int16_t *ltp_param,
    8040             :     int16_t *ltp_bits,
    8041             :     float *A,
    8042             :     const int16_t disable_ltp,
    8043             :     const int16_t element_mode );
    8044             : 
    8045             : void tcx_ltp_post(
    8046             :     Decoder_State *st,
    8047             :     TCX_LTP_DEC_HANDLE hTcxLtpDec,
    8048             :     const int16_t core,
    8049             :     const int16_t output_frame,
    8050             :     const int16_t L_frame,
    8051             :     float sig[],
    8052             :     const float tcx_buf[] );
    8053             : 
    8054             : int16_t tcx_ltp_decode_params(
    8055             :     int16_t *ltp_param,
    8056             :     int16_t *pitch_int,
    8057             :     int16_t *pitch_fr,
    8058             :     float *gain,
    8059             :     const int16_t pitmin,
    8060             :     const int16_t pitfr1,
    8061             :     const int16_t pitfr2,
    8062             :     const int16_t pitmax,
    8063             :     const int16_t pitres );
    8064             : 
    8065             : int16_t enc_lsf_tcxlpc(
    8066             :     const int16_t **indices, /* i  : Ptr to VQ indices                                   */
    8067             :     BSTR_ENC_HANDLE hBstr    /* i/o: encoder bitstream handle                            */
    8068             : );
    8069             : 
    8070             : void msvq_enc(
    8071             :     const float *const *cb,      /* i  : Codebook (indexed cb[*stages][levels][p])            */
    8072             :     const int16_t dims[],        /* i  : Dimension of each codebook stage (NULL: full dim.)   */
    8073             :     const int16_t offs[],        /* i  : Starting dimension of each codebook stage (NULL: 0)  */
    8074             :     const float u[],             /* i  : Vector to be encoded (prediction and mean removed)   */
    8075             :     const int16_t *levels,       /* i  : Number of levels in each stage                       */
    8076             :     const int16_t maxC,          /* i  : Tree search size (number of candidates kept from one stage to the next == M-best) */
    8077             :     const int16_t stages,        /* i  : Number of stages                                     */
    8078             :     const float w[],             /* i  : Weights                                              */
    8079             :     const int16_t N,             /* i  : Vector dimension                                     */
    8080             :     const int16_t maxN,          /* i  : Codebook dimension                                   */
    8081             :     const int16_t applyDCT_flag, /* i  : applyDCT flag                                   */
    8082             :     float *invTrfMatrix,         /* i/o: expanded synthesis matrix                            */
    8083             :     int16_t Idx[]                /* o  : Indices                                              */
    8084             : );
    8085             : 
    8086             : void msvq_dec(
    8087             :     const float *const *cb,       /* i  : Codebook (indexed cb[*stages][levels][p])            */
    8088             :     const int16_t dims[],         /* i  : Dimension of each codebook stage (NULL: full dim.)   */
    8089             :     const int16_t offs[],         /* i  : Starting dimension of each codebook stage (NULL: 0)  */
    8090             :     const int16_t stages,         /* i  : Number of stages                                     */
    8091             :     const int16_t N,              /* i  : Vector dimension                                     */
    8092             :     const int16_t maxN,           /* i  : Codebook dimension                                   */
    8093             :     const int16_t Idx[],          /* i  : Indices                                              */
    8094             :     const int16_t applyIDCT_flag, /* i  : applyIDCT flag                                 */
    8095             :     const float *invTrfMatrix,    /* i  : synthesis matrix                                     */
    8096             :     float *uq,                    /* o  : quantized vector                                     */
    8097             :     Word16 *uq_ind                /* o  : quantized vector (fixed point)                       */
    8098             : );
    8099             : 
    8100             : 
    8101             : void dec_FDCNG_MSVQ_stage1(
    8102             :     int16_t j_full,            /* i  : index full range                     */
    8103             :     int16_t n,                 /* i  : dimension to generate                */
    8104             :     const float *invTrfMatrix, /* i  : IDCT matrix for synthesis            */
    8105             :     const DCTTYPE idcttype,    /* i  : specify which IDCT                   */
    8106             :     float *uq,                 /* o  : synthesized stage1 vector            */
    8107             :     Word16 *uq_ind             /* o  : synthesized stage1 vector in BASOP   */
    8108             : );
    8109             : 
    8110             : void create_IDCT_N_Matrix(
    8111             :     float *inv_matrixFloatQ, /* i/o: RAM buffer */
    8112             :     const int16_t N,         /* i  : DCT length, number of time samples             */
    8113             :     const int16_t n_cols,    /* i  : number of dct coeffs (as DCT may be truncated) */
    8114             :     const int16_t alloc_size /* i  : RAM buffer size in elements                    */
    8115             : );
    8116             : 
    8117             : void dctT2_N_apply_matrix(
    8118             :     const float *input,           /* i  : input  in fdcng or DCT(fdcng) domain     */
    8119             :     float *output,                /* o  : output in DCT(fdcng) or fdcng ordomain   */
    8120             :     const int16_t dct_dim,        /* i  : dct processing dim possibly truncated    */
    8121             :     const int16_t fdcngvq_dim,    /* i  : fdcng domain length                      */
    8122             :     const float *matrix,          /* i  : IDCT matrix                              */
    8123             :     const int16_t matrix_row_dim, /* i  :                                          */
    8124             :     const DCTTYPE dcttype         /* i  : matrix  operation type                   */
    8125             : );
    8126             : 
    8127             : void extend_dctN_input(
    8128             :     const float *input,     /* i  : input in fdcng domain                         */
    8129             :     const float *dct_input, /* i  : input in dctN(fdcng) domain                   */
    8130             :     const int16_t in_dim,   /* i  : in_dim == N                                   */
    8131             :     float *ext_sig,         /* o  : extended output in fdcng domain               */
    8132             :     const int16_t out_dim,  /* i  : output total dim                              */
    8133             :     float *matrix,          /* i  : idct synthesis matrix N rows, n_cols  columns */
    8134             :     const int16_t n_cols,   /* i  : number of columns ==  DCT truncation length   */
    8135             :     const DCTTYPE dcttype   /* i  : matrix operation type                         */
    8136             : );
    8137             : 
    8138             : /*! r: (p_max , best candidate sofar ) */
    8139             : int16_t msvq_stage1_dct_search(
    8140             :     const float *u,                           /* i  : target                                        */
    8141             :     const int16_t N,                          /* i  : target length and  IDCT synthesis length      */
    8142             :     const int16_t maxC_st1,                   /* i  : number of final stage 1 candidates to provide */
    8143             :     const DCTTYPE dcttype,                    /* e.g. DCT_T2_16_XX, DCT_T2_24_XX;                   */
    8144             :     const int16_t max_dct_trunc,              /* i  :  maximum of truncation lenghts                */
    8145             :     float *invTrfMatrix,                      /* i  : IDCT synthesis matrix for dim N               */
    8146             :     const float *midQ_truncQ,                 /* i  : midQ  vector                                  */
    8147             :     const float *dct_invScaleF,               /* i  : global inv scale factors                      */
    8148             :     const float *dct_scaleF,                  /* i  : global scale factors                          */
    8149             :     const Word16 n_segm,                      /* i  : number of segments                            */
    8150             :     const Word16 *cols_per_segment,           /* i  : remaining length per segment                  */
    8151             :     const Word16 *trunc_dct_cols_per_segment, /* i  : trunc length per segment                      */
    8152             :     const Word16 *entries_per_segment,        /* i  : number of rows per segment                    */
    8153             :     const Word16 *cum_entries_per_segment,    /* i  : number of cumulative entries                  */
    8154             :     const Word8 *const W8Qx_dct_sections[],   /* i  : Word8(byte) segment  table ptrs               */
    8155             :     const Word16 *col_syn_shift[],            /* i  : columnwise  syn shift tables                  */
    8156             :     const Word8 *segm_neighbour_fwd,          /* i  : circular neighbour list fwd                   */
    8157             :     const Word8 *segm_neighbour_rev,          /* i  : circular neighbour list reverse               */
    8158             :     const Word16 npost_check,                 /* i  : number of neigbours to check , should be even */
    8159             :     float *st1_mse_ptr,                       /* i  : dynRAM buffer for MSEs                        */
    8160             :     int16_t *indices_st1_local,               /* o  :  selected cand indices                        */
    8161             :     float *st1_syn_vec_ptr,                   /* i/o:  buffer for IDCT24 synthesis                  */
    8162             :     float *dist1_ptr                          /* o  :  resulting stage 1 MSEs in DCT-N domain       */
    8163             : );
    8164             : 
    8165             : /*! r: (updated p_max) */
    8166             : int16_t msvq_stage1_dct_recalc_candidates_fdcng_wb(
    8167             :     const float *st1_syn_vec_ptr, /* i  : IDCT24 synthesis vectors       */
    8168             :     const float *u,               /* i  : target   signal                */
    8169             :     const int16_t maxC_st1,       /* i  : number of candidates in stage1 */
    8170             :     float *dist_ptr               /* i/o: updated  MSE vector for stage1 */
    8171             : );
    8172             : 
    8173             : void PulseResynchronization(
    8174             :     const float *src_exc,       /* i  : Input excitation buffer                 */
    8175             :     float *dst_exc,             /* o  : output excitation buffer                */
    8176             :     const int16_t nFrameLength, /* i  : frame length                            */
    8177             :     const int16_t nSubframes,   /* i  : Number of subframes                     */
    8178             :     const float pitchStart,     /* i  : Pitch at the end of the last frame      */
    8179             :     const float pitchEnd        /* i  : Pitch at the end of the current  frame  */
    8180             : );
    8181             : 
    8182             : void con_acelp(
    8183             :     float A[],                /* i  : coefficients NxAz[M+1]      */
    8184             :     const int16_t coder_type, /* i  : ACELP coder type            */
    8185             :     float synth[],            /* i/o: synthesis                   */
    8186             :     int16_t *pT,              /* o  :   pitch for all subframe    */
    8187             :     float *pgainT,            /* o  :   pitch gain for all subfr  */
    8188             :     float stab_fac,           /* i  : stability of isf            */
    8189             :     Decoder_State *st,        /* i/o:  coder memory state         */
    8190             :     float pitch_buffer[],     /* i/o: floating pitch values for each subframe          */
    8191             :     float *voice_factors,     /* o  : voicing factors             */
    8192             :     float *bwe_exc            /* o  : excitation for SWB TBE      */
    8193             : );
    8194             : 
    8195             : void con_tcx(
    8196             :     Decoder_State *st,       /* i/o: coder memory state          */
    8197             :     float synth[],           /* i/o: synth[]                     */
    8198             :     const float coh,         /* i  : coherence of stereo signal  */
    8199             :     int16_t *noise_seed,     /* i/o: noise seed for stereo       */
    8200             :     const int16_t only_left, /* i  : TD-PLC only in left channel */
    8201             :     const float A_cng[]      /* i  : CNG LP filter coefficients  */
    8202             : );
    8203             : 
    8204             : /*! r: codebook index */
    8205             : int16_t tcxlpc_get_cdk(
    8206             :     const int16_t coder_type /* i  : GC/VC indicator             */
    8207             : );
    8208             : 
    8209             : int16_t lsf_msvq_ma_encprm(
    8210             :     BSTR_ENC_HANDLE hBstr,
    8211             :     const int16_t *param_lpc,
    8212             :     const int16_t core,
    8213             :     const int16_t acelp_mode,
    8214             :     const int16_t acelp_midLpc,
    8215             :     const int16_t bits_param_lpc[],
    8216             :     const int16_t no_indices );
    8217             : 
    8218             : int16_t lsf_msvq_ma_decprm(
    8219             :     Decoder_State *st,
    8220             :     int16_t *param_lpc );
    8221             : 
    8222             : int16_t dec_lsf_tcxlpc(
    8223             :     Decoder_State *st,        /* i  : Decoder state        */
    8224             :     int16_t **indices,        /* o  : Ptr to VQ indices    */
    8225             :     const int16_t narrowband, /* i  : narrowband flag      */
    8226             :     const int16_t cdk         /* i  : codebook selector    */
    8227             : );
    8228             : 
    8229             : int16_t D_lsf_tcxlpc(
    8230             :     const int16_t indices[],  /* i  : VQ indices           */
    8231             :     float lsf_q[],            /* o  : quantized lsf        */
    8232             :     Word16 lsp_q_ind[],       /* o  : quantized lsp (w/o MA prediction) */
    8233             :     const int16_t narrowband, /* i  : narrowband flag      */
    8234             :     const int16_t cdk,        /* i  : codebook selector    */
    8235             :     const float mem_MA[]      /* i  : MA memory            */
    8236             : );
    8237             : 
    8238             : void lsf_update_memory(
    8239             :     const int16_t narrowband, /* i  : narrowband flag                             */
    8240             :     const float qlsf[],       /* i  : quantized lsf coefficients                  */
    8241             :     float old_mem_MA[],       /* i  : MA memory                                   */
    8242             :     float mem_MA[]            /* o  : updated MA memory                           */
    8243             : );
    8244             : 
    8245             : int16_t Q_lsf_tcxlpc(
    8246             :     /* const */ float lsf[],  /* i  : original lsf             */
    8247             :     float lsf_q[],            /* o  : quantized lsf            */
    8248             :     Word16 lsp_q_ind[],       /* o  : quantized lsp (w/o MA prediction) */
    8249             :     int16_t indices[],        /* o  : VQ indices               */
    8250             :     const int16_t narrowband, /* i  : narrowband flag          */
    8251             :     const int16_t cdk,        /* i  : codebook selector        */
    8252             :     const float mem_MA[],     /* i  : MA memory                */
    8253             :     const int16_t coder_type, /* i  : acelp extended mode      */
    8254             :     const float *Bin_Ener     /* i  : Spectrum energy          */
    8255             : );
    8256             : 
    8257             : int16_t E_LPC_lsp_unweight(
    8258             :     const float lsp_w[],  /* i  : weighted lsp             */
    8259             :     float lsp_uw[],       /* o  : unweighted lsp           */
    8260             :     float lsf_uw[],       /* o  : unweighted lsf           */
    8261             :     const float inv_gamma /* i  : inverse weighting factor */
    8262             : );
    8263             : 
    8264             : int16_t lsf_ind_is_active(
    8265             :     const Word16 lsf_q_ind[],
    8266             :     const float means[],
    8267             :     const int16_t narrowband,
    8268             :     const int16_t cdk );
    8269             : 
    8270             : void midlsf_enc(
    8271             :     const float qlsf0[],
    8272             :     const float qlsf1[],
    8273             :     const float lsf[],
    8274             :     int16_t *idx,
    8275             :     const int16_t N,
    8276             :     const float *Bin_Ener,
    8277             :     const int16_t narrowBand,
    8278             :     const int32_t sr_core,
    8279             :     const int16_t coder_type );
    8280             : 
    8281             : void midlsf_dec(
    8282             :     const float qlsf0[],
    8283             :     const float qlsf1[],
    8284             :     const int16_t idx,
    8285             :     float qlsf[],
    8286             :     const int16_t N,
    8287             :     const int16_t coder_type,
    8288             :     int16_t *mid_lsf_int,
    8289             :     const int16_t prev_bfi,
    8290             :     const int16_t safety_net );
    8291             : 
    8292             : void lsf_end_enc(
    8293             :     Encoder_State *st,
    8294             :     const float *lsf,
    8295             :     float *qlsf,
    8296             :     const int16_t nBits,
    8297             :     const int16_t coder_type_org,
    8298             :     const int16_t force_sf,
    8299             :     int16_t *lpc_param,
    8300             :     int16_t *no_stages,
    8301             :     int16_t *bits_param_lpc,
    8302             :     const int16_t coder_type_raw,
    8303             :     const float tdm_lsfQ_PCh[M] /* i  : Q LSFs for primary channel          */
    8304             : );
    8305             : 
    8306             : void lsf_end_dec(
    8307             :     Decoder_State *st,            /* i/o: decoder state structure                 */
    8308             :     const int16_t coder_type_org, /* i  : coding type                             */
    8309             :     const int16_t bwidth,         /* i  : input signal bandwidth                  */
    8310             :     const int16_t nBits,          /* i  : number of bits used for ISF quantization*/
    8311             :     float *qlsf,                  /* o  : quantized LSFs in the cosine domain     */
    8312             :     int16_t *lpc_param,           /* i  : LPC parameters                          */
    8313             :     int16_t *LSF_Q_prediction,    /* o  : LSF prediction mode                     */
    8314             :     int16_t *nb_indices,          /* o  : number of indices                       */
    8315             :     const float tdm_lsfQ_PCh[M]   /* i  : Q LSFs for primary channel          */
    8316             : );
    8317             : 
    8318             : ivas_error find_pred_mode(
    8319             :     int16_t *predmode,
    8320             :     const int16_t coder_type,
    8321             :     const int16_t bwidth,
    8322             :     const int32_t int_fs,
    8323             :     int16_t *p_mode_lvq,
    8324             :     int16_t *p_mode_lvq_p,
    8325             :     const int32_t core_brate );
    8326             : 
    8327             : void lpc_quantization(
    8328             :     Encoder_State *st,
    8329             :     const float lsp[],
    8330             :     const float lspmid[],
    8331             :     float lsp_q[],
    8332             :     float lsf_q[],
    8333             :     float lspmid_q[],
    8334             :     const int16_t coder_type,
    8335             :     const int16_t acelp_midLpc,
    8336             :     int16_t param_lpc[],
    8337             :     int16_t nbits_lpc[],
    8338             :     int16_t *bits_param_lpc,
    8339             :     int16_t *no_param_lpc );
    8340             : 
    8341             : void lpc_unquantize(
    8342             :     Decoder_State *st,
    8343             :     float *lsf,
    8344             :     float *lsp,
    8345             :     int16_t *param_lpc,
    8346             :     float *lspmid,
    8347             :     float *lsfmid,
    8348             :     const int16_t coder_type,
    8349             :     int16_t *LSF_Q_prediction /* o  : LSF prediction mode                     */
    8350             : );
    8351             : 
    8352             : void dlpc_bfi(
    8353             :     const int16_t L_frame,
    8354             :     float *lsf_q,             /* o  : quantized lsfs                         */
    8355             :     const float *lsfold,      /* i  : past quantized lsf                     */
    8356             :     const int16_t last_good,  /* i  : last good received frame               */
    8357             :     const int16_t nbLostCmpt, /* i  : counter of consecutive bad frames      */
    8358             :     float mem_MA[],           /* i/o: quantizer memory for MA model          */
    8359             :     float mem_AR[],           /* i/o: quantizer memory for MA model          */
    8360             :     float *stab_fac,          /* i  : lsf stability factor                   */
    8361             :     float *lsf_adaptive_mean, /* i  : lsf adaptive mean, updated when BFI==0 */
    8362             :     const int16_t numlpc,     /* i  : Number of division per superframe      */
    8363             :     float lsf_cng[],
    8364             :     const int16_t plcBackgroundNoiseUpdated,
    8365             :     float *lsf_q_cng,     /* o  : quantized lsfs of background noise      */
    8366             :     float *old_lsf_q_cng, /* o  : old quantized lsfs for background noise */
    8367             :     const float lsfBase[] /* i  : base for differential lsf coding        */
    8368             : );
    8369             : 
    8370             : void lsf_dec_bfi(
    8371             :     const int16_t codec_mode,                /* i  : codec_mode: MODE1 | MODE2              */
    8372             :     float *lsf,                              /* o  : estimated LSF vector                   */
    8373             :     const float *lsfold,                     /* i  : past quantized lsf                     */
    8374             :     float *lsf_adaptive_mean,                /* i  : lsf adaptive mean, updated when BFI==0 */
    8375             :     const float lsfBase[],                   /* i  : base for differential lsf coding       */
    8376             :     float *mem_MA,                           /* i/o: quantizer memory for MA model          */
    8377             :     float *mem_AR,                           /* o  : quantizer memory for AR model          */
    8378             :     const float stab_fac,                    /* i  : lsf stability factor                   */
    8379             :     const int16_t last_coder_type,           /* i  : last coder type                        */
    8380             :     const int16_t L_frame,                   /* i  : frame length                           */
    8381             :     const int16_t last_good,                 /* i  : last good received frame               */
    8382             :     const int16_t nbLostCmpt,                /* i  : counter of consecutive bad frames      */
    8383             :     const int16_t plcBackgroundNoiseUpdated, /* i  : background noise already updated?      */
    8384             :     float *lsf_q_cng,                        /* o  : quantized lsfs of background noise     */
    8385             :     float *lsf_cng,                          /* i  : long term target for fading to bg noise*/
    8386             :     float *old_lsf_q_cng,                    /* o  : old quantized lsfs for background noise*/
    8387             :     const int16_t Last_GSC_pit_band_idx,     /* i  : AC mode (GSC) - Last pitch band index  */
    8388             :     const int16_t Opt_AMR_WB,                /* i  : IO flag                                */
    8389             :     const int16_t bwidth                     /* i  : coded bandwidth                        */
    8390             : );
    8391             : 
    8392             : const float *PlcGetlsfBase(
    8393             :     const int16_t pcQuantization,
    8394             :     const int16_t narrowBand,
    8395             :     const int32_t sr_core );
    8396             : 
    8397             : void Unified_weighting(
    8398             :     const float Bin_Ener_128[], /* i  : FFT Bin energy 128 bins in two sets     */
    8399             :     const float lsf[],          /* i  : LSF vector                              */
    8400             :     float w[],                  /* o  : LP weighting filter (numerator)         */
    8401             :     const int16_t narrowBand,   /* i  : flag for Narrowband                     */
    8402             :     const int16_t unvoiced,     /* i  : flag for Unvoiced frame                 */
    8403             :     const int32_t sr_core,      /* i  : sampling rate of core-coder             */
    8404             :     const int16_t order         /* i  : LP order                                */
    8405             : );
    8406             : 
    8407             : int16_t vad_init(
    8408             :     VAD_CLDFB_HANDLE hVAD_CLDFB /* i/o: CLDFB VAD state                         */
    8409             : );
    8410             : 
    8411             : int16_t vad_proc(
    8412             :     float realValues[16][60],    /* i  : CLDFB real values                       */
    8413             :     float imagValues[16][60],    /* i  : CLDFB imag values                       */
    8414             :     float *sb_power,             /* i/o: Energy of CLDFB data                    */
    8415             :     const int16_t numBands,      /* i  : number of input bands                   */
    8416             :     VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state                         */
    8417             :     int16_t *cldfb_addition,
    8418             :     const int16_t vada_flag /* i  : VAD flag                                */
    8419             : );
    8420             : 
    8421             : void subband_FFT(
    8422             :     float Sr[16][60], /* i  : real part                               */
    8423             :     float Si[16][60], /* i  : imag part                               */
    8424             :     float *spec_amp   /* o  : spectral amplitude                      */
    8425             : );
    8426             : 
    8427             : int16_t update_decision(
    8428             :     VAD_CLDFB_HANDLE hVAD_CLDFB,    /* i/o: CLDFB VAD state                        */
    8429             :     const float snr,                /* i  : frequency domain SNR                    */
    8430             :     const float tsnr,               /* i  : time domain SNR                         */
    8431             :     const float frame_energy,       /* i  : current frame energy                    */
    8432             :     const float high_eng,           /* i  : current frame high frequency energy     */
    8433             :     const int16_t vad_flag,         /* i  : VAD flag                                */
    8434             :     const int16_t music_backgound_f /* i  : background music flag                   */
    8435             : );
    8436             : 
    8437             : void frame_spec_dif_cor_rate(
    8438             :     float spec_amp[],         /* i  : spectral amplitude                      */
    8439             :     float pre_spec_low_dif[], /* i/o: low spectrum different                  */
    8440             :     float f_tonality_rate[]   /* o  : tonality rate                           */
    8441             : );
    8442             : 
    8443             : void ltd_stable(
    8444             :     float frames_power[],     /* i/o: energy of several frames                */
    8445             :     float ltd_stable_rate[],  /* o  : time-domain stable rate                 */
    8446             :     const float frame_energy, /* i  : current frame energy                    */
    8447             :     const int16_t frameloop   /* i  : number of  frames                       */
    8448             : );
    8449             : 
    8450             : void SNR_calc(
    8451             :     const float frame_sb_energy[], /* i  : energy of sub-band divided non-uniformly*/
    8452             :     const float sb_bg_energy[],    /* i  : sub-band background energy              */
    8453             :     const float t_bg_energy,       /* i  : time background energy of several frames*/
    8454             :     float *snr,                    /* o  : frequency domain SNR                    */
    8455             :     float *tsnr,                   /* o  : time domain SNR                         */
    8456             :     const float frame_energy,      /* i  : current frame energy                    */
    8457             :     const int16_t bwidth           /* i  : audio bandwidth                         */
    8458             : );
    8459             : 
    8460             : void background_update(
    8461             :     VAD_CLDFB_HANDLE hVAD_CLDFB,     /* i/o: CLDFB VAD state                         */
    8462             :     float frame_energy,              /* i  : current frame energy 2                  */
    8463             :     const int16_t update_flag,       /* i  : current frame update flag               */
    8464             :     const int16_t music_backgound_f, /* i  : background music flag                   */
    8465             :     const float snr );
    8466             : 
    8467             : void bg_music_decision(
    8468             :     VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state                         */
    8469             :     int16_t *music_backgound_f,  /* i  : background music flag                   */
    8470             :     const float frame_energy     /* i  : current frame energy 1                  */
    8471             : );
    8472             : 
    8473             : void est_energy(
    8474             :     float sb_power[],        /* o  : energy of sub-band divided uniformly    */
    8475             :     float frame_sb_energy[], /* o  : energy of sub-band divided non-uniformly*/
    8476             :     float *p_frame_energy,   /* o  : frame energy 1                          */
    8477             :     float *p_frame_energy2,  /* o  : frame energy 2                          */
    8478             :     float *p_high_energy,    /* o  : high frequency energy                   */
    8479             :     const int16_t bw         /* i  : bandwidth                               */
    8480             : );
    8481             : 
    8482             : void spec_center(
    8483             :     float spec_power[],    /* i  : energy of sub-band divided uniformly    */
    8484             :     float sp_center[],     /* o  : spectral center                         */
    8485             :     const int16_t bw_index /* i  : bandwidth                               */
    8486             : );
    8487             : 
    8488             : void spec_flatness(
    8489             :     float spec_amp[],        /* i  : spectral amplitude                      */
    8490             :     float smooth_spec_amp[], /* i  : smoothed spectral amplitude             */
    8491             :     float sSFM[]             /* o  : spectral flatness rate                  */
    8492             : );
    8493             : 
    8494             : int16_t comvad_decision(
    8495             :     VAD_CLDFB_HANDLE hVAD_CLDFB,     /* i/o: CLDFB VAD state                         */
    8496             :     const float snr,                 /* i  : frequency domain SNR                    */
    8497             :     const float tsnr,                /* i  : time domain SNR                         */
    8498             :     const float snr_flux,            /* i  : average tsnr of several frames          */
    8499             :     const float lt_snr,              /* i  : long time SNR calculated by fg_energy and bg_energy*/
    8500             :     const float lt_snr_org,          /* i  : original long time SNR                  */
    8501             :     const float lf_snr,              /* i  : long time frequency domain SNR calculated by l_speech_snr and l_silence_snr*/
    8502             :     const float frame_energy,        /* i  : current frame energy                    */
    8503             :     const int16_t music_backgound_f, /* i  : background music flag                   */
    8504             :     int16_t *cldfb_addition,
    8505             :     const int16_t vada_flag /* i  : VAD flag                                */
    8506             : );
    8507             : 
    8508             : void calc_snr_flux(
    8509             :     float tsnr,      /* i  : time-domain SNR                         */
    8510             :     float pre_snr[], /* i/o:  time-domain SNR storage                */
    8511             :     float *snr_flux  /* o  : average tsnr                            */
    8512             : );
    8513             : 
    8514             : void calc_lt_snr(
    8515             :     float *lt_snr_org,              /* o  : original long time SNR                  */
    8516             :     float *lt_snr,                  /* o  : long time SNR calculated by fg_energy and bg_energy*/
    8517             :     const float fg_energy,          /* i  : foreground energy sum                   */
    8518             :     const int16_t fg_energy_count,  /* i  : number of the foreground energy frame   */
    8519             :     const float bg_energy,          /* i  : background energy sum                   */
    8520             :     const int16_t bg_energy_count,  /* i  : number of the background energy frame   */
    8521             :     const int16_t bw_index,         /* i  : band width index                        */
    8522             :     const float lt_noise_sp_center0 /* i  : long time noise spectral center by 0    */
    8523             : );
    8524             : 
    8525             : void calc_lf_snr(
    8526             :     float *lf_snr_smooth,              /* o  : smoothed lf_snr                         */
    8527             :     float *lf_snr,                     /* o  : long time frequency domain SNR calculated by l_speech_snr and l_silence_snr*/
    8528             :     const float l_speech_snr,          /* i  : sum of active frames snr                */
    8529             :     const int16_t l_speech_snr_count,  /* i  : number of the active frame              */
    8530             :     const float l_silence_snr,         /* i  : sum of the nonactive frames snr         */
    8531             :     const int16_t l_silence_snr_count, /* i  : number of the nonactive frame           */
    8532             :     const int16_t fg_energy_count,     /* i  : number of the foreground energy frame   */
    8533             :     const int16_t bg_energy_count,     /* i  : number of the background energy frame   */
    8534             :     const int16_t bw_index             /* i  : band width index                        */
    8535             : );
    8536             : 
    8537             : float construct_snr_thresh(
    8538             :     const float sp_center[],             /* i  : spectral center                         */
    8539             :     const float snr_flux,                /* i  : snr flux                                */
    8540             :     const float lt_snr,                  /* i  : long time time domain snr               */
    8541             :     const float lf_snr,                  /* i  : long time frequency domain snr          */
    8542             :     const int16_t continuous_speech_num, /* i  : continuous speech number                */
    8543             :     const int16_t continuous_noise_num,  /* i  : continuous noise number                 */
    8544             :     const int16_t fg_energy_est_start,   /* i  : whether if estimated energy             */
    8545             :     const int16_t bw_index               /* i  : band width index                        */
    8546             : );
    8547             : 
    8548             : ivas_error createFdCngCom(
    8549             :     HANDLE_FD_CNG_COM *hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */
    8550             : );
    8551             : 
    8552             : void deleteFdCngCom(
    8553             :     HANDLE_FD_CNG_COM *hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */
    8554             : );
    8555             : 
    8556             : void initFdCngCom(
    8557             :     HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */
    8558             :     const float scale );
    8559             : 
    8560             : void initPartitions(
    8561             :     const int16_t *part_in,
    8562             :     const int16_t npart_in,
    8563             :     const int16_t startBand,
    8564             :     const int16_t stopBand,
    8565             :     int16_t *part_out,
    8566             :     int16_t *npart_out,
    8567             :     int16_t *midband,
    8568             :     float *psize,
    8569             :     float *psize_inv,
    8570             :     const int16_t stopBandFR );
    8571             : 
    8572             : void minimum_statistics(
    8573             :     const int16_t len,    /* i  : Vector length                                       */
    8574             :     const int16_t lenFFT, /* i  : Length of the FFT part of the vectors               */
    8575             :     float *psize,
    8576             :     float *msPeriodog, /* i  : Periodograms                                        */
    8577             :     float *msNoiseFloor,
    8578             :     float *msNoiseEst, /* o  : Noise estimates                                     */
    8579             :     float *msAlpha,
    8580             :     float *msPsd,
    8581             :     float *msPsdFirstMoment,
    8582             :     float *msPsdSecondMoment,
    8583             :     float *msMinBuf,
    8584             :     float *msBminWin,
    8585             :     float *msBminSubWin,
    8586             :     float *msCurrentMin,
    8587             :     float *msCurrentMinOut,
    8588             :     float *msCurrentMinSubWindow,
    8589             :     int16_t *msLocalMinFlag,
    8590             :     int16_t *msNewMinFlag,
    8591             :     float *msPeriodogBuf,
    8592             :     int16_t *msPeriodogBufPtr,
    8593             :     HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables   */
    8594             :     const int16_t enc_dec,       /* i  : encoder/decoder indicator                               */
    8595             :     const int16_t element_mode   /* i  : IVAS element mode                                       */
    8596             : );
    8597             : 
    8598             : void generate_comfort_noise_enc(
    8599             :     Encoder_State *st /* i/o: encoder state structure                 */
    8600             : );
    8601             : 
    8602             : void generate_comfort_noise_dec(
    8603             :     float **bufferReal,     /* o  : Real part of input bands                                */
    8604             :     float **bufferImag,     /* o  : Imaginary part of input bands                           */
    8605             :     Decoder_State *st,      /* i/o: decoder state structure                                 */
    8606             :     const int16_t nchan_out /* i  : number of output channels                               */
    8607             : );
    8608             : 
    8609             : void generate_comfort_noise_dec_hf(
    8610             :     float **bufferReal,          /* o  : Real part of input bands                                */
    8611             :     float **bufferImag,          /* o  : Imaginary part of input bands                           */
    8612             :     HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables   */
    8613             :     const int16_t cng_flag       /* i  : CNG Flag */
    8614             : );
    8615             : 
    8616             : void generate_masking_noise(
    8617             :     float *timeDomainBuffer,          /* i/o: time-domain signal                               */
    8618             :     HANDLE_FD_CNG_COM hFdCngCom,      /* i/o: FD_CNG structure containing all buffers and variables   */
    8619             :     const int16_t length,             /* i  : frame size                                       */
    8620             :     const int16_t core,               /* i  : core                                             */
    8621             :     const int16_t return_noise,       /* i  : noise is returned instead of added               */
    8622             :     const int16_t secondary,          /* i  : indicator for secondary channel                  */
    8623             :     const int16_t element_mode,       /* i  : element mode                                     */
    8624             :     STEREO_CNG_DEC_HANDLE hStereoCng, /* i  : stereo CNG handle                                */
    8625             :     const int16_t nchan_out           /* i  : number of output channels */
    8626             : );
    8627             : 
    8628             : void generate_masking_noise_update_seed(
    8629             :     HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables   */
    8630             : );
    8631             : 
    8632             : void generate_masking_noise_mdct(
    8633             :     float *mdctBuffer,          /* i/o: time-domain signal                                      */
    8634             :     HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables   */
    8635             : );
    8636             : 
    8637             : void SynthesisSTFT_dirac(
    8638             :     float *fftBuffer, /* i  : FFT bins */
    8639             :     float *timeDomainOutput,
    8640             :     float *olapBuffer,
    8641             :     const float *olapWin,
    8642             :     const int16_t samples_out,
    8643             :     HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */
    8644             : );
    8645             : 
    8646             : void generate_masking_noise_dirac(
    8647             :     HANDLE_FD_CNG_COM hFdCngCom,      /* i/o: FD_CNG structure containing all buffers and variables */
    8648             :     HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i  : filterbank state                                      */
    8649             :     float *tdBuffer,                  /* i/o: time-domain signal, if NULL no LB-CNA                 */
    8650             :     float *Cldfb_RealBuffer,          /* o  : CLDFD real buffer                                     */
    8651             :     float *Cldfb_ImagBuffer,          /* o  : CLDFD imaginary buffer                                */
    8652             :     const int16_t slot_index,         /* i  : CLDFB slot index                                      */
    8653             :     const int16_t cna_flag,           /* i  : CNA flag for LB and HB                                */
    8654             :     const int16_t fd_cng_flag         /* i  : FD-CNG flag for HB                                    */
    8655             : );
    8656             : 
    8657             : void generate_stereo_masking_noise(
    8658             :     float *syn,                          /* i/o: time-domain signal              */
    8659             :     Decoder_State *st,                   /* i/o: decoder state structure         */
    8660             :     STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i  : TD stereo structure             */
    8661             :     const int16_t flag_sec_CNA,          /* i  : CNA flag for secondary channel  */
    8662             :     const int16_t fadeOut,               /* i  : only fade out of previous state */
    8663             :     STEREO_CNG_DEC_HANDLE hStereoCng,    /* i  : stereo CNG handle               */
    8664             :     const int16_t nchan_out              /* i  : number of output channels       */
    8665             : );
    8666             : 
    8667             : void apply_scale(
    8668             :     float *scale,                  /* i  : scale factor                                            */
    8669             :     const int16_t bwidth,          /* i  : audio bandwidth                                         */
    8670             :     const int32_t brate,           /* i  : Bit rate                                                */
    8671             :     const SCALE_SETUP *scaleTable, /* i  : Scale table                                             */
    8672             :     const int16_t scaleTableSize   /* i  : Size of scale table                                     */
    8673             : );
    8674             : 
    8675             : void compress_range(
    8676             :     float *in,
    8677             :     float *out,
    8678             :     const int16_t len );
    8679             : 
    8680             : void expand_range(
    8681             :     float *in,
    8682             :     float *out,
    8683             :     const int16_t len );
    8684             : 
    8685             : void bandcombinepow(
    8686             :     const float *bandpow,   /* i  : Power for each band */
    8687             :     const int16_t nband,    /* i  : Number of bands */
    8688             :     int16_t *part,          /* i  : Partition upper boundaries (band indices starting from 0) */
    8689             :     const int16_t npart,    /* i  : Number of partitions */
    8690             :     const float *psize_inv, /* i  : Inverse partition sizes */
    8691             :     float *partpow          /* o  : Power for each partition */
    8692             : );
    8693             : 
    8694             : void scalebands(
    8695             :     const float *partpow,   /* i  : Power for each partition */
    8696             :     int16_t *part,          /* i  : Partition upper boundaries (band indices starting from 0) */
    8697             :     const int16_t npart,    /* i  : Number of partitions */
    8698             :     int16_t *midband,       /* i  : Central band of each partition */
    8699             :     const int16_t nFFTpart, /* i  : Number of FFT partitions */
    8700             :     const int16_t nband,    /* i  : Number of bands */
    8701             :     float *bandpow,         /* o  : Power for each band */
    8702             :     const int16_t flag_fft_en );
    8703             : 
    8704             : void AnalysisSTFT(
    8705             :     const float *timeDomainInput,
    8706             :     float *fftBuffer,    /* o  : FFT bins */
    8707             :     HANDLE_FD_CNG_COM st /* i/o: FD_CNG structure containing all buffers and variables */
    8708             : );
    8709             : 
    8710             : void SynthesisSTFT(
    8711             :     float *fftBuffer,
    8712             :     float *timeDomainOutput,
    8713             :     float *olapBuffer,
    8714             :     const float *olapWin,
    8715             :     const int16_t tcx_transition,
    8716             :     HANDLE_FD_CNG_COM hFdCngCom,
    8717             :     const int16_t element_mode, /* i  : element mode              */
    8718             :     const int16_t nchan_out     /* i  : number of output channels */
    8719             : );
    8720             : 
    8721             : float rand_gauss(
    8722             :     float *x,
    8723             :     int16_t *seed );
    8724             : 
    8725             : void lpc_from_spectrum(
    8726             :     HANDLE_FD_CNG_COM hFdCngCom,
    8727             :     const int16_t start,
    8728             :     const int16_t stop,
    8729             :     const float preemph_fac );
    8730             : 
    8731             : ivas_error createFdCngDec(
    8732             :     HANDLE_FD_CNG_DEC *hFdCngDec );
    8733             : 
    8734             : void deleteFdCngDec(
    8735             :     HANDLE_FD_CNG_DEC *hFdCngDec );
    8736             : 
    8737             : void initFdCngDec(
    8738             :     DEC_CORE_HANDLE st /* i/o: decoder state structure     */
    8739             : );
    8740             : 
    8741             : void configureFdCngDec(
    8742             :     HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: Contains the variables related to the FD-based CNG process  */
    8743             :     const int16_t bwidth,
    8744             :     const int32_t total_brate,
    8745             :     const int16_t L_frame,
    8746             :     const int16_t last_L_frame,
    8747             :     const int16_t element_mode );
    8748             : 
    8749             : void ApplyFdCng(
    8750             :     float *timeDomainInput,
    8751             :     float *powerSpectrum,
    8752             :     float **realBuffer, /* i/o: Real part of the buffer                 */
    8753             :     float **imagBuffer, /* i/o: Imaginary part of the buffer            */
    8754             :     Decoder_State *st,
    8755             :     const int16_t concealWholeFrame, /* i  : binary flag indicating frame loss       */
    8756             :     const int16_t is_music );
    8757             : 
    8758             : void generate_comfort_noise_dec(
    8759             :     float **bufferReal,     /* o  : Real part of input bands      */
    8760             :     float **bufferImag,     /* o  : Imaginary part of input bands */
    8761             :     Decoder_State *st,      /* i/o: decoder state structure       */
    8762             :     const int16_t nchan_out /* i  : number of output channels     */
    8763             : );
    8764             : 
    8765             : /*! r: CNG energy */
    8766             : float cng_energy(
    8767             :     const int16_t element_mode, /* i  : element mode                            */
    8768             :     const int16_t bwidth,       /* i  : audio bandwidh                          */
    8769             :     const int16_t CNG_mode,     /* i  : mode for DTX configuration              */
    8770             :     const float CNG_att,        /* i  : attenuation factor for CNG              */
    8771             :     const float *inputBuffer,   /* i  : input signal                            */
    8772             :     const int16_t len           /* i  : vector length                           */
    8773             : );
    8774             : 
    8775             : void FdCng_decodeSID(
    8776             :     Decoder_State *st /* i/o: decoder state structure                 */
    8777             : );
    8778             : 
    8779             : void FdCng_exc(
    8780             :     HANDLE_FD_CNG_COM hFdCngCom,
    8781             :     int16_t *CNG_mode,
    8782             :     const int16_t L_frame,
    8783             :     const float *lsp_old,
    8784             :     const int16_t first_CNG,
    8785             :     float *lsp_CNG,
    8786             :     float *Aq,      /* o  : LPC coeffs                              */
    8787             :     float *lsp_new, /* o  : lsp                                     */
    8788             :     float *lsf_new, /* o  : lsf                                     */
    8789             :     float *exc,     /* o  : LP excitation                           */
    8790             :     float *exc2,    /* o  : LP excitation                           */
    8791             :     float *bwe_exc  /* o  : LP excitation for BWE                   */
    8792             : );
    8793             : 
    8794             : void noisy_speech_detection(
    8795             :     HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: FD_CNG structure                        */
    8796             :     const int16_t vad,           /* i  : VAD flag                                */
    8797             :     const float syn[]            /* i  : input time-domain frame                 */
    8798             : );
    8799             : 
    8800             : ivas_error createFdCngEnc(
    8801             :     HANDLE_FD_CNG_ENC *hFdCngEnc /* i/o: FD_CNG structure                        */
    8802             : );
    8803             : 
    8804             : void deleteFdCngEnc(
    8805             :     HANDLE_FD_CNG_ENC *hFdCngEnc /* i/o: FD_CNG structure                        */
    8806             : );
    8807             : 
    8808             : void configureFdCngEnc(
    8809             :     HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: Contains the variables related to the FD-based CNG process */
    8810             :     const int16_t bwidth,
    8811             :     const int32_t total_brate );
    8812             : 
    8813             : void initFdCngEnc(
    8814             :     HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: Contains the variables related to the FD-based CNG process */
    8815             :     const int32_t input_Fs,      /* i  : input signal sampling frequency in Hz                      */
    8816             :     const float scale            /* i  : scaling factor                                             */
    8817             : );
    8818             : 
    8819             : void resetFdCngEnc(
    8820             :     Encoder_State *st /* i/o: encoder state structure                                    */
    8821             : );
    8822             : 
    8823             : void perform_noise_estimation_enc(
    8824             :     float *band_energies,        /* i  : energy in critical bands without minimum noise floor E_MIN */
    8825             :     float *enerBuffer,           /* i  : energy buffer                                              */
    8826             :     HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: CNG structure containing all buffers and variables         */
    8827             :     const int32_t input_Fs,      /* i  : input sampling rate                                        */
    8828             :     CPE_ENC_HANDLE hCPE );
    8829             : 
    8830             : void AdjustFirstSID(
    8831             :     Encoder_State *st /* i/o: encoder state structure                                    */
    8832             : );
    8833             : 
    8834             : void FdCng_encodeSID(
    8835             :     Encoder_State *st /* i/o: encoder state structure                                    */
    8836             : );
    8837             : 
    8838             : void GetParameters(
    8839             :     ParamsBitMap const *paramsBitMap,
    8840             :     const int16_t nParams,
    8841             :     void const *pParameter,
    8842             :     int16_t **pStream,
    8843             :     int16_t *pnSize,
    8844             :     int16_t *pnBits );
    8845             : 
    8846             : void SetParameters(
    8847             :     ParamsBitMap const *paramsBitMap,
    8848             :     const int16_t nParams,
    8849             :     void *pParameter,
    8850             :     const int16_t **pStream,
    8851             :     int16_t *pnSize );
    8852             : 
    8853             : void WriteToBitstream(
    8854             :     ParamsBitMap const *paramsBitMap,
    8855             :     const int16_t nParams,
    8856             :     const int16_t **pStream,
    8857             :     int16_t *pnSize,
    8858             :     BSTR_ENC_HANDLE hBstr,
    8859             :     int16_t *pnBits );
    8860             : 
    8861             : void ReadFromBitstream(
    8862             :     ParamsBitMap const *paramsBitMap,
    8863             :     const int16_t nArrayLength,
    8864             :     Decoder_State *st,
    8865             :     int16_t **pStream,
    8866             :     int16_t *pnSize );
    8867             : 
    8868             : void const *GetTnsFilterOrder( void const *p, const int16_t index, int16_t *pValue );
    8869             : void *SetTnsFilterOrder( void *p, const int16_t index, const int16_t value );
    8870             : void const *GetNumOfTnsFilters( void const *p, const int16_t index, int16_t *pValue );
    8871             : void *SetNumOfTnsFilters( void *p, const int16_t index, const int16_t value );
    8872             : void const *GetTnsEnabled( void const *p, const int16_t index, int16_t *pValue );
    8873             : void *SetTnsEnabled( void *p, const int16_t index, const int16_t value );
    8874             : void const *GetTnsEnabledSingleFilter( void const *p, const int16_t index, int16_t *pValue );
    8875             : void *SetTnsEnabledSingleFilter( void *p, const int16_t index, const int16_t value );
    8876             : void const *GetTnsFilterCoeff( void const *p, const int16_t index, int16_t *pValue );
    8877             : void *SetTnsFilterCoeff( void *p, const int16_t index, const int16_t value );
    8878             : 
    8879             : void const *GetTnsOnWhite( void const *p, const int16_t index, int16_t *pValue );
    8880             : void *SetTnsOnWhite( void *p, const int16_t index, const int16_t value );
    8881             : 
    8882             : int16_t GetSWBTCX10TnsFilterCoeffBits( const int16_t value, const int16_t index );
    8883             : int16_t EncodeSWBTCX10TnsFilterCoeff( const int16_t value, const int16_t index );
    8884             : int16_t DecodeSWBTCX10TnsFilterCoeff( Decoder_State *st, const int16_t index, int16_t *pValue );
    8885             : int16_t GetSWBTCX20TnsFilterCoeffBits( const int16_t value, const int16_t index );
    8886             : int16_t EncodeSWBTCX20TnsFilterCoeff( const int16_t value, const int16_t index );
    8887             : int16_t DecodeSWBTCX20TnsFilterCoeff( Decoder_State *st, const int16_t index, int16_t *pValue );
    8888             : 
    8889             : int16_t GetWBTCX20TnsFilterCoeffBits( const int16_t value, const int16_t index );
    8890             : int16_t EncodeWBTCX20TnsFilterCoeff( const int16_t, const int16_t index );
    8891             : int16_t DecodeWBTCX20TnsFilterCoeff( Decoder_State *st, const int16_t index, int16_t *pValue );
    8892             : 
    8893             : int16_t GetTnsFilterOrderBitsSWBTCX10( const int16_t value, const int16_t index );
    8894             : int16_t EncodeTnsFilterOrderSWBTCX10( const int16_t value, const int16_t index );
    8895             : int16_t DecodeTnsFilterOrderSWBTCX10( Decoder_State *st, const int16_t index, int16_t *pValue );
    8896             : int16_t GetTnsFilterOrderBitsSWBTCX20( const int16_t value, const int16_t index );
    8897             : int16_t EncodeTnsFilterOrderSWBTCX20( const int16_t value, const int16_t index );
    8898             : int16_t DecodeTnsFilterOrderSWBTCX20( Decoder_State *st, const int16_t index, int16_t *pValue );
    8899             : int16_t GetTnsFilterOrderBits( const int16_t value, const int16_t index );
    8900             : int16_t EncodeTnsFilterOrder( const int16_t value, const int16_t index );
    8901             : int16_t DecodeTnsFilterOrder( Decoder_State *st, const int16_t index, int16_t *pValue );
    8902             : 
    8903             : void ResetTnsData(
    8904             :     STnsData *pTnsData );
    8905             : 
    8906             : void ClearTnsFilterCoefficients(
    8907             :     STnsFilter *pTnsFilter );
    8908             : 
    8909             : void InitTnsConfiguration(
    8910             :     const int16_t bwidth,
    8911             :     const int16_t frameLength,
    8912             :     STnsConfig *pTnsConfig,
    8913             :     const int16_t igfStopFreq,
    8914             :     const int32_t total_brate,
    8915             :     const int16_t element_mode,
    8916             :     const int16_t MCT_flag );
    8917             : 
    8918             : int16_t DetectTnsFilt(
    8919             :     const STnsConfig *pTnsConfig, /* i  : TNS Configuration struct     */
    8920             :     const float pSpectrum[],      /* i  : MDCT spectrum                */
    8921             :     TRAN_DET_HANDLE hTranDet,     /* i  : transient detection handle   */
    8922             :     const int16_t isTCX10,        /* i  : TCX10 or TCX20?              */
    8923             :     const float ltp_gain,         /* i  : LTP gain                     */
    8924             :     STnsData *pTnsData,           /* o  : TNS data struct              */
    8925             :     float *predictionGain         /* o  : TNS prediction gain          */
    8926             : );
    8927             : 
    8928             : void ApplyTnsFilter(
    8929             :     STnsConfig const *pTnsConfig,
    8930             :     STnsData const *pTnsData,
    8931             :     float spectrum[],
    8932             :     const int16_t fIsAnalysis );
    8933             : 
    8934             : int16_t ITF_Detect(
    8935             :     const float pSpectrum[],
    8936             :     const int16_t startLine,
    8937             :     const int16_t stopLine,
    8938             :     const int16_t maxOrder,
    8939             :     float *A,
    8940             :     float *predictionGain,
    8941             :     int16_t *curr_order );
    8942             : 
    8943             : void ITF_Apply(
    8944             :     float spectrum[],
    8945             :     const int16_t startLine,
    8946             :     const int16_t stopLine,
    8947             :     const float *A,
    8948             :     const int16_t curr_order );
    8949             : 
    8950             : void EncodeTnsData(
    8951             :     STnsConfig const *pTnsConfig, /* i  : TNS Configuration struct          */
    8952             :     STnsData const *pTnsData,     /* i  : TNS data struct (quantized param) */
    8953             :     int16_t *stream,              /* o  : internal data stream              */
    8954             :     int16_t *pnSize,              /* o  : number of written parameters      */
    8955             :     int16_t *pnBits               /* o  : number of written bits            */
    8956             : );
    8957             : 
    8958             : int16_t DecodeTnsData(
    8959             :     STnsConfig const *pTnsConfig,
    8960             :     const int16_t *stream,
    8961             :     int16_t *pnSize,
    8962             :     STnsData *pTnsData );
    8963             : 
    8964             : void WriteTnsData(
    8965             :     const STnsConfig *pTnsConfig, /* i  : TNS Configuration struct          */
    8966             :     const int16_t *stream,        /* i  : internal data stream              */
    8967             :     int16_t *pnSize,              /* o  : number of written parameters      */
    8968             :     BSTR_ENC_HANDLE hBstr,        /* o  : bitstream                         */
    8969             :     int16_t *pnBits               /* o  : number of written bits            */
    8970             : );
    8971             : 
    8972             : void ReadTnsData(
    8973             :     STnsConfig const *pTnsConfig,
    8974             :     Decoder_State *st,
    8975             :     int16_t *pnBits,
    8976             :     int16_t *stream,
    8977             :     int16_t *pnSize );
    8978             : 
    8979             : void cldfbAnalysis(
    8980             :     const float *timeIn,             /* i  : time buffer                 */
    8981             :     float **realBuffer,              /* o  : real value buffer           */
    8982             :     float **imagBuffer,              /* o  : imag value buffer           */
    8983             :     const int16_t samplesToProcess,  /* i  : number of input samples     */
    8984             :     HANDLE_CLDFB_FILTER_BANK h_cldfb /* i  : filterbank state            */
    8985             : );
    8986             : 
    8987             : void cldfbAnalysis_ts(
    8988             :     const float *timeIn,                     /* i  : time buffer                 */
    8989             :     float realBuffer[CLDFB_NO_CHANNELS_MAX], /* o  : real value buffer           */
    8990             :     float imagBuffer[CLDFB_NO_CHANNELS_MAX], /* o  : imag value buffer           */
    8991             :     const int16_t samplesToProcess,          /* i  : samples to process          */
    8992             :     HANDLE_CLDFB_FILTER_BANK h_cldfb         /* i  : filterbank state            */
    8993             : );
    8994             : 
    8995             : void cldfbSynthesis(
    8996             :     float **realBuffer,              /* i  : real values                 */
    8997             :     float **imagBuffer,              /* i  : imag values                 */
    8998             :     float *timeOut,                  /* o  : synthesized output          */
    8999             :     const int16_t samplesToProcess,  /* i  : number of samples           */
    9000             :     HANDLE_CLDFB_FILTER_BANK h_cldfb /* i  : filter bank state           */
    9001             : );
    9002             : 
    9003             : void configureCldfb(
    9004             :     HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: filter bank handle        */
    9005             :     const int32_t sampling_rate       /* i  : sampling rate             */
    9006             : );
    9007             : 
    9008             : void analysisCldfbEncoder(
    9009             :     Encoder_State *st, /* i/o: encoder state structure     */
    9010             :     const float *timeIn,
    9011             :     const int16_t samplesToProcess,
    9012             :     float realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
    9013             :     float imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
    9014             :     float *ppBuf_Ener );
    9015             : 
    9016             : ivas_error openCldfb(
    9017             :     HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle               */
    9018             :     CLDFB_TYPE type,                   /* i  : analysis or synthesis            */
    9019             :     const int32_t sampling_rate,       /* i  : sampling rate                    */
    9020             :     CLDFB_PROTOTYPE prototype          /* i  : CLDFB version (1.25ms/5ms delay) */
    9021             : );
    9022             : 
    9023             : void resampleCldfb(
    9024             :     HANDLE_CLDFB_FILTER_BANK hs, /* i/o: filter bank handle          */
    9025             :     const int32_t newSamplerate  /* i  : new samplerate to operate   */
    9026             : );
    9027             : 
    9028             : ivas_error cldfb_save_memory(
    9029             :     HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle          */
    9030             : );
    9031             : 
    9032             : void cldfb_restore_memory(
    9033             :     HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle          */
    9034             : );
    9035             : 
    9036             : void cldfb_reset_memory(
    9037             :     HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle          */
    9038             : );
    9039             : 
    9040             : void deleteCldfb(
    9041             :     HANDLE_CLDFB_FILTER_BANK *h_cldfb /* i/o: filter bank handle          */
    9042             : );
    9043             : 
    9044             : void fft_cldfb(
    9045             :     float *data,       /* i/o: input/output vector         */
    9046             :     const int16_t size /* i  : size of fft operation       */
    9047             : );
    9048             : 
    9049             : void BITS_ALLOC_init_config_acelp(
    9050             :     const int32_t bit_rate,
    9051             :     const int16_t narrowBand,
    9052             :     const int16_t nb_subfr,
    9053             :     ACELP_config *acelp_cfg /* o  : configuration structure of ACELP    */
    9054             : );
    9055             : 
    9056             : int16_t BITS_ALLOC_config_acelp(
    9057             :     const int16_t bits_frame, /* i  : remaining bit budget for the frame  */
    9058             :     const int16_t coder_type, /* i  : acelp coder type                    */
    9059             :     ACELP_config *acelp_cfg,  /* i/o: configuration structure of ACELP    */
    9060             :     const int16_t narrowband, /* i  : narrowband flag                     */
    9061             :     const int16_t nb_subfr    /* i  : number of subframes                 */
    9062             : );
    9063             : 
    9064             : ivas_error config_acelp1(
    9065             :     const int16_t enc_dec,                  /* i  : encoder/decoder flag                */
    9066             :     const int32_t total_brate,              /* i  : total bitrate                       */
    9067             :     const int32_t core_brate_inp,           /* i  : core bitrate                        */
    9068             :     const int16_t core,                     /* i  : core                                */
    9069             :     const int16_t extl,                     /* i  : extension layer                     */
    9070             :     const int32_t extl_brate,               /* i  : extension layer bitrate             */
    9071             :     const int16_t L_frame,                  /* i  : frame length at internal Fs         */
    9072             :     const int16_t GSC_noisy_speech,         /* i  : GSC on SWB noisy speech flag        */
    9073             :     ACELP_config *acelp_cfg,                /* i  : ACELP bit-allocation                */
    9074             :     const int16_t signaling_bits,           /* i  : number of signaling bits            */
    9075             :     const int16_t coder_type,               /* i  : coder type                          */
    9076             :     const int16_t inactive_coder_type_flag, /* i  : AVQ (0) or GSC (1) IC flag          */
    9077             :     const int16_t tc_subfr,                 /* i  : TC subfr ID                         */
    9078             :     const int16_t tc_call,                  /* i  : TC call number (0,1,2)              */
    9079             :     int16_t *nBits_es_Pred,                 /* o  : number of bits for Es_pred Q        */
    9080             :     int16_t *unbits,                        /* o  : number of unused bits               */
    9081             :     const int16_t element_mode,             /* i  : element mode                        */
    9082             :     int16_t *uc_two_stage_flag,             /* o  : flag undicating two-stage UC        */
    9083             :     const int16_t tdm_lp_reuse_flag,        /* i  : LPC reuse flag (can be 1 only with secondary channel*/
    9084             :     const int16_t tdm_low_rate_mode,        /* i  : secondary channel low rate mode flag*/
    9085             :     const int16_t idchan,                   /* i  : channel id                          */
    9086             :     const int16_t tdm_Pitch_reuse_flag,     /* i  : primary channel pitch reuse flag    */
    9087             :     const int16_t tdm_LRTD_flag,            /* i  : LRTD stereo mode flag               */
    9088             :     const int16_t GSC_IVAS_mode             /* i  : GSC IVAS mode                       */
    9089             : );
    9090             : 
    9091             : /*! r: ACELP16k flag */
    9092             : int16_t set_ACELP_flag(
    9093             :     const int16_t element_mode,  /* i  : element mode                        */
    9094             :     const int32_t element_brate, /* i  : element bitrate                     */
    9095             :     const int32_t total_brate,   /* i  : total bitrate per channel           */
    9096             :     const int16_t idchan,        /* i  : Channel id                          */
    9097             :     const int16_t tdm_LRTD_flag, /* i  : LRTD stereo mode flag               */
    9098             :     const int16_t bwidth,        /* i  : audio bandwidth                     */
    9099             :     const int16_t cng_type       /* i  : CNG type                            */
    9100             : );
    9101             : 
    9102             : void FEC_clas_estim(
    9103             :     const float *syn,
    9104             :     const float *pitch,                /* i  : pitch values for each subframe                 */
    9105             :     const int16_t L_frame,             /* i  : length of the frame                            */
    9106             :     const int16_t coder_type,          /* i  : coder type                                     */
    9107             :     const int16_t codec_mode,          /* i  : codec mode                                     */
    9108             :     float *mem_syn_clas_estim,         /* i/o: memory of the synthesis signal for frame class estimation */
    9109             :     int16_t *clas,                     /* i/o: frame classification                           */
    9110             :     float *lp_speech,                  /* i/o: long term active speech energy average         */
    9111             :     const int16_t Opt_AMR_WB,          /* i  : flag indicating AMR-WB IO mode                 */
    9112             :     int16_t *decision_hyst,            /* i/o: hysteresis of the music/speech decision        */
    9113             :     int16_t *locattack,                /* i/o: detection of attack (mainly to localized speech burst) */
    9114             :     int16_t *UV_cnt,                   /* i/o: number of consecutives frames classified as UV */
    9115             :     float *LT_UV_cnt,                  /* i/o: long term consecutives frames classified as UV */
    9116             :     float *Last_ener,                  /* i/o: last_energy frame                              */
    9117             :     int16_t *amr_io_class,             /* i/o: classification for AMR-WB IO mode              */
    9118             :     float *lt_diff_etot,               /* i/o: long-term total energy variation               */
    9119             :     float *class_para,                 /* o  : classification para. fmerit1                   */
    9120             :     const float LTP_Gain,              /* i  :                                                */
    9121             :     const int16_t narrowBand,          /* i  :                                                */
    9122             :     const SIGNAL_CLASSIFIER_MODE mode, /* i  :                                                */
    9123             :     const int16_t bfi,                 /* i  :                                                */
    9124             :     const float preemph_fac,           /* i  :                                                */
    9125             :     const int16_t tcxonly,             /* i  :                                                */
    9126             :     const int32_t last_core_brate,     /* i  : last core bitrate                              */
    9127             :     const int16_t FEC_mode             /* i  : ACELP FEC mode                                 */
    9128             : );
    9129             : 
    9130             : void InitTransientDetection(
    9131             :     const int16_t nFrameLength,
    9132             :     const int16_t nTCXDelay,
    9133             :     TRAN_DET_HANDLE hTranDet,
    9134             :     const int16_t ext_mem_flag );
    9135             : 
    9136             : void RunTransientDetection(
    9137             :     const float *input,      /* i  : input signal                            */
    9138             :     const int16_t length,    /* i  : frame length                            */
    9139             :     TRAN_DET_HANDLE hTranDet /* i/o: transient detection handle              */
    9140             : );
    9141             : 
    9142             : float GetTCXAvgTemporalFlatnessMeasure(
    9143             :     TRAN_DET_HANDLE hTranDet,
    9144             :     const int16_t nCurrentSubblocks,
    9145             :     const int16_t nPrevSubblocks );
    9146             : 
    9147             : float GetTCXMaxenergyChange(
    9148             :     TRAN_DET_HANDLE hTranDet,
    9149             :     const int16_t isTCX10,
    9150             :     const int16_t nCurrentSubblocks,
    9151             :     const int16_t nPrevSubblocks );
    9152             : 
    9153             : void SetTCXModeInfo(
    9154             :     Encoder_State *st,        /* i/o: encoder state structure                 */
    9155             :     TRAN_DET_HANDLE hTranDet, /* i/o: transient detection handle              */
    9156             :     int16_t *tcxModeOverlap   /* o  : window overlap of current frame         */
    9157             : );
    9158             : 
    9159             : void TCX_MDCT(
    9160             :     const float *x,
    9161             :     float *y,
    9162             :     const int16_t l,
    9163             :     const int16_t m,
    9164             :     const int16_t r,
    9165             :     const int16_t element_mode );
    9166             : 
    9167             : void TCX_MDST(
    9168             :     const float *x,
    9169             :     float *y,
    9170             :     const int16_t l,
    9171             :     const int16_t m,
    9172             :     const int16_t r,
    9173             :     const int16_t element_mode );
    9174             : 
    9175             : void TCX_MDCT_Inverse(
    9176             :     const float *x,
    9177             :     float *y,
    9178             :     const int16_t l,
    9179             :     const int16_t m,
    9180             :     const int16_t r,
    9181             :     const int16_t element_mode );
    9182             : 
    9183             : void TCX_MDST_Inverse(
    9184             :     const float *x,
    9185             :     float *y,
    9186             :     const int16_t l,
    9187             :     const int16_t m,
    9188             :     const int16_t r,
    9189             :     const int16_t element_mode );
    9190             : 
    9191             : void TCX_MDXT_Inverse(
    9192             :     const float *x,
    9193             :     float *y,
    9194             :     const int16_t l,
    9195             :     const int16_t m,
    9196             :     const int16_t r,
    9197             :     const uint16_t kernel_type );
    9198             : 
    9199             : void post_decoder(
    9200             :     Decoder_State *st,
    9201             :     float synth_buf[],
    9202             :     const float pit_gain[],
    9203             :     const int16_t pitch[],
    9204             :     float signal_out[],
    9205             :     float bpf_noise_buf[] );
    9206             : 
    9207             : float bass_pf_enc(
    9208             :     const float *orig,          /* i  : 12.8kHz original signal                     */
    9209             :     const float *syn,           /* i  : 12.8kHz synthesis to postfilter             */
    9210             :     const float pitch_buf[],    /* i  : Pitch gain for all subframes (gainT_sf[16]) */
    9211             :     const float gainT_sf[],     /* i  : Pitch gain for all subframes (gainT_sf[16]) */
    9212             :     const int16_t l_frame,      /* i  : frame length (should be multiple of l_subfr)*/
    9213             :     const int16_t l_subfr_in,   /* i  : sub-frame length (60/64)                    */
    9214             :     float mem_bpf[],            /* i/o: memory state [2*L_FILT]                     */
    9215             :     float mem_error_bpf[],      /* i/o: memory state [2*L_FILT]                     */
    9216             :     int16_t *gain_factor_param, /* o  : quantized gain factor                       */
    9217             :     const int16_t mode,         /* i  : coding mode of adapt bpf                    */
    9218             :     float *mem_deemph_err,      /* i/o: Error deemphasis memory                     */
    9219             :     float *lp_ener              /* i/o: long_term error signal energy               */
    9220             : );
    9221             : 
    9222             : void cldfb_synth_set_bandsToZero(
    9223             :     Decoder_State *st, /* i/o: decoder state structure             */
    9224             :     float **rAnalysis,
    9225             :     float **iAnalysis,
    9226             :     const int16_t nTimeSlots );
    9227             : 
    9228             : void longadd(
    9229             :     uint16_t a[],       /* i/o: vector of the length lena */
    9230             :     const uint16_t b[], /* i/o: vector of the length lenb */
    9231             :     const int16_t lena, /* i/o: length of vector a[]      */
    9232             :     const int16_t lenb  /* i/o: length of vector b[]      */
    9233             : );
    9234             : 
    9235             : void longshiftright(
    9236             :     uint16_t a[],      /* i  : vector of the length lena                */
    9237             :     const int16_t b,   /* i  : number of bit positions to shift right   */
    9238             :     uint16_t d[],      /* o  : vector of the length lend                */
    9239             :     int16_t lena,      /* i  : length of vector a[]                     */
    9240             :     const int16_t lend /* i  : length of vector d[]                     */
    9241             : );
    9242             : 
    9243             : void longshiftleft(
    9244             :     const uint16_t a[], /* i  : vector of the length len              */
    9245             :     const int16_t b,    /* i  : number of bit positions to shift left */
    9246             :     uint16_t d[],       /* o  : vector of the length len              */
    9247             :     const int16_t len   /* i  : length of vector a[] and d[]          */
    9248             : );
    9249             : 
    9250             : void open_decoder_LPD(
    9251             :     Decoder_State *st,               /* i/o: decoder state structure                */
    9252             :     const int32_t total_brate,       /* i  : total bitrate                          */
    9253             :     const int32_t last_total_brate,  /* i  : last total bitrate                     */
    9254             :     const int16_t bwidth,            /* i  : audio bandwidth                        */
    9255             :     const int16_t MCT_flag,          /* i  : hMCT handle allocated (1) or not (0)   */
    9256             :     const int16_t last_element_mode, /* i  : last element mode                      */
    9257             :     const int16_t is_init            /* i  : indicate call during initialization    */
    9258             : );
    9259             : 
    9260             : void acelp_plc_mdct_transition(
    9261             :     Decoder_State *st /* i/o: Decoder state */
    9262             : );
    9263             : 
    9264             : void tcxltp_dec_init(
    9265             :     TCX_LTP_DEC_HANDLE hTcxLtpDec,
    9266             :     const int16_t ini_frame,
    9267             :     const int16_t last_codec_mode,
    9268             :     const int16_t element_mode,
    9269             :     const int16_t pit_max,
    9270             :     const int32_t sr_core );
    9271             : 
    9272             : void reset_tcx_overl_buf(
    9273             :     TCX_DEC_HANDLE hTcxDec /* i/o: TCX decoder handle          */
    9274             : );
    9275             : 
    9276             : void update_decoder_LPD_cng(
    9277             :     Decoder_State *st, /* i/o: decoder state structure     */
    9278             :     float *timeDomainBuffer,
    9279             :     float *A,
    9280             :     float *bpf_noise_buf );
    9281             : 
    9282             : void reconfig_decoder_LPD(
    9283             :     Decoder_State *st,         /* i/o: decoder state structure  */
    9284             :     const int16_t bits_frame,  /* i  : bit budget               */
    9285             :     const int16_t bwidth,      /* i  : audio bandwidth          */
    9286             :     const int32_t total_brate, /* i  : total bitrate            */
    9287             :     const int16_t L_frame_old  /* i  : frame length             */
    9288             : );
    9289             : 
    9290             : void mode_switch_decoder_LPD(
    9291             :     Decoder_State *st,              /* i/o: decoder state structure             */
    9292             :     const int16_t bwidth,           /* i  : audio bandwidth                     */
    9293             :     const int32_t total_brate,      /* i  : total bitrate                       */
    9294             :     const int32_t last_total_brate, /* i  : last frame total bitrate            */
    9295             :     const int16_t frame_size_index, /* i  : index determining the frame size    */
    9296             :     const int16_t MCT_flag,         /* i  : hMCT handle allocated (1) or not (0)*/
    9297             :     const int16_t last_element_mode /* i  : last element mode                   */
    9298             : );
    9299             : 
    9300             : void dec_acelp_tcx_frame(
    9301             :     Decoder_State *st,               /* i/o: decoder state structure             */
    9302             :     int16_t *concealWholeFrame,      /* i/o: concealment flag                    */
    9303             :     float *output,                   /* o  : synthesis                           */
    9304             :     float *bpf_noise_buf,            /* i/o: BPF noise buffer                    */
    9305             :     float *pcmbufFB,                 /* o  : synthesis @output_FS                */
    9306             :     float bwe_exc_extended[],        /* i/o: bandwidth extended excitation       */
    9307             :     float *voice_factors,            /* o  : voicing factors                     */
    9308             :     float pitch_buf[],               /* o  : floating pitch for each subframe    */
    9309             :     STEREO_CNG_DEC_HANDLE hStereoCng /* i  : stereo CNG handle                   */
    9310             : );
    9311             : 
    9312             : void decoder_LPD(
    9313             :     Decoder_State *st,     /* i/o: decoder memory state pointer        */
    9314             :     float signal_out[],    /* o  : signal with LPD delay (7 subfrs)    */
    9315             :     float signal_outFB[],  /* o  : synthesis @output_FS                */
    9316             :     int16_t *total_nbbits, /* i/o: number of bits / decoded bits       */
    9317             :     float *bpf_noise_buf,  /* i/o: BPF noise buffer                    */
    9318             :     int16_t bfi,           /* i  : BFI flag                            */
    9319             :     int16_t *bitsRead,     /* o  : number of read bits                 */
    9320             :     int16_t param[],       /* o  : buffer of parameters                */
    9321             :     float *pitch_buf,      /* i/o: floating pitch values for each subfr*/
    9322             :     float *voice_factors,  /* o  : voicing factors                     */
    9323             :     float *ptr_bwe_exc     /* o  : excitation for SWB TBE              */
    9324             : );
    9325             : 
    9326             : int16_t tcxGetNoiseFillingTilt(
    9327             :     const float A[],
    9328             :     const int16_t L_frame,
    9329             :     const int16_t mode,
    9330             :     float *noiseTiltFactor );
    9331             : 
    9332             : void tcxFormantEnhancement(
    9333             :     float xn_buf[],
    9334             :     const float *gainlpc,
    9335             :     float spectrum[],
    9336             :     const int16_t L_frame );
    9337             : 
    9338             : void tcxInvertWindowGrouping(
    9339             :     TCX_CONFIG_HANDLE hTcxCfg,
    9340             :     float xn_buf[],
    9341             :     float spectrum[],
    9342             :     const int16_t L_frame,
    9343             :     const int16_t fUseTns,
    9344             :     const int16_t last_core,
    9345             :     const int16_t index,
    9346             :     const int16_t frame_cnt,
    9347             :     const int16_t bfi );
    9348             : 
    9349             : void tcx5SpectrumInterleaving(
    9350             :     const int16_t tcx5Size,
    9351             :     float *spectrum );
    9352             : 
    9353             : void tcx5SpectrumDeinterleaving(
    9354             :     const int16_t tcx5Size,
    9355             :     float *spectrum );
    9356             : 
    9357             : void tcx5TnsGrouping(
    9358             :     const int16_t L_frame,
    9359             :     const int16_t L_spec,
    9360             :     float *spectrum );
    9361             : 
    9362             : void tcx5TnsUngrouping(
    9363             :     const int16_t L_frame,
    9364             :     const int16_t L_spec,
    9365             :     float *spectrum,
    9366             :     const int16_t enc_dec );
    9367             : 
    9368             : void lerp(
    9369             :     const float *f,
    9370             :     float *f_out,
    9371             :     const int16_t bufferNewSize,
    9372             :     const int16_t bufferOldSize );
    9373             : 
    9374             : void encoderSideLossSimulation(
    9375             :     Encoder_State *st,
    9376             :     PLC_ENC_EVS_HANDLE hPlc_Ext,
    9377             :     float *isf_q,
    9378             :     const float stab_fac,
    9379             :     const int16_t calcOnlyISF,
    9380             :     const int16_t L_frame );
    9381             : 
    9382             : void enc_prm_side_Info(
    9383             :     PLC_ENC_EVS_HANDLE hPlc_Ext,
    9384             :     Encoder_State *st );
    9385             : 
    9386             : void GplcTcxEncSetup(
    9387             :     const int16_t tcxltp_pitch_int,
    9388             :     PLC_ENC_EVS_HANDLE hPlc_Ext );
    9389             : 
    9390             : int16_t encSideSpecPowDiffuseDetector(
    9391             :     float *isf_ref,
    9392             :     float *isf_con,
    9393             :     const int32_t sr_core,
    9394             :     float *prev_isf4_mean,
    9395             :     const int16_t sw,
    9396             :     const int16_t coder_type );
    9397             : 
    9398             : void updateSpecPowDiffuseIdx(
    9399             :     const float gain_pitch_buf[], /* i  : gain pitch values   */
    9400             :     const float gain_code_buf[],  /* i  : gain pitch values   */
    9401             :     int16_t glr_idx[2],           /* o  : */
    9402             :     float mean_gc[2]              /* o  : */
    9403             : );
    9404             : 
    9405             : void getLookAheadResSig(
    9406             :     float *speechLookAhead,
    9407             :     const float *A,
    9408             :     float *res,
    9409             :     const int16_t L_frame,
    9410             :     const int16_t L_subfr,
    9411             :     const int16_t m,
    9412             :     const int16_t numSubFrame );
    9413             : 
    9414             : void updatelsfForConcealment(
    9415             :     PLC_ENC_EVS_HANDLE decState,
    9416             :     float *lsf );
    9417             : 
    9418             : void getConcealedLP(
    9419             :     PLC_ENC_EVS_HANDLE memDecState,
    9420             :     float *AqCon,
    9421             :     const float xsfBase[],
    9422             :     const int32_t sr_core,
    9423             :     const int16_t last_good,
    9424             :     const int16_t L_frame );
    9425             : 
    9426             : void RecLpcSpecPowDiffuseLc(
    9427             :     float *ispq,
    9428             :     float *isp_old,
    9429             :     float *isfq,
    9430             :     Decoder_State *st,
    9431             :     const int16_t reset_q );
    9432             : 
    9433             : void modify_lsf(
    9434             :     float *lsf,
    9435             :     const int16_t n,
    9436             :     const int32_t sr_core,
    9437             :     const int16_t reset_q );
    9438             : 
    9439             : void init_PLC_enc(
    9440             :     PLC_ENC_EVS_HANDLE hPlcExt,
    9441             :     const int32_t sr_core );
    9442             : 
    9443             : void gPLC_encInfo(
    9444             :     PLC_ENC_EVS_HANDLE hPlcExt,
    9445             :     const int32_t total_brate,
    9446             :     const int16_t bwidth,
    9447             :     const int16_t last_clas,
    9448             :     const int16_t coder_type );
    9449             : 
    9450             : void resetTecDec(
    9451             :     TEC_DEC_HANDLE hTecDec );
    9452             : 
    9453             : void calcGainTemp_TBE(
    9454             :     float **pCldfbRealSrc,
    9455             :     float **pCldfbImagSrc,
    9456             :     float *loBuffer,
    9457             :     const int16_t startPos,   /*!<  Start position of the current envelope. */
    9458             :     const int16_t stopPos,    /*!<  Stop position of the current envelope. */
    9459             :     const int16_t lowSubband, /* lowSubband */
    9460             :     float *pGainTemp,
    9461             :     const int16_t code );
    9462             : 
    9463             : void procTecTfa_TBE(
    9464             :     float *hb_synth,
    9465             :     float *gain,
    9466             :     const int16_t flat_flag,
    9467             :     const int16_t last_core,
    9468             :     const int16_t L_subfr,
    9469             :     const int16_t code );
    9470             : 
    9471             : void resetTecEnc(
    9472             :     TEC_ENC_HANDLE hTecEnc,
    9473             :     const int16_t flag );
    9474             : 
    9475             : void calcHiEnvLoBuff(
    9476             :     const int16_t noCols,
    9477             :     const int16_t *pFreqBandTable, /* i  : freqbandTable            */
    9478             :     const int16_t nSfb,            /* i  : Number of scalefactors   */
    9479             :     float **pYBuf,
    9480             :     float *loBuf,
    9481             :     float *hiTempEnv );
    9482             : 
    9483             : void calcLoEnvCheckCorrHiLo(
    9484             :     const int16_t noCols,
    9485             :     const int16_t *pFreqBandTable, /* i  : freqbandTable           */
    9486             :     float *loBuf,
    9487             :     float *loTempEnv,
    9488             :     float *loTempEnv_ns,
    9489             :     float *hiTempEnv,
    9490             :     int16_t *corr_flag /* o  : 0 for original, 1 for TEC */
    9491             : );
    9492             : 
    9493             : void tfaCalcEnv(
    9494             :     const float *shb_speech,
    9495             :     float *enr );
    9496             : 
    9497             : int16_t tfaEnc_TBE(
    9498             :     const float *enr,
    9499             :     const int16_t last_core,
    9500             :     const float *voicing,
    9501             :     const float *pitch_buf );
    9502             : 
    9503             : void tecEnc_TBE(
    9504             :     int16_t *corrFlag,
    9505             :     const float *voicing,
    9506             :     const int16_t coder_type );
    9507             : 
    9508             : void set_TEC_TFA_code(
    9509             :     const int16_t corrFlag,
    9510             :     int16_t *tec_flag,
    9511             :     int16_t *tfa_flag );
    9512             : 
    9513             : float Damping_fact(
    9514             :     const int16_t coder_type, /* i  : ACELP core coder type                            */
    9515             :     const int16_t nbLostCmpt, /* i  : compt for number of consecutive lost frame       */
    9516             :     int16_t last_good,        /* i  : class of last good received frame                */
    9517             :     float stab_fac,           /* i  : LSF stability factor                             */
    9518             :     float *lp_gainp,          /* i/o: low passed pitch gain used for concealment       */
    9519             :     const int16_t core        /* i  : current core: ACELP = 0, TCX20 = 1, TCX10 = 2    */
    9520             : );
    9521             : 
    9522             : void fer_energy(
    9523             :     const int16_t L_frame,  /* i  : frame length                           */
    9524             :     const int16_t clas,     /* i  : frame classification                   */
    9525             :     const float synth[],    /* i  : synthesized speech at Fs = 12k8 Hz     */
    9526             :     const float pitch,      /* i  : pitch period                           */
    9527             :     float *enr,             /* o  : pitch-synchronous or half_frame energy */
    9528             :     const int16_t useOffset /* i  : speech pointer offset (0 or L_FRAME)   */
    9529             : );
    9530             : 
    9531             : float getLevelSynDeemph(
    9532             :     const float h1Init[],    /* i  : input value or vector to be processed */
    9533             :     const float A[],         /* i  : LPC coefficients                      */
    9534             :     const int16_t lenLpcExc, /* i  : length of the LPC excitation buffer   */
    9535             :     const float preemph_fac, /* i  : preemphasis factor                    */
    9536             :     const int16_t numLoops   /* i  : number of loops                       */
    9537             : );
    9538             : 
    9539             : void genPlcFiltBWAdap(
    9540             :     const int32_t sr_core, /* i  : core sampling rate                                         */
    9541             :     float *lpFiltAdapt,    /* o  : filter coefficients for filtering codebooks in case of flc */
    9542             :     const int16_t type,    /* i  : type of filter, either 0 : lowpass or 1 : highpass         */
    9543             :     const float alpha      /* i  : fade out factor [0 1) used decrease filter tilt            */
    9544             : );
    9545             : 
    9546             : void highPassFiltering(
    9547             :     const int16_t last_good, /* i  : last classification type                           */
    9548             :     const int16_t L_buffer,  /* i  : buffer length                                      */
    9549             :     float exc2[],            /* i/o: unvoiced excitation before the high pass filtering */
    9550             :     const float hp_filt[],   /* i  : high pass filter coefficients                      */
    9551             :     const int16_t l_fir_fer  /* i  : high pass filter length                            */
    9552             : );
    9553             : 
    9554             : int16_t GetPLCModeDecision(
    9555             :     Decoder_State *st /* i/o: decoder memory state pointer                        */
    9556             : );
    9557             : 
    9558             : void addBassPostFilter(
    9559             :     const float *harm_timeIn,
    9560             :     const int16_t samplesToProcess,
    9561             :     float **rAnalysis,
    9562             :     float **iAnalysis,
    9563             :     HANDLE_CLDFB_FILTER_BANK cldfb );
    9564             : 
    9565             : ivas_error TonalMDCTConceal_Init(
    9566             :     TonalMDCTConcealPtr hTonalMDCTConc,
    9567             :     const uint16_t samplesPerBlock,
    9568             :     const uint16_t nSamplesCore,
    9569             :     const uint16_t nScaleFactors,
    9570             :     TCX_CONFIG_HANDLE hTcxCfg );
    9571             : 
    9572             : void TonalMDCTConceal_SaveFreqSignal(
    9573             :     TonalMDCTConcealPtr hTonalMDCTConc,
    9574             :     const float *mdctSpectrum,
    9575             :     const uint16_t numSamples,
    9576             :     const uint16_t nNewSamplesCore,
    9577             :     const float *scaleFactors,
    9578             :     const int16_t infoIGFStartLine );
    9579             : 
    9580             : void TonalMDCTConceal_UpdateState(
    9581             :     TonalMDCTConcealPtr hTonalMDCTConc,
    9582             :     const int16_t numSamples,
    9583             :     const float pitchLag,
    9584             :     const int16_t badBlock,
    9585             :     const int16_t tonalConcealmentActive );
    9586             : 
    9587             : void TonalMDCTConceal_SaveTimeSignal(
    9588             :     TonalMDCTConcealPtr hTonalMDCTConc,
    9589             :     float *timeSignal,
    9590             :     const int16_t numSamples );
    9591             : 
    9592             : void TonalMDCTConceal_Detect(
    9593             :     const TonalMDCTConcealPtr hTonalMDCTConc,          /*IN */
    9594             :     const float pitchLag,                              /*IN */
    9595             :     int16_t *umIndices,                                /*OUT*/
    9596             :     const PsychoacousticParameters *psychParamsCurrent /*IN*/
    9597             : );
    9598             : 
    9599             : void TonalMDCTConceal_Apply(
    9600             :     TonalMDCTConcealPtr hTonalMDCTConc,                /*IN */
    9601             :     float *mdctSpectrum,                               /*OUT*/
    9602             :     const PsychoacousticParameters *psychParamsCurrent /*IN*/
    9603             : );
    9604             : 
    9605             : void TonalMDCTConceal_InsertNoise(
    9606             :     const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */
    9607             :     float *mdctSpectrum,                      /*OUT*/
    9608             :     const int16_t tonalConcealmentActive,
    9609             :     int16_t *pSeed, /*IN/OUT*/
    9610             :     const float tiltCompFactor,
    9611             :     const float crossfadeGain,
    9612             :     const float concealment_noise[L_FRAME48k],
    9613             :     const float cngLevelBackgroundTrace_bfi,
    9614             :     const int16_t crossOverFreq );
    9615             : 
    9616             : void DetectTonalComponents(
    9617             :     uint16_t indexOfTonalPeak[],
    9618             :     uint16_t lowerIndex[],
    9619             :     uint16_t upperIndex[],
    9620             :     uint16_t *pNumIndexes,
    9621             :     const float lastPitchLag,
    9622             :     const float currentPitchLag,
    9623             :     const float lastMDCTSpectrum[],
    9624             :     const float scaleFactors[],
    9625             :     const float secondLastPowerSpectrum[],
    9626             :     const uint16_t nSamples,
    9627             :     const uint16_t nSamplesCore,
    9628             :     float floorPowerSpectrum,
    9629             :     const PsychoacousticParameters *psychParamsCurrent );
    9630             : 
    9631             : void RefineTonalComponents(
    9632             :     uint16_t indexOfTonalPeak[],
    9633             :     uint16_t lowerIndex[],
    9634             :     uint16_t upperIndex[],
    9635             :     float phaseDiff[],
    9636             :     float phases[],
    9637             :     uint16_t *pNumIndexes,
    9638             :     const float lastPitchLag,
    9639             :     const float currentPitchLag,
    9640             :     const float lastMDCTSpectrum[],
    9641             :     const float scaleFactors[],
    9642             :     const float secondLastPowerSpectrum[],
    9643             :     const uint16_t nSamples,
    9644             :     const uint16_t nSamplesCore,
    9645             :     float floorPowerSpectrum,
    9646             :     const PsychoacousticParameters *psychParamsCurrent );
    9647             : 
    9648             : ivas_error PsychoacousticParameters_Init(
    9649             :     const int32_t sr_core,  /* i  : sampling rate of core-coder                                     */
    9650             :     const int16_t nBins,    /* i  : Number of bins (spectral lines)                                 */
    9651             :     const int8_t nBands,    /* i  : Number of spectrum subbands                                     */
    9652             :     const int16_t isTCX20,  /* i  : Flag indicating if the subband division is for TCX20 or TCX10   */
    9653             :     const int16_t isWarped, /* i  : Flag indicating if the scale is linear or warped                */
    9654             :     PsychoacousticParameters *pPsychParams );
    9655             : 
    9656             : void concealment_init(
    9657             :     const int16_t L_frameTCX,
    9658             :     T_PLCInfo_HANDLE hPlcInfo );
    9659             : 
    9660             : void concealment_decode(
    9661             :     const int16_t core,
    9662             :     float *invkoef,
    9663             :     T_PLCInfo_HANDLE hPlcInfo );
    9664             : 
    9665             : void concealment_update(
    9666             :     const int16_t bfi,
    9667             :     const int16_t core,
    9668             :     const int16_t harmonic,
    9669             :     float *invkoef,
    9670             :     T_PLCInfo_HANDLE hPlcInfo );
    9671             : 
    9672             : void concealment_update2(
    9673             :     const float *outx_new,
    9674             :     T_PLCInfo_HANDLE hPlcInfo,
    9675             :     const int16_t L_frameTCX );
    9676             : 
    9677             : void concealment_signal_tuning(
    9678             :     Decoder_State *st,
    9679             :     const int16_t bfi,
    9680             :     float *outx_new,
    9681             :     const int16_t past_core_mode );
    9682             : 
    9683             : void waveform_adj2(
    9684             :     T_PLCInfo_HANDLE hPlcInfo,
    9685             :     float *overlapbuf,
    9686             :     float *outx_new,
    9687             :     const int16_t delay,
    9688             :     const int16_t bfi_cnt,
    9689             :     const int16_t bfi );
    9690             : 
    9691             : float SFM_Cal(
    9692             :     const float fcoef[],
    9693             :     const int16_t n );
    9694             : 
    9695             : void set_state(
    9696             :     int16_t *state,
    9697             :     const int16_t num,
    9698             :     const int16_t N );
    9699             : 
    9700             : int16_t RFFTN(
    9701             :     float *afftData,
    9702             :     const float *trigPtr,
    9703             :     const int16_t len,
    9704             :     const int16_t isign );
    9705             : 
    9706             : void DoFFT(
    9707             :     float *re2,
    9708             :     float *im2,
    9709             :     const int16_t length );
    9710             : 
    9711             : /*! r: flag indicating a valid bitrate */
    9712             : int16_t is_EVS_bitrate(
    9713             :     const int32_t ivas_total_brate, /* i  : EVS total bitrate  */
    9714             :     int16_t *Opt_AMR_WB             /* i  : AMR-WB IO flag     */
    9715             : );
    9716             : 
    9717             : /*! r: codec mode */
    9718             : int16_t get_codec_mode(
    9719             :     const int32_t total_brate /* i  : total bitrate   */
    9720             : );
    9721             : 
    9722             : int16_t getTcxonly(
    9723             :     const int16_t element_mode, /* i  : IVAS element mode                   */
    9724             :     const int32_t total_brate,  /* i  : total bitrate                       */
    9725             :     const int16_t MCT_flag,     /* i  : hMCT handle allocated (1) or not (0)*/
    9726             :     const int16_t is_ism_format /* i  : flag indicating ISM format          */
    9727             : );
    9728             : 
    9729             : int16_t getTnsAllowed(
    9730             :     const int32_t total_brate, /* i  : total bitrate               */
    9731             :     const int16_t igf,         /* i  : flag indicating IGF activity*/
    9732             :     const int16_t element_mode /* i  : IVAS element mode           */
    9733             : );
    9734             : 
    9735             : int16_t getCtxHm(
    9736             :     const int16_t element_mode, /* i  : IVAS element mode           */
    9737             :     const int32_t total_brate,  /* i  : total bitrate               */
    9738             :     const int16_t rf_flag       /* i  : flag to signal the RF mode  */
    9739             : );
    9740             : 
    9741             : int16_t getResq(
    9742             :     const int32_t total_brate /* i  : total bitrate   */
    9743             : );
    9744             : 
    9745             : int16_t getRestrictedMode(
    9746             :     const int16_t element_mode, /* i  : IVAS element mode               */
    9747             :     const int32_t total_brate,  /* i  : total bitrate                   */
    9748             :     const int16_t Opt_AMR_WB    /* i  : flag indicating AMR-WB IO mode  */
    9749             : );
    9750             : 
    9751             : int16_t getMdctWindowLength(
    9752             :     const int16_t fscale );
    9753             : 
    9754             : int16_t sr2fscale(
    9755             :     const int32_t sr_core /* i  : internal sampling rate        */
    9756             : );
    9757             : 
    9758             : int32_t getCoreSamplerateMode2(
    9759             :     const int16_t element_mode,     /* i  : IVAS element mode              */
    9760             :     const int32_t total_brate,      /* i  : total bitrate                  */
    9761             :     const int16_t bwidth,           /* i  : audio bandwidth                */
    9762             :     const int16_t flag_ACELP16k,    /* i  : ACELP@16kHz flag               */
    9763             :     const int16_t rf_mode,          /* i  : flag to signal the RF mode     */
    9764             :     const IVAS_FORMAT is_ism_format /* i  : flag indicating ISM format     */
    9765             : );
    9766             : 
    9767             : float getTcxBandwidth(
    9768             :     const int16_t bwidth /* i  : audio bandwidth        */
    9769             : );
    9770             : 
    9771             : int16_t getIgfPresent(
    9772             :     const int16_t element_mode, /* i  : IVAS element mode           */
    9773             :     const int32_t total_brate,  /* i  : total bitrate               */
    9774             :     const int16_t bwidth,       /* i  : audio bandwidth             */
    9775             :     const int16_t rf_mode       /* i  : flag to signal the RF mode  */
    9776             : );
    9777             : 
    9778             : int16_t getCnaPresent(
    9779             :     const int16_t element_mode,  /* i  : element mode             */
    9780             :     const int32_t element_brate, /* i  : element bitrate          */
    9781             :     const int32_t total_brate,   /* i  : total bitrate            */
    9782             :     const int16_t bwidth         /* i  : audio bandwidth          */
    9783             : );
    9784             : 
    9785             : int16_t getTcxLtp(
    9786             :     const int32_t sr_core /* i  : internal sampling rate                              */
    9787             : );
    9788             : 
    9789             : int16_t initPitchLagParameters(
    9790             :     const int32_t sr_core, /* i  : internal sampling rate                              */
    9791             :     int16_t *pit_min,
    9792             :     int16_t *pit_fr1,
    9793             :     int16_t *pit_fr1b,
    9794             :     int16_t *pit_fr2,
    9795             :     int16_t *pit_max );
    9796             : 
    9797             : void attenuateNbSpectrum(
    9798             :     const int16_t L_frame,
    9799             :     float *spectrum );
    9800             : 
    9801             : void SetModeIndex(
    9802             :     Encoder_State *st,               /* i  : Encoder state                          */
    9803             :     const int32_t last_total_brate,  /* i  : last total bitrate                     */
    9804             :     const int16_t last_element_mode, /* i  : last IVAS element mode                 */
    9805             :     const int16_t MCT_flag           /* i  : hMCT handle allocated (1) or not (0)   */
    9806             : );
    9807             : 
    9808             : int16_t getNumTcxCodedLines(
    9809             :     const int16_t bwidth /* i  : audio bandwidth        */
    9810             : );
    9811             : 
    9812             : int16_t getTcxLpcShapedAri(
    9813             :     const int32_t total_brate, /* i  : total bitrate                */
    9814             :     const int16_t rf_mode,     /* i  : flag to signal the RF mode   */
    9815             :     const int16_t element_mode /* i  : IVAS element mode            */
    9816             : );
    9817             : 
    9818             : void IGFEncApplyMono(
    9819             :     Encoder_State *st,              /* i  : Encoder state                                          */
    9820             :     const int16_t igfGridIdx,       /* i  : IGF grid index                                         */
    9821             :     float *pMDCTSpectrum,           /* i/o: MDCT spectrum                                          */
    9822             :     float *pPowerSpectrum,          /* i/o: MDCT^2 + MDST^2 spectrum, or estimate                  */
    9823             :     const int16_t isTCX20,          /* i  : flag indicating if the input is TCX20 or TCX10/2xTCX5  */
    9824             :     const int16_t isTNSActive,      /* i  : flag indicating if the TNS is active                   */
    9825             :     const int16_t sp_aud_decision0, /* i  : first stage switching decision                         */
    9826             :     const int16_t vad_hover_flag    /* i  : VAD hangover flag                                      */
    9827             : );
    9828             : 
    9829             : void IGFEncApplyStereo(
    9830             :     STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct,             /* i/o: MDCT stereo encoder structure               */
    9831             :     int16_t ms_mask[2][MAX_SFB],                         /* i  : bandwise MS mask                            */
    9832             :     const IGF_ENC_INSTANCE_HANDLE hIGFEnc[CPE_CHANNELS], /* i  : instance handle of IGF Encoder              */
    9833             :     const int16_t igfGridIdx,                            /* i  : IGF grid index                              */
    9834             :     Encoder_State *sts[CPE_CHANNELS],                    /* i  : Encoder state                               */
    9835             :     float *pPowerSpectrum[CPE_CHANNELS],                 /* i/o: MDCT^2 + MDST^2 spectrum, or estimate       */
    9836             :     float *pPowerSpectrumMsInv[CPE_CHANNELS][NB_DIV],    /* i/o: inverse power spectrum                      */
    9837             :     float *inv_spectrum[CPE_CHANNELS][NB_DIV],           /* i  : inverse spectrum                            */
    9838             :     const int16_t frameno,                               /* i  : flag indicating index of current subframe   */
    9839             :     const int16_t sp_aud_decision0,                      /* i  : sp_aud_decision0                            */
    9840             :     const int32_t element_brate,                         /* i  : element bitrate                             */
    9841             :     const int16_t mct_on                                 /* i  : flag mct block (1) or stereo (0)              */
    9842             : );
    9843             : 
    9844             : void IGFEncConcatenateBitstream(
    9845             :     const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i  : instance handle of IGF Encoder                 */
    9846             :     const int16_t bsBits,                  /* i  : number of IGF bits written to list of indices  */
    9847             :     BSTR_ENC_HANDLE hBstr                  /* i/o: bitstream handle                               */
    9848             : );
    9849             : 
    9850             : void IGFEncResetTCX10BitCounter(
    9851             :     const IGF_ENC_INSTANCE_HANDLE hIGFEnc /* i  : instance handle of IGF Encoder */
    9852             : );
    9853             : 
    9854             : ivas_error IGF_Reconfig(
    9855             :     IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder  */
    9856             :     const int16_t igf,                /* i  : IGF on/off                      */
    9857             :     const int16_t reset,              /* i  : reset flag                      */
    9858             :     const int32_t brate,              /* i  : bitrate for configuration       */
    9859             :     const int16_t bwidth,             /* i  : signal bandwidth                */
    9860             :     const int16_t element_mode,       /* i  : IVAS element mode               */
    9861             :     const int16_t rf_mode             /* i  : flag to signal the RF mode      */
    9862             : );
    9863             : 
    9864             : void IGFEncSetMode(
    9865             :     const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i  : instance handle of IGF Encoder */
    9866             :     const int32_t total_brate,             /* i  : encoder total bitrate          */
    9867             :     const int16_t bwidth,                  /* i  : encoder audio bandwidth        */
    9868             :     const int16_t element_mode,            /* i  : IVAS element mode              */
    9869             :     const int16_t rf_mode                  /* i  : flag to signal the RF mode     */
    9870             : );
    9871             : 
    9872             : /*! r: number of bits written per frame */
    9873             : int16_t IGFEncWriteBitstream(
    9874             :     const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i  : instance handle of IGF Encoder                                              */
    9875             :     BSTR_ENC_HANDLE hBstr,                 /* i/o: encoder bitstream handle                                                    */
    9876             :     int16_t *pBitOffset,                   /* i  : ptr to bitOffset counter                                                    */
    9877             :     const int16_t igfGridIdx,              /* i  : igf grid index see declaration of IGF_GRID_IDX for details                  */
    9878             :     const int16_t isIndepFlag              /* i  : if 1 frame is independent, 0 = frame is coded with data from previous frame */
    9879             : );
    9880             : 
    9881             : /*! r: total number of bits written */
    9882             : int16_t IGFEncWriteConcatenatedBitstream(
    9883             :     const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i  : instance handle of IGF Encoder */
    9884             :     BSTR_ENC_HANDLE hBstr                  /* i/o: encoder bitstream handle       */
    9885             : );
    9886             : 
    9887             : void IGFDecApplyMono(
    9888             :     const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i  : instance handle of IGF Decoder                       */
    9889             :     float *spectrum,                       /* i/o: MDCT spectrum                                        */
    9890             :     const int16_t igfGridIdx,              /* i  : in case of CELP->TCX switching, use 1.25 framelength */
    9891             :     const int16_t bfi,                     /* i  : frame loss == 1, frame good == 0                     */
    9892             :     const int16_t element_mode             /* i  : IVAS element mode                                    */
    9893             : );
    9894             : 
    9895             : void IGFDecCopyLPCFlatSpectrum(
    9896             :     const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Decoder     */
    9897             :     const float *pSpectrumFlat,            /* i  : LPC flattend spectrum from TCX dec */
    9898             :     const int16_t igfGridIdx               /* i  : IGF grid index                     */
    9899             : );
    9900             : 
    9901             : void IGFDecReadData(
    9902             :     const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Deccoder                      */
    9903             :     Decoder_State *st,                     /* i  : decoder state                                        */
    9904             :     const int16_t igfGridIdx,              /* i  : in case of CELP->TCX switching, use 1.25 framelength */
    9905             :     const int16_t isIndepFrame             /* i  : if 1: arith dec force reset, if 0: no reset          */
    9906             : );
    9907             : 
    9908             : /*! r: return igfAllZero flag indicating if no envelope is transmitted */
    9909             : int16_t IGFDecReadLevel(
    9910             :     const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Deccoder                                  */
    9911             :     Decoder_State *st,                     /* i  : decoder state                                                    */
    9912             :     const int16_t igfGridIdx,              /* i  : in case of CELP->TCX switching, use 1.25 framelength             */
    9913             :     const int16_t isIndepFrame             /* i  : if 1: arith dec force reset, if 0: no reset                      */
    9914             : );
    9915             : 
    9916             : void IGFDecRestoreTCX10SubFrameData(
    9917             :     const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* o  : instance handle of IGF Decoder      */
    9918             :     const int16_t subFrameIdx              /* i  : index of subframe                   */
    9919             : );
    9920             : 
    9921             : void init_igf_dec(
    9922             :     IGF_DEC_INSTANCE_HANDLE hIGFDec /* i/o: IGF decoder handle                  */
    9923             : );
    9924             : 
    9925             : void IGFDecSetMode(
    9926             :     const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* o  : instance handle of IGF Decoder      */
    9927             :     const int32_t total_brate,             /* i  : bitrate                             */
    9928             :     const int16_t bwidth,                  /* i  : audio bandwidth                     */
    9929             :     const int16_t element_mode,            /* i  : IVAS element mode                   */
    9930             :     const int16_t defaultStartLine,        /* i  : default start subband index         */
    9931             :     const int16_t defaultStopLine,         /* i  : default stop subband index          */
    9932             :     const int16_t rf_mode                  /* i  : flag to signal the RF mode          */
    9933             : );
    9934             : 
    9935             : void IGFDecStoreTCX10SubFrameData(
    9936             :     const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Decoder      */
    9937             :     const int16_t subFrameIdx              /* i  : index of subframe                   */
    9938             : );
    9939             : 
    9940             : void IGFDecUpdateInfo(
    9941             :     const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Decoder      */
    9942             :     const int16_t subFrameIdx,             /* i  : subframe index                      */
    9943             :     const int16_t igfGridIdx               /* i  : IGF grid index                      */
    9944             : );
    9945             : 
    9946             : /*! r: error value: 0 -> error, 1 -> ok */
    9947             : int16_t IGFCommonFuncsIGFConfiguration(
    9948             :     const int32_t total_brate,  /* i  : bitrate in bs e.g. 9600 for 9.6kbs  */
    9949             :     const int16_t bwidth,       /* i  : audio bandwidth                     */
    9950             :     const int16_t element_mode, /* i  : IVAS element mode                   */
    9951             :     H_IGF_INFO hIGFInfo,        /* o  : IGF info handle                     */
    9952             :     const int16_t rf_mode       /* i  : flag to signal the RF mode          */
    9953             : );
    9954             : 
    9955             : /*! r: error value: 0 -> error, 1 -> ok */
    9956             : int16_t IGFCommonFuncsIGFGetCFTables(
    9957             :     const int32_t total_brate,   /* i  : bitrate in bs e.g. 9600 for 9.6kbs  */
    9958             :     const int16_t bwidth,        /* i  : audio bandwidth                     */
    9959             :     const int16_t element_mode,  /* i  : element mode                        */
    9960             :     const int16_t rf_mode,       /* i  : flag to signal the RF mode          */
    9961             :     const uint16_t **cf_se00,    /* i  : CF table for t == 0 and f == 0      */
    9962             :     const uint16_t **cf_se01,    /* i  : CF table for t == 0 and f == 1      */
    9963             :     int16_t *cf_off_se01,        /* o  : offset for CF table above           */
    9964             :     const uint16_t **cf_se02,    /* i  : CF tables for t == 0 and f >= 2     */
    9965             :     const int16_t **cf_off_se02, /* o  : offsets for CF tables above         */
    9966             :     const uint16_t **cf_se10,    /* i  : CF table for t == 1 and f == 0      */
    9967             :     int16_t *cf_off_se10,        /* o  : offset for CF table above           */
    9968             :     const uint16_t **cf_se11,    /* i  : CF tables for t == 1 and f >= 1     */
    9969             :     const int16_t **cf_off_se11  /* o  : offsets for CF tables above         */
    9970             : );
    9971             : 
    9972             : /*! r: multiplication factor */
    9973             : int16_t IGF_ApplyTransFac(
    9974             :     const int16_t val,   /* i  : input value for multiplication, Q15                                          */
    9975             :     const float transFac /* i  : multiplicator for variable val, Q14: 1.25f=0x5000, 1.0f=0x4000, 0.5f=0x2000  */
    9976             : );
    9977             : 
    9978             : /*! r: return bitrate index */
    9979             : int16_t IGF_MapBitRateToIndex(
    9980             :     const int32_t brate,        /* i  : bitrate                         */
    9981             :     const int16_t bwidth,       /* i  : audio bandwidth                 */
    9982             :     const int16_t element_mode, /* i  : IVAS element mode               */
    9983             :     const int16_t rf_mode       /* i  : flag to signal the RF mode      */
    9984             : );
    9985             : 
    9986             : void IGFSCFEncoderOpen(
    9987             :     IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i  : handle to public data           */
    9988             :     H_IGF_INFO hIgfInfo,                   /* i  : IGF info handle                 */
    9989             :     const int32_t total_brate,             /* i  : total bitrate                   */
    9990             :     const int16_t bwidth,                  /* i  : audio bandwidth                 */
    9991             :     const int16_t element_mode,            /* i  : IVAS element mode               */
    9992             :     const int16_t rf_mode                  /* i  : flag to signal the RF mode      */
    9993             : );
    9994             : 
    9995             : void IGFSCFEncoderReset(
    9996             :     IGFSCFENC_INSTANCE_HANDLE hPublicData /* i  : handle to public data or NULL in case there was no instance created */
    9997             : );
    9998             : 
    9999             : int16_t IGFSCFEncoderEncode(
   10000             :     IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i  : handle to public data or NULL in case there was no instance created          */
   10001             :     BSTR_ENC_HANDLE hBstr,                 /* i/o: encoder bitstream handle                                                     */
   10002             :     const int16_t bitCount,                /* i  : offset to the first bit in bitbuffer which should be readed by iisArithDecoderDecode function */
   10003             :     int16_t *sfe,                          /* i  : ptr to an array which contain quantized scalefactor energies                 */
   10004             :     const int16_t igfGridIdx,              /* i  : igf grid index see declaration of IGF_GRID_IDX for details                   */
   10005             :     const int16_t indepFlag                /* i  : if 1 frame is independent, 0 = frame is coded with data from previous frame  */
   10006             : );
   10007             : 
   10008             : void IGFSCFEncoderSaveContextState(
   10009             :     IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i  : handle to public data or NULL in case there was no instance created */
   10010             :     const int16_t igfGridIdx               /* i  : igf grid index see declaration of IGF_GRID_IDX for details          */
   10011             : );
   10012             : 
   10013             : void IGFSCFEncoderRestoreContextState(
   10014             :     IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i  : handle to public data or NULL in case there was no instance created */
   10015             :     const int16_t igfGridIdx               /* i  : igf grid index see declaration of IGF_GRID_IDX for details          */
   10016             : );
   10017             : 
   10018             : void IGFSCFDecoderOpen(
   10019             :     IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i  : handle to public data       */
   10020             :     H_IGF_INFO hIgfInfo,                   /* i  : IGF info handle             */
   10021             :     const int32_t total_brate,
   10022             :     const int16_t bwidth,
   10023             :     const int16_t element_mode,
   10024             :     const int16_t rf_mode );
   10025             : 
   10026             : void IGFSCFDecoderReset(
   10027             :     IGFSCFDEC_INSTANCE_HANDLE hPublicData /* i  : handle to public data or NULL in case there was no instance created     */
   10028             : );
   10029             : 
   10030             : void IGFSCFDecoderDecode(
   10031             :     IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i  : handle to public data or NULL in case there was no instance created     */
   10032             :     Decoder_State *st,                     /* i/o: pointer to decoder state                                                */
   10033             :     int16_t *sfe,                          /* o  : ptr to an array which will contain the decoded quantized coefficients   */
   10034             :     const int16_t igfGridIdx,              /* i  : igf grid index see declaration of IGF_GRID_IDX for details              */
   10035             :     const int16_t indepFlag                /* i  : if  1 on input the decoder will be forced to reset,
   10036             :                                                    if  0 on input the decoder will be forced to encode without a reset     */
   10037             : );
   10038             : 
   10039             : /*! r: offset value */
   10040             : int16_t tbe_celp_exc_offset(
   10041             :     const int16_t T0,     /* i  : Integer pitch */
   10042             :     const int16_t T0_frac /* i  : Fractional part of the pitch */
   10043             : );
   10044             : 
   10045             : void blend_subfr2(
   10046             :     float *sigIn1, /* i  : input signal for fade-out */
   10047             :     float *sigIn2, /* i  : input signal for fade-in  */
   10048             :     float *sigOut  /* o  : output signal             */
   10049             : );
   10050             : 
   10051             : void init_tcx_window_cfg(
   10052             :     TCX_CONFIG_HANDLE hTcxCfg,          /* i  : TCX Config handle        */
   10053             :     const int32_t sr_core,              /* i  : SR core                  */
   10054             :     const int32_t input_Fs,             /* i  : input/output SR          */
   10055             :     const int16_t L_frame,              /* i  : L_frame at sr_core       */
   10056             :     const int16_t L_frameTCX,           /* i  : L_frame at i/o SR        */
   10057             :     const int16_t encoderLookahead_enc, /* i  : encoder LA at sr_core    */
   10058             :     const int16_t encoderLookahead_FB,  /* i  : encoder LA at i/o SR     */
   10059             :     const int16_t mdctWindowLength,     /* i  : window length at sr_core */
   10060             :     const int16_t mdctWindowLengthFB,   /* i  : window length at i/o SR  */
   10061             :     const int16_t element_mode          /* i  : mode of CPE/SCE          */
   10062             : );
   10063             : 
   10064             : void init_tcx_cfg(
   10065             :     TCX_CONFIG_HANDLE hTcxCfg,
   10066             :     const int32_t total_brate,
   10067             :     const int32_t sr_core,
   10068             :     const int32_t input_Fs,
   10069             :     const int16_t L_frame,
   10070             :     const int16_t bwidth,
   10071             :     const int16_t L_frameTCX,
   10072             :     const int16_t fscale,
   10073             :     const int16_t encoderLookahead_enc,
   10074             :     const int16_t encoderLookahead_FB,
   10075             :     const float preemph_fac,
   10076             :     const int16_t tcxonly,
   10077             :     const int16_t rf_mode,
   10078             :     const int16_t igf,
   10079             :     const int16_t infoIGFStopFreq,
   10080             :     const int16_t element_mode,
   10081             :     const int16_t ini_frame,
   10082             :     const int16_t MCT_flag /* i  : hMCT handle allocated (1) or not (0)  */
   10083             : );

Generated by: LCOV version 1.14