LCOV - code coverage report
Current view: top level - lib_enc - setmodeindex_fx.c (source / functions) Hit Total Coverage
Test: Coverage on main @ 61b27367e0d19b9fc53332787af331bed7af66b1 Lines: 34 36 94.4 %
Date: 2025-10-21 02:53:18 Functions: 2 2 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 "rom_enc.h"
      10             : #include "prot_fx.h"     /* Function prototypes                    */
      11             : #include "prot_fx_enc.h" /* Function prototypes                    */
      12             : 
      13             : 
      14             : /*---------------------------------------------------------------------------
      15             : 
      16             :    function name: SetModeIndex_fx
      17             :    description:   function for configuring the codec between frames - currently bit rate and bandwidth only
      18             :                   must not be called while a frame is encoded - hence mutexes must be used in MT environments
      19             : 
      20             :    format:        BANDWIDTH*16 + BITRATE (mode index)
      21             : 
      22             :   ---------------------------------------------------------------------------*/
      23             : 
      24        1312 : void SetModeIndex_fx(
      25             :     Encoder_State *st,
      26             :     Word32 last_total_brate,        /* Q0 */
      27             :     const Word16 last_element_mode, /* Q0 */
      28             :     const Word16 is_mct,            /* Q0 */
      29             :     const Word16 shift )
      30             : {
      31        1312 :     Word16 ini_frame_loc = st->ini_frame; // Q0
      32             : 
      33        1312 :     test();
      34        1312 :     test();
      35        1312 :     if ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && EQ_16( last_element_mode, IVAS_CPE_MDCT ) && EQ_16( st->idchan, 1 ) )
      36             :     {
      37           0 :         st->ini_frame = 0;
      38           0 :         move16();
      39             :     }
      40             : 
      41             :     /* Reconfigure the core coder */
      42        1312 :     test();
      43        1312 :     test();
      44        1312 :     test();
      45        1312 :     IF(
      46             :         ( NE_32( last_total_brate, st->total_brate ) ) ||
      47             :         ( NE_16( st->last_bwidth, st->bwidth ) ) ||
      48             :         ( EQ_16( st->last_codec_mode, MODE1 ) && EQ_16( st->element_mode, EVS_MONO ) ) ||
      49             :         ( ( NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) ) && GT_16( st->element_mode, EVS_MONO ) ) ||
      50             :         ( NE_16( st->rf_mode_last, st->rf_mode ) ) ||
      51             :         ( GT_16( st->element_mode, EVS_MONO ) && st->ini_frame == 0 ) )
      52             :     {
      53          88 :         core_coder_mode_switch_fx( st, last_total_brate, is_mct, shift );
      54             :     }
      55        1312 :     st->ini_frame = ini_frame_loc; // Q0
      56             : 
      57        1312 :     return;
      58             : }
      59             : 
      60             : 
      61      956481 : void SetModeIndex_ivas_fx(
      62             :     Encoder_State *st,              /* i  : Encoder state                          */
      63             :     const Word32 last_total_brate,  /* i  : last total bitrate                     Q0*/
      64             :     const Word16 last_element_mode, /* i  : last IVAS element mode                 Q0*/
      65             :     const Word16 MCT_flag           /* i  : hMCT handle allocated (1) or not (0)   Q0*/
      66             : )
      67             : {
      68      956481 :     Word16 ini_frame_loc = st->ini_frame; // Q0
      69      956481 :     move16();
      70             : 
      71      956481 :     test();
      72      956481 :     test();
      73      956481 :     IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && NE_16( last_element_mode, IVAS_CPE_MDCT ) && EQ_16( st->idchan, 1 ) )
      74             :     {
      75         749 :         st->ini_frame = 0;
      76         749 :         move16();
      77             :     }
      78             : 
      79      956481 :     test();
      80      956481 :     test();
      81      956481 :     test();
      82      956481 :     test();
      83      956481 :     test();
      84      956481 :     test();
      85      956481 :     test();
      86      956481 :     test();
      87      956481 :     test();
      88             :     /* Reconfigure the core coder */
      89      956481 :     IF( ( NE_32( last_total_brate, st->total_brate ) ) ||
      90             :         ( NE_16( st->last_bwidth, st->bwidth ) ) ||
      91             :         ( EQ_16( st->last_codec_mode, MODE1 ) && EQ_16( st->element_mode, EVS_MONO ) ) ||
      92             :         ( ( NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) ) && GT_16( st->element_mode, EVS_MONO ) ) ||
      93             :         ( NE_16( st->rf_mode_last, st->rf_mode ) ) ||
      94             :         ( st->element_mode > EVS_MONO && st->ini_frame == 0 ) )
      95             :     {
      96       32258 :         core_coder_mode_switch_ivas_fx( st, last_total_brate, MCT_flag );
      97             :     }
      98             : 
      99      956481 :     st->ini_frame = ini_frame_loc; // Q0
     100      956481 :     move16();
     101             : 
     102      956481 :     return;
     103             : }

Generated by: LCOV version 1.14