LCOV - code coverage report
Current view: top level - lib_enc - ivas_decision_matrix_enc.c (source / functions) Hit Total Coverage
Test: Coverage on main @ 6baab0c613aa6c7100498ed7b93676aa8198a493 Lines: 139 140 99.3 %
Date: 2025-05-28 04:28:20 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /******************************************************************************************************
       2             : 
       3             :    (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
       4             :    Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
       5             :    Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
       6             :    Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
       7             :    contributors to this repository. All Rights Reserved.
       8             : 
       9             :    This software is protected by copyright law and by international treaties.
      10             :    The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
      11             :    Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
      12             :    Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
      13             :    Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
      14             :    contributors to this repository retain full ownership rights in their respective contributions in
      15             :    the software. This notice grants no license of any kind, including but not limited to patent
      16             :    license, nor is any license granted by implication, estoppel or otherwise.
      17             : 
      18             :    Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
      19             :    contributions.
      20             : 
      21             :    This software is provided "AS IS", without any express or implied warranties. The software is in the
      22             :    development stage. It is intended exclusively for experts who have experience with such software and
      23             :    solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
      24             :    and fitness for a particular purpose are hereby disclaimed and excluded.
      25             : 
      26             :    Any dispute, controversy or claim arising under or in relation to providing this software shall be
      27             :    submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
      28             :    accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
      29             :    the United Nations Convention on Contracts on the International Sales of Goods.
      30             : 
      31             : *******************************************************************************************************/
      32             : 
      33             : #include <stdint.h>
      34             : #include "options.h"
      35             : #include "cnst.h"
      36             : #include "ivas_cnst.h"
      37             : #include "rom_com.h"
      38             : #include "prot.h"
      39             : #include "ivas_prot.h"
      40             : #include "ivas_rom_com.h"
      41             : #ifdef DEBUGGING
      42             : #include "debug.h"
      43             : #endif
      44             : #include "wmc_auto.h"
      45             : 
      46             : 
      47             : /*-----------------------------------------------------------------*
      48             :  *  ivas_decision_matrix_enc()
      49             :  *
      50             :  *  Core technology selection in the IVAS codec
      51             :  *
      52             :  *  CPE
      53             :  *  bitrate    13.2          16.4          24.4           32            48            >48(*)
      54             :  * ----------------------------------------------------------------------------------------
      55             :  *  WB
      56             :  *  speech     ACELP         ACELP         ACELP          ACELP         ACELP         TCX
      57             :  *  music      GSC/TCX       GSC/TCX       TCX/HQ         TCX/HQ        TCX/HQ        TCX
      58             :  *  inactive   ACELP-I/TCX   ACELP-I/TCX   ACELP-I/TCX    ACELP-I/TCX   ACELP-I/TCX   TCX
      59             :  *
      60             :  *  SWB
      61             :  *  speech     ACELP         ACELP         ACELP          ACELP         ACELP         TCX
      62             :  *  music      GSC/TCX       GSD/TCX       TCX/HQ         TCX/HQ        TCX/HQ        TCX
      63             :  *  inactive   ACELP-I/TCX   ACELP-I/TCX   ACELP-I/TCX    ACELP-I/TCX   ACELP-I/TCX   TCX
      64             :  *
      65             :  *  FB
      66             :  *  speech                                                ACELP         ACELP         TCX
      67             :  *  music                                                 TCX/HQ        TCX/HQ        TCX
      68             :  *  inactive                                              ACELP-I/TCX   ACELP-I/TCX   TCX
      69             :  *
      70             :  * ACELP-I: GSC Inactive mode used for total_brate <= 28 kbps (total_brate), AVQ Inactive mode used otherwise
      71             :  * (*): TCX core is selected when total_brate > 48kbps, not CPE bitrate
      72             :  * Note: in MDCT stereo mode, TCX core is selected for all content
      73             :  * -------------------------------------------------------------------------------------------------------------------------------------------------------------*/
      74             : 
      75    15522449 : void ivas_decision_matrix_enc(
      76             :     Encoder_State *st,              /* i  : encoder state structure                 */
      77             :     const int32_t element_brate,    /* i  : element bitrate                         */
      78             :     const float fft_buff[],         /* i  : FFT buffer                              */
      79             :     const float enerBuffer[],       /* i  : energy buffer                           */
      80             :     const int16_t last_element_mode /* i  : last element mode                       */
      81             : )
      82             : {
      83             :     int32_t icbwe_brate;
      84             :     /* init */
      85    15522449 :     icbwe_brate = 0;
      86             : 
      87             :     /* initialization */
      88    15522449 :     st->core = -1;
      89    15522449 :     st->extl = -1;
      90    15522449 :     st->extl_brate = 0;
      91    15522449 :     if ( st->element_mode != IVAS_CPE_MDCT )
      92             :     {
      93     4471043 :         st->igf = 0;
      94             :     }
      95             : 
      96             :     /* SID and FRAME_NO_DATA frames */
      97    15522449 :     if ( st->Opt_DTX_ON && ( st->core_brate == SID_2k40 || st->core_brate == FRAME_NO_DATA ) )
      98             :     {
      99       90914 :         st->core = ACELP_CORE;
     100             : 
     101       90914 :         if ( st->input_Fs >= 32000 && st->bwidth >= SWB )
     102             :         {
     103       69419 :             st->extl = SWB_CNG;
     104             :         }
     105             : 
     106       90914 :         st->rf_mode = 0;
     107             : 
     108       90914 :         return;
     109             :     }
     110             : 
     111             :     /*---------------------------------------------------------------------*
     112             :      * Select the core
     113             :      *---------------------------------------------------------------------*/
     114             : 
     115    15431535 :     if ( st->element_mode == IVAS_SCE && st->low_rate_mode )
     116             :     {
     117             :         /* ISM low-rate mode */
     118      266718 :         st->core = ACELP_CORE;
     119      266718 :         st->coder_type = INACTIVE;
     120             :     }
     121    15164817 :     else if ( st->total_brate > MAX_ACELP_BRATE )
     122             :     {
     123             :         /* highest bitrates */
     124     8782565 :         st->core = TCX_20_CORE;
     125             :     }
     126     6382252 :     else if ( st->element_mode == IVAS_CPE_MDCT )
     127             :     {
     128             :         /* in MDCT stereo set TCX core */
     129     3101694 :         st->core = TCX_20_CORE;
     130             :     }
     131     3280558 :     else if ( st->coder_type == INACTIVE )
     132             :     {
     133             :         /* inactive frames */
     134      354304 :         if ( st->cng_type == FD_CNG && st->total_brate >= STEREO_TCX_MIN_RATE )
     135             :         {
     136      300459 :             st->core = TCX_20_CORE;
     137             :         }
     138             :         else
     139             :         {
     140       53845 :             st->core = ACELP_CORE;
     141             :         }
     142             :     }
     143     2926254 :     else if ( st->sp_aud_decision1 == 0 && st->sp_aud_decision2 == 0 )
     144             :     {
     145             :         /* speech */
     146     1225928 :         st->core = ACELP_CORE;
     147             :     }
     148     1700326 :     else if ( st->sp_aud_decision1 == 1 && st->sp_aud_decision2 == 0 )
     149             :     {
     150             :         /* music w. GSC core */
     151       61489 :         st->core = ACELP_CORE;
     152             :     }
     153             :     else /* sp_aud_decision1 == 1 && *sp_aud_decision2 == 1 */
     154             :     {
     155             :         /* music w. TCX or HQ core */
     156     1638837 :         st->core = TCX_20_CORE;
     157             : 
     158     1638837 :         if ( st->element_mode == IVAS_CPE_TD || st->sp_aud_decision0 == 0 )
     159             :         {
     160      529756 :             st->core = TCX_20_CORE;
     161             :         }
     162             :         else
     163             :         {
     164             :             /* select TCX core or HQ core using bits_frame_nominal to match the TCX configuration bitrate */
     165     1109081 :             st->core = mdct_classifier( st, fft_buff, enerBuffer, st->bits_frame_nominal * FRAMES_PER_SEC );
     166             :         }
     167             :     }
     168             : 
     169             :     /* do not allow TD stereo ACELP core -> DFT stereo TCX core switching as it is on the WC complexity path */
     170    15431535 :     if ( ( ( st->last_core == ACELP_CORE && last_element_mode == IVAS_CPE_TD && st->element_mode == IVAS_CPE_DFT ) || ( st->tdm_LRTD_flag == 1 && st->total_brate <= IVAS_16k4 ) ) && st->core == TCX_20_CORE && st->total_brate <= MAX_ACELP_BRATE ) /* Override TCX in case of LRTD && primary channel has low bitrate*/
     171             :     {
     172        1428 :         st->core = ACELP_CORE;
     173             :     }
     174             : 
     175             :     /* sanity check: highest bitrates in ISM */
     176    15431535 :     if ( st->is_ism_format && st->tcxonly && st->total_brate > MAX_ACELP_BRATE_ISM )
     177             :     {
     178      773622 :         st->core = TCX_20_CORE;
     179             :     }
     180             : 
     181             : #ifdef DEBUGGING
     182             :     if ( st->idchan == 0 )
     183             :     {
     184             :         if ( st->force == FORCE_SPEECH && st->element_mode != IVAS_CPE_MDCT && st->total_brate <= MAX_ACELP_BRATE )
     185             :         {
     186             :             st->core = ACELP_CORE;
     187             :         }
     188             :         else if ( st->force == FORCE_MUSIC && st->core == ACELP_CORE )
     189             :         {
     190             :             st->core = TCX_20_CORE;
     191             :         }
     192             :         else if ( st->force == FORCE_ACELP && st->element_mode != IVAS_CPE_MDCT && st->total_brate <= MAX_ACELP_BRATE )
     193             :         {
     194             :             st->core = ACELP_CORE;
     195             :             if ( st->coder_type == AUDIO )
     196             :             {
     197             :                 st->coder_type = GENERIC;
     198             :             }
     199             :         }
     200             :         else if ( st->force == FORCE_GSC && element_brate < IVAS_24k4 )
     201             :         {
     202             :             st->core = ACELP_CORE;
     203             :         }
     204             :         else if ( st->force == FORCE_TCX )
     205             :         {
     206             :             st->core = TCX_20_CORE;
     207             :         }
     208             :         else if ( st->force == FORCE_HQ && st->element_mode != IVAS_CPE_MDCT && element_brate >= IVAS_24k4 )
     209             :         {
     210             :             st->core = HQ_CORE;
     211             :         }
     212             :     }
     213             : #endif
     214             : 
     215             :     /* TCX not available at low bitrates -> replace it by GSC */
     216    15431535 :     if ( st->core == TCX_20_CORE && st->total_brate < STEREO_TCX_MIN_RATE )
     217             :     {
     218       13331 :         st->core = ACELP_CORE;
     219             : 
     220             :         /* In TD stereo below 24.4 kbps we cannot overwrite the `coder_type` when it is set to TRANSITION, */
     221             :         /* as it is used for TD stereo bit allocation. To ensure consistent bit allocation, it must remain unchanged on the decoder side. */
     222       13331 :         if ( st->idchan == 0 && !( element_brate < IVAS_24k4 && st->coder_type == TRANSITION && st->element_mode == IVAS_CPE_TD ) )
     223             :         {
     224       13331 :             st->coder_type = AUDIO;
     225             :         }
     226             : 
     227       13331 :         st->sp_aud_decision2 = 0;
     228             : 
     229       13331 :         if ( st->low_rate_mode )
     230             :         {
     231           0 :             st->coder_type = INACTIVE;
     232             :         }
     233             :     }
     234             : 
     235             :     /* sanity check to avoid too low ACELP bitrate in case of "limitation to avoid too high bitrate in one active TCX channel" at element_brate = 32000 */
     236    15431535 :     if ( st->is_ism_format && st->flag_ACELP16k && !st->low_rate_mode && st->core == ACELP_CORE && st->total_brate < ACELP_16k_LOW_LIMIT + FB_TBE_1k8 )
     237             :     {
     238         784 :         st->core = TCX_20_CORE;
     239             :     }
     240             : 
     241             :     /*---------------------------------------------------------------------*
     242             :      * Select ACELP and GSC extension layer
     243             :      *---------------------------------------------------------------------*/
     244             : 
     245    15431535 :     if ( st->core == ACELP_CORE )
     246             :     {
     247             :         /* WB */
     248     1619324 :         if ( st->bwidth == WB )
     249             :         {
     250      478154 :             if ( st->total_brate < MIN_BRATE_WB_BWE || ( st->idchan == 1 && st->element_mode == IVAS_CPE_TD ) )
     251             :             {
     252      262622 :                 st->extl = WB_BWE;
     253             :             }
     254      215532 :             else if ( st->total_brate >= MIN_BRATE_WB_BWE && !st->flag_ACELP16k )
     255             :             {
     256       98680 :                 if ( ( st->sp_aud_decision1 == 1 && st->sp_aud_decision2 == 0 ) || st->coder_type == INACTIVE )
     257             :                 {
     258       27534 :                     st->extl = WB_BWE;
     259       27534 :                     st->extl_brate = WB_BWE_0k35;
     260             :                 }
     261             :                 else
     262             :                 {
     263       71146 :                     st->extl = WB_TBE;
     264             : 
     265       71146 :                     if ( st->total_brate < MIN_BRATE_WB_TBE_1k05 || ( st->element_mode == IVAS_CPE_TD && st->total_brate < MIN_TDM_BRATE_WB_TBE_1k05 ) )
     266             :                     {
     267       11439 :                         st->extl_brate = WB_TBE_0k35;
     268             :                     }
     269             :                     else
     270             :                     {
     271       59707 :                         st->extl_brate = WB_TBE_1k05;
     272             :                     }
     273             :                 }
     274             :             }
     275             :         }
     276             : 
     277             :         /* SWB and FB */
     278     1141170 :         else if ( st->bwidth == SWB || st->bwidth == FB )
     279             :         {
     280     1141170 :             if ( st->total_brate >= MIN_BRATE_SWB_BWE /*&& (*coder_type != AUDIO || st->total_brate >= (MIN_BWE_PRI_BRATE+600))*/
     281        6709 :                  || ( st->total_brate >= MIN_MIN_BRATE_LRTD_SWB_BWE && st->element_mode == IVAS_CPE_TD && st->bwidth == SWB && st->tdm_LRTD_flag ) || ( element_brate < IVAS_16k4 && st->total_brate >= MIN_MIN_BRATE_LRTD_SWB_BWE && st->element_mode == IVAS_CPE_TD && st->bwidth == SWB ) )
     282             :             {
     283     1135204 :                 if ( ( ( ( st->sp_aud_decision1 == 1 && st->sp_aud_decision2 == 0 ) || st->coder_type == INACTIVE ) && !st->GSC_noisy_speech ) /* Note: SWB BWE is not used for GSC noisy speech */ )
     284             :                 {
     285       95032 :                     st->extl = SWB_BWE;
     286       95032 :                     st->extl_brate = SWB_BWE_1k6;
     287             : 
     288       95032 :                     if ( st->bwidth == FB )
     289             :                     {
     290       18471 :                         st->extl = FB_BWE;
     291       18471 :                         st->extl_brate = FB_BWE_1k8;
     292             :                     }
     293             :                 }
     294             :                 else
     295             :                 {
     296     1040172 :                     st->extl = SWB_TBE;
     297     1040172 :                     st->extl_brate = SWB_TBE_1k6;
     298             : 
     299     1040172 :                     if ( st->total_brate >= MIN_BRATE_SWB_TBE_2k80 && st->flag_ACELP16k && st->element_mode == IVAS_SCE )
     300             :                     {
     301      206261 :                         st->extl_brate = SWB_TBE_2k8;
     302             :                     }
     303      833911 :                     else if ( st->tdm_LRTD_flag == 1 && st->element_mode == IVAS_CPE_TD )
     304             :                     {
     305       42837 :                         if ( st->element_brate < IVAS_24k4 )
     306             :                         {
     307        1995 :                             st->extl_brate = SWB_TBE_1k10;
     308             :                         }
     309             :                         else
     310             :                         {
     311       40842 :                             st->extl_brate = SWB_TBE_1k75;
     312             :                         }
     313             :                     }
     314      791074 :                     else if ( st->total_brate < MIN_BRATE_SWB_TBE_1k60 )
     315             :                     {
     316      276639 :                         st->extl_brate = SWB_TBE_0k95;
     317             :                     }
     318             : 
     319     1040172 :                     if ( st->bwidth == FB )
     320             :                     {
     321      347560 :                         st->extl = FB_TBE;
     322      347560 :                         st->extl_brate = FB_TBE_1k8;
     323             : 
     324      347560 :                         if ( st->total_brate >= MIN_BRATE_SWB_TBE_2k80 && st->flag_ACELP16k && st->element_mode == IVAS_SCE )
     325             :                         {
     326      149979 :                             st->extl_brate = FB_TBE_3k0;
     327             :                         }
     328             :                     }
     329             :                 }
     330             :             }
     331             :             else
     332             :             {
     333        5966 :                 st->extl = WB_BWE;
     334        5966 :                 st->extl_brate = 0;
     335             :             }
     336             : 
     337             :             /* set IC-BWE bitrate */
     338     1141170 :             if ( st->element_mode == IVAS_CPE_TD && ( st->idchan == 0 ) && !st->tdm_LRTD_flag )
     339             :             {
     340        1552 :                 icbwe_brate = STEREO_BITS_ICBWE * FRAMES_PER_SEC;
     341        1552 :                 if ( st->flag_ACELP16k == 0 )
     342             :                 {
     343          33 :                     icbwe_brate = ( STEREO_BITS_ICBWE - STEREO_ICBWE_SPBITS ) * FRAMES_PER_SEC;
     344             :                 }
     345             :             }
     346     1139618 :             else if ( st->element_mode == IVAS_CPE_DFT )
     347             :             {
     348      317222 :                 icbwe_brate = STEREO_BITS_ICBWE_DFT * FRAMES_PER_SEC;
     349      317222 :                 if ( st->flag_ACELP16k == 0 )
     350             :                 {
     351      166534 :                     icbwe_brate = ( STEREO_BITS_ICBWE_DFT - STEREO_ICBWE_SPBITS ) * FRAMES_PER_SEC;
     352             :                 }
     353             :             }
     354             : 
     355     1141170 :             if ( st->element_mode >= IVAS_CPE_DFT && st->core == ACELP_CORE && ( st->extl == SWB_TBE || st->extl == FB_TBE ) && !( st->element_mode == IVAS_CPE_TD && st->tdm_LRTD_flag ) )
     356             :             {
     357      269937 :                 icbwe_brate += STEREO_ICBWE_MSFLAG_BITS * FRAMES_PER_SEC;
     358             :             }
     359             :         }
     360             :     }
     361             : 
     362             :     /* set core bitrate */
     363    15431535 :     st->core_brate = st->total_brate - st->extl_brate - icbwe_brate;
     364             : 
     365    15431535 :     if ( st->ini_frame == 0 )
     366             :     {
     367             :         /* avoid core switching in the very first frame */
     368      129500 :         st->last_core = st->core;
     369      129500 :         st->last_core_brate = st->core_brate;
     370      129500 :         st->last_extl = st->extl;
     371             :     }
     372             : 
     373             :     /*-----------------------------------------------------------------*
     374             :      * set inactive coder_type flag in ACELP core
     375             :      *-----------------------------------------------------------------*/
     376             : 
     377    15431535 :     st->inactive_coder_type_flag = 0; /* AVQ by default */
     378    15431535 :     if ( st->total_brate <= MAX_GSC_INACTIVE_BRATE )
     379             :     {
     380     3943539 :         st->inactive_coder_type_flag = 1; /* GSC */
     381             :     }
     382             : 
     383    15431535 :     return;
     384             : }
     385             : 
     386             : 
     387             : /*---------------------------------------------------------------------*
     388             :  * ivas_signaling_enc()
     389             :  *
     390             :  * write signaling information of SCE/CPE mode into the bitstream
     391             :  *---------------------------------------------------------------------*/
     392             : 
     393    10269543 : void ivas_signaling_enc(
     394             :     Encoder_State *st,                 /* i/o: encoder state structure                          */
     395             :     const int16_t MCT_flag,            /* i  : hMCT handle allocated (1) or not (0)             */
     396             :     const int32_t element_brate,       /* i  : element bitrate                                  */
     397             :     const int16_t tdm_SM_or_LRTD_Pri,  /* i  : channel combination scheme flag in TD stereo OR LRTD primary channel */
     398             :     const int16_t tdm_Pitch_reuse_flag /* i  : primary channel pitch reuse flag in TD stereo    */
     399             : )
     400             : {
     401             :     int16_t ind;
     402    10269543 :     BSTR_ENC_HANDLE hBstr = st->hBstr;
     403             : 
     404    10269543 :     if ( st->element_mode == IVAS_CPE_TD && st->idchan == 1 )
     405             :     {
     406             :         /* minimal signaling for the secondary channel, most of the parameters are deduced from the primary channel */
     407       28632 :         signaling_enc_secondary( st, tdm_SM_or_LRTD_Pri, tdm_Pitch_reuse_flag );
     408             :     }
     409    10240911 :     else if ( st->element_mode == IVAS_SCE && st->low_rate_mode )
     410             :     {
     411             :         /* ISM Low-rate mode -> do nothing -> always WB, ACELP core, IC coder_type */
     412             :     }
     413     9974193 :     else if ( ( st->element_mode == IVAS_CPE_MDCT && st->idchan == 1 ) || st->core_brate <= SID_2k40 )
     414             :     {
     415             :         /* do nothing */
     416             :     }
     417             :     else
     418             :     {
     419     6998459 :         if ( st->idchan == 0 )
     420             :         {
     421             :             /*--------------------------------------------------------------------------
     422             :              * Write element mode info
     423             :              *--------------------------------------------------------------------------*/
     424             : 
     425     6998459 :             if ( ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD ) && !MCT_flag ) /* note: in MCT, the MDCT stereo is used exclusively */
     426             :             {
     427      792148 :                 ind = st->element_mode - IVAS_CPE_DFT;
     428      792148 :                 push_indice( hBstr, IND_SMODE, ind, NBITS_ELEMENT_MODE );
     429             :             }
     430             : 
     431             :             /*--------------------------------------------------------------------------
     432             :              * Write band-width info
     433             :              *--------------------------------------------------------------------------*/
     434             : 
     435     6998459 :             if ( st->element_mode == IVAS_SCE && element_brate < MIN_BRATE_SWB_SCE )
     436             :             {
     437             :                 /* only WB is supported */
     438             :             }
     439     6970937 :             else if ( ( element_brate < MIN_BRATE_FB_STEREO && !st->is_ism_format ) ||
     440      231198 :                       ( element_brate < MIN_BRATE_FB_ISM && st->is_ism_format ) )
     441             :             {
     442             :                 /* WB and SWB are supported */
     443     1226240 :                 ind = st->bwidth - WB;
     444     1226240 :                 push_indice( hBstr, IND_BWIDTH, ind, 1 );
     445             :             }
     446             :             else
     447             :             {
     448             :                 /* WB, SWB and FB are supported */
     449     5744697 :                 push_indice( hBstr, IND_BWIDTH, st->bwidth, NBITS_BWIDTH );
     450             :             }
     451             : 
     452     6998459 :             if ( st->element_mode != IVAS_CPE_MDCT )
     453             :             {
     454             :                 /*--------------------------------------------------------------------------
     455             :                  * Write ACELP/MDCT core selection bit
     456             :                  *--------------------------------------------------------------------------*/
     457             : 
     458     4113639 :                 if ( st->element_mode == IVAS_CPE_TD || st->total_brate >= STEREO_TCX_MIN_RATE )
     459             :                 {
     460     4082058 :                     if ( st->core == ACELP_CORE )
     461             :                     {
     462     1292393 :                         push_indice( hBstr, IND_CORE, 0, 1 );
     463             :                     }
     464             :                     else
     465             :                     {
     466     2789665 :                         push_indice( hBstr, IND_CORE, 1, 1 );
     467             :                     }
     468             :                 }
     469             : 
     470             :                 /*--------------------------------------------------------------------------
     471             :                  * Write core dependent signaling
     472             :                  *--------------------------------------------------------------------------*/
     473             : 
     474     4113639 :                 if ( st->core == ACELP_CORE )
     475             :                 {
     476             :                     /* write coder type */
     477     1323974 :                     push_indice( hBstr, IND_ACELP_SIGNALLING, st->coder_type, 3 );
     478             : 
     479     1323974 :                     if ( element_brate >= FRMT_SHP_MIN_BRATE_IVAS )
     480             :                     {
     481             :                         /* write sharpening flag */
     482      718549 :                         push_indice( hBstr, IND_SHARP_FLAG, st->sharpFlag, 1 );
     483             :                     }
     484             : 
     485             :                     /* write extension layer flag to distinguish between TBE (0) and BWE (1) */
     486     1323974 :                     if ( st->extl_brate > 0 )
     487             :                     {
     488     1207108 :                         if ( st->extl == WB_TBE || st->extl == SWB_TBE || st->extl == FB_TBE )
     489             :                         {
     490     1091765 :                             push_indice( hBstr, IND_BWE_FLAG, 0, 1 );
     491             :                         }
     492      115343 :                         else if ( st->extl == WB_BWE || st->extl == SWB_BWE || st->extl == FB_BWE )
     493             :                         {
     494      115343 :                             push_indice( hBstr, IND_BWE_FLAG, 1, 1 );
     495             :                         }
     496             :                     }
     497             :                 }
     498             :                 else /* MDCT core */
     499             :                 {
     500             :                     /* write TCX/HQ selection flag */
     501     2789665 :                     if ( st->core == HQ_CORE )
     502             :                     {
     503       74800 :                         push_indice( hBstr, IND_MDCT_CORE, 0, 1 );
     504             :                     }
     505             :                     else /* TCX20/TCX10 core */
     506             :                     {
     507     2714865 :                         push_indice( hBstr, IND_MDCT_CORE, 1, 1 );
     508             :                     }
     509             : 
     510     2789665 :                     if ( st->core == HQ_CORE )
     511             :                     {
     512       74800 :                         if ( st->last_core == ACELP_CORE )
     513             :                         {
     514        1662 :                             push_indice( hBstr, IND_HQ_SWITCHING_FLG, 1, 1 );
     515             :                         }
     516             :                         else
     517             :                         {
     518       73138 :                             push_indice( hBstr, IND_HQ_SWITCHING_FLG, 0, 1 );
     519             :                         }
     520             :                     }
     521             :                 }
     522             :             } /* element_mode != IVAS_CPE_MDCT */
     523             :         }
     524             :     }
     525             : 
     526    10269543 :     return;
     527             : }

Generated by: LCOV version 1.14