LCOV - code coverage report
Current view: top level - lib_dec - gs_dec_fx.c (source / functions) Hit Total Coverage
Test: Coverage on main -- dec/rend @ 633e3f2e309758d10805ef21e0436356fe719b7a Lines: 389 413 94.2 %
Date: 2025-08-23 01:22:27 Functions: 4 4 100.0 %

          Line data    Source code
       1             : /*====================================================================================
       2             :     EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
       3             :   ====================================================================================*/
       4             : 
       5             : #include <stdint.h>
       6             : #include "options.h"
       7             : #include "cnst.h"
       8             : #include "rom_com.h"
       9             : #include "prot_fx.h"
      10             : #include "ivas_cnst.h"
      11             : /*=========================================================================*/
      12             : /* FUNCTION : void decod_audio_fx();                                                                   */
      13             : /*-------------------------------------------------------------------------*/
      14             : /* PURPOSE :  Decode audio (AC) frames                                             */
      15             : /*-------------------------------------------------------------------------*/
      16             : /*    INPUT ARGUMENTS :                                                                                                */
      17             : /* _ (Word16[]) Aq                      : LP filter coefficient         Q12                        */
      18             : /* _ (Word16) coder_type                : coding type                           Q0                         */
      19             : /* _(Word16) Q_exc              :Q format of excitation                    */
      20             : /*-------------------------------------------------------------------------*/
      21             : /* OUTPUT ARGUMENTS :                                                                                                      */
      22             : /* _ (Word16[]) pitch_buf_fx    : floating pitch values for each subframe Q6*/
      23             : /* _ (Word16[]) voice_factors_fx: frame error rate                              Q15                 */
      24             : /*--------------------------------------------------------------------------*/
      25             : /* INPUT/OUTPUT ARGUMENTS :                                                                                         */
      26             : /*  Decoder_State *st_fx        : decoder  memory structure                 */
      27             : /* _ (Word16[]) exc_fx                  : adapt. excitation exc (Q_exc)                     */
      28             : /* _ (Word16[]) exc2_fx                 : adapt. excitation/total exc (Q_exc)       */
      29             : /*--------------------------------------------------------------------------*/
      30             : /* RETURN ARGUMENTS :                                                                                                       */
      31             : /* _ None                                                                                                                                   */
      32             : /*==========================================================================*/
      33             : 
      34       13840 : void decod_audio_fx(
      35             :     Decoder_State *st_fx,              /* i/o: decoder static memory                                            */
      36             :     Word16 dct_epit[],                 /* o  : GSC excitation in DCT domain              Qx*/
      37             :     const Word16 *Aq,                  /* i  : LP filter coefficient                     Q12*/
      38             :     Word16 *pitch_buf,                 /* o  : Word16 pitch values for each subframe      Q6*/
      39             :     Word16 *voice_factors,             /* o  : voicing factors                           Q15*/
      40             :     Word16 *exc,                       /* i/o: adapt. excitation exc                     Q_exc*/
      41             :     Word16 *exc2,                      /* i/o: adapt. excitation/total exc               Q_exc*/
      42             :     Word16 *bwe_exc,                   /* o  : excitation for SWB TBE                    Q_exc*/
      43             :     Word16 *lsf_new,                   /* i  : ISFs at the end of the frame              Qx*/
      44             :     Word16 *gain_buf,                  /* o  : Word16 pitch gain for each subframe              Q14*/
      45             :     const Word16 tdm_lp_reuse_flag,    /* i  : LPC reuse flag                            Q0*/
      46             :     const Word16 tdm_low_rate_mode,    /* i  : secondary channel low rate mode flag      Q0*/
      47             :     const Word16 tdm_Pitch_reuse_flag, /* i  : primary channel pitch reuse flag          Q0*/
      48             :     const Word16 tdm_Pri_pitch_buf[]   /* i  : primary channel pitch buffer              Q6*/
      49             : )
      50             : {
      51             :     Word16 tmp_nb_bits_tot, pit_band_idx;
      52             :     Word16 code[4 * L_SUBFR];
      53             :     Word16 Diff_len, nb_subfr, i;
      54             :     Word16 nb_frame_flg;
      55       13840 :     Word16 Es_pred = 0;
      56             :     Word16 Len, max_len;
      57             :     Word16 gsc_attack_flag;
      58             : 
      59             :     Word16 low_pit;
      60             :     Word16 last_bin;
      61             :     Word16 nbits;
      62             : 
      63             :     Word16 exc_wo_nf[L_FRAME16k];
      64             :     GSC_DEC_HANDLE hGSCDec;
      65       13840 :     hGSCDec = st_fx->hGSCDec;
      66             : 
      67       13840 :     move16(); // Es_pred
      68             : 
      69             :     /*---------------------------------------------------------------*
      70             :      * Initialization
      71             :      *---------------------------------------------------------------*/
      72             : 
      73       13840 :     Diff_len = 0;
      74       13840 :     move16();
      75             : 
      76             :     /* decode GSC attack flag (used to reduce possible pre-echo) */
      77       13840 :     gsc_attack_flag = (Word16) get_next_indice_fx( st_fx, 1 ); /* Q0 */
      78       13840 :     move16();
      79             : 
      80             :     /* decode GSC SWB speech flag */
      81       13840 :     test();
      82       13840 :     test();
      83       13840 :     test();
      84       13840 :     test();
      85       13840 :     test();
      86       13840 :     test();
      87       13840 :     test();
      88       13840 :     IF( GE_16( st_fx->GSC_IVAS_mode, 1 ) || ( st_fx->coder_type != INACTIVE && ( ( st_fx->element_mode == EVS_MONO && GE_32( st_fx->total_brate, ACELP_13k20 ) ) ||
      89             :                                                                                  ( st_fx->element_mode > EVS_MONO && GT_32( st_fx->total_brate, MIN_BRATE_GSC_NOISY_FLAG ) && GE_16( st_fx->bwidth, SWB ) && !st_fx->flag_ACELP16k ) ) ) )
      90             :     {
      91        4847 :         st_fx->GSC_noisy_speech = (Word16) get_next_indice_fx( st_fx, 1 ); /* Q0 */
      92        4847 :         move16();
      93             :     }
      94             : 
      95             :     /* safety check in case of bit errors */
      96       13840 :     test();
      97       13840 :     test();
      98       13840 :     IF( st_fx->GSC_noisy_speech && LT_16( st_fx->bwidth, SWB ) && st_fx->GSC_IVAS_mode == 0 )
      99             :     {
     100           0 :         st_fx->BER_detect = 1; /* Q0 */
     101           0 :         move16();
     102           0 :         st_fx->GSC_noisy_speech = 0;
     103           0 :         move16();
     104             :     }
     105             : 
     106             :     /* set bit-allocation */
     107             : #ifdef NONBE_1325_TD_STEREO_QUANT_LSF_SEC
     108       13840 :     config_acelp1_fx( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
     109             : #else
     110             :     config_acelp1_fx( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
     111             : #endif
     112             : 
     113             :     /*---------------------------------------------------------------*
     114             :      * Decode energy dynamics
     115             :      *---------------------------------------------------------------*/
     116             : 
     117       13840 :     test();
     118       13840 :     test();
     119       13840 :     IF( GE_16( st_fx->GSC_IVAS_mode, 1 ) || ( EQ_16( st_fx->GSC_noisy_speech, 1 ) && st_fx->GSC_IVAS_mode == 0 ) )
     120             :     {
     121        4847 :         nb_subfr = NB_SUBFR; /* Q0 */
     122        4847 :         move16();
     123        4847 :         hGSCDec->cor_strong_limit = 0;
     124        4847 :         move16();
     125        4847 :         hGSCDec->noise_lev = NOISE_LEVEL_SP3; /* Q0 */
     126        4847 :         move16();
     127             : 
     128        4847 :         IF( GE_16( st_fx->GSC_IVAS_mode, 1 ) )
     129             :         {
     130        4152 :             test();
     131        4152 :             if ( LT_32( st_fx->core_brate, GSC_L_RATE_STG ) && LT_32( st_fx->GSC_IVAS_mode, 3 ) )
     132             :             {
     133        1823 :                 nb_subfr = 2; /* Q0 */
     134        1823 :                 move16();
     135             :             }
     136        4152 :             hGSCDec->noise_lev = NOISE_LEVEL_SP2; /* Q0 */
     137        4152 :             move16();
     138             : 
     139        4152 :             IF( EQ_16( st_fx->GSC_IVAS_mode, 3 ) ) /* Music like */
     140             :             {
     141        2303 :                 hGSCDec->noise_lev = NOISE_LEVEL_SP0; /* Q0 */
     142        2303 :                 move16();
     143             :             }
     144        1849 :             ELSE IF( st_fx->GSC_noisy_speech == 0 ) /* speech like but not noisy */
     145             :             {
     146        1750 :                 hGSCDec->noise_lev = NOISE_LEVEL_SP3; /* Q0 */
     147        1750 :                 move16();
     148             :             }
     149             :         }
     150             :     }
     151             :     ELSE
     152             :     {
     153        8993 :         IF( LE_32( st_fx->core_brate, ACELP_8k00 ) )
     154             :         {
     155        4726 :             hGSCDec->noise_lev = add( (Word16) get_next_indice_fx( st_fx, 2 ), NOISE_LEVEL_SP2 ); /* Q0 */
     156        4726 :             move16();
     157             :         }
     158             :         ELSE
     159             :         {
     160        4267 :             hGSCDec->noise_lev = add( (Word16) get_next_indice_fx( st_fx, 3 ), NOISE_LEVEL_SP0 ); /* Q0 */
     161        4267 :             move16();
     162             :         }
     163             : 
     164             :         /*---------------------------------------------------------------*
     165             :          * Decode number of subframes
     166             :          *---------------------------------------------------------------*/
     167             : 
     168        8993 :         test();
     169        8993 :         test();
     170        8993 :         IF( EQ_16( st_fx->L_frame, L_FRAME16k ) && ( LE_32( st_fx->core_brate, ACELP_13k20 ) || st_fx->coder_type == INACTIVE ) )
     171             :         {
     172        2533 :             hGSCDec->cor_strong_limit = 0;
     173        2533 :             move16();
     174        2533 :             nb_subfr = 1; /* Q0 */
     175        2533 :             move16();
     176             :         }
     177             :         ELSE
     178             :         {
     179        6460 :             hGSCDec->cor_strong_limit = 1; /* Q0 */
     180        6460 :             move16();
     181        6460 :             nb_subfr = SWNB_SUBFR; /* Q0 */
     182        6460 :             move16();
     183             : 
     184        6460 :             IF( GE_32( st_fx->core_brate, ACELP_9k60 ) )
     185             :             {
     186        1245 :                 nbits = 1; /* Q0 */
     187        1245 :                 move16();
     188             : 
     189        1245 :                 test();
     190        1245 :                 if ( EQ_16( st_fx->L_frame, L_FRAME16k ) && GE_32( st_fx->core_brate, MIN_RATE_4SBFR ) )
     191             :                 {
     192           0 :                     nbits = 2; /* Q0 */
     193           0 :                     move16();
     194             :                 }
     195             : 
     196        1245 :                 nb_frame_flg = (Word16) get_next_indice_fx( st_fx, nbits ); /* Q0 */
     197        1245 :                 move16();
     198             : 
     199        1245 :                 test();
     200        1245 :                 IF( s_and( nb_frame_flg, 0x1 ) == 0 )
     201             :                 {
     202        1238 :                     nb_subfr = 2 * SWNB_SUBFR;
     203        1238 :                     move16();
     204        1238 :                     hGSCDec->cor_strong_limit = 0;
     205        1238 :                     move16();
     206             :                 }
     207           7 :                 ELSE IF( EQ_16( st_fx->L_frame, L_FRAME16k ) && GE_32( st_fx->core_brate, MIN_RATE_4SBFR ) )
     208             :                 {
     209           0 :                     nb_subfr = 2 * SWNB_SUBFR; /* cor_strong already set to 1 */
     210           0 :                     move16();
     211             :                 }
     212             : 
     213        1245 :                 if ( EQ_16( shr( nb_frame_flg, 1 ), 1 ) )
     214             :                 {
     215           0 :                     nb_subfr = shl( nb_subfr, 1 ); /* Q0 */
     216             :                 }
     217             :             }
     218             :         }
     219             :     }
     220             : 
     221       13840 :     test();
     222       13840 :     if ( EQ_16( st_fx->L_frame, L_FRAME16k ) && EQ_16( nb_subfr, NB_SUBFR ) )
     223             :     {
     224           0 :         nb_subfr = NB_SUBFR16k; /* Q0 */
     225           0 :         move16();
     226             :     }
     227             : 
     228             :     /*---------------------------------------------------------------*
     229             :      * Decode the last band where the adaptive (pitch) contribution is significant
     230             :      *---------------------------------------------------------------*/
     231             : 
     232       13840 :     IF( LT_32( st_fx->core_brate, CFREQ_BITRATE ) )
     233             :     {
     234        8758 :         nbits = 3; /* Q0 */
     235        8758 :         move16();
     236        8758 :         test();
     237        8758 :         if ( LT_32( st_fx->core_brate, ACELP_9k60 ) && ( st_fx->coder_type == INACTIVE ) )
     238             :         {
     239         343 :             nbits = 1; /* Q0 */
     240         343 :             move16();
     241             :         }
     242             :     }
     243             :     ELSE
     244             :     {
     245        5082 :         nbits = 4; /* Q0 */
     246        5082 :         move16();
     247             :     }
     248       13840 :     test();
     249       13840 :     IF( LT_32( st_fx->core_brate, ACELP_9k60 ) && st_fx->coder_type != INACTIVE )
     250             :     {
     251        6782 :         pit_band_idx = 1; /* Q0 */
     252        6782 :         move16();
     253             :     }
     254             :     ELSE
     255             :     {
     256        7058 :         pit_band_idx = (Word16) get_next_indice_fx( st_fx, nbits ); /* Q0 */
     257        7058 :         move16();
     258             :     }
     259             : 
     260       13840 :     IF( pit_band_idx != 0 )
     261             :     {
     262       11784 :         IF( LT_32( st_fx->core_brate, ACELP_9k60 ) )
     263             :         {
     264        7027 :             pit_band_idx = 7 + BAND1k2; /* Q0 */
     265        7027 :             move16();                   /* At low rate, if pitch model is chosen, then for to be use on extented and constant frequency range */
     266             :         }
     267             :         ELSE
     268             :         {
     269        4757 :             pit_band_idx = add( pit_band_idx, BAND1k2 ); /* Q0 */
     270             :         }
     271             : 
     272             :         /* detect bit errors in the bitstream */
     273       11784 :         IF( GT_16( pit_band_idx, 13 ) ) /* The maximum decodable index is 10 + BAND1k2 (3) = 13 */
     274             :         {
     275           0 :             pit_band_idx = 13; /* Q0 */
     276           0 :             move16();
     277           0 :             st_fx->BER_detect = 1; /* Q0 */
     278           0 :             move16();
     279             :         }
     280       11784 :         Diff_len = mfreq_loc_div_25[pit_band_idx]; /* Q0 */
     281       11784 :         move16();
     282             :     }
     283       13840 :     hGSCDec->Last_GSC_pit_band_idx = pit_band_idx; /* Q0 */
     284       13840 :     move16();
     285             : 
     286             :     /*--------------------------------------------------------------------------------------*
     287             :      * Decode adaptive (pitch) excitation contribution
     288             :      * Reset unvaluable part of the adaptive (pitch) excitation contribution
     289             :      *--------------------------------------------------------------------------------------*/
     290       13840 :     IF( GT_16( pit_band_idx, BAND1k2 ) )
     291             :     {
     292             :         /*---------------------------------------------------------------*
     293             :          * Decode adaptive (pitch) excitation contribution
     294             :          *---------------------------------------------------------------*/
     295       11784 :         test();
     296       11784 :         test();
     297       11784 :         test();
     298       11784 :         test();
     299       11784 :         test();
     300       11784 :         test();
     301       11784 :         test();
     302       11784 :         test();
     303       11784 :         IF( !( ( st_fx->GSC_IVAS_mode > 0 ) && EQ_16( idiv1616( st_fx->L_frame, nb_subfr ), 2 * L_SUBFR ) && LT_16( st_fx->GSC_IVAS_mode, 3 ) ) &&
     304             :             ( ( GE_32( st_fx->core_brate, MIN_RATE_FCB ) || st_fx->GSC_noisy_speech ) &&
     305             :               ( ( EQ_16( nb_subfr, NB_SUBFR ) && EQ_16( st_fx->L_frame, L_FRAME ) ) || ( EQ_16( nb_subfr, NB_SUBFR16k ) && EQ_16( st_fx->L_frame, L_FRAME16k ) ) ) ) )
     306             :         {
     307             :             Word16 indice;
     308         695 :             nbits = Es_pred_bits_tbl[BIT_ALLOC_IDX_fx( st_fx->core_brate, GENERIC, -1, -1 )]; /* Q0 */
     309         695 :             move16();
     310         695 :             if ( st_fx->element_mode > EVS_MONO )
     311             :             {
     312         695 :                 nbits = 5; /* Q0 */
     313         695 :                 move16();
     314             :             }
     315             : 
     316         695 :             indice = get_next_indice_fx( st_fx, nbits ); /* Q0 */
     317             : 
     318         695 :             Es_pred_dec_fx( &Es_pred, indice, nbits, 0 );
     319             :         }
     320             : 
     321       11784 :         dec_pit_exc_fx( st_fx, Aq, st_fx->coder_type, Es_pred, pitch_buf, code, exc, bwe_exc, nb_subfr, gain_buf, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf );
     322             : 
     323       11784 :         IF( LT_32( st_fx->core_brate, ACELP_9k60 ) )
     324             :         {
     325        7027 :             minimum_fx( pitch_buf, shr( st_fx->L_frame, 6 ), &low_pit );
     326        7027 :             low_pit = shr( low_pit, 6 ); /*Q6 -> Q0 */
     327             : 
     328        7027 :             IF( LT_16( low_pit, 64 ) )
     329             :             {
     330        3072 :                 pit_band_idx = 9 + BAND1k2; /* Q0 */
     331        3072 :                 move16();
     332        3072 :                 if ( st_fx->bwidth == NB )
     333             :                 {
     334           0 :                     pit_band_idx = 7 + BAND1k2; /* Q0 */
     335           0 :                     move16();
     336             :                 }
     337             :             }
     338        3955 :             ELSE IF( LT_16( low_pit, 128 ) )
     339             :             {
     340        2227 :                 pit_band_idx = 5 + BAND1k2; /* Q0 */
     341        2227 :                 move16();
     342             :             }
     343             :             ELSE
     344             :             {
     345        1728 :                 pit_band_idx = 3 + BAND1k2; /* Q0 */
     346        1728 :                 move16();
     347             :             }
     348             : 
     349        7027 :             Diff_len = mfreq_loc_div_25[pit_band_idx]; /* Q0 */
     350        7027 :             move16();
     351        7027 :             hGSCDec->Last_GSC_pit_band_idx = pit_band_idx; /* Q0 */
     352        7027 :             move16();
     353             :         }
     354             : 
     355             :         /*---------------------------------------------------------------*
     356             :          * DCT transform
     357             :          *---------------------------------------------------------------*/
     358       11784 :         edct_16fx( exc, dct_epit, st_fx->L_frame, 7, st_fx->element_mode );
     359             : 
     360             :         /*---------------------------------------------------------------*
     361             :          * Reset unvaluable part of the adaptive (pitch) excitation contribution
     362             :          *---------------------------------------------------------------*/
     363             : 
     364       11784 :         max_len = sub( st_fx->L_frame, Diff_len ); /* Q0 */
     365             : 
     366       11784 :         if ( st_fx->bwidth == NB )
     367             :         {
     368           0 :             max_len = sub( 160, Diff_len ); /* Q0 */
     369             :         }
     370             : 
     371       11784 :         Len = 80;
     372       11784 :         move16();
     373       11784 :         if ( LT_16( max_len, 80 ) )
     374             :         {
     375        3316 :             Len = max_len; /* Q0 */
     376        3316 :             move16();
     377             :         }
     378             : 
     379       11784 :         test();
     380       11784 :         IF( EQ_32( st_fx->core_brate, ACELP_8k00 ) && st_fx->bwidth != NB )
     381             :         {
     382        2026 :             FOR( i = 0; i < max_len; i++ )
     383             :             {
     384        2005 :                 dct_epit[i + Diff_len] = 0;
     385        2005 :                 move16();
     386             :             }
     387             :         }
     388             :         ELSE
     389             :         {
     390      900331 :             FOR( i = 0; i < Len; i++ )
     391             :             {
     392      888568 :                 dct_epit[i + Diff_len] = mult_r( dct_epit[i + Diff_len], sm_table_fx[i] ); /* Qx */
     393      888568 :                 move16();
     394             :             }
     395             : 
     396      620702 :             FOR( ; i < max_len; i++ )
     397             :             {
     398      608939 :                 dct_epit[i + Diff_len] = 0;
     399      608939 :                 move16();
     400             :             }
     401             :         }
     402             :         // PMT("in the rare case of 4 subfr, bfi_pitch_fx might be wrong")
     403       11784 :         st_fx->bfi_pitch_fx = mean_fx( pitch_buf, nb_subfr ); /* Q6 */
     404       11784 :         move16();
     405       11784 :         st_fx->bfi_pitch_frame = st_fx->L_frame; /* Q0 */
     406       11784 :         move16();
     407             : 
     408       11784 :         Diff_len = add( Diff_len, 1 ); /* Q0 */
     409       11784 :         st_fx->bpf_off = 0;
     410       11784 :         move16();
     411             :     }
     412             :     ELSE
     413             :     {
     414             :         /* No adaptive (pitch) excitation contribution */
     415        2056 :         st_fx->bpf_off = 1;
     416        2056 :         move16();
     417        2056 :         set16_fx( dct_epit, 0, st_fx->L_frame );
     418             : 
     419        2056 :         IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
     420             :         {
     421        1507 :             set16_fx( pitch_buf, ( L_SUBFR16k * 64 ), NB_SUBFR16k );
     422             :         }
     423             :         ELSE
     424             :         {
     425         549 :             set16_fx( pitch_buf, L_SUBFR * 64, NB_SUBFR );
     426             :         }
     427             : 
     428        2056 :         set16_fx( gain_buf, 0, NB_SUBFR16k );
     429             : 
     430        2056 :         st_fx->bfi_pitch_fx = L_SUBFR * 64;
     431        2056 :         move16();
     432        2056 :         st_fx->bfi_pitch_frame = st_fx->L_frame; /* Q0 */
     433        2056 :         move16();
     434        2056 :         st_fx->lp_gainp_fx = 0;
     435        2056 :         move16();
     436        2056 :         st_fx->lp_gainc_fx = 0;
     437        2056 :         move16();
     438        2056 :         st_fx->tilt_code_fx = 0;
     439        2056 :         move16();
     440        2056 :         pit_band_idx = 0;
     441        2056 :         move16();
     442        2056 :         Diff_len = 0;
     443        2056 :         move16();
     444             :     }
     445             : 
     446             :     /*--------------------------------------------------------------------------------------*
     447             :      * GSC decoder
     448             :      *--------------------------------------------------------------------------------------*/
     449             : 
     450             :     /* find the current total number of bits used */
     451             : 
     452       13840 :     tmp_nb_bits_tot = st_fx->next_bit_pos; /* Q0 */
     453       13840 :     move16();
     454             : 
     455       13840 :     if ( st_fx->extl_brate_orig > 0 )
     456             :     {
     457             :         /* subtract 1 bit for TBE/BWE BWE flag (bit counted in extl_brate) */
     458       13725 :         tmp_nb_bits_tot = sub( tmp_nb_bits_tot, 1 ); /* Q0 */
     459             :     }
     460             : 
     461       13840 :     test();
     462       13840 :     test();
     463       13840 :     if ( st_fx->coder_type == INACTIVE && LE_32( st_fx->core_brate, ACELP_9k60 ) && st_fx->idchan == 0 )
     464             :     {
     465         358 :         tmp_nb_bits_tot = add( tmp_nb_bits_tot, 5 ); /* Q0 */
     466             :     }
     467             : 
     468       13840 :     IF( EQ_16( st_fx->idchan, 1 ) )
     469             :     {
     470           0 :         tmp_nb_bits_tot = add( tmp_nb_bits_tot, TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS ); /* Q0 */
     471           0 :         if ( EQ_16( st_fx->tdm_LRTD_flag, 1 ) )
     472             :         {
     473           0 :             tmp_nb_bits_tot = sub( tmp_nb_bits_tot, STEREO_BITS_TCA ); /* Q0 */
     474             :         }
     475             :     }
     476             : 
     477             : 
     478       13840 :     Word16 Q_exc_old = st_fx->Q_exc;
     479       13840 :     move16();
     480       13840 :     gsc_dec_fx( st_fx, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st_fx->coder_type, &last_bin, lsf_new, exc_wo_nf, &st_fx->Q_exc );
     481             : 
     482       13840 :     IF( NE_16( Q_exc_old, st_fx->Q_exc ) )
     483             :     {
     484           5 :         Q_exc_old = sub( Q_exc_old, st_fx->Q_exc );
     485           5 :         IF( st_fx->hGSCDec )
     486             :         {
     487           5 :             Scale_sig( st_fx->hGSCDec->last_exc_dct_in_fx, L_FRAME16k, Q_exc_old ); /* Q_exc_old */
     488             :         }
     489           5 :         IF( bwe_exc )
     490             :         {
     491           5 :             Scale_sig( bwe_exc - PIT16k_MAX * 2, ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2, Q_exc_old ); /* Q_exc_old */
     492             :         }
     493             :     }
     494             :     /*--------------------------------------------------------------------------------------*
     495             :      * iDCT transform
     496             :      *--------------------------------------------------------------------------------------*/
     497             : 
     498       13840 :     edct_16fx( dct_epit, exc, st_fx->L_frame, 7, st_fx->element_mode );
     499       13840 :     edct_16fx( exc_wo_nf, exc_wo_nf, st_fx->L_frame, 7, st_fx->element_mode );
     500             :     /*----------------------------------------------------------------------*
     501             :      * Remove potential pre-echo in case an onset has been detected
     502             :      *----------------------------------------------------------------------*/
     503             : 
     504       13840 :     pre_echo_att_fx( &hGSCDec->Last_frame_ener_fx, exc, gsc_attack_flag, st_fx->Q_exc, st_fx->last_coder_type, st_fx->L_frame );
     505             : 
     506             :     /*--------------------------------------------------------------------------------------*
     507             :      * Update BWE excitation
     508             :      *--------------------------------------------------------------------------------------*/
     509             : 
     510       13840 :     IF( st_fx->hBWE_TD != NULL )
     511             :     {
     512       13840 :         set16_fx( voice_factors, 0, NB_SUBFR16k );
     513       13840 :         IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
     514             :         {
     515        2533 :             interp_code_4over2_fx( exc, bwe_exc, st_fx->L_frame );
     516             :         }
     517             :         ELSE
     518             :         {
     519       11307 :             interp_code_5over2_fx( exc, bwe_exc, L_FRAME );
     520             :         }
     521             :     }
     522             :     /*--------------------------------------------------------------------------------------*
     523             :      * Updates
     524             :      *--------------------------------------------------------------------------------------*/
     525             : 
     526       13840 :     Copy( exc, exc2, st_fx->L_frame );      /* Q_exc */
     527       13840 :     Copy( exc_wo_nf, exc, st_fx->L_frame ); /* Q_exc */
     528             : 
     529             :     /*--------------------------------------------------------------------------------------*
     530             :      * Channel aware mode parameters
     531             :      *--------------------------------------------------------------------------------------*/
     532             : 
     533       13840 :     set16_fx( st_fx->tilt_code_dec_fx, 0, NB_SUBFR16k );
     534             : 
     535       13840 :     return;
     536             : }
     537             : 
     538             : /*==========================================================================*/
     539             : /* FUNCTION : void gsc_dec_fx   ()                                                                  */
     540             : /*--------------------------------------------------------------------------*/
     541             : /* PURPOSE  :  Generic audio signal decoder                                 */
     542             : /*--------------------------------------------------------------------------*/
     543             : /*    INPUT ARGUMENTS :                                                                                                 */
     544             : /* _ (Word16) pit_band_idx       : bin position of the cut-off frequency Q0 */
     545             : /* _ (Word16) Diff_len           : Lenght of the difference signal       Q0 */
     546             : /* _ (Word16) coder_type         : coding type                                       Q0 */
     547             : /* _ (Word16) bits_used          : Number of bit used before frequency Q Q0 */
     548             : /* _ (Word16) nb_subfr           : Number of subframe considered         Q0 */
     549             : /* _ (Word16)  Qexc              : Q format of exc_dct_in                               */
     550             : /*--------------------------------------------------------------------------*/
     551             : /* OUTPUT ARGUMENTS :                                                                                                       */
     552             : /* _ None                                                                   */
     553             : /*--------------------------------------------------------------------------*/
     554             : /* INPUT/OUTPUT ARGUMENTS :                                                                                         */
     555             : /*   Decoder_State *st_fx:Decoder State Structure                        */
     556             : /* _ (Word16[]) exc_dct_in : dctof pitch-only excitation / total excitation Qexc*/
     557             : /*--------------------------------------------------------------------------*/
     558             : /* RETURN ARGUMENTS :                                                                                                       */
     559             : /* _None                                                                            */
     560             : /*==========================================================================*/
     561             : 
     562       20795 : void gsc_dec_fx(
     563             :     Decoder_State *st_fx,      /* i/o: State structure                                            */
     564             :     Word16 exc_dct_in[],       /* i/o: dct of pitch-only excitation / total excitation       Q_exc*/
     565             :     const Word16 pit_band_idx, /* i  : bin position of the cut-off frequency               `    Q0*/
     566             :     const Word16 Diff_len,     /* i  : Lenght of the difference signal (before pure spectral)   Q0*/
     567             :     const Word16 bits_used,    /* i  : Number of bit used before frequency Q                                    Q0*/
     568             :     const Word16 nb_subfr,     /* i  : Number of subframe considered                                                    Q0*/
     569             :     const Word16 coder_type,   /* i  : coding type                                                                                              Q0*/
     570             :     Word16 *last_bin,          /* i  : last bin of bit allocation                                                               Q0*/
     571             :     const Word16 *lsf_new,     /* i  : ISFs at the end of the frame                             Qx*/
     572             :     Word16 *exc_wo_nf,         /* o  : excitation (in f domain) without noisefill            Q_exc*/
     573             :     Word16 *Q_exc )
     574             : {
     575             :     Word16 i, j, bit, nb_subbands, pvq_len;
     576             :     Word16 bitallocation_band[MBANDS_GN_BITALLOC16k];
     577             :     Word16 bitallocation_exc[2];
     578             :     Word16 Ener_per_bd_iQ[MBANDS_GN_BITALLOC16k];
     579             :     Word16 max_ener_band[MBANDS_GN_BITALLOC16k];
     580             :     Word16 exc_diffQ[L_FRAME16k];
     581             :     Word16 bits_per_bands[MBANDS_GN_BITALLOC16k];
     582             :     Word16 concat_out[L_FRAME16k];
     583             :     Word16 max_eq, max_eq_val;
     584             :     Word16 inpulses_fx[NB_SFM];
     585             :     Word16 imaxpulse_fx[NB_SFM];
     586             :     Word16 mean_gain;
     587       20795 :     Word16 Mbands_gn = MBANDS_GN;
     588       20795 :     Word16 Qexc_diffQ = Q_PVQ_OUT;
     589             :     Word32 L_tmp;
     590             :     Word16 Q_tmp;
     591             :     Word16 seed_init;
     592             :     GSC_DEC_HANDLE hGSCDec;
     593       20795 :     hGSCDec = st_fx->hGSCDec;
     594             : 
     595       20795 :     move16(); /* for Mbands_gn */
     596       20795 :     move16(); /* for Qexc_diffQ */
     597       20795 :     set16_fx( inpulses_fx, 0, NB_SFM );
     598       20795 :     set16_fx( imaxpulse_fx, 0, NB_SFM );
     599             : 
     600             :     /*--------------------------------------------------------------------------------------*
     601             :      * Initialization
     602             :      *--------------------------------------------------------------------------------------*/
     603       20795 :     bit = bits_used;
     604       20795 :     move16();
     605             : 
     606       20795 :     test();
     607       20795 :     test();
     608       20795 :     test();
     609       20795 :     if ( coder_type == INACTIVE && ( EQ_16( st_fx->tdm_LRTD_flag, 1 ) || EQ_16( st_fx->element_mode, IVAS_SCE ) ) && LE_32( st_fx->core_brate, GSC_LRES_GAINQ_LIMIT ) )
     610             :     {
     611        6302 :         bit = add( bit, GSC_LRES_NB_NITS ); /* Q0 */
     612             :     }
     613             : 
     614       20795 :     if ( EQ_16( st_fx->L_frame, L_FRAME16k ) )
     615             :     {
     616        2537 :         Mbands_gn = MBANDS_GN16k; /* Q0 */
     617        2537 :         move16();
     618             :     }
     619             : 
     620       20795 :     set16_fx( exc_diffQ, 0, st_fx->L_frame );
     621             : 
     622             :     /*--------------------------------------------------------------------------------------*
     623             :      * Gain decoding
     624             :      *--------------------------------------------------------------------------------------*/
     625             : 
     626       20795 :     test();
     627       20795 :     IF( st_fx->bfi || st_fx->BER_detect )
     628             :     {
     629             :         /* copy old gain */
     630         204 :         Copy( hGSCDec->old_y_gain_fx, Ener_per_bd_iQ, Mbands_gn ); /* Q_old_gain */
     631         204 :         mean_gain = mult_r( st_fx->lp_gainc_fx, 3277 );            /*Q3*/
     632        3476 :         FOR( i = 0; i < Mbands_gn; i++ )
     633             :         {
     634        3272 :             Ener_per_bd_iQ[i] = add( Ener_per_bd_iQ[i], shl( mean_gain, 9 ) ); /*Q12*/
     635        3272 :             move16();
     636             :         }
     637             : 
     638         204 :         st_fx->lp_gainc_fx = mult_r( st_fx->lp_gainc_fx, 32112 ); /*Q3*/
     639         204 :         move16();
     640             :     }
     641             :     ELSE
     642             :     {
     643       20591 :         i = 0;
     644       20591 :         move16();
     645       97344 :         WHILE( LT_16( i, SIZE_BRATE_INTERMED_TBL ) )
     646             :         {
     647       97344 :             if ( LE_32( st_fx->core_brate, brate_intermed_tbl[i] ) )
     648             :             {
     649       20591 :                 break;
     650             :             }
     651       76753 :             i++;
     652             :         }
     653             : 
     654       20591 :         test();
     655       20591 :         test();
     656       20591 :         test();
     657       30378 :         if ( st_fx->element_mode > EVS_MONO && EQ_16( coder_type, AUDIO ) &&
     658       16191 :              LE_32( st_fx->core_brate, STEREO_GSC_BIT_RATE_ALLOC ) && EQ_32( brate_intermed_tbl[i], ACELP_9k60 ) ) /* Bit allocation is mapped to 8 kb/s instead of 9.6 kb/s in this case */
     659             :         {
     660        1232 :             i--;
     661             :         }
     662             : 
     663       20591 :         IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
     664             :         {
     665           6 :             mean_gain = gsc_gaindec_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q3 */
     666             :         }
     667             :         ELSE
     668             :         {
     669       20585 :             mean_gain = gsc_gaindec_ivas_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q3 */
     670             :         }
     671             : 
     672       20591 :         st_fx->lp_gainc_fx = mult_r( 640, mean_gain ); /*10 in Q6 x Q12 -> lp_gainc in Q3 */
     673       20591 :         move16();
     674             :     }
     675             : 
     676       20795 :     *last_bin = 0;
     677       20795 :     move16();
     678       20795 :     test();
     679       20795 :     IF( EQ_32( st_fx->core_brate, ACELP_8k00 ) && st_fx->bwidth != NB )
     680             :     {
     681          21 :         bitallocation_exc[0] = 0;
     682          21 :         move16();
     683          21 :         bitallocation_exc[1] = 0;
     684          21 :         move16();
     685             :     }
     686             : 
     687       20795 :     set16_fx( bitallocation_band, 0, MBANDS_GN );
     688             : 
     689       20795 :     test();
     690       20795 :     IF( ( EQ_16( st_fx->bfi, 1 ) ) || st_fx->BER_detect )
     691             :     {
     692             :         /*--------------------------------------------------------------------------------------*
     693             :          * Copy old spectrum
     694             :          * reduce spectral dynamic
     695             :          * save spectrum
     696             :          *--------------------------------------------------------------------------------------*/
     697             : 
     698         204 :         max_eq = 32767;
     699         204 :         move16();
     700             : 
     701         204 :         test();
     702         204 :         IF( EQ_16( st_fx->last_good, INACTIVE_CLAS ) || EQ_16( st_fx->Last_GSC_noisy_speech_flag, 1 ) )
     703             :         {
     704       31096 :             FOR( i = 0; i < st_fx->L_frame; i++ )
     705             :             {
     706       30976 :                 L_tmp = L_shr( L_mult( Random( &hGSCDec->seed_tcx ), 26214 ), 5 ); /*Q10*/
     707       30976 :                 L_tmp = L_mac( L_tmp, hGSCDec->Last_GSC_spectrum_fx[i], 6554 );    /*Q10*/
     708       30976 :                 hGSCDec->Last_GSC_spectrum_fx[i] = round_fx( L_tmp );              /*Q10*/
     709       30976 :                 move16();
     710             :             }
     711             :         }
     712             : 
     713         204 :         Copy( hGSCDec->Last_GSC_spectrum_fx, exc_diffQ, st_fx->L_frame ); /* Q10 */
     714             : 
     715       52684 :         FOR( i = 0; i < st_fx->L_frame; i++ )
     716             :         {
     717       52480 :             hGSCDec->Last_GSC_spectrum_fx[i] = mult_r( hGSCDec->Last_GSC_spectrum_fx[i], 24576 ); /*Q10*/
     718       52480 :             move16();
     719             :         }
     720             :     }
     721             :     ELSE
     722             :     {
     723             :         /*--------------------------------------------------------------------------------------*
     724             :          * PVQ decoder
     725             :          *--------------------------------------------------------------------------------------*/
     726             : 
     727       20591 :         bands_and_bit_alloc_ivas_fx( hGSCDec->cor_strong_limit, hGSCDec->noise_lev, st_fx->core_brate, Diff_len, bit, &bit, Ener_per_bd_iQ,
     728       20591 :                                      max_ener_band, bits_per_bands, &nb_subbands, NULL, NULL, &pvq_len, coder_type, st_fx->bwidth, st_fx->GSC_noisy_speech,
     729       20591 :                                      st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode );
     730             : 
     731       20591 :         IF( bit == 0 )
     732             :         {
     733           0 :             set16_fx( concat_out, 0, L_FRAME16k );
     734             :         }
     735             : 
     736       20591 :         pvq_core_dec_fx( st_fx, gsc_sfm_start, gsc_sfm_end, gsc_sfm_size, concat_out, &Q_tmp, bit, nb_subbands, bits_per_bands, NULL, inpulses_fx, imaxpulse_fx, ACELP_CORE );
     737       20591 :         IF( nb_subbands > 0 )
     738             :         {
     739       20591 :             Scale_sig( concat_out, gsc_sfm_end[nb_subbands - 1], sub( Q_PVQ_OUT, Q_tmp ) ); /* Q_PVQ_OUT */
     740             :         }
     741             : 
     742       20591 :         seed_init = 0;
     743       20591 :         move16();
     744             : 
     745       20591 :         max_eq = 0;
     746       20591 :         move16();
     747       20591 :         max_eq_val = 32767; /* 1.0f in Q15 */
     748       20591 :         move16();
     749             : 
     750       20591 :         test();
     751       20591 :         test();
     752       20591 :         test();
     753       20591 :         IF( ( ( LT_32( st_fx->core_brate, ACELP_7k20 ) && EQ_16( st_fx->GSC_noisy_speech, 1 ) ) || LT_32( st_fx->core_brate, 6000 ) ) && LE_16( coder_type, UNVOICED ) )
     754             :         {
     755        6689 :             j = maximum_fx( concat_out, imult1616( nb_subbands, 16 ), &max_eq );
     756        6689 :             Word16 temp_max_eq = add( abs_s( concat_out[j] ), 10 ) /*0.01f in Q10*/;
     757        6689 :             if ( LE_16( temp_max_eq, ONE_IN_Q10 ) )
     758             :             {
     759        6307 :                 max_eq = max_eq_val; /* Q15 */
     760        6307 :                 move16();
     761             :             }
     762             :             ELSE
     763             :             {
     764         382 :                 Word16 exp = 5;
     765         382 :                 move16();
     766         382 :                 max_eq = Inv16( temp_max_eq, &exp );
     767         382 :                 max_eq = shl( max_eq, exp ); /* Q15 */
     768             :             }
     769             :         }
     770             : 
     771             :         /* Reorder Q bands */
     772      167576 :         FOR( j = 0; j < nb_subbands; j++ )
     773             :         {
     774      146985 :             Copy( concat_out + imult1616( j, 16 ), exc_diffQ + imult1616( max_ener_band[j], 16 ), 16 ); /* Q_PVQ_OUT */
     775             : 
     776      146985 :             *last_bin = s_max( *last_bin, max_ener_band[j] ); /* Q0 */
     777      146985 :             move16();
     778             : 
     779      146985 :             bitallocation_band[max_ener_band[j]] = 1; /* Q0 */
     780      146985 :             move16();
     781             : 
     782      146985 :             seed_init = add( seed_init, inpulses_fx[j] ); /* Q0 */
     783             :         }
     784       20591 :         test();
     785       20591 :         IF( NE_16( st_fx->last_coder_type, AUDIO )         /* First audio frame */
     786             :             && NE_16( st_fx->last_coder_type, UNVOICED ) ) /* last_coder_type == INACTIVE is overwritten in update_dec to UNVOICED */
     787             :         {
     788      377714 :             FOR( j = 0; j < shl( nb_subbands, 4 ); j++ )
     789             :             {
     790      374896 :                 IF( concat_out[j] > 0 )
     791             :                 {
     792       57222 :                     seed_init = extract_l( L_shl( seed_init, 3 ) ); /* Q0 */
     793             :                 }
     794      374896 :                 if ( concat_out[j] < 0 )
     795             :                 {
     796       57131 :                     seed_init = add_sat( seed_init, 3 ); /* Q0 */
     797             :                 }
     798             :             }
     799             : 
     800        2818 :             hGSCDec->seed_tcx = seed_init; /* Q0 */
     801        2818 :             move16();
     802             :         }
     803       20591 :         test();
     804       20591 :         IF( EQ_32( st_fx->core_brate, ACELP_8k00 ) && st_fx->bwidth != NB )
     805             :         {
     806          21 :             if ( exc_diffQ[L_FRAME8k - 2] != 0 )
     807             :             {
     808           0 :                 bitallocation_exc[0] = 1; /* Q0 */
     809           0 :                 move16();
     810             :             }
     811             : 
     812          21 :             if ( exc_diffQ[L_FRAME8k - 1] != 0 )
     813             :             {
     814           3 :                 bitallocation_exc[1] = 1; /* Q0 */
     815           3 :                 move16();
     816             :             }
     817             :         }
     818             : 
     819       20591 :         Copy( exc_diffQ, hGSCDec->Last_GSC_spectrum_fx, st_fx->L_frame ); /* Q_PVQ_OUT */
     820             : 
     821             :         /*--------------------------------------------------------------------------------------*
     822             :          * Skip adaptive (pitch) contribution frequency band (no noise added over the time contribution)
     823             :          * Find x pulses between 1.6-3.2kHz to code in the spectrum of the residual signal
     824             :          * Gain is based on the inter-correlation gain between the pulses found and residual signal
     825             :          *--------------------------------------------------------------------------------------*/
     826             : 
     827       20591 :         test();
     828       20591 :         test();
     829       20591 :         test();
     830       20591 :         test();
     831       20591 :         IF( GE_16( st_fx->GSC_IVAS_mode, 1 ) && EQ_16( st_fx->GSC_noisy_speech, 1 ) )
     832             :         {
     833       19107 :             FOR( i = 64; i < st_fx->L_frame; i++ )
     834             :             {
     835       19008 :                 exc_diffQ[i] = mult_r( exc_diffQ[i], max_eq ); /* Q_PVQ_OUT */
     836       19008 :                 move16();
     837             :             }
     838             :         }
     839       20492 :         ELSE IF( ( ( LT_32( st_fx->core_brate, ACELP_7k20 ) && EQ_16( st_fx->GSC_noisy_speech, 1 ) ) || LT_32( st_fx->core_brate, 6000 ) ) && LE_16( st_fx->coder_type, UNVOICED ) )
     840             :         {
     841     1719073 :             FOR( i = 0; i < L_FRAME; i++ )
     842             :             {
     843     1712384 :                 exc_diffQ[i] = mult_r( exc_diffQ[i], max_eq ); /* Q_PVQ_OUT */
     844     1712384 :                 move16();
     845             :             }
     846             :         }
     847             :         ELSE
     848             :         {
     849       13803 :             freq_dnw_scaling_fx( hGSCDec->cor_strong_limit, st_fx->coder_type, hGSCDec->noise_lev, st_fx->core_brate, exc_diffQ, Qexc_diffQ, st_fx->L_frame );
     850             :         }
     851             :     }
     852             : 
     853             :     /*--------------------------------------------------------------------------------------*
     854             :      * Estimate noise level
     855             :      *--------------------------------------------------------------------------------------*/
     856             : 
     857       20795 :     highband_exc_dct_in_ivas_fx( st_fx->core_brate, mfreq_bindiv_loc, *last_bin, Diff_len, hGSCDec->noise_lev, pit_band_idx, exc_diffQ,
     858       20795 :                                  &hGSCDec->seed_tcx, Ener_per_bd_iQ, nb_subfr, exc_dct_in, st_fx->last_coder_type, bitallocation_band, lsf_new,
     859       20795 :                                  hGSCDec->last_exc_dct_in_fx, &hGSCDec->last_ener_fx, hGSCDec->last_bitallocation_band, bitallocation_exc, st_fx->bfi, coder_type,
     860       20795 :                                  st_fx->bwidth, exc_wo_nf, Qexc_diffQ, Q_exc, st_fx->GSC_noisy_speech, hGSCDec->lt_ener_per_band_fx, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode );
     861             : 
     862       20795 :     exc_dct_in[0] = 0;
     863       20795 :     move16();
     864             : 
     865       20795 :     return;
     866             : }
     867             : 
     868             : /*-------------------------------------------------------------------*
     869             :  * GSC_dec_init()
     870             :  *
     871             :  * Initialize GSC decoder state structure
     872             :  *-------------------------------------------------------------------*/
     873             : 
     874           3 : void GSC_dec_init(
     875             :     GSC_DEC_HANDLE hGSCDec /* i/o: GSC data handle  */
     876             : )
     877             : {
     878           3 :     hGSCDec->seed_tcx = 15687; /* Q0 */
     879           3 :     hGSCDec->cor_strong_limit = 1;
     880           3 :     move16();
     881           3 :     move16();
     882             : 
     883           3 :     hGSCDec->noise_lev = NOISE_LEVEL_SP0; /* Q0 */
     884           3 :     hGSCDec->Last_GSC_pit_band_idx = 0;
     885           3 :     move16();
     886           3 :     move16();
     887             : 
     888           3 :     set16_fx( hGSCDec->Last_GSC_spectrum_fx, 0, L_FRAME );
     889           3 :     set16_fx( hGSCDec->last_exc_dct_in_fx, 0, L_FRAME );
     890           3 :     set16_fx( hGSCDec->old_y_gain_fx, 0, MBANDS_GN );
     891           3 :     set16_fx( hGSCDec->lt_ener_per_band_fx, 4096, MBANDS_GN ); /*Q12*/
     892             : 
     893           3 :     hGSCDec->last_ener_fx = 0;
     894           3 :     move16();
     895           3 :     set16_fx( hGSCDec->last_bitallocation_band, 0, 6 );
     896             : 
     897           3 :     hGSCDec->Last_frame_ener_fx = MAX_32;
     898           3 :     move32();
     899           3 :     return;
     900             : }
     901             : 
     902        3441 : void GSC_dec_init_ivas_fx(
     903             :     GSC_DEC_HANDLE hGSCDec /* i/o: GSC data handle  */
     904             : )
     905             : {
     906        3441 :     hGSCDec->seed_tcx = 15687; /* Q0 */
     907        3441 :     move16();
     908        3441 :     hGSCDec->cor_strong_limit = 1;
     909        3441 :     move16();
     910        3441 :     set16_fx( hGSCDec->old_y_gain_fx, 0, MBANDS_GN );
     911        3441 :     hGSCDec->noise_lev = NOISE_LEVEL_SP0;
     912        3441 :     move16();
     913        3441 :     set16_fx( hGSCDec->Last_GSC_spectrum_fx, 0, L_FRAME16k );
     914        3441 :     hGSCDec->Last_GSC_pit_band_idx = 0;
     915        3441 :     move16();
     916             : 
     917        3441 :     set16_fx( hGSCDec->lt_ener_per_band_fx, 4096, MBANDS_GN16k ); /*Q12*/
     918        3441 :     set16_fx( hGSCDec->last_exc_dct_in_fx, 0, L_FRAME16k );
     919        3441 :     hGSCDec->last_ener_fx = 0;
     920        3441 :     move16();
     921        3441 :     set16_fx( hGSCDec->last_bitallocation_band, 0, 6 );
     922             : 
     923        3441 :     hGSCDec->Last_frame_ener_fx = MAX_32;
     924        3441 :     move32();
     925             : 
     926        3441 :     return;
     927             : }

Generated by: LCOV version 1.14