LCOV - code coverage report
Current view: top level - lib_dec - decision_matrix_dec_fx.c (source / functions) Hit Total Coverage
Test: Coverage on main enc/dec/rend @ 3b2f07138c61dcf997bbf4165d0882f794b2995f Lines: 189 416 45.4 %
Date: 2025-05-03 01:55:50 Functions: 1 1 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 "prot_fx.h"
       8             : #include "stat_dec.h"
       9             : #include "rom_com.h"
      10             : #include "stl.h"
      11             : 
      12             : 
      13             : /*-----------------------------------------------------------------*
      14             :  * decision_matrix_dec()
      15             :  *
      16             :  * ACELP/HQ core selection
      17             :  * Read ACELP signaling bits from the bitstream
      18             :  * Set extension layers
      19             :  *-----------------------------------------------------------------*/
      20        1852 : void decision_matrix_dec_fx(
      21             :     Decoder_State *st,          /* i/o: decoder state structure                   */
      22             :     Word16 *sharpFlag,          /* o  : formant sharpening flag Q0                */
      23             :     Word16 *hq_core_type,       /* o  : HQ core type Q0                           */
      24             :     Word16 *core_switching_flag /* o  : ACELP->HQ switching frame flag Q0         */
      25             : )
      26             : {
      27             :     Word16 start_idx;
      28             :     Word16 ppp_nelp_mode;
      29             :     Word32 ind;
      30             :     Word16 nBits;
      31             :     Word16 tmp16, temp_core;
      32             : 
      33             :     /* init */
      34        1852 :     st->core = -1;
      35        1852 :     move16();
      36        1852 :     st->core_brate = L_deposit_l( 0 );
      37        1852 :     st->extl = -1;
      38        1852 :     move16();
      39        1852 :     st->extl_brate = 0;
      40        1852 :     move16();
      41        1852 :     st->ppp_mode_dec = 0;
      42        1852 :     move16();
      43        1852 :     st->nelp_mode_dec = 0;
      44        1852 :     move16();
      45        1852 :     st->igf = 0;
      46        1852 :     move16();
      47             : 
      48        1852 :     IF( GT_32( st->total_brate, ACELP_8k00 ) )
      49             :     {
      50        1852 :         st->vbr_hw_BWE_disable_dec = 0;
      51        1852 :         move16();
      52             :     }
      53             : 
      54        1852 :     IF( EQ_16( st->mdct_sw, MODE2 ) )
      55             :     {
      56          66 :         st->core = HQ_CORE;
      57          66 :         move16();
      58             :     }
      59             :     ELSE
      60             :     {
      61        1786 :         test();
      62        1786 :         IF( ( st->total_brate == FRAME_NO_DATA ) || EQ_32( st->total_brate, SID_2k40 ) )
      63             :         {
      64           0 :             st->core = ACELP_CORE;
      65           0 :             move16();
      66           0 :             st->core_brate = st->total_brate;
      67           0 :             move32();
      68             : 
      69           0 :             IF( st->total_brate != FRAME_NO_DATA )
      70             :             {
      71           0 :                 st->cng_type = get_next_indice_fx( st, 1 ); // Q0
      72             : 
      73           0 :                 IF( st->cng_type == LP_CNG )
      74             :                 {
      75           0 :                     st->L_frame = L_FRAME;
      76           0 :                     move16();
      77             : 
      78           0 :                     tmp16 = get_next_indice_fx( st, 1 ); // Q0
      79           0 :                     if ( EQ_16( tmp16, 1 ) )
      80             :                     {
      81           0 :                         st->L_frame = L_FRAME16k;
      82           0 :                         move16();
      83             :                     }
      84             :                 }
      85             :                 ELSE
      86             :                 {
      87           0 :                     st->bwidth = get_next_indice_fx( st, 2 ); // Q0
      88             : 
      89           0 :                     tmp16 = get_next_indice_fx( st, 1 ); // Q0
      90           0 :                     move16();
      91             : 
      92           0 :                     st->L_frame = L_FRAME16k;
      93           0 :                     move16();
      94           0 :                     if ( tmp16 == 0 )
      95             :                     {
      96           0 :                         st->L_frame = L_FRAME;
      97           0 :                         move16();
      98             :                     }
      99             :                 }
     100             :             }
     101             : 
     102           0 :             test();
     103           0 :             if ( GE_32( st->output_Fs, 32000 ) && GE_16( st->bwidth, SWB ) )
     104             :             {
     105           0 :                 st->extl = SWB_CNG;
     106           0 :                 move16();
     107             :             }
     108             : 
     109           0 :             test();
     110           0 :             test();
     111           0 :             test();
     112           0 :             if ( ( st->total_brate == FRAME_NO_DATA ) && st->prev_bfi && !st->bfi && GT_16( st->L_frame, L_FRAME16k ) )
     113             :             {
     114           0 :                 st->L_frame = st->last_CNG_L_frame;
     115           0 :                 move16();
     116             :             }
     117             : 
     118           0 :             return;
     119             :         }
     120             : 
     121             :         /* SC-VBR */
     122        1786 :         ELSE IF( EQ_32( st->total_brate, PPP_NELP_2k80 ) )
     123             :         {
     124           0 :             st->core = ACELP_CORE;
     125           0 :             move16();
     126           0 :             st->core_brate = PPP_NELP_2k80;
     127           0 :             move32();
     128           0 :             st->L_frame = L_FRAME;
     129           0 :             move16();
     130           0 :             st->fscale = sr2fscale_fx( INT_FS_FX ); // Q0
     131           0 :             move16();
     132             : 
     133           0 :             IF( st->ini_frame == 0 )
     134             :             {
     135             :                 /* avoid switching of internal ACELP Fs in the very first frame */
     136           0 :                 st->last_L_frame = st->L_frame;
     137           0 :                 move16();
     138           0 :                 st->last_core = st->core;
     139           0 :                 move16();
     140           0 :                 st->last_core_brate = st->core_brate;
     141           0 :                 move32();
     142           0 :                 st->last_extl = st->extl;
     143           0 :                 move16();
     144             :             }
     145             : 
     146           0 :             st->vbr_hw_BWE_disable_dec = 1;
     147           0 :             move16();
     148           0 :             get_next_indice_fx( st, 1 ); // Q0
     149             : 
     150           0 :             ppp_nelp_mode = get_next_indice_fx( st, 2 ); // Q0
     151             : 
     152             :             /* 0 - PPP_NB, 1 - PPP_WB, 2 - NELP_NB, 3 - NELP_WB */
     153           0 :             IF( ppp_nelp_mode == 0 )
     154             :             {
     155           0 :                 st->ppp_mode_dec = 1;
     156           0 :                 move16();
     157           0 :                 st->coder_type = VOICED;
     158           0 :                 move16();
     159           0 :                 st->bwidth = NB;
     160           0 :                 move16();
     161             :             }
     162           0 :             ELSE IF( EQ_16( ppp_nelp_mode, 1 ) )
     163             :             {
     164           0 :                 st->ppp_mode_dec = 1;
     165           0 :                 move16();
     166           0 :                 st->coder_type = VOICED;
     167           0 :                 move16();
     168           0 :                 st->bwidth = WB;
     169           0 :                 move16();
     170             :             }
     171           0 :             ELSE IF( EQ_16( ppp_nelp_mode, 2 ) )
     172             :             {
     173           0 :                 st->nelp_mode_dec = 1;
     174           0 :                 move16();
     175           0 :                 st->coder_type = UNVOICED;
     176           0 :                 move16();
     177           0 :                 st->bwidth = NB;
     178           0 :                 move16();
     179             :             }
     180           0 :             ELSE IF( EQ_16( ppp_nelp_mode, 3 ) )
     181             :             {
     182           0 :                 st->nelp_mode_dec = 1;
     183           0 :                 move16();
     184           0 :                 st->coder_type = UNVOICED;
     185           0 :                 move16();
     186           0 :                 st->bwidth = WB;
     187           0 :                 move16();
     188             :             }
     189             : 
     190             : 
     191           0 :             return;
     192             :         }
     193             : 
     194             :         /*---------------------------------------------------------------------*
     195             :          * ACELP/HQ core selection
     196             :          *---------------------------------------------------------------------*/
     197             : 
     198        1786 :         test();
     199        1786 :         IF( LT_32( st->total_brate, ACELP_24k40 ) )
     200             :         {
     201         786 :             st->core = ACELP_CORE;
     202         786 :             move16();
     203             :         }
     204        1000 :         ELSE IF( GE_32( st->total_brate, ACELP_24k40 ) && LE_32( st->total_brate, ACELP_64k ) )
     205             :         {
     206             :             /* read the ACELP/HQ core selection bit */
     207        1000 :             temp_core = get_next_indice_fx( st, 1 ); // Q0
     208             : 
     209        1000 :             st->core = HQ_CORE;
     210        1000 :             move16();
     211        1000 :             if ( temp_core == 0 )
     212             :             {
     213         669 :                 st->core = ACELP_CORE;
     214         669 :                 move16();
     215             :             }
     216             :         }
     217             :     }
     218             : 
     219             :     /*-----------------------------------------------------------------*
     220             :      * Read ACELP signaling bits from the bitstream
     221             :      *-----------------------------------------------------------------*/
     222             : 
     223        1852 :     IF( st->core == ACELP_CORE )
     224             :     {
     225             :         /* find the section in the ACELP signaling table corresponding to bitrate */
     226        1455 :         start_idx = 0;
     227        1455 :         move16();
     228       85044 :         WHILE( NE_32( acelp_sig_tbl[start_idx], st->total_brate ) )
     229             :         {
     230       83589 :             start_idx = add( start_idx, 1 );
     231       83589 :             IF( GE_16( start_idx, MAX_ACELP_SIG ) )
     232             :             {
     233           0 :                 st->BER_detect = 1;
     234           0 :                 move16();
     235           0 :                 start_idx = 0;
     236           0 :                 move16();
     237           0 :                 BREAK;
     238             :             }
     239             :         }
     240             : 
     241             :         /* skip the bitrate */
     242        1455 :         start_idx = add( start_idx, 1 );
     243             : 
     244             :         /* retrieve the number of bits */
     245        1455 :         nBits = extract_l( acelp_sig_tbl[start_idx] );
     246        1455 :         start_idx = add( start_idx, 1 );
     247             : 
     248        1455 :         start_idx = add( start_idx, get_next_indice_fx( st, nBits ) ); // Q0
     249        1455 :         IF( GE_16( start_idx, MAX_ACELP_SIG ) )
     250             :         {
     251           0 :             ind = 0;
     252           0 :             move32();
     253           0 :             st->BER_detect = 1;
     254           0 :             move16();
     255             :         }
     256             :         ELSE
     257             :         {
     258             :             /* retrieve the signaling indice */
     259        1455 :             ind = acelp_sig_tbl[start_idx];
     260        1455 :             move32();
     261             : 
     262             :             /* convert signaling indice into signaling information */
     263        1455 :             st->coder_type = extract_l( L_and( ind, 0x7L ) ); // Q0
     264        1455 :             IF( EQ_16( st->coder_type, LR_MDCT ) )
     265             :             {
     266          32 :                 st->core = HQ_CORE;
     267          32 :                 move16();
     268          32 :                 st->bwidth = extract_l( L_and( L_shr( ind, 3 ), 0x7L ) ); // Q0
     269          32 :                 move16();
     270             :             }
     271             :             ELSE
     272             :             {
     273        1423 :                 st->bwidth = extract_l( L_and( L_shr( ind, 3 ), 0x7L ) ); // Q0
     274        1423 :                 move16();
     275        1423 :                 *sharpFlag = extract_l( L_and( L_shr( ind, 6 ), 0x1L ) ); // Q0
     276        1423 :                 move16();
     277             :             }
     278             :         }
     279             : 
     280             :         /* detect corrupted signaling (due to bit errors) */
     281        1455 :         test();
     282        1455 :         test();
     283        1455 :         test();
     284        1455 :         test();
     285        1455 :         test();
     286        1455 :         test();
     287        1455 :         test();
     288        1455 :         test();
     289        1455 :         test();
     290        1455 :         test();
     291        1455 :         test();
     292        1455 :         test();
     293        1455 :         test();
     294        1455 :         test();
     295        1455 :         test();
     296        1455 :         test();
     297        1455 :         IF( ( st->BER_detect ) ||
     298             :             ( GE_32( ind, 1 << 7 ) ) ||
     299             :             ( LE_32( st->total_brate, ACELP_13k20 ) && EQ_16( st->bwidth, FB ) ) ||
     300             :             ( GE_32( st->total_brate, ACELP_32k ) && ( st->bwidth == NB ) ) ||
     301             :             ( GE_32( st->total_brate, ACELP_32k ) && !( EQ_16( st->coder_type, GENERIC ) || EQ_16( st->coder_type, TRANSITION ) || ( st->coder_type == INACTIVE ) ) ) ||
     302             :             ( LT_32( st->total_brate, ACELP_13k20 ) && ( st->bwidth != NB ) && EQ_16( st->coder_type, LR_MDCT ) ) ||
     303             :             ( GE_32( st->total_brate, ACELP_13k20 ) && EQ_16( st->coder_type, UNVOICED ) ) ||
     304             :             ( GE_32( st->total_brate, ACELP_13k20 ) && EQ_16( st->coder_type, AUDIO ) && ( st->bwidth == NB ) ) )
     305             :         {
     306           0 :             st->BER_detect = 0;
     307           0 :             move16();
     308           0 :             st->bfi = 1;
     309           0 :             move16();
     310             : 
     311           0 :             IF( st->ini_frame == 0 )
     312             :             {
     313           0 :                 st->core = ACELP_CORE;
     314           0 :                 move16();
     315           0 :                 st->L_frame = L_FRAME;
     316           0 :                 move16();
     317           0 :                 st->last_core = st->core;
     318           0 :                 move16();
     319           0 :                 st->last_core_brate = st->core_brate;
     320           0 :                 move32();
     321             :             }
     322           0 :             ELSE IF( EQ_32( st->last_total_brate, -1 ) ) /* can happen in case of BER when no good frame was received before */
     323             :             {
     324           0 :                 st->coder_type = st->last_coder_type;
     325           0 :                 move16();
     326           0 :                 st->bwidth = st->last_bwidth;
     327           0 :                 move16();
     328           0 :                 st->total_brate = st->last_total_brate_ber;
     329           0 :                 move32();
     330           0 :                 test();
     331           0 :                 IF( EQ_16( st->last_core, AMR_WB_CORE ) )
     332             :                 {
     333           0 :                     st->core = ACELP_CORE;
     334           0 :                     move16();
     335           0 :                     st->codec_mode = MODE1;
     336           0 :                     move16();
     337             :                 }
     338           0 :                 ELSE IF( EQ_16( st->last_core_bfi, TCX_20_CORE ) || EQ_16( st->last_core_bfi, TCX_10_CORE ) )
     339             :                 {
     340           0 :                     st->core = st->last_core_bfi;
     341           0 :                     move16();
     342           0 :                     st->codec_mode = MODE2;
     343           0 :                     move16();
     344             :                 }
     345             :                 ELSE
     346             :                 {
     347           0 :                     st->core = st->last_core;
     348           0 :                     move16();
     349           0 :                     st->codec_mode = MODE1;
     350           0 :                     move16();
     351             :                 }
     352           0 :                 st->core_brate = st->last_core_brate;
     353           0 :                 move32();
     354           0 :                 st->extl = st->last_extl;
     355           0 :                 move16();
     356           0 :                 st->extl_brate = L_sub( st->total_brate, st->core_brate );
     357           0 :                 move32();
     358             :             }
     359             :             ELSE
     360             :             {
     361           0 :                 st->coder_type = st->last_coder_type;
     362           0 :                 move16();
     363           0 :                 st->bwidth = st->last_bwidth;
     364           0 :                 move16();
     365           0 :                 st->total_brate = st->last_total_brate;
     366           0 :                 move16();
     367             : 
     368           0 :                 test();
     369           0 :                 IF( EQ_16( st->last_core, AMR_WB_CORE ) )
     370             :                 {
     371           0 :                     st->core = ACELP_CORE;
     372           0 :                     move16();
     373           0 :                     st->codec_mode = MODE1;
     374           0 :                     move16();
     375             :                 }
     376           0 :                 ELSE IF( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) )
     377             :                 {
     378           0 :                     st->core = st->last_core;
     379           0 :                     move16();
     380           0 :                     st->codec_mode = MODE2;
     381           0 :                     move16();
     382             :                 }
     383             :                 ELSE
     384             :                 {
     385           0 :                     st->core = st->last_core;
     386           0 :                     move16();
     387           0 :                     st->codec_mode = MODE1;
     388           0 :                     move16();
     389             :                 }
     390           0 :                 st->core_brate = st->last_core_brate;
     391           0 :                 move32();
     392           0 :                 st->extl = st->last_extl;
     393           0 :                 move16();
     394           0 :                 st->extl_brate = L_sub( st->total_brate, st->core_brate );
     395             :             }
     396             : 
     397           0 :             return;
     398             :         }
     399             :     }
     400             : 
     401             :     /*-----------------------------------------------------------------*
     402             :      * Set extension layers
     403             :      *-----------------------------------------------------------------*/
     404             : 
     405        1852 :     test();
     406        1852 :     test();
     407        1852 :     test();
     408        1852 :     test();
     409        1852 :     test();
     410        1852 :     test();
     411        1852 :     test();
     412        1852 :     test();
     413        1852 :     test();
     414        1852 :     test();
     415        1852 :     test();
     416        1852 :     test();
     417        1852 :     test();
     418        1852 :     test();
     419        1852 :     IF( EQ_16( st->core, ACELP_CORE ) && EQ_16( st->bwidth, WB ) && LT_32( st->total_brate, ACELP_9k60 ) )
     420             :     {
     421           0 :         if ( st->vbr_hw_BWE_disable_dec == 0 )
     422             :         {
     423           0 :             st->extl = WB_BWE;
     424           0 :             move16();
     425             :         }
     426             :     }
     427        1852 :     ELSE IF( EQ_16( st->core, ACELP_CORE ) && EQ_16( st->bwidth, WB ) && GE_32( st->total_brate, ACELP_9k60 ) && LE_32( st->total_brate, ACELP_16k40 ) )
     428             :     {
     429             :         /* read the WB TBE/BWE selection bit */
     430           0 :         tmp16 = get_next_indice_fx( st, 1 ); // Q0
     431           0 :         IF( EQ_16( tmp16, 1 ) )
     432             :         {
     433           0 :             st->extl = WB_BWE;
     434           0 :             move16();
     435           0 :             st->extl_brate = WB_BWE_0k35;
     436           0 :             move32();
     437             :         }
     438             :         ELSE
     439             :         {
     440           0 :             st->extl = WB_TBE;
     441           0 :             move16();
     442           0 :             st->extl_brate = WB_TBE_1k05;
     443           0 :             move32();
     444             :         }
     445             :     }
     446        1852 :     ELSE IF( EQ_16( st->core, ACELP_CORE ) && ( EQ_16( st->bwidth, SWB ) || EQ_16( st->bwidth, FB ) ) && GE_32( st->total_brate, ACELP_13k20 ) )
     447             :     {
     448        1423 :         IF( GE_32( st->total_brate, ACELP_48k ) )
     449             :         {
     450         669 :             st->extl = SWB_BWE_HIGHRATE;
     451         669 :             move16();
     452         669 :             if ( EQ_16( st->bwidth, FB ) )
     453             :             {
     454           0 :                 st->extl = FB_BWE_HIGHRATE;
     455           0 :                 move16();
     456             :             }
     457             : 
     458         669 :             st->extl_brate = SWB_BWE_16k;
     459         669 :             move32();
     460             :         }
     461             : 
     462             :         /* read the SWB TBE/BWE selection bit */
     463             :         ELSE
     464             :         {
     465         754 :             tmp16 = get_next_indice_fx( st, 1 );
     466         754 :             IF( tmp16 )
     467             :             {
     468           6 :                 st->extl = SWB_BWE;
     469           6 :                 move16();
     470           6 :                 st->extl_brate = SWB_BWE_1k6;
     471           6 :                 move32();
     472             :             }
     473             :             ELSE
     474             :             {
     475         748 :                 st->extl = SWB_TBE;
     476         748 :                 move16();
     477         748 :                 st->extl_brate = SWB_TBE_1k6;
     478         748 :                 move32();
     479         748 :                 if ( GE_32( st->total_brate, ACELP_24k40 ) )
     480             :                 {
     481           0 :                     st->extl_brate = SWB_TBE_2k8;
     482           0 :                     move32();
     483             :                 }
     484             :             }
     485             :         }
     486             : 
     487             :         /* set FB TBE and FB BWE extension layers */
     488        1423 :         test();
     489        1423 :         IF( EQ_16( st->bwidth, FB ) && GE_32( st->total_brate, ACELP_24k40 ) )
     490             :         {
     491           0 :             IF( EQ_16( st->extl, SWB_BWE ) )
     492             :             {
     493           0 :                 st->extl = FB_BWE;
     494           0 :                 move16();
     495           0 :                 st->extl_brate = FB_BWE_1k8;
     496           0 :                 move32();
     497             :             }
     498           0 :             ELSE IF( EQ_16( st->extl, SWB_TBE ) )
     499             :             {
     500           0 :                 st->extl = FB_TBE;
     501           0 :                 move16();
     502             :                 {
     503           0 :                     st->extl_brate = FB_TBE_3k0;
     504           0 :                     move32();
     505             :                 }
     506             :             }
     507             :         }
     508             :     }
     509             : 
     510             :     /* set core bitrate */
     511        1852 :     st->core_brate = L_sub( st->total_brate, st->extl_brate );
     512        1852 :     move32();
     513             : 
     514             :     /*-----------------------------------------------------------------*
     515             :      * Read HQ signaling bits from the bitstream
     516             :      * Set HQ core type
     517             :      *-----------------------------------------------------------------*/
     518             : 
     519             : 
     520        1852 :     IF( EQ_16( st->core, HQ_CORE ) )
     521             :     {
     522         429 :         IF( NE_16( st->mdct_sw, MODE2 ) )
     523             :         {
     524             :             /* skip the HQ/TCX core switching flag */
     525         363 :             get_next_indice_tmp_fx( st, 1 ); // Q0
     526             :         }
     527             : 
     528             :         /* read ACELP->HQ core switching flag */
     529         429 :         *core_switching_flag = get_next_indice_fx( st, 1 ); // Q0
     530             : 
     531         429 :         IF( EQ_16( *core_switching_flag, 1 ) )
     532             :         {
     533          24 :             st->last_L_frame_ori = st->last_L_frame;
     534          24 :             move16();
     535             : 
     536             :             /* read ACELP L_frame info */
     537          24 :             st->last_L_frame = L_FRAME16k;
     538          24 :             move16();
     539          24 :             tmp16 = get_next_indice_fx( st, 1 ); // Q0
     540          24 :             if ( tmp16 == 0 )
     541             :             {
     542           5 :                 st->last_L_frame = L_FRAME;
     543           5 :                 move16();
     544             :             }
     545             :         }
     546             : 
     547         429 :         IF( NE_16( st->mdct_sw, MODE2 ) )
     548             :         {
     549             : 
     550             :             /* read/set band-width (needed for different I/O sampling rate support) */
     551         363 :             IF( GT_32( st->total_brate, ACELP_16k40 ) )
     552             :             {
     553         331 :                 tmp16 = get_next_indice_fx( st, 2 ); // Q0
     554             : 
     555         331 :                 IF( tmp16 == 0 )
     556             :                 {
     557           0 :                     st->bwidth = NB;
     558           0 :                     move16();
     559             :                 }
     560         331 :                 ELSE IF( EQ_16( tmp16, 1 ) )
     561             :                 {
     562           0 :                     st->bwidth = WB;
     563           0 :                     move16();
     564             :                 }
     565         331 :                 ELSE IF( EQ_16( tmp16, 2 ) )
     566             :                 {
     567         331 :                     st->bwidth = SWB;
     568         331 :                     move16();
     569             :                 }
     570             :                 ELSE
     571             :                 {
     572           0 :                     st->bwidth = FB;
     573           0 :                     move16();
     574             :                 }
     575             :             }
     576             :         }
     577             : 
     578             :         /* detect bit errors in signaling */
     579         429 :         test();
     580         429 :         test();
     581         429 :         test();
     582         429 :         test();
     583         429 :         IF( ( GE_32( st->total_brate, ACELP_24k40 ) && ( st->bwidth == NB ) ) ||
     584             :             ( EQ_16( st->core, HQ_CORE ) && LE_32( st->total_brate, LRMDCT_CROSSOVER_POINT ) && EQ_16( st->bwidth, FB ) ) )
     585             :         {
     586           0 :             st->bfi = 1;
     587           0 :             move16();
     588             : 
     589           0 :             st->core_brate = st->total_brate;
     590           0 :             move32();
     591           0 :             st->extl = -1;
     592           0 :             move16();
     593           0 :             st->extl_brate = 0;
     594           0 :             move32();
     595           0 :             IF( EQ_16( st->last_core, AMR_WB_CORE ) )
     596             :             {
     597           0 :                 st->core = ACELP_CORE;
     598           0 :                 move16();
     599           0 :                 st->L_frame = L_FRAME;
     600           0 :                 move16();
     601           0 :                 st->codec_mode = MODE1;
     602           0 :                 move16();
     603           0 :                 st->last_L_frame = L_FRAME;
     604           0 :                 move16();
     605             : 
     606           0 :                 IF( GE_32( st->total_brate, ACELP_16k40 ) )
     607             :                 {
     608           0 :                     st->total_brate = ACELP_13k20;
     609           0 :                     move32();
     610           0 :                     st->core_brate = st->total_brate;
     611           0 :                     move32();
     612             :                 }
     613             :             }
     614             :             ELSE
     615             :             {
     616             :                 /* make sure, we are in a valid configuration wrt to bandwidth */
     617           0 :                 st->bwidth = WB;
     618           0 :                 move16();
     619             :             }
     620             :         }
     621             : 
     622             :         /* set HQ core type */
     623         429 :         *hq_core_type = NORMAL_HQ_CORE;
     624         429 :         move16();
     625             : 
     626         429 :         test();
     627         429 :         test();
     628         429 :         IF( ( EQ_16( st->bwidth, SWB ) || EQ_16( st->bwidth, WB ) ) && LE_32( st->total_brate, LRMDCT_CROSSOVER_POINT ) )
     629             :         {
     630          32 :             *hq_core_type = LOW_RATE_HQ_CORE;
     631          32 :             move16();
     632             :         }
     633         397 :         ELSE IF( EQ_16( st->bwidth, NB ) )
     634             :         {
     635           0 :             *hq_core_type = LOW_RATE_HQ_CORE;
     636           0 :             move16();
     637             :         }
     638             :     }
     639             : 
     640             :     /*-----------------------------------------------------------------*
     641             :      * Set ACELP frame lnegth
     642             :      *-----------------------------------------------------------------*/
     643             : 
     644        1852 :     test();
     645        1852 :     test();
     646        1852 :     test();
     647        1852 :     test();
     648        1852 :     test();
     649        1852 :     test();
     650        1852 :     test();
     651        1852 :     test();
     652        1852 :     test();
     653        1852 :     IF( st->core_brate == FRAME_NO_DATA )
     654             :     {
     655             :         /* prevent "L_frame" changes in CNG segments */
     656           0 :         st->L_frame = st->last_L_frame;
     657           0 :         move16();
     658             :     }
     659        1852 :     ELSE IF( EQ_32( st->core_brate, SID_2k40 ) && EQ_16( st->bwidth, WB ) && st->first_CNG && LT_16( st->hTdCngDec->act_cnt2, MIN_ACT_CNG_UPD ) )
     660             :     {
     661             :         /* prevent "L_frame" changes in SID frame after short segment of active frames */
     662           0 :         st->L_frame = st->last_CNG_L_frame;
     663           0 :         move16();
     664             :     }
     665        1852 :     ELSE IF( ( EQ_32( st->core_brate, SID_2k40 ) && GE_32( st->total_brate, ACELP_9k60 ) && EQ_16( st->bwidth, WB ) ) ||
     666             :              ( GE_32( st->total_brate, ACELP_32k ) && LT_32( st->total_brate, HQ_96k ) ) || ( EQ_32( st->total_brate, ACELP_24k40 ) && GE_16( st->bwidth, WB ) ) )
     667             :     {
     668        1066 :         st->L_frame = L_FRAME16k;
     669        1066 :         move16();
     670             :     }
     671             :     ELSE
     672             :     {
     673         786 :         st->L_frame = L_FRAME;
     674         786 :         move16();
     675             :     }
     676             : 
     677        1852 :     st->nb_subfr = NB_SUBFR;
     678        1852 :     move16();
     679        1852 :     if ( EQ_16( st->L_frame, L_FRAME16k ) )
     680             :     {
     681        1066 :         st->nb_subfr = NB_SUBFR16k;
     682        1066 :         move16();
     683             :     }
     684             : 
     685        1852 :     st->extl_orig = st->extl;
     686        1852 :     move16();
     687        1852 :     st->extl_brate_orig = st->extl_brate;
     688        1852 :     move32();
     689             : 
     690        1852 :     test();
     691        1852 :     IF( EQ_32( st->output_Fs, 8000 ) )
     692             :     {
     693           0 :         st->extl = -1;
     694           0 :         move16();
     695             :     }
     696        1852 :     ELSE IF( EQ_32( st->output_Fs, 16000 ) && EQ_16( st->L_frame, L_FRAME16k ) )
     697             :     {
     698           0 :         st->extl = -1;
     699           0 :         move16();
     700           0 :         st->extl_brate = L_deposit_l( 0 );
     701             :     }
     702             : 
     703        1852 :     IF( st->ini_frame == 0 )
     704             :     {
     705             :         /* avoid switching of internal ACELP Fs in the very first frame */
     706           2 :         st->last_L_frame = st->L_frame;
     707           2 :         move16();
     708           2 :         st->last_core = st->core;
     709           2 :         move16();
     710           2 :         st->last_core_brate = st->core_brate;
     711           2 :         move32();
     712           2 :         st->last_extl = st->extl;
     713           2 :         move16();
     714             :     }
     715             : 
     716             :     /*-----------------------------------------------------------------*
     717             :      * set inactive coder_type flag in ACELP core
     718             :      *-----------------------------------------------------------------*/
     719             : 
     720        1852 :     st->inactive_coder_type_flag = 0; /* AVQ by default */
     721        1852 :     move16();
     722             : 
     723        1852 :     if ( LE_32( st->total_brate, MAX_GSC_INACTIVE_BRATE ) )
     724             :     {
     725         852 :         st->inactive_coder_type_flag = 1; /* GSC */
     726         852 :         move16();
     727             :     }
     728             : 
     729        1852 :     return;
     730             : }

Generated by: LCOV version 1.14