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_fx.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 : function name: SetModeIndex_fx 16 : description: function for configuring the codec between frames - currently bit rate and bandwidth only 17 : must not be called while a frame is encoded - hence mutexes must be used in MT environments 18 : 19 : format: BANDWIDTH*16 + BITRATE (mode index) 20 : 21 : ---------------------------------------------------------------------------*/ 22 : 23 1310 : void SetModeIndex_fx( 24 : Encoder_State *st, 25 : Word32 last_total_brate, /* Q0 */ 26 : const Word16 last_element_mode, /* Q0 */ 27 : const Word16 is_mct, /* Q0 */ 28 : const Word16 shift ) 29 : { 30 1310 : Word16 ini_frame_loc = st->ini_frame; // Q0 31 : 32 1310 : test(); 33 1310 : test(); 34 1310 : if ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && EQ_16( last_element_mode, IVAS_CPE_MDCT ) && EQ_16( st->idchan, 1 ) ) 35 : { 36 0 : st->ini_frame = 0; 37 0 : move16(); 38 : } 39 : 40 : /* Reconfigure the core coder */ 41 1310 : test(); 42 1310 : test(); 43 1310 : test(); 44 1310 : IF( 45 : ( NE_32( last_total_brate, st->total_brate ) ) || 46 : ( NE_16( st->last_bwidth, st->bwidth ) ) || 47 : ( EQ_16( st->last_codec_mode, MODE1 ) && EQ_16( st->element_mode, EVS_MONO ) ) || 48 : ( ( NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) ) && GT_16( st->element_mode, EVS_MONO ) ) || 49 : ( NE_16( st->rf_mode_last, st->rf_mode ) ) || 50 : ( GT_16( st->element_mode, EVS_MONO ) && st->ini_frame == 0 ) ) 51 : { 52 63 : core_coder_mode_switch_fx( st, last_total_brate, is_mct, shift ); 53 : } 54 1310 : st->ini_frame = ini_frame_loc; // Q0 55 : 56 1310 : return; 57 : } 58 : 59 : 60 929726 : void SetModeIndex_ivas_fx( 61 : Encoder_State *st, /* i : Encoder state */ 62 : const Word32 last_total_brate, /* i : last total bitrate Q0*/ 63 : const Word16 last_element_mode, /* i : last IVAS element mode Q0*/ 64 : const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) Q0*/ 65 : ) 66 : { 67 929726 : Word16 ini_frame_loc = st->ini_frame; // Q0 68 929726 : move16(); 69 : 70 929726 : test(); 71 929726 : test(); 72 929726 : IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && NE_16( last_element_mode, IVAS_CPE_MDCT ) && EQ_16( st->idchan, 1 ) ) 73 : { 74 749 : st->ini_frame = 0; 75 749 : move16(); 76 : } 77 : 78 929726 : test(); 79 929726 : test(); 80 929726 : test(); 81 929726 : test(); 82 929726 : test(); 83 929726 : test(); 84 929726 : test(); 85 929726 : test(); 86 929726 : test(); 87 : /* Reconfigure the core coder */ 88 929726 : IF( ( NE_32( last_total_brate, st->total_brate ) ) || 89 : ( NE_16( st->last_bwidth, st->bwidth ) ) || 90 : ( EQ_16( st->last_codec_mode, MODE1 ) && EQ_16( st->element_mode, EVS_MONO ) ) || 91 : ( ( NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) ) && GT_16( st->element_mode, EVS_MONO ) ) || 92 : ( NE_16( st->rf_mode_last, st->rf_mode ) ) || 93 : ( st->element_mode > EVS_MONO && st->ini_frame == 0 ) ) 94 : { 95 30980 : core_coder_mode_switch_ivas_fx( st, last_total_brate, MCT_flag ); 96 : } 97 : 98 929726 : st->ini_frame = ini_frame_loc; // Q0 99 929726 : move16(); 100 : 101 929726 : return; 102 : }