diff --git a/Workspace_msvc/lib_enc.vcxproj b/Workspace_msvc/lib_enc.vcxproj index 93a2a85486561bebdb5cba3e8dec8989a68afb61..110c863c42514925ea3caf425acffe30642a2910 100644 --- a/Workspace_msvc/lib_enc.vcxproj +++ b/Workspace_msvc/lib_enc.vcxproj @@ -242,7 +242,6 @@ - diff --git a/Workspace_msvc/lib_enc.vcxproj.filters b/Workspace_msvc/lib_enc.vcxproj.filters index 0165869a652b48c1578988cf4406ed6a159bce20..059d4829125c26df0fabbd44708d8045992d3ef4 100644 --- a/Workspace_msvc/lib_enc.vcxproj.filters +++ b/Workspace_msvc/lib_enc.vcxproj.filters @@ -253,9 +253,6 @@ encoder_all_c - - encoder_all_c - encoder_all_c diff --git a/lib_com/igf_base_fx.c b/lib_com/igf_base_fx.c index 79e1ee704021a8bd28d57413eb0315a6d16fcde8..45748b9c9968721cf92eaf51752600a842122a63 100644 --- a/lib_com/igf_base_fx.c +++ b/lib_com/igf_base_fx.c @@ -381,6 +381,7 @@ Word16 IGF_MapBitRateToIndex( return bitRateIndex; /*Q0*/ } +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS /**********************************************************************/ /* IGF grid setup **************************************************************************/ @@ -890,6 +891,12 @@ static void IGF_gridSetUp( H_IGF_GRID hGrid, /**< ou } } static void IGF_gridSetUp_ivas_fx( +#else +/**********************************************************************/ /* +IGF grid setup +**************************************************************************/ +static void IGF_gridSetUp( +#endif H_IGF_GRID hGrid, /* o : IGF grid handle */ Word16 bitRateIndex, /* i : IGF bitrate index */ const Word32 sampleRate, /* i : sample rate */ @@ -991,6 +998,10 @@ static void IGF_gridSetUp_ivas_fx( move16(); hGrid->infoGranuleLen = frameLength; /*Q0*/ move16(); +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + hGrid->infoTransFac = transFac; /*Q14*/ + move16(); +#endif hGrid->sfbWrap[0] = 0; move16(); hGrid->tile[0] = hGrid->startLine; /*Q0*/ @@ -1148,7 +1159,12 @@ void IGFCommonFuncsMDCTSquareSpec( const Word16 sqrtBgn, /**< in const Word16 mdctSpec_e, /**< in: | exponent of mdctSpectrum */ Word32 *mdctSquareSpec, /**< out: | MDCT square spectrum */ Word16 *mdctSquareSpec_e, /**< out: | exponent of mdctSquareSpec */ - Word16 indexOffset /**< in: Q0 | index offset */ +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + Word16 indexOffset, /**< in: Q0 | index offset */ + const Word16 element_mode /**< in: | IVAS element mode type */ +#else + Word16 indexOffset /**< in: Q0 | index offset */ +#endif ) { Word16 i; @@ -1170,12 +1186,24 @@ void IGFCommonFuncsMDCTSquareSpec( const Word16 sqrtBgn, /**< in FOR( i = sqrtBgn; i < sqrtEnd; i++ ) { +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IF( EQ_16( element_mode, EVS_MONO ) ) + { + tmp = round_fx_sat( L_shl_sat( mdctSpec[i], s1 ) ); /*(15 - mdctSpec_e)+ S1*/ + } + ELSE + { + tmp = extract_h( L_shl( mdctSpec[i], s1 ) ); /*(15 - mdctSpec_e)+ S1*/ + } +#else tmp = round_fx_sat( L_shl_sat( mdctSpec[i], s1 ) ); /*(15 - mdctSpec_e)+ S1*/ - mdctSquareSpec[j++] = L_mult0( tmp, tmp ); /*31 - mdctSquareSpec_e*/ +#endif + mdctSquareSpec[j++] = L_mult0( tmp, tmp ); /*31 - mdctSquareSpec_e*/ move32(); } } +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS /**********************************************************************/ /* calculate the MDCT square spectrum in the IGF range (for IVAS) **************************************************************************/ @@ -1212,6 +1240,7 @@ void IGFCommonFuncsMDCTSquareSpec_ivas( const Word16 sqrtBgn, /**< in move32(); } } +#endif /**********************************************************************/ /* @@ -1298,6 +1327,7 @@ Word16 IGFCommonFuncsIGFConfiguration( return retValue; } +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS Word16 IGFCommonFuncsIGFConfiguration_ivas_fx( const Word32 total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */ const Word16 bwidth, /* i : audio bandwidth */ @@ -1350,32 +1380,60 @@ Word16 IGFCommonFuncsIGFConfiguration_ivas_fx( /* set up regular IGF grid for TCX 20 (transfac = 1.f) */ hGrid = &hIGFInfo->grid[IGF_GRID_LB_NORM]; +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGF_gridSetUp( hGrid, + hIGFInfo->bitRateIndex, + sampleRate, + frameLength, + 16384 /*1 Q14*/, + igfMinFq ); +#else IGF_gridSetUp_ivas_fx( hGrid, hIGFInfo->bitRateIndex, sampleRate, frameLength, 16384 /*1 Q14*/, igfMinFq ); +#endif /* set up IGF grid for CELP->TCX 20 transitions (transfac = 1.25) */ hGrid = &hIGFInfo->grid[IGF_GRID_LB_TRAN]; +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGF_gridSetUp( hGrid, + hIGFInfo->bitRateIndex, + sampleRate, + frameLength, + 20480 /*1.25 Q14*/, + igfMinFq ); +#else IGF_gridSetUp_ivas_fx( hGrid, hIGFInfo->bitRateIndex, sampleRate, frameLength, 20480 /*1.25 Q14*/, igfMinFq ); +#endif /* set up IGF grid for TCX 10 (transfac = 0.5) */ hGrid = &hIGFInfo->grid[IGF_GRID_LB_SHORT]; +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGF_gridSetUp( hGrid, + hIGFInfo->bitRateIndex, + sampleRate, + frameLength, + 8192 /*0.50f Q14*/, + igfMinFq ); +#else IGF_gridSetUp_ivas_fx( hGrid, hIGFInfo->bitRateIndex, sampleRate, frameLength, 8192 /*0.50f Q14*/, igfMinFq ); +#endif } return retValue; /*Q0*/ } +#endif /**********************************************************************/ /* selects cumulative frequency tables and offsets for the IGF SCF arithmetic coder diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index ba65afec02816a7ff13a61885e29a07ccc4bc2bf..6f17d9717bd8eb927dbbca778bb48ff3f9b1e5ff 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1425,13 +1425,14 @@ void mdct_read_IGF_bits_fx( Decoder_State *st0 /* i : pointer to handle where bitstream is read */ ); +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS void IGFDecReadData_ivas_fx( const IGF_DEC_INSTANCE_HANDLE hInstance, /* i : instance handle of IGF Deccoder */ Decoder_State *st, /* i : decoder state */ const Word16 igfGridIdx, /* i : in case of CELP->TCX switching, use 1.25 framelength */ const Word16 isIndepFrame /* i : if 1: arith dec force reset, if 0: no reset */ ); - +#endif void stereo_tca_init_dec_fx( STEREO_TCA_DEC_HANDLE hStereoTCA /* i/o: Stereo TCA handle for Fixed */ ); diff --git a/lib_com/options.h b/lib_com/options.h index 6f0d8e55eecabd7851829ca66e771ef0e0d4ba91..2a836e0597ed2c73f83802632555414377f975ed 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -92,6 +92,7 @@ #define HARM_FD_BWE /* VA: harmonize core-coder FD BWE function duplications */ #define FIX_2411_Harmonize_TNSANALYSIS_DETECTTNSFILT /* FhG: basop issue 2411: harmonize TNSAnalysis*_fx(), DetectTnsFilt*_fx()*/ #define HARMONIZE_READ_DECODE_TNS /* FhG basop 2389: Harm between two pairs of functions. */ +#define FIX_2346_DUPLICATED_IGF_FUNCTIONS /* FhG: basop issue 2346: Review potentially duplicated IGF functions */ /* #################### End BE switches ################################## */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 49e042e2db19e255f9c8204595d6a34082816bba..b386a63a764789d41b4b203c1739d30f37f7fa11 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -5426,9 +5426,15 @@ void IGFCommonFuncsMDCTSquareSpec( const Word16 mdctSpec_e, /**< in: | exponent of mdctSpectrum */ Word32 *mdctSquareSpec, /**< out: | MDCT square spectrum */ Word16 *mdctSquareSpec_e, /**< out: | exponent of mdctSquareSpec */ - Word16 indexOffset /**< in: Q0 | index offset */ +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + Word16 indexOffset, /**< in: Q0 | index offset */ + const Word16 element_mode /**< in: | IVAS element mode type */ +#else + Word16 indexOffset /**< in: Q0 | index offset */ +#endif ); +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS void IGFCommonFuncsMDCTSquareSpec_ivas( const Word16 sqrtBgn, /**< in: Q0 | start MDCT subband index */ const Word16 sqrtEnd, /**< in: Q0 | stop MDCT subband index */ @@ -5438,6 +5444,7 @@ void IGFCommonFuncsMDCTSquareSpec_ivas( Word16 *mdctSquareSpec_e, /**< out: | exponent of mdctSquareSpec */ Word16 indexOffset /**< in: Q0 | index offset */ ); +#endif Word16 IGFCommonFuncsIGFConfiguration( const Word32 total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */ @@ -5447,6 +5454,7 @@ Word16 IGFCommonFuncsIGFConfiguration( const Word16 rf_mode /* i : flag to signal the RF mode */ ); +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS Word16 IGFCommonFuncsIGFConfiguration_ivas_fx( const Word32 total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */ const Word16 bwidth, /* i : audio bandwidth */ @@ -5454,7 +5462,7 @@ Word16 IGFCommonFuncsIGFConfiguration_ivas_fx( H_IGF_INFO hIGFInfo, /* o : IGF info handle */ const Word16 rf_mode /* i : flag to signal the RF mode */ ); - +#endif Word16 IGFCommonFuncsIGFGetCFTables_fx( const Word32 total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */ const Word16 bwidth, /* i : audio bandwidth */ @@ -8283,7 +8291,7 @@ void IGFDecSetMode( const Word16 defaultStopLine, /* i : default stop subband index */ const Word16 rf_mode /* i : flag to signal the RF mode */ ); - +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS void IGFDecSetMode_ivas_fx( const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i : instance handle of IGF Decoder */ const Word32 total_brate, /* i : bitrate */ @@ -8293,17 +8301,28 @@ void IGFDecSetMode_ivas_fx( const Word16 defaultStopLine, /* i : default stop subband index */ const Word16 rf_mode /* i : flag to signal the RF mode */ ); - +#endif +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS void IGFDecUpdateInfo( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ const Word16 igfGridIdx /**< in: | IGF grid index */ ); +#endif +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS +void IGFDecUpdateInfo( + const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Decoder */ + const Word16 subFrameIdx, /* i : index of subframe */ + const Word16 igfGridIdx, /* i : IGF grid index */ + const Word16 element_mode /* i : IVAS element mode type */ +); +#else void IGFDecUpdateInfo_ivas_fx( const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Decoder */ const Word16 subFrameIdx, /* i : subframe index */ const Word16 igfGridIdx /* i : IGF grid index */ ); +#endif void IGFDecCopyLPCFlatSpectrum( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ @@ -10093,6 +10112,7 @@ void IGFSaveSpectrumForITF_ivas_fx( const Word32 *pITFSpectrum, /* i : MDCT spectrum */ Word16 exp_pITFSpectrum ); +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS Word16 IGFEncWriteBitstream_ivas_fx( const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ @@ -10100,7 +10120,8 @@ Word16 IGFEncWriteBitstream_ivas_fx( const Word16 igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ const Word16 isIndepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */ ); - +#endif +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS Word16 IGFSCFEncoderEncode_ivas_fx( IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i/o: handle to public data or NULL in case there was no instance created */ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ @@ -10109,7 +10130,7 @@ Word16 IGFSCFEncoderEncode_ivas_fx( const Word16 igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ const Word16 indepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */ ); - +#endif Word16 ari_encode_14bits_ext_ivas_fx( Word16 *ptr, /* Q0 */ Word16 bp, /* Q0 */ @@ -10281,6 +10302,7 @@ void SetModeIndex_ivas_fx( const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) Q0*/ ); +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS void IGFEncSetMode_ivas_fx( const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i/o: instance handle of IGF Encoder */ const Word32 total_brate, /* i : encoder total bitrate */ @@ -10288,7 +10310,7 @@ void IGFEncSetMode_ivas_fx( const Word16 element_mode, /* i : IVAS element mode */ const Word16 rf_mode /* i : flag to signal the RF mode */ ); - +#endif void init_tcx_cfg_ivas_fx( TCX_CONFIG_HANDLE hTcxCfg, const Word32 total_brate, diff --git a/lib_dec/core_dec_switch_fx.c b/lib_dec/core_dec_switch_fx.c index 5c824532e509ffcadec103225bc849184731f1e0..d643ac0c42ce82f7be928dde1a2cb7e791082b81 100644 --- a/lib_dec/core_dec_switch_fx.c +++ b/lib_dec/core_dec_switch_fx.c @@ -313,7 +313,11 @@ void mode_switch_decoder_LPD_ivas_fx( IF( st->igf && ( ( st->idchan == 0 ) || EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) ) { /* switch IGF configuration */ +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGFDecSetMode( st->hIGFDec, total_brate, bwidth, st->element_mode, -1, -1, st->rf_flag ); +#else IGFDecSetMode_ivas_fx( st->hIGFDec, total_brate, bwidth, st->element_mode, -1, -1, st->rf_flag ); +#endif } test(); test(); diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 0b954c17c41712a68c250b803f9d1ea0431944ea..b82ba4e55053f4994410820ae86565cef048afec 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -219,7 +219,11 @@ void decoder_tcx_fx( test(); IF( ( EQ_16( L_frame, shr( st->L_frame, 1 ) ) ) && ( st->tcxonly ) ) { +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGFDecUpdateInfo( st->hIGFDec, frame_cnt, IGF_GRID_LB_SHORT, st->element_mode ); +#else IGFDecUpdateInfo( st->hIGFDec, IGF_GRID_LB_SHORT ); +#endif } ELSE { @@ -227,11 +231,19 @@ void decoder_tcx_fx( test(); IF( ( EQ_16( st->last_core, ACELP_CORE ) ) || ( left_rect && st->bfi ) ) { +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGFDecUpdateInfo( st->hIGFDec, frame_cnt, IGF_GRID_LB_TRAN, st->element_mode ); +#else IGFDecUpdateInfo( st->hIGFDec, IGF_GRID_LB_TRAN ); +#endif } ELSE { +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGFDecUpdateInfo( st->hIGFDec, frame_cnt, IGF_GRID_LB_NORM, st->element_mode ); +#else IGFDecUpdateInfo( st->hIGFDec, IGF_GRID_LB_NORM ); +#endif } } @@ -3742,7 +3754,11 @@ void init_tcx_info_fx( test(); IF( EQ_16( *L_frame, shr( st->L_frame, 1 ) ) && ( st->tcxonly ) ) { +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGFDecUpdateInfo( st->hIGFDec, frame_cnt, IGF_GRID_LB_SHORT, st->element_mode ); +#else IGFDecUpdateInfo_ivas_fx( st->hIGFDec, frame_cnt, IGF_GRID_LB_SHORT ); +#endif } ELSE { @@ -3750,11 +3766,19 @@ void init_tcx_info_fx( test(); IF( st->last_core == ACELP_CORE || ( *left_rect && st->bfi ) ) { +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGFDecUpdateInfo( st->hIGFDec, frame_cnt, IGF_GRID_LB_TRAN, st->element_mode ); +#else IGFDecUpdateInfo_ivas_fx( st->hIGFDec, frame_cnt, IGF_GRID_LB_TRAN ); +#endif } ELSE { +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGFDecUpdateInfo( st->hIGFDec, frame_cnt, IGF_GRID_LB_NORM, st->element_mode ); +#else IGFDecUpdateInfo_ivas_fx( st->hIGFDec, frame_cnt, IGF_GRID_LB_NORM ); +#endif } } } @@ -3801,7 +3825,11 @@ void decoder_tcx_IGF_mono_fx( } } +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGFDecUpdateInfo( st->hIGFDec, frame_cnt, igfGridIdx, st->element_mode ); +#else IGFDecUpdateInfo_ivas_fx( st->hIGFDec, frame_cnt, igfGridIdx ); +#endif IF( st->igf ) { @@ -3907,7 +3935,11 @@ void decoder_tcx_IGF_stereo_fx( move16(); } } +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGFDecUpdateInfo( sts[0]->hIGFDec, k, igfGridIdx, sts[0]->element_mode ); +#else IGFDecUpdateInfo_ivas_fx( sts[0]->hIGFDec, k, igfGridIdx ); +#endif test(); IF( EQ_16( L_frame, shr( sts[1]->L_frame, 1 ) ) && ( sts[1]->tcxonly ) ) @@ -3929,7 +3961,11 @@ void decoder_tcx_IGF_stereo_fx( move16(); } } +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGFDecUpdateInfo( sts[1]->hIGFDec, k, igfGridIdx, sts[1]->element_mode ); +#else IGFDecUpdateInfo_ivas_fx( sts[1]->hIGFDec, k, igfGridIdx ); +#endif IF( sts[0]->igf ) @@ -5058,9 +5094,17 @@ void decoder_tcx_noisefilling_fx( { IGFDecCopyLPCFlatSpectrum_fx( st->hIGFDec, x, *x_e, IGF_GRID_LB_SHORT ); /* also replace flat spectrum for the second TCX10 sub frame */ +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGFDecUpdateInfo( st->hIGFDec, 1, IGF_GRID_LB_SHORT, st->element_mode ); +#else IGFDecUpdateInfo_ivas_fx( st->hIGFDec, 1, IGF_GRID_LB_SHORT ); +#endif IGFDecCopyLPCFlatSpectrum_fx( st->hIGFDec, x, *x_e, IGF_GRID_LB_SHORT ); +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGFDecUpdateInfo( st->hIGFDec, 0, IGF_GRID_LB_SHORT, st->element_mode ); +#else IGFDecUpdateInfo_ivas_fx( st->hIGFDec, 0, IGF_GRID_LB_SHORT ); +#endif Copy( st->hIGFDec->igfData.igf_curr_subframe[0][0], st->hIGFDec->igfData.igf_curr_subframe[1][0], IGF_MAX_SFB ); } ELSE IF( bfi && st->igf && ( frame_cnt == 0 ) && ( EQ_16( L_frameTCX, shr( hTcxDec->L_frameTCX, 1 ) ) ) ) diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index fba40748cd832d65b1b32a2a3ea0aac9ee6229a1..4b6af5b14fe225aa6ecef9314f017983f010021d 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -75,7 +75,7 @@ static Word16 IGF_getScaleFactor32Cond( /**< ou return i; } - +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS /**********************************************************************/ /* measures TCX noise **************************************************************************/ @@ -173,6 +173,82 @@ static Word16 ivas_IGF_replaceTCXNoise_1_fx( /**< out: Q return noise; } +#else + +static Word16 IGF_replaceTCXNoise_1( /**< out: Q0 | number of noise bands */ + const Word32 *in, /**< in: | MDCT spectrum */ + Word16 in_exp, /**< in: | MDCT spectrum exponent */ + Word16 s_l, /**< in: Q0 | noise headroom (for EVS) */ + const Word16 *TCXNoise, /**< in: Q0 | tcx noise indicator vector */ + const Word16 start, /**< in: Q0 | start MDCT subband index */ + const Word16 stop, /**< in: Q0 | stop MDCT subband index */ + Word32 *totalNoiseNrg, /**< out: | measured noise energy */ + Word16 *totalNoiseNrg_exp, /**< out: | measured noise energy exponent */ + const Word16 element_mode /**< in: | IVAS element mode type */ +) +{ + Word16 sb, tmp16, shift, noise; + Word32 tmp32, nE32; + Word64 nE64; + + shift = 2; + move16(); + noise = 0; + move16(); + tmp16 = 0; + move16(); + tmp32 = 0; + move32(); + nE32 = 0; + move32(); + nE64 = 0; + move64(); + s_l = sub( s_l, 5 ); + + *totalNoiseNrg = 0; + move32(); + IF( totalNoiseNrg_exp ) + { + *totalNoiseNrg_exp = 0; + move16(); + } + + FOR( sb = start; sb < stop; sb++ ) + { + IF( TCXNoise[sb] ) + { + IF( EQ_16( element_mode, EVS_MONO ) ) + { + tmp16 = extract_h( L_shl( in[sb], s_l ) ); // Q31 + s_l + nE32 = L_mac( nE32, tmp16, tmp16 ); // Q31 + s_l + } + ELSE + { + tmp32 = L_shr( in[sb], shift ); + nE64 = W_mac_32_32( nE64, tmp32, tmp32 ); // 62 - (in_exp + shift + in_exp + shift + 1) + } + noise = add( noise, 1 ); + } + } + + IF( EQ_16( element_mode, EVS_MONO ) ) + { + *totalNoiseNrg = nE32; // Q31 + s_l + move32(); + } + ELSE IF( nE64 ) + { + tmp16 = W_norm( nE64 ); + nE64 = W_shl( nE64, tmp16 ); + *totalNoiseNrg = W_extract_h( nE64 ); + move32(); + *totalNoiseNrg_exp = sub( add( shl( shift, 1 ), shl( in_exp, 1 ) ), tmp16 ); + move16(); + } + + return noise; +} +#endif /**********************************************************************/ /* replaces TCX noise @@ -525,6 +601,7 @@ static void IGF_convert_exponent_per_idx_to_per_tile( H_IGF_GRID hGrid, } } +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS /**********************************************************************/ /* prepare IGF spectrum **************************************************************************/ @@ -677,6 +754,23 @@ static void IGF_prep( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in } } +#endif + +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS +/**********************************************************************/ /* +prepare IGF spectrum +**************************************************************************/ +static void IGF_prep( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in: | IGF private data handle */ + const Word16 igfGridIdx, /**< in: Q0 | in case of CELP->TCX switching, use 1.25 framelength */ + const Word16 *TCXNoise, /**< in: Q0 | TCX noise vector */ + Word32 *igf_spec, /**< in/out: | prepared IGF spectrum */ + Word16 *igf_spec_e, /**< in/out: | array exponents of igf_spec, one exponent per tile */ + Word32 *src_spec, /**< in/out: | source spectrum */ + const Word16 src_spec_e, /**< in: | exponent of src_spec, whitening off */ + const Word16 specMed_e, /**< in: | exponent of medium flattening level */ + const Word16 element_mode /**< in: | element mode */ +) +#else /**********************************************************************/ /* prepare IGF spectrum (for IVAS) **************************************************************************/ @@ -690,6 +784,7 @@ static void IGF_prep_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in const Word16 specMed_e, /**< in: | exponent of medium flattening level */ const Word16 element_mode /**< in: | element mode */ ) +#endif { H_IGF_GRID hGrid; H_IGF_INFO hInfo; @@ -1269,7 +1364,12 @@ static void IGF_calc( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in const Word32 *spectrum, /**< in: Q31 | MDCT spectrum */ const Word16 spectrum_e, /**< in: | exponent of pSpectralData */ Word32 *igf_spec, /**< in: Q31 | prepared IGF spectrum */ - Word16 *igf_spec_e /**< in: | array exponents of igf_spec, one exponent per tile */ +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + Word16 *igf_spec_e, /**< in: | array exponents of igf_spec, one exponent per tile */ + const Word16 element_mode /**< in: | IVAS element mode type */ +#else + Word16 *igf_spec_e /**< in: | array exponents of igf_spec, one exponent per tile */ +#endif ) { H_IGF_GRID hGrid; @@ -1299,7 +1399,12 @@ static void IGF_calc( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in spectrum_e, squaredSpectra, squaredSpectra_e, +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + 0, + element_mode ); +#else 0 ); +#endif /* calculate the energy per SFB of the survied subbands */ IGFCommonFuncsCalcSfbEnergyPowerSpec( hGrid->startSfb, @@ -1320,7 +1425,12 @@ static void IGF_calc( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in igf_spec_e[i], squaredSpectra, &squaredSpectra_e[i], +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + 0, + element_mode ); +#else 0 ); +#endif /* set all squared values to 0, if the core contains survied lines */ IGF_setLinesToZero( hGrid->tile[i], @@ -1339,7 +1449,7 @@ static void IGF_calc( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in } } - +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS /**********************************************************************/ /* calculates IGF energies (for IVAS) **************************************************************************/ @@ -1417,6 +1527,7 @@ static void IGF_calc_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in igf_pN_e ); } } +#endif /**********************************************************************/ /* apply IGF @@ -1558,7 +1669,12 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in *spectrum_e, energyTmp, &dE_e, +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + negate( tmp ), + EVS_MONO ); +#else negate( tmp ) ); +#endif L_tmp = sum_array_norm( energyTmp, 24, &shift ); /* float: dE = (float)sqrt(dE / 24.f); basop: */ @@ -2222,6 +2338,16 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in /* collect energy below hGrid->startLine: */ tmp = sub( hGrid->startLine, 24 ); +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGFCommonFuncsMDCTSquareSpec( tmp, + hGrid->startLine, + spectrum, + *spectrum_e, + energyTmp, + &dE_e, + negate( tmp ), + IVAS_CPE_MDCT ); +#else IGFCommonFuncsMDCTSquareSpec_ivas( tmp, hGrid->startLine, spectrum, @@ -2229,6 +2355,7 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in energyTmp, &dE_e, negate( tmp ) ); +#endif L_tmp = sum_array_norm( energyTmp, 24, &shift ); /* float: dE = (float)sqrt(dE / 24.f); basop: */ @@ -2931,7 +3058,8 @@ static void IGF_getWhiteSpectralData_ivas( /**********************************************************************/ /* refines the IGF grid **************************************************************************/ -static void IGF_RefineGrid( H_IGF_GRID hGrid /**< in/out: | IGF grid handle */ +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS +static void IGF_RefineGrid( H_IGF_GRID hGrid /**< in/out: | IGF grid handle */ ) { Word16 a[IGF_MAX_SFB + 1]; @@ -2976,6 +3104,10 @@ static void IGF_RefineGrid( H_IGF_GRID hGrid /**< in } static void IGF_RefineGrid_ivas_fx( H_IGF_GRID hGrid /**< in/out: | IGF grid handle */ +#else +static void IGF_RefineGrid( H_IGF_GRID hGrid, /**< in/out: | IGF grid handle */ + const Word16 element_mode /**< in : | IVAS element mode type */ +#endif ) { Word16 a[IGF_MAX_SFB + 1]; @@ -2998,12 +3130,19 @@ static void IGF_RefineGrid_ivas_fx( H_IGF_GRID hGrid /**< in/out: | IGF grid han delta = mac_r( 0x00195000, 29491 /*0.45f Q16*/, shl_sat( delta, 5 ) ); a[tmp] = add( hGrid->swb_offset[sfb], shr( delta, 6 ) ); move16(); - // Rounding off delta values >=t+0.5 to t+1 - IF( GE_16( sub( delta, shl( shr( delta, 6 ), 6 ) ), MID ) ) +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IF( GT_16( element_mode, EVS_MONO ) ) { - a[tmp] = add( a[tmp], 1 ); - move16(); +#endif + // Rounding off delta values >=t+0.5 to t+1 + IF( GE_16( sub( delta, shl( shr( delta, 6 ), 6 ) ), MID ) ) + { + a[tmp] = add( a[tmp], 1 ); + move16(); + } +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS } +#endif IF( s_and( a[tmp], 1 ) != 0 ) { a[tmp] = sub( a[tmp], 1 ); @@ -3028,11 +3167,19 @@ static void IGF_RefineGrid_ivas_fx( H_IGF_GRID hGrid /**< in/out: | IGF grid han /**********************************************************************/ /* reads whitening information from the bitstream **************************************************************************/ -void IGFDecReadData_ivas_fx( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Deccoder */ - Decoder_State *st, /**< in: | decoder state */ - const Word16 igfGridIdx, /**< in: Q0 | in case of CELP->TCX switching, use 1.25 framelength */ - const Word16 isIndepFrame /**< in: Q0 | if 1: arith dec force reset, if 0: no reset */ +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS +void IGFDecReadData( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Deccoder */ + Decoder_State *st, /**< in: | decoder state */ + const Word16 igfGridIdx, /**< in: Q0 | in case of CELP->TCX switching, use 1.25 framelength */ + const Word16 isIndepFrame /**< in: Q0 | if 1: arith dec force reset, if 0: no reset */ ) +#else +void IGFDecReadData_ivas_fx( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Deccoder */ + Decoder_State *st, /**< in: | decoder state */ + const Word16 igfGridIdx, /**< in: Q0 | in case of CELP->TCX switching, use 1.25 framelength */ + const Word16 isIndepFrame /**< in: Q0 | if 1: arith dec force reset, if 0: no reset */ +) +#endif { IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData; H_IGF_GRID hGrid; @@ -3074,7 +3221,11 @@ void IGFDecReadData_ivas_fx( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in { IGF_decode_whitening_level( st, hPrivateData, 0 ); test(); +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IF( ( EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_48000_CPE ) || EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_FB_48000_CPE ) ) && GT_16( st->element_mode, EVS_MONO ) ) +#else IF( EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_48000_CPE ) || EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_FB_48000_CPE ) ) +#endif { tmp = 0; move16(); @@ -3113,6 +3264,7 @@ void IGFDecReadData_ivas_fx( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in } } +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS void IGFDecReadData( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Deccoder */ Decoder_State *st, /**< in: | decoder state */ const Word16 igfGridIdx, /**< in: Q0 | in case of CELP->TCX switching, use 1.25 framelength */ @@ -3187,7 +3339,7 @@ void IGFDecReadData( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | ins IGF_decode_temp_flattening_trigger( st, hInstance ); } } - +#endif /**********************************************************************/ /* read the IGF level information from the bitsream **************************************************************************/ @@ -3312,11 +3464,20 @@ void IGFDecApplyMono( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in igf_spec + hGrid->minSrcSubband, sub( hGrid->startLine, hGrid->minSrcSubband ) ); hPrivateData->n_noise_bands = IGF_replaceTCXNoise_1( igf_spec, +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + 0, +#endif hPrivateData->headroom_TCX_noise_white, hInstance->infoTCXNoise_evs, hGrid->minSrcSubband, hGrid->startLine, +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + &hPrivateData->totalNoiseNrg, + NULL, + EVS_MONO ); +#else &hPrivateData->totalNoiseNrg ); +#endif move16(); move16(); @@ -3333,11 +3494,20 @@ void IGFDecApplyMono( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in sub( hGrid->startLine, hGrid->minSrcSubband ) ); hPrivateData->n_noise_bands_off = IGF_replaceTCXNoise_1( hPrivateData->pSpecFlat, +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + 0, +#endif hPrivateData->headroom_TCX_noise, hInstance->infoTCXNoise_evs, hGrid->minSrcSubband, hGrid->startLine, +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + &hPrivateData->totalNoiseNrg_off, + NULL, + EVS_MONO ); +#else &hPrivateData->totalNoiseNrg_off ); +#endif move16(); move16(); @@ -3353,13 +3523,23 @@ void IGFDecApplyMono( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in igf_spec_e, hPrivateData->pSpecFlat, hPrivateData->pSpecFlat_exp, +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + specMed_e, + EVS_MONO ); +#else specMed_e ); +#endif IGF_calc( hPrivateData, igfGridIdx, spectrum, *spectrum_e, igf_spec, +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + igf_spec_e, + EVS_MONO ); +#else igf_spec_e ); +#endif IGF_appl( hPrivateData, igfGridIdx, spectrum, @@ -3491,6 +3671,17 @@ void IGFDecApplyMono_ivas( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in specMed_e = igf_spec_e[i]; move16(); +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + hPrivateData->n_noise_bands = IGF_replaceTCXNoise_1( igf_spec, + igf_spec_e[i], + 0, + hInstance->infoTCXNoise_ptr, + hGrid->minSrcSubband, + hGrid->startLine, + &hPrivateData->totalNoiseNrg, + &hPrivateData->totalNoiseNrg_exp, + element_mode ); +#else hPrivateData->n_noise_bands = ivas_IGF_replaceTCXNoise_1_fx( igf_spec, igf_spec_e[i], hInstance->infoTCXNoise_ptr, @@ -3498,6 +3689,7 @@ void IGFDecApplyMono_ivas( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in hGrid->startLine, &hPrivateData->totalNoiseNrg, &hPrivateData->totalNoiseNrg_exp ); +#endif move16(); BREAK; @@ -3510,6 +3702,17 @@ void IGFDecApplyMono_ivas( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in IF( EQ_16( hPrivateData->currWhiteningLevel[i], IGF_WHITENING_OFF ) ) { +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + hPrivateData->n_noise_bands_off = IGF_replaceTCXNoise_1( hPrivateData->pSpecFlat, + hPrivateData->pSpecFlat_exp, + 0, + hInstance->infoTCXNoise_ptr, + hGrid->minSrcSubband, + hGrid->startLine, + &hPrivateData->totalNoiseNrg_off, + &hPrivateData->totalNoiseNrg_off_exp, + element_mode ); +#else hPrivateData->n_noise_bands_off = ivas_IGF_replaceTCXNoise_1_fx( hPrivateData->pSpecFlat, hPrivateData->pSpecFlat_exp, hInstance->infoTCXNoise_ptr, @@ -3517,11 +3720,23 @@ void IGFDecApplyMono_ivas( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in hGrid->startLine, &hPrivateData->totalNoiseNrg_off, &hPrivateData->totalNoiseNrg_off_exp ); +#endif move16(); BREAK; } } +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGF_prep( hPrivateData, + igfGridIdx, + hInstance->infoTCXNoise_ptr, + igf_spec, + igf_spec_e, + hPrivateData->pSpecFlat, + hPrivateData->pSpecFlat_exp, + specMed_e, + element_mode ); +#else IGF_prep_ivas( hPrivateData, igfGridIdx, hInstance->infoTCXNoise_ptr, @@ -3531,12 +3746,23 @@ void IGFDecApplyMono_ivas( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in hPrivateData->pSpecFlat_exp, specMed_e, element_mode ); +#endif +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGF_calc( hPrivateData, + igfGridIdx, + spectrum, + *spectrum_e, + igf_spec, + igf_spec_e, + element_mode ); +#else IGF_calc_ivas( hPrivateData, igfGridIdx, spectrum, *spectrum_e, igf_spec, igf_spec_e ); +#endif IGF_appl_ivas( hPrivateData, igfGridIdx, spectrum, @@ -3702,7 +3928,17 @@ void IGFDecApplyStereo( move16(); } - +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + hPrivateDataL->n_noise_bands = IGF_replaceTCXNoise_1( igf_specL_fx, + specMedL_e, + 0, + hIGFDecL->infoTCXNoise_ptr, + hGrid->minSrcSubband, + hGrid->startLine, + &hPrivateDataL->totalNoiseNrg, + &hPrivateDataL->totalNoiseNrg_exp, + IVAS_CPE_MDCT ); +#else hPrivateDataL->n_noise_bands = ivas_IGF_replaceTCXNoise_1_fx( igf_specL_fx, specMedL_e, hIGFDecL->infoTCXNoise_ptr, @@ -3710,6 +3946,7 @@ void IGFDecApplyStereo( hGrid->startLine, &hPrivateDataL->totalNoiseNrg, &hPrivateDataL->totalNoiseNrg_exp ); +#endif move16(); IF( !bfi ) @@ -3732,6 +3969,17 @@ void IGFDecApplyStereo( move16(); } +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + hPrivateDataR->n_noise_bands = IGF_replaceTCXNoise_1( igf_specR_fx, + specMedR_e, + 0, + hIGFDecR->infoTCXNoise_ptr, + hGrid->minSrcSubband, + hGrid->startLine, + &hPrivateDataR->totalNoiseNrg, + &hPrivateDataR->totalNoiseNrg_exp, + IVAS_CPE_MDCT ); +#else hPrivateDataR->n_noise_bands = ivas_IGF_replaceTCXNoise_1_fx( igf_specR_fx, specMedR_e, hIGFDecR->infoTCXNoise_ptr, @@ -3739,6 +3987,7 @@ void IGFDecApplyStereo( hGrid->startLine, &hPrivateDataR->totalNoiseNrg, &hPrivateDataR->totalNoiseNrg_exp ); +#endif move16(); BREAK; } @@ -3749,6 +3998,17 @@ void IGFDecApplyStereo( test(); IF( EQ_16( hPrivateDataL->currWhiteningLevel[i], IGF_WHITENING_OFF ) || EQ_16( hPrivateDataR->currWhiteningLevel[i], IGF_WHITENING_OFF ) ) { +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + hPrivateDataL->n_noise_bands_off = IGF_replaceTCXNoise_1( hPrivateDataL->pSpecFlat, + hPrivateDataL->pSpecFlat_exp, + 0, + hIGFDecL->infoTCXNoise_ptr, + hGrid->minSrcSubband, + hGrid->startLine, + &hPrivateDataL->totalNoiseNrg_off, + &hPrivateDataL->totalNoiseNrg_off_exp, + IVAS_CPE_MDCT ); +#else hPrivateDataL->n_noise_bands_off = ivas_IGF_replaceTCXNoise_1_fx( hPrivateDataL->pSpecFlat, hPrivateDataL->pSpecFlat_exp, hIGFDecL->infoTCXNoise_ptr, @@ -3756,8 +4016,20 @@ void IGFDecApplyStereo( hGrid->startLine, &hPrivateDataL->totalNoiseNrg_off, &hPrivateDataL->totalNoiseNrg_off_exp ); +#endif move16(); +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + hPrivateDataR->n_noise_bands_off = IGF_replaceTCXNoise_1( hPrivateDataR->pSpecFlat, + hPrivateDataR->pSpecFlat_exp, + 0, + hIGFDecR->infoTCXNoise_ptr, + hGrid->minSrcSubband, + hGrid->startLine, + &hPrivateDataR->totalNoiseNrg_off, + &hPrivateDataR->totalNoiseNrg_off_exp, + IVAS_CPE_MDCT ); +#else hPrivateDataR->n_noise_bands_off = ivas_IGF_replaceTCXNoise_1_fx( hPrivateDataR->pSpecFlat, hPrivateDataR->pSpecFlat_exp, hIGFDecR->infoTCXNoise_ptr, @@ -3765,6 +4037,7 @@ void IGFDecApplyStereo( hGrid->startLine, &hPrivateDataR->totalNoiseNrg_off, &hPrivateDataR->totalNoiseNrg_off_exp ); +#endif move16(); BREAK; } @@ -3806,6 +4079,22 @@ void IGFDecApplyStereo( igf_specR_e_arr, igf_specR_e ); +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGF_calc( hPrivateDataL, + igfGridIdx, + spectrumL_fx, + *spectrumL_e, + igf_specL_fx, + igf_specL_e, + IVAS_CPE_MDCT ); + IGF_calc( hPrivateDataR, + igfGridIdx, + spectrumR_fx, + *spectrumR_e, + igf_specR_fx, + igf_specR_e, + IVAS_CPE_MDCT ); +#else IGF_calc_ivas( hPrivateDataL, igfGridIdx, spectrumL_fx, @@ -3818,6 +4107,7 @@ void IGFDecApplyStereo( *spectrumR_e, igf_specR_fx, igf_specR_e ); +#endif IGF_appl_ivas( hPrivateDataL, igfGridIdx, spectrumL_fx, @@ -3894,11 +4184,23 @@ void IGFDecSetMode( move16(); test(); +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IF( ( LE_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_FB_48000 ) && EQ_16( element_mode, EVS_MONO ) ) || + ( NE_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_FB_96000 ) && NE_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_FB_96000_CPE ) && + NE_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_FB_128000 ) && NE_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_FB_128000_CPE ) && GT_16( element_mode, EVS_MONO ) ) ) +#else IF( ( LE_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_48000 ) ) || ( LE_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_FB_48000 ) ) ) +#endif { +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGF_RefineGrid( &hPrivateData->igfInfo.grid[IGF_GRID_LB_NORM], element_mode ); + IGF_RefineGrid( &hPrivateData->igfInfo.grid[IGF_GRID_LB_TRAN], element_mode ); + IGF_RefineGrid( &hPrivateData->igfInfo.grid[IGF_GRID_LB_SHORT], element_mode ); +#else IGF_RefineGrid( &hPrivateData->igfInfo.grid[IGF_GRID_LB_NORM] ); IGF_RefineGrid( &hPrivateData->igfInfo.grid[IGF_GRID_LB_TRAN] ); IGF_RefineGrid( &hPrivateData->igfInfo.grid[IGF_GRID_LB_SHORT] ); +#endif } } ELSE @@ -3913,8 +4215,17 @@ void IGFDecSetMode( move16(); fprintf( stderr, "IGFDecSetMode: initialization error!\n" ); } + IF( GT_16( element_mode, EVS_MONO ) ) + { + hIGFDec->flag_sparse = &hIGFDec->flag_sparseBuf[0]; + hIGFDec->infoTCXNoise_ptr = &hIGFDec->infoTCXNoise_evs[0]; + hIGFDec->virtualSpec_fx = &hIGFDec->virtualSpec[0]; + hIGFDec->igfData.pSpecFlat = &hIGFDec->igfData.pSpecFlatBuf_fx[0]; + hIGFDec->igfData.igfInfo.nfSeed = &hIGFDec->igfData.igfInfo.nfSeedBuf[0]; + } + return; } - +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS void IGFDecSetMode_ivas_fx( const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i : instance handle of IGF Decoder */ const Word32 total_brate, /* i : bitrate */ @@ -3931,7 +4242,11 @@ void IGFDecSetMode_ivas_fx( hIGFDec->isIGFActive = 0; move16(); +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IF( IGFCommonFuncsIGFConfiguration( total_brate, bwidth, element_mode, &hPrivateData->igfInfo, rf_mode ) ) +#else IF( IGFCommonFuncsIGFConfiguration_ivas_fx( total_brate, bwidth, element_mode, &hPrivateData->igfInfo, rf_mode ) ) +#endif { IGFSCFDecoderOpen( &hPrivateData->hArithSCFdec, &hPrivateData->igfInfo, total_brate, bwidth, element_mode, rf_mode ); @@ -3953,9 +4268,15 @@ void IGFDecSetMode_ivas_fx( IF( NE_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_FB_96000 ) && NE_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_FB_96000_CPE ) && NE_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_FB_128000 ) && NE_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_FB_128000_CPE ) ) { +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGF_RefineGrid( &hPrivateData->igfInfo.grid[IGF_GRID_LB_NORM], element_mode ); + IGF_RefineGrid( &hPrivateData->igfInfo.grid[IGF_GRID_LB_TRAN], element_mode ); + IGF_RefineGrid( &hPrivateData->igfInfo.grid[IGF_GRID_LB_SHORT], element_mode ); +#else IGF_RefineGrid_ivas_fx( &hPrivateData->igfInfo.grid[IGF_GRID_LB_NORM] ); IGF_RefineGrid_ivas_fx( &hPrivateData->igfInfo.grid[IGF_GRID_LB_TRAN] ); IGF_RefineGrid_ivas_fx( &hPrivateData->igfInfo.grid[IGF_GRID_LB_SHORT] ); +#endif } /* IGFDecOutInformation(hIGFDec); */ } @@ -3979,6 +4300,8 @@ void IGFDecSetMode_ivas_fx( hIGFDec->igfData.igfInfo.nfSeed = &hIGFDec->igfData.igfInfo.nfSeedBuf[0]; return; } +#endif +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS /**********************************************************************/ /* updates the start/stop frequency of IGF according to igfGridIdx **************************************************************************/ @@ -4004,7 +4327,22 @@ void IGFDecUpdateInfo( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in move16(); } } +#endif +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS +/*-------------------------------------------------------------------* + * IGFDecUpdateInfo() + * + * updates the start/stop frequency of IGF according to igfGridIdx + *-------------------------------------------------------------------*/ + +void IGFDecUpdateInfo( + const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Decoder */ + const Word16 subFrameIdx, /* i : index of subframe */ + const Word16 igfGridIdx, /* i : IGF grid index */ + const Word16 element_mode /* i : IVAS element mode type */ +) +#else /*-------------------------------------------------------------------* * IGFDecUpdateInfo_ivas_fx() * @@ -4016,22 +4354,30 @@ void IGFDecUpdateInfo_ivas_fx( const Word16 subFrameIdx, /* i : index of subframe */ const Word16 igfGridIdx /* i : IGF grid index */ ) +#endif { IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData; H_IGF_GRID hGrid; - hIGFDec->flag_sparse = &hIGFDec->flag_sparseBuf[0]; - hIGFDec->infoTCXNoise_ptr = &hIGFDec->infoTCXNoise_evs[0]; +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IF( GT_16( element_mode, EVS_MONO ) ) + { +#endif + hIGFDec->flag_sparse = &hIGFDec->flag_sparseBuf[0]; + hIGFDec->infoTCXNoise_ptr = &hIGFDec->infoTCXNoise_evs[0]; - hIGFDec->virtualSpec_fx = &hIGFDec->virtualSpec[0]; - hIGFDec->igfData.pSpecFlat = &hIGFDec->igfData.pSpecFlatBuf_fx[0]; + hIGFDec->virtualSpec_fx = &hIGFDec->virtualSpec[0]; + hIGFDec->igfData.pSpecFlat = &hIGFDec->igfData.pSpecFlatBuf_fx[0]; - hIGFDec->igfData.igfInfo.nfSeed = &hIGFDec->igfData.igfInfo.nfSeedBuf[0]; + hIGFDec->igfData.igfInfo.nfSeed = &hIGFDec->igfData.igfInfo.nfSeedBuf[0]; - IF( EQ_16( igfGridIdx, IGF_GRID_LB_SHORT ) ) - { - IGFDecRestoreTCX10SubFrameData_fx( hIGFDec, subFrameIdx ); + IF( EQ_16( igfGridIdx, IGF_GRID_LB_SHORT ) ) + { + IGFDecRestoreTCX10SubFrameData_fx( hIGFDec, subFrameIdx ); + } +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS } +#endif hPrivateData = &hIGFDec->igfData; IF( hIGFDec->isIGFActive ) diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index dd889e83b3c2ab415635b729a742bcb0c5feb988..0cf2b1c3a166823d7b98a2b943e1b41fd3074b28 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -676,7 +676,11 @@ ivas_error mct_dec_reconfigure_fx( IF( st->igf ) { +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGFDecSetMode( st->hIGFDec, st_ivas->hCPE[cpe_id]->element_brate, st->bwidth, st->element_mode, -1, -1, st->rf_flag ); +#else IGFDecSetMode_ivas_fx( st->hIGFDec, st_ivas->hCPE[cpe_id]->element_brate, st->bwidth, st->element_mode, -1, -1, st->rf_flag ); +#endif } } } diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index c085d5674d93cc609b236e82860de45c7ecbf739..518ddf3d4c0a879810f738a30258f2232bbff2dc 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -72,7 +72,11 @@ void mdct_read_IGF_bits_fx( /* read IGF payload */ IGFDecReadLevel( st->hIGFDec, st0, temp, 1 ); +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGFDecReadData( st->hIGFDec, st0, temp, 1 ); +#else IGFDecReadData_ivas_fx( st->hIGFDec, st0, temp, 1 ); +#endif } IF( EQ_16( st->core, TCX_10_CORE ) ) @@ -91,7 +95,11 @@ void mdct_read_IGF_bits_fx( } IGFDecReadLevel( st->hIGFDec, st0, IGF_GRID_LB_SHORT, temp ); +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGFDecReadData( st->hIGFDec, st0, IGF_GRID_LB_SHORT, temp ); +#else IGFDecReadData_ivas_fx( st->hIGFDec, st0, IGF_GRID_LB_SHORT, temp ); +#endif IGFDecStoreTCX10SubFrameData( st->hIGFDec, k ); } diff --git a/lib_enc/core_enc_init_fx.c b/lib_enc/core_enc_init_fx.c index 23dcd45b1e045f3c67b71541339f573956bfbf6e..7ad4fb50649a8f5f00ef14b110488d20a8676d2a 100644 --- a/lib_enc/core_enc_init_fx.c +++ b/lib_enc/core_enc_init_fx.c @@ -1061,7 +1061,11 @@ void init_coder_ace_plus_ivas_fx( test(); IF( st->igf && st->hIGFEnc != NULL ) { +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGFEncSetMode_fx( st->hIGFEnc, igf_brate, st->bwidth, st->element_mode, st->rf_mode ); +#else IGFEncSetMode_ivas_fx( st->hIGFEnc, igf_brate, st->bwidth, st->element_mode, st->rf_mode ); +#endif } ELSE IF( st->hIGFEnc != NULL ) { diff --git a/lib_enc/enc_prm_fx.c b/lib_enc/enc_prm_fx.c index e28dd0bf99392be34f6c528b1a6fc31db9afd3c2..2f529a2659db57437e74774ca573fb21920af697 100644 --- a/lib_enc/enc_prm_fx.c +++ b/lib_enc/enc_prm_fx.c @@ -777,11 +777,19 @@ void enc_prm_fx( move16(); IF( EQ_16( st->last_core, ACELP_CORE ) ) { +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGFEncWriteBitstream_fx( st->hIGFEnc, hBstr, &st->hIGFEnc->infoTotalBitsPerFrameWritten, IGF_GRID_LB_TRAN, 1, st->element_mode ); +#else IGFEncWriteBitstream_fx( st->hIGFEnc, hBstr, &st->hIGFEnc->infoTotalBitsPerFrameWritten, IGF_GRID_LB_TRAN, 1 ); +#endif } ELSE { +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGFEncWriteBitstream_fx( st->hIGFEnc, hBstr, &st->hIGFEnc->infoTotalBitsPerFrameWritten, IGF_GRID_LB_NORM, 1, st->element_mode ); +#else IGFEncWriteBitstream_fx( st->hIGFEnc, hBstr, &st->hIGFEnc->infoTotalBitsPerFrameWritten, IGF_GRID_LB_NORM, 1 ); +#endif } } total_nbbits = sub( hBstr->nb_bits_tot, nbits_start ); /* Q0 */ @@ -1095,7 +1103,11 @@ void writeTCXparam_fx( test(); IF( LT_16( st->element_mode, IVAS_CPE_MDCT ) && k == 0 && st->igf && EQ_16( core, TCX_10_CORE ) ) { +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + nbits_igf = IGFEncWriteConcatenatedBitstream_fx( st->hIGFEnc, hBstr ); /* Q0 */ +#else nbits_igf = IGFEncWriteConcatenatedBitstream_ivas_fx( st->hIGFEnc, hBstr ); /* Q0 */ +#endif } flag_ctx_hm = 0; @@ -1258,7 +1270,11 @@ void writeTCXparam_fx( } st->hIGFEnc->infoTotalBitsPerFrameWritten = 0; move16(); +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGFEncWriteBitstream_fx( st->hIGFEnc, hBstr, &st->hIGFEnc->infoTotalBitsPerFrameWritten, gridIdx, 1, st->element_mode ); +#else IGFEncWriteBitstream_ivas_fx( st->hIGFEnc, hBstr, &st->hIGFEnc->infoTotalBitsPerFrameWritten, gridIdx, 1 ); +#endif } total_nbbits = sub( hBstr->nb_bits_tot, nbits_start ); /* Q0 */ diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index 72a26b2482533cde5902e0b020ed60d1f0ca799b..487aa095c044609c724527c2d0e254dc34632251 100755 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -156,7 +156,12 @@ static void IGF_CalculateEnvelope( MDCTSpectrum_e, LFMDCTSpectrum, &LFMDCTSpectrum_exp, +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + 0, + EVS_MONO ); +#else 0 ); +#endif IGFCommonFuncsCalcSfbEnergyPowerSpec( hGrid->startSfb, hGrid->stopSfb, hGrid->swb_offset, @@ -173,7 +178,12 @@ static void IGF_CalculateEnvelope( MDCTSpectrum_e, LFMDCTSpectrum, &LFMDCTSpectrum_exp, +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + 0, + EVS_MONO ); +#else 0 ); +#endif IGFCommonFuncsCalcSfbEnergyPowerSpec( hGrid->startSfb, hGrid->stopSfb, hGrid->swb_offset, @@ -285,7 +295,7 @@ static void IGF_CalculateEnvelope( return; } - +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS /**********************************************************************/ /* writes IGF SCF values **************************************************************************/ @@ -340,7 +350,11 @@ static void IGF_WriteEnvelope( IGFSCFEncoderSaveContextState_fx( &hPrivateData->hIGFSCFArithEnc, igfGridIdx ); } +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + *pBitOffset = IGFSCFEncoderEncode_fx( &hPrivateData->hIGFSCFArithEnc, hBstr, *pBitOffset, &hPrivateData->igfScfQuantized[hGrid->startSfb], igfGridIdx, EVS_MONO, isIndepFlag ); +#else *pBitOffset = IGFSCFEncoderEncode_fx( &hPrivateData->hIGFSCFArithEnc, hBstr, *pBitOffset, &hPrivateData->igfScfQuantized[hGrid->startSfb], igfGridIdx, isIndepFlag ); +#endif move16(); if ( NULL == hBstr ) @@ -349,7 +363,86 @@ static void IGF_WriteEnvelope( } } } +#else +/*-------------------------------------------------------------------* + * IGF_WriteEnvelope() + * + * writes IGF SCF values + *-------------------------------------------------------------------*/ +/*! r: number of bits writen */ +static Word16 IGF_WriteEnvelope( + const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 *pBitOffset, /* i : ptr to bitOffset counter */ + const Word16 igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ + const Word16 isIndepFlag, /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */ + Word16 *igfAllZero, /* i : returns 1 if all IGF scfs are zero, else 0 */ + const Word16 element_mode /* i : IVAS element mode type */ +) +{ + IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData; + H_IGF_GRID hGrid; + Word16 sfb; + Word16 totBitCount; + Word16 startBitCount; + + startBitCount = *pBitOffset; + totBitCount = 0; + *igfAllZero = 1; + move16(); + move16(); + move16(); + hPrivateData = &hIGFEnc->igfData; + hGrid = &hPrivateData->igfInfo.grid[igfGridIdx]; + + FOR( sfb = hGrid->startSfb; sfb < hGrid->stopSfb; sfb++ ) + { + IF( hPrivateData->igfScfQuantized[sfb] != 0 ) + { + *igfAllZero = 0; + move16(); + BREAK; + } + } + + IF( *igfAllZero != 0 ) + { + IGF_write_bit_fx( hBstr, pBitOffset, 1 ); + + if ( NULL == hBstr ) + { + IGFSCFEncoderSaveContextState_fx( &hPrivateData->hIGFSCFArithEnc, igfGridIdx ); + } + IGFSCFEncoderReset_fx( &hPrivateData->hIGFSCFArithEnc ); + + if ( NULL == hBstr ) + { + IGFSCFEncoderRestoreContextState_fx( &hPrivateData->hIGFSCFArithEnc, igfGridIdx ); + } + } + ELSE + { + IGF_write_bit_fx( hBstr, pBitOffset, 0 ); + + if ( NULL == hBstr ) + { + IGFSCFEncoderSaveContextState_fx( &hPrivateData->hIGFSCFArithEnc, igfGridIdx ); + } + + *pBitOffset = IGFSCFEncoderEncode_fx( &hPrivateData->hIGFSCFArithEnc, hBstr, *pBitOffset, &hPrivateData->igfScfQuantized[hGrid->startSfb], igfGridIdx, element_mode, isIndepFlag ); + move16(); + + if ( NULL == hBstr ) + { + IGFSCFEncoderRestoreContextState_fx( &hPrivateData->hIGFSCFArithEnc, igfGridIdx ); + } + } + totBitCount = sub( *pBitOffset, startBitCount ); + + return totBitCount; +} +#endif /**********************************************************************/ /* identifies significant spectral content **************************************************************************/ @@ -701,9 +794,18 @@ crest factor calculation Word16 IGF_getCrest( /**< out: Q15| crest factor */ Word16 *crest_exp, /**< out: | exponent of crest factor */ const Word32 *powerSpectrum, /**< in: Q31 | power spectrum */ - const Word16 powerSpectrum_exp, /**< in: | exponent of power spectrum */ - const Word16 start, /**< in: Q0 | start subband index */ - const Word16 stop /**< in: Q0 | stop subband index */ +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + const Word16 *powerSpectrum_exp, /**< in: | exponent of power spectrum */ +#else + const Word16 powerSpectrum_exp, /**< in: | exponent of power spectrum */ +#endif + const Word16 start, /**< in: Q0 | start subband index */ +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + const Word16 stop, /**< in: Q0 | stop subband index */ + const Word16 element_mode /**< in: | IVAS element mode type */ +#else + const Word16 stop /**< in: Q0 | stop subband index */ +#endif ) { Word16 i; @@ -714,6 +816,9 @@ Word16 IGF_getCrest( /**< ou Word16 crest; Word16 tmp; Word32 tmp32; +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + Word16 powSpec_exp; +#endif x_eff32 = 0; move32(); @@ -723,14 +828,26 @@ Word16 IGF_getCrest( /**< ou move16(); *crest_exp = 1; move16(); +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + powSpec_exp = powerSpectrum_exp[0]; + move16(); +#endif FOR( i = start; i < stop; i++ ) { /*x = max(0, (int)(log(powerSpectrum[i]) * INV_LOG_2));*/ /*see IGF_getSFM for more comment */ +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IF( GT_16( element_mode, EVS_MONO ) ) + { + powSpec_exp = powerSpectrum_exp[i]; /* exponent is a vector in IVAS (and a scalar in EVS) */ + } + x = sub( sub( powSpec_exp, norm_l( powerSpectrum[i] ) ), 1 ); /*Q0*/ +#else x = sub( sub( powerSpectrum_exp, norm_l( powerSpectrum[i] ) ), 1 ); /*Q0*/ - if ( powerSpectrum[i] == 0 ) /*special case: energy is zero*/ +#endif + if ( powerSpectrum[i] == 0 ) /*special case: energy is zero*/ { x = 0; move16(); @@ -778,7 +895,7 @@ Word16 IGF_getCrest( /**< ou return crest; } - +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS Word16 IGF_getCrest_ivas( /**< out: Q15| crest factor */ Word16 *crest_exp, /**< out: | exponent of crest factor */ const Word32 *powerSpectrum, /**< in: Q31 | power spectrum */ @@ -859,6 +976,7 @@ Word16 IGF_getCrest_ivas( /**< out: Q15| crest return crest; } +#endif /************************************************************************* calculates spectral flatness measurment @@ -868,7 +986,12 @@ Word16 IGF_getSFM( /**< out: Q15| SFM value const Word32 *energy, /**< in: Q31| energies */ const Word16 *energy_exp, /**< in: | exponent of energies */ const Word16 start, /**< in: Q0 | start subband index */ - const Word16 stop /**< in: Q0 | stop subband index */ +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + const Word16 stop, /**< in: Q0 | stop subband index */ + const Word16 element_mode /**< in: | IVAS element mode type */ +#else + const Word16 stop /**< in: Q0 | stop subband index */ +#endif ) { Word16 n, i, s; @@ -879,12 +1002,42 @@ Word16 IGF_getSFM( /**< out: Q15| SFM value Word16 numf; Word32 SFM32; Word16 invDenom, SFM; +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + Word64 W_denom; + Word16 en_exp; + +#else move32(); move32(); move32(); +#endif num = 0; move32(); +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + *SFM_exp = 0; + move16(); + SFM = 32767 /*1.0f Q15*/; + move16(); + en_exp = energy_exp[0]; + move16(); + IF( EQ_16( element_mode, EVS_MONO ) ) + { + denom = L_shr( 2147483 /*0,001 in Q31 - float is "1", here*/, s_min( en_exp, 31 ) ); + denom = L_max( denom, 1 ); + move32(); + move32(); + W_denom = W_deposit32_l( denom ); + move64(); + } + ELSE + { + denom = 65536; // 1.f in Q16 + move32(); + denom_exp = 15; + move16(); + } +#else denom = L_shr( 2147483 /*0,001 in Q31 - float is "1", here*/, s_min( *energy_exp, 31 ) ); denom = L_max( denom, 1 ); *SFM_exp = 0; @@ -893,6 +1046,7 @@ Word16 IGF_getSFM( /**< out: Q15| SFM value move16(); Word64 W_denom = W_deposit32_l( denom ); +#endif FOR( i = start; i < stop; i++ ) { /*ln(x * 2^-Qx * 2^xExp) = ln(x) - Qx + xExp*/ @@ -900,8 +1054,15 @@ Word16 IGF_getSFM( /**< out: Q15| SFM value /* n = sub(sub(31,norm_l(tmp32)),1); */ /*<- ld */ /* n = sub(n,31); */ /*<- -Qx */ /* n = add(n,*energy_exp); */ /*<- +xExp */ - +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IF( GT_16( element_mode, EVS_MONO ) ) + { + en_exp = energy_exp[i]; /* exponent is a vector in IVAS (and a scalar in EVS) */ + } + n = sub( sub( en_exp, norm_l( energy[i] ) ), 1 ); /*<-- short form*/ +#else n = sub( sub( *energy_exp, norm_l( energy[i] ) ), 1 ); /*<-- short form*/ +#endif if ( energy[i] == 0 ) /*special case: energy is zero*/ { @@ -912,11 +1073,30 @@ Word16 IGF_getSFM( /**< out: Q15| SFM value n = s_max( 0, n ); num = L_add( num, L_deposit_l( n ) ); /*Q0*/ +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IF( EQ_16( element_mode, EVS_MONO ) ) + { + W_denom = W_add( W_deposit32_l( energy[i] ), W_denom ); + } + ELSE + { + denom = BASOP_Util_Add_Mant32Exp( energy[i], en_exp, denom, denom_exp, &denom_exp ); + } +#else W_denom = W_add( W_deposit32_l( energy[i] ), W_denom ); +#endif } +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IF( EQ_16( element_mode, EVS_MONO ) ) + { + denom = w_norm_llQ31( W_denom, &denom_exp ); /*Q31*/ + denom_exp = add( denom_exp, en_exp ); + } +#else denom = w_norm_llQ31( W_denom, &denom_exp ); /*Q31*/ denom_exp = add( denom_exp, *energy_exp ); +#endif /* calculate SFM only if signal is present */ IF( denom != 0 ) @@ -964,6 +1144,7 @@ Word16 IGF_getSFM( /**< out: Q15| SFM value return SFM /*Q15*/; } +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS /************************************************************************* calculates spectral flatness measurment **************************************************************************/ @@ -1060,7 +1241,7 @@ Word16 IGF_getSFM_ivas_fx( /**< out: Q15| SFM value return SFM /*Q15*/; } - +#endif /**********************************************************************/ /* calculates the IGF whitening levels by SFM and crest **************************************************************************/ @@ -1136,8 +1317,16 @@ static void IGF_Whitening( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in FOR( p = 0; p < nT; p++ ) { /*tmp = IGF_getSFM(powerSpectrum, hGrid->tile[p], hGrid->tile[p+1]) / IGF_getCrest(powerSpectrum, hGrid->tile[p], hGrid->tile[p+1]);*/ +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + SFM = IGF_getSFM( &SFM_exp, powerSpectrum, &powerSpectrum_exp, hGrid->tile[p], hGrid->tile[p + 1], EVS_MONO ); +#else SFM = IGF_getSFM( &SFM_exp, powerSpectrum, &powerSpectrum_exp, hGrid->tile[p], hGrid->tile[p + 1] ); +#endif +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + crest = IGF_getCrest( &crest_exp, powerSpectrum, &powerSpectrum_exp, hGrid->tile[p], hGrid->tile[p + 1], EVS_MONO ); +#else crest = IGF_getCrest( &crest_exp, powerSpectrum, powerSpectrum_exp, hGrid->tile[p], hGrid->tile[p + 1] ); +#endif tmp = BASOP_Util_Divide1616_Scale( SFM, crest, &s ); /* Q15 */ s = add( s, sub( SFM_exp, crest_exp ) ); @@ -1224,7 +1413,7 @@ static void IGF_Whitening( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in return; } - +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS /**********************************************************************/ /* write whitening levels into bitstream **************************************************************************/ @@ -1255,7 +1444,51 @@ static void IGF_WriteWhiteningTile_fx( return; } +#else +/*-------------------------------------------------------------------* + * IGF_WriteWhiteningTile_fx() + * + * write whitening levels into bitstream + *-------------------------------------------------------------------*/ + +/*! r: number of bits written */ +static Word16 IGF_WriteWhiteningTile_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 *pBitOffset, /**< in: | ptr to bitOffset counter */ + Word16 whiteningLevel /**< in: Q0 | whitening levels to write */ +) +{ + Word16 totBitCount; + Word16 startBitCount; + totBitCount = 0; + startBitCount = *pBitOffset; + move16(); + move16(); + + IF( EQ_16( whiteningLevel, IGF_WHITENING_MID ) ) + { + IGF_write_bits( hBstr, pBitOffset, 0, 1 ); + } + ELSE + { + IGF_write_bits( hBstr, pBitOffset, 1, 1 ); + IF( EQ_16( whiteningLevel, IGF_WHITENING_OFF ) ) + { + IGF_write_bits( hBstr, pBitOffset, 0, 1 ); + } + ELSE + { + IGF_write_bits( hBstr, pBitOffset, 1, 1 ); + } + } + totBitCount = sub( *pBitOffset, startBitCount ); + + return totBitCount; +} + +#endif +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS /**********************************************************************/ /* writes the whitening levels **************************************************************************/ @@ -1353,7 +1586,129 @@ static void IGF_WriteWhiteningLevels_fx( } } } +#else +/*-------------------------------------------------------------------* + * IGF_WriteWhiteningLevels_fx() + * + * writes the whitening levels + *-------------------------------------------------------------------*/ + +/**< out: Q0 | total number of bits written */ +static Word16 IGF_WriteWhiteningLevels_fx( + const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF encoder */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 *pBitOffset, /**< in: | ptr to bitOffset counter */ + const Word16 igfGridIdx, /**< in: Q0 | igf grid index see declaration of IGF_GRID_IDX for details */ + const Word16 isIndepFlag /**< in: Q0 | if 1 frame is independent, 0 = frame is coded with data from previous frame */ +) +{ + IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData; + H_IGF_GRID hGrid; + Word16 p; + Word16 nTiles; + Word16 isSame; + Word32 tmp32; + Word16 totBitCount; + Word16 startBitCount; + + totBitCount = 0; + move16(); + isSame = 1; + move16(); + startBitCount = *pBitOffset; + move16(); + hPrivateData = &hInstance->igfData; + hGrid = &hPrivateData->igfInfo.grid[igfGridIdx]; + nTiles = hGrid->nTiles; + move16(); + + IF( isIndepFlag ) + { + isSame = 0; + move16(); + } + ELSE + { + p = 0; + move16(); + tmp32 = 0; + move32(); + test(); + WHILE( ( LT_16( p, nTiles ) ) && ( tmp32 == 0 ) ) + { + test(); + tmp32 = L_sub( hPrivateData->igfCurrWhiteningLevel[p], hPrivateData->igfPrevWhiteningLevel[p] ); + if ( tmp32 != 0 ) + { + isSame = 0; + move16(); + } + p++; + } + } + IF( isSame ) + { + IGF_write_bits( hBstr, pBitOffset, 1, 1 ); + } + ELSE + { + IF( !isIndepFlag ) + { + IGF_write_bits( hBstr, pBitOffset, 0, 1 ); + } + IGF_WriteWhiteningTile_fx( hBstr, pBitOffset, hPrivateData->igfCurrWhiteningLevel[0] ); + p = 1; + move16(); + tmp32 = 0; + move32(); + test(); + IF( EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_48000_CPE ) || EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_FB_48000_CPE ) ) + { + isSame = 1; + move16(); + } + ELSE + { + if ( LT_16( p, nTiles ) ) + { + isSame = 1; + move16(); + } + test(); + WHILE( ( LT_16( p, nTiles ) ) && ( tmp32 == 0 ) ) + { + test(); + tmp32 = L_sub( hPrivateData->igfCurrWhiteningLevel[p], hPrivateData->igfCurrWhiteningLevel[p - 1] ); + if ( tmp32 != 0 ) + { + isSame = 0; + move16(); + } + p++; + } + } + test(); + IF( !isSame ) + { + IGF_write_bits( hBstr, pBitOffset, 1, 1 ); + FOR( p = 1; p < nTiles; p++ ) + { + IGF_WriteWhiteningTile_fx( hBstr, pBitOffset, hPrivateData->igfCurrWhiteningLevel[p] ); + } + } + ELSE IF( NE_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_48000_CPE ) && NE_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_FB_48000_CPE ) ) + { + IGF_write_bits( hBstr, pBitOffset, 0, 1 ); + } + } + + totBitCount = sub( *pBitOffset, startBitCount ); + + return totBitCount; +} +#endif +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS /**********************************************************************/ /* write flattening trigger **************************************************************************/ @@ -1371,7 +1726,38 @@ static void IGF_WriteFlatteningTrigger_fx( IGF_write_bits( hBstr, pBitOffset, flatteningTrigger, 1 ); } +#else +/*-------------------------------------------------------------------* + * IGF_WriteFlatteningTrigger_fx() + * + * write flattening trigger + *-------------------------------------------------------------------*/ + +/*! r: number of bits written */ +static Word16 IGF_WriteFlatteningTrigger_fx( + const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */ + BSTR_ENC_HANDLE hBstr, /**< inout: | encoder bitstream handle */ + Word16 *pBitOffset /**< in: | ptr to bitOffset counter */ +) +{ + Word16 flatteningTrigger; + + Word16 totBitCount; + Word16 startBitCount; + totBitCount = 0; + startBitCount = *pBitOffset; + flatteningTrigger = hInstance->flatteningTrigger; + move16(); + move16(); + move16(); + + IGF_write_bits( hBstr, pBitOffset, flatteningTrigger, 1 ); + totBitCount = sub( *pBitOffset, startBitCount ); + return totBitCount; +} + +#endif /**********************************************************************/ /* updates the start/stop frequency of IGF according to igfGridIdx **************************************************************************/ @@ -1405,7 +1791,12 @@ Word16 IGFEncWriteBitstream_fx( /**< ou BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ Word16 *pBitOffset, /**< in: | ptr to bitOffset counter */ const Word16 igfGridIdx, /**< in: Q0 | igf grid index see declaration of IGF_GRID_IDX for details */ - const Word16 isIndepFlag /**< in: Q0 | if 1 frame is independent, 0 = frame is coded with data from previous frame */ +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + const Word16 isIndepFlag, /**< in: Q0 | if 1 frame is independent, 0 = frame is coded with data from previous frame */ + const Word16 element_mode /**< in: | IVAS element mode type */ +#else + const Word16 isIndepFlag /**< in: Q0 | if 1 frame is independent, 0 = frame is coded with data from previous frame */ +#endif ) { Word16 igfAllZero; @@ -1423,12 +1814,17 @@ Word16 IGFEncWriteBitstream_fx( /**< ou move16(); } - IGF_WriteEnvelope( hInstance, /* i: instance handle of IGF Encoder */ - hBstr, /* i: encoder state */ - pBitOffset, /* i: ptr to bitOffset counter */ - igfGridIdx, /* i: igf grid index see definition of IGF_GRID_IDX for details */ - isIndepFlag, /* i: if 1 frame is independent, 0 = frame is coded with data from previous frame */ - &igfAllZero ); /* o: *igfAllZero */ + IGF_WriteEnvelope( hInstance, /* i: instance handle of IGF Encoder */ + hBstr, /* i: encoder state */ + pBitOffset, /* i: ptr to bitOffset counter */ + igfGridIdx, /* i: igf grid index see definition of IGF_GRID_IDX for details */ + isIndepFlag, /* i: if 1 frame is independent, 0 = frame is coded with data from previous frame */ +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + &igfAllZero, /* o: *igfAllZero */ + element_mode ); /* i: IVAS element mode type */ +#else + &igfAllZero ); /* o: *igfAllZero */ +#endif IGF_WriteWhiteningLevels_fx( hInstance, /* i: instance handle of IGF Encoder */ hBstr, /* i: encoder state */ @@ -1447,6 +1843,7 @@ Word16 IGFEncWriteBitstream_fx( /**< ou return hInstance->infoTotalBitsPerFrameWritten; } +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS /**********************************************************************/ /* sets the IGF mode according to given bitrate **************************************************************************/ @@ -1522,7 +1919,7 @@ void IGFEncSetMode_fx( set32_fx( hIGFEnc->spec_be_igf, 0, N_MAX_TCX - IGF_START_MN ); return; } - +#endif /*-------------------------------------------------------------------* * pack_bit() * @@ -1559,6 +1956,18 @@ static void pack_bit_fx( return; } +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS +/*-------------------------------------------------------------------* + * IGFEncConcatenateBitstream() + * + * IGF bitstream concatenation for TCX10 modes + *-------------------------------------------------------------------*/ + +void IGFEncConcatenateBitstream( const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ + const Word16 bsBits, /* i : number of IGF bits written to list of indices */ + BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */ +) +#else /*-------------------------------------------------------------------* * IGFEncConcatenateBitstream_fx() * @@ -1569,6 +1978,7 @@ void IGFEncConcatenateBitstream_ivas_fx( const IGF_ENC_INSTANCE_HANDLE hIGFEnc, const Word16 bsBits, /* i : number of IGF bits written to list of indices */ BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */ ) +#endif { Word16 i; IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData; @@ -1657,6 +2067,7 @@ Word16 IGFEncWriteConcatenatedBitstream_fx( return hInstance->infoTotalBitsWritten; } +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS Word16 IGFEncWriteConcatenatedBitstream_ivas_fx( /**< out: Q0 | total number of bits written */ const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */ BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ @@ -1685,6 +2096,7 @@ Word16 IGFEncWriteConcatenatedBitstream_ivas_fx( return hInstance->infoTotalBitsWritten; } +#endif /**********************************************************************/ /* apply the IGF encoder, main encoder interface @@ -1777,11 +2189,19 @@ ivas_error IGF_Reconfig_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hIGFEnc\n" ) ); } +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGFEncSetMode_fx( *hIGFEnc, brate, bwidth, element_mode, rf_mode ); +#else IGFEncSetMode_ivas_fx( *hIGFEnc, brate, bwidth, element_mode, rf_mode ); +#endif } ELSE IF( igf && reset ) { +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGFEncSetMode_fx( *hIGFEnc, brate, bwidth, element_mode, rf_mode ); +#else IGFEncSetMode_ivas_fx( *hIGFEnc, brate, bwidth, element_mode, rf_mode ); +#endif } ELSE IF( !igf && *hIGFEnc != NULL ) { @@ -2808,15 +3228,33 @@ static void IGF_CalculateStereoEnvelope_fx( move16(); move16(); +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + // tmp_tb = IGF_getSFM(pPowerSpectrum, swb_offset[sfb], swb_offset[sfb + 1]) / IGF_getCrest(pPowerSpectrum, swb_offset[sfb], swb_offset[sfb + 1]); + sfm = IGF_getSFM( &sfm_exp, pPowerSpectrum_fx, pPowerSpectrum_e, swb_offset[sfb], swb_offset[sfb + 1], IVAS_CPE_MDCT ); +#else // tmp_tb = IGF_getSFM_ivas(pPowerSpectrum, swb_offset[sfb], swb_offset[sfb + 1]) / IGF_getCrest_ivas(pPowerSpectrum, swb_offset[sfb], swb_offset[sfb + 1]); sfm = IGF_getSFM_ivas_fx( &sfm_exp, pPowerSpectrum_fx, pPowerSpectrum_e, swb_offset[sfb], swb_offset[sfb + 1] ); +#endif +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + crest = IGF_getCrest( &crest_exp, pPowerSpectrum_fx, pPowerSpectrum_e, swb_offset[sfb], swb_offset[sfb + 1], IVAS_CPE_MDCT ); +#else crest = IGF_getCrest_ivas( &crest_exp, pPowerSpectrum_fx, pPowerSpectrum_e, swb_offset[sfb], swb_offset[sfb + 1] ); +#endif tmp_tb_fx = BASOP_Util_Divide1616_Scale( sfm, crest, &tmp_e ); tmp_tb_e = add( tmp_e, sub( sfm_exp, crest_exp ) ); /*stores the resultant exponent for tmp_tb_fx*/ +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + // tmp_sb = IGF_getSFM(tileSrcSpec, 0, strt_cpy - tmp) / IGF_getCrest(tileSrcSpec, 0, strt_cpy - tmp); + sfm = IGF_getSFM( &sfm_exp, tileSrcSpec_fx, tileSrcSpec_e, 0, sub( strt_cpy, tmp ), IVAS_CPE_MDCT ); +#else // tmp_sb = IGF_getSFM_ivas(tileSrcSpec, 0, strt_cpy - tmp) / IGF_getCrest_ivas(tileSrcSpec, 0, strt_cpy - tmp); sfm = IGF_getSFM_ivas_fx( &sfm_exp, tileSrcSpec_fx, tileSrcSpec_e, 0, sub( strt_cpy, tmp ) ); +#endif +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + crest = IGF_getCrest( &crest_exp, tileSrcSpec_fx, tileSrcSpec_e, 0, sub( strt_cpy, tmp ), IVAS_CPE_MDCT ); +#else crest = IGF_getCrest_ivas( &crest_exp, tileSrcSpec_fx, tileSrcSpec_e, 0, sub( strt_cpy, tmp ) ); +#endif tmp_sb_fx = BASOP_Util_Divide1616_Scale( sfm, crest, &tmp_e ); tmp_sb_e = add( tmp_e, sub( sfm_exp, crest_exp ) ); /*stores the resultant exponent for tmp_sb_fx*/ @@ -2959,18 +3397,36 @@ static void IGF_CalculateStereoEnvelope_fx( IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( slope_fx, add( slope_e, 16 ), negate( threshold_fx ), add( threshold_e, 16 ) ), -1 ) ) { Word16 shift = shr( width, 1 ); +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + // shiftedSFM = IGF_getSFM( pPowerSpectrum, swb_offset[sfb] - shift, swb_offset[sfb + 1] - shift ) / IGF_getCrest( pPowerSpectrum, swb_offset[sfb] - shift, swb_offset[sfb + 1] - shift ); + sfm = IGF_getSFM( &sfm_exp, pPowerSpectrum_fx, pPowerSpectrum_e, sub( swb_offset[sfb], shift ), sub( swb_offset[sfb + 1], shift ), IVAS_CPE_MDCT ); +#else // shiftedSFM = IGF_getSFM_ivas( pPowerSpectrum, swb_offset[sfb] - shift, swb_offset[sfb + 1] - shift ) / IGF_getCrest_ivas( pPowerSpectrum, swb_offset[sfb] - shift, swb_offset[sfb + 1] - shift ); sfm = IGF_getSFM_ivas_fx( &sfm_exp, pPowerSpectrum_fx, pPowerSpectrum_e, sub( swb_offset[sfb], shift ), sub( swb_offset[sfb + 1], shift ) ); +#endif +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + crest = IGF_getCrest( &crest_exp, pPowerSpectrum_fx, pPowerSpectrum_e, sub( swb_offset[sfb], shift ), sub( swb_offset[sfb + 1], shift ), IVAS_CPE_MDCT ); +#else crest = IGF_getCrest_ivas( &crest_exp, pPowerSpectrum_fx, pPowerSpectrum_e, sub( swb_offset[sfb], shift ), sub( swb_offset[sfb + 1], shift ) ); +#endif shiftedSFM_fx = BASOP_Util_Divide1616_Scale( sfm, crest, &shiftedSFM_e ); } ELSE IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( slope_fx, add( slope_e, 16 ), threshold_fx, add( threshold_e, 16 ) ), 1 ) && ( NE_16( sfb, sub( hGrid->sfbWrap[hGrid->nTiles], 1 ) ) ) ) { Word16 shift; shift = shr( width, 1 ); +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + // shiftedSFM = IGF_getSFM( pPowerSpectrum, swb_offset[sfb] + shift, swb_offset[sfb + 1] + shift ) / IGF_getCrest( pPowerSpectrum, swb_offset[sfb] + shift, swb_offset[sfb + 1] + shift ); + sfm = IGF_getSFM( &sfm_exp, pPowerSpectrum_fx, pPowerSpectrum_e, add( swb_offset[sfb], shift ), add( swb_offset[sfb + 1], shift ), IVAS_CPE_MDCT ); +#else // shiftedSFM = IGF_getSFM_ivas( pPowerSpectrum, swb_offset[sfb] + shift, swb_offset[sfb + 1] + shift ) / IGF_getCrest_ivas( pPowerSpectrum, swb_offset[sfb] + shift, swb_offset[sfb + 1] + shift ); sfm = IGF_getSFM_ivas_fx( &sfm_exp, pPowerSpectrum_fx, pPowerSpectrum_e, add( swb_offset[sfb], shift ), add( swb_offset[sfb + 1], shift ) ); +#endif +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + crest = IGF_getCrest( &crest_exp, pPowerSpectrum_fx, pPowerSpectrum_e, add( swb_offset[sfb], shift ), add( swb_offset[sfb + 1], shift ), IVAS_CPE_MDCT ); +#else crest = IGF_getCrest_ivas( &crest_exp, pPowerSpectrum_fx, pPowerSpectrum_e, add( swb_offset[sfb], shift ), add( swb_offset[sfb + 1], shift ) ); +#endif shiftedSFM_fx = BASOP_Util_Divide1616_Scale( sfm, crest, &shiftedSFM_e ); } IF( shiftedSFM_fx ) @@ -3163,7 +3619,7 @@ static void IGF_CalculateStereoEnvelope_fx( return; } - +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS /*-------------------------------------------------------------------* * IGF_WriteEnvelope() * @@ -3229,7 +3685,11 @@ static Word16 IGF_WriteEnvelope_ivas( IGFSCFEncoderSaveContextState_fx( &hPrivateData->hIGFSCFArithEnc, igfGridIdx ); } +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + *pBitOffset = IGFSCFEncoderEncode_fx( &hPrivateData->hIGFSCFArithEnc, hBstr, *pBitOffset, &hPrivateData->igfScfQuantized[hGrid->startSfb], igfGridIdx, IVAS_SCE, isIndepFlag ); +#else *pBitOffset = IGFSCFEncoderEncode_ivas_fx( &hPrivateData->hIGFSCFArithEnc, hBstr, *pBitOffset, &hPrivateData->igfScfQuantized[hGrid->startSfb], igfGridIdx, isIndepFlag ); +#endif move16(); if ( NULL == hBstr ) @@ -3242,7 +3702,7 @@ static Word16 IGF_WriteEnvelope_ivas( return totBitCount; } - +#endif /*-------------------------------------------------------------------* * IGF_Whitening() * @@ -3702,7 +4162,7 @@ static void IGF_Whitening_ivas_fx( return; } - +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS /*-------------------------------------------------------------------* * IGF_WriteWhiteningTile_fx() * @@ -3744,8 +4204,8 @@ static Word16 IGF_WriteWhiteningTile_ivas_fx( return totBitCount; } - - +#endif +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS /*-------------------------------------------------------------------* * IGF_WriteWhiteningLevels_fx() * @@ -3815,7 +4275,11 @@ static Word16 IGF_WriteWhiteningLevels_ivas_fx( { IGF_write_bits( hBstr, pBitOffset, 0, 1 ); } +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGF_WriteWhiteningTile_fx( hBstr, pBitOffset, hPrivateData->igfCurrWhiteningLevel[0] ); +#else IGF_WriteWhiteningTile_ivas_fx( hBstr, pBitOffset, hPrivateData->igfCurrWhiteningLevel[0] ); +#endif p = 1; move16(); tmp32 = 0; @@ -3852,7 +4316,11 @@ static Word16 IGF_WriteWhiteningLevels_ivas_fx( IGF_write_bits( hBstr, pBitOffset, 1, 1 ); FOR( p = 1; p < nTiles; p++ ) { +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGF_WriteWhiteningTile_fx( hBstr, pBitOffset, hPrivateData->igfCurrWhiteningLevel[p] ); +#else IGF_WriteWhiteningTile_ivas_fx( hBstr, pBitOffset, hPrivateData->igfCurrWhiteningLevel[p] ); +#endif } } ELSE IF( NE_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_48000_CPE ) && NE_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_FB_48000_CPE ) ) @@ -3865,8 +4333,8 @@ static Word16 IGF_WriteWhiteningLevels_ivas_fx( return totBitCount; } - - +#endif +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS /*-------------------------------------------------------------------* * IGF_WriteFlatteningTrigger_fx() * @@ -3896,8 +4364,8 @@ static Word16 IGF_WriteFlatteningTrigger_ivas_fx( return totBitCount; } - - +#endif +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS /*-------------------------------------------------------------------* * IGFEncWriteBitstream() * @@ -3927,22 +4395,46 @@ Word16 IGFEncWriteBitstream_ivas_fx( move16(); } - IGF_WriteEnvelope_ivas( hIGFEnc, /* i: instance handle of IGF Encoder */ - hBstr, /* i: encoder state */ - pBitOffset, /* i: ptr to bitOffset counter */ - igfGridIdx, /* i: igf grid index see definition of IGF_GRID_IDX for details */ - isIndepFlag, /* i: if 1 frame is independent, 0 = frame is coded with data from previous frame */ - &igfAllZero ); /* o: *igfAllZero */ - - IGF_WriteWhiteningLevels_ivas_fx( hIGFEnc, /* i: instance handle of IGF Encoder */ - hBstr, /* i: encoder state */ - pBitOffset, /* i: ptr to bitOffset counter */ - igfGridIdx, /* i: igf grid index see definition of IGF_GRID_IDX for details */ - isIndepFlag ); /* i: if 1 frame is independent, 0 = frame is coded with data from previous frame */ - +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGF_WriteEnvelope( hIGFEnc, /* i: instance handle of IGF Encoder */ + hBstr, /* i: encoder state */ + pBitOffset, /* i: ptr to bitOffset counter */ + igfGridIdx, /* i: igf grid index see definition of IGF_GRID_IDX for details */ + isIndepFlag, /* i: if 1 frame is independent, 0 = frame is coded with data from previous frame */ + &igfAllZero, /* o: *igfAllZero */ + IVAS_SCE ); /* i: IVAS element mode type */ +#else + IGF_WriteEnvelope_ivas( hIGFEnc, /* i: instance handle of IGF Encoder */ + hBstr, /* i: encoder state */ + pBitOffset, /* i: ptr to bitOffset counter */ + igfGridIdx, /* i: igf grid index see definition of IGF_GRID_IDX for details */ + isIndepFlag, /* i: if 1 frame is independent, 0 = frame is coded with data from previous frame */ + &igfAllZero ); /* o: *igfAllZero */ +#endif + +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGF_WriteWhiteningLevels_fx( hIGFEnc, /* i: instance handle of IGF Encoder */ + hBstr, /* i: encoder state */ + pBitOffset, /* i: ptr to bitOffset counter */ + igfGridIdx, /* i: igf grid index see definition of IGF_GRID_IDX for details */ + isIndepFlag ); /* i: if 1 frame is independent, 0 = frame is coded with data from previous frame */ +#else + IGF_WriteWhiteningLevels_ivas_fx( hIGFEnc, /* i: instance handle of IGF Encoder */ + hBstr, /* i: encoder state */ + pBitOffset, /* i: ptr to bitOffset counter */ + igfGridIdx, /* i: igf grid index see definition of IGF_GRID_IDX for details */ + isIndepFlag ); /* i: if 1 frame is independent, 0 = frame is coded with data from previous frame */ +#endif + +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGF_WriteFlatteningTrigger_fx( hIGFEnc, /* i: instance handle of IGF Encoder */ + hBstr, /* i: encoder state */ + pBitOffset ); /* i: ptr to bitOffset counter */ +#else IGF_WriteFlatteningTrigger_ivas_fx( hIGFEnc, /* i: instance handle of IGF Encoder */ hBstr, /* i: encoder state */ pBitOffset ); /* i: ptr to bitOffset counter */ +#endif hIGFEnc->infoTotalBitsPerFrameWritten = sub( *pBitOffset, startBitCount ); hIGFEnc->infoTotalBitsWritten = add( hIGFEnc->infoTotalBitsWritten, hIGFEnc->infoTotalBitsPerFrameWritten ); @@ -3951,7 +4443,7 @@ Word16 IGFEncWriteBitstream_ivas_fx( return hIGFEnc->infoTotalBitsPerFrameWritten; } - +#endif /*-------------------------------------------------------------------* * IGFEncSetMode() @@ -3959,7 +4451,11 @@ Word16 IGFEncWriteBitstream_ivas_fx( * sets the IGF mode according to given bitrate *-------------------------------------------------------------------*/ +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS +void IGFEncSetMode_fx( +#else void IGFEncSetMode_ivas_fx( +#endif const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i/o: instance handle of IGF Encoder */ const Word32 total_brate, /* i : encoder total bitrate */ const Word16 bwidth, /* i : encoder audio bandwidth */ @@ -3976,6 +4472,7 @@ void IGFEncSetMode_ivas_fx( set16_fx( hPrivateData->igfScfQuantized, 0, IGF_MAX_SFB ); set16_fx( hPrivateData->igfCurrWhiteningLevel, 0, IGF_MAX_TILES ); set16_fx( hPrivateData->igfPrevWhiteningLevel, 0, IGF_MAX_TILES ); +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS set16_fx( hPrivateData->igfWhiteningHangoverCnt, 0, IGF_MAX_TILES ); FOR( i = 0; i < IGF_MAX_TILES; i++ ) { @@ -3984,6 +4481,7 @@ void IGFEncSetMode_ivas_fx( hPrivateData->igfPastSFM_pos = 0; move16(); +#endif FOR( i = 0; i < IGF_BITBUFSIZE / 8; i++ ) { @@ -3994,6 +4492,17 @@ void IGFEncSetMode_ivas_fx( move16(); set32_fx( hPrivateData->prevSFM_FIR, 0, IGF_MAX_TILES ); set16_fx( hPrivateData->prevSFM_IIR, 0, IGF_MAX_TILES ); +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + /* IVAS specific settings */ + set16_fx( hPrivateData->igfWhiteningHangoverCnt, 0, IGF_MAX_TILES ); + FOR( i = 0; i < IGF_MAX_TILES; i++ ) + { + set16_fx( hPrivateData->igfPastSFM_fx[i], -( ONE_IN_Q13 ), IGF_PAST_SFM_LEN ); + } + + hPrivateData->igfPastSFM_pos = 0; + move16(); +#endif set16_fx( hPrivateData->dampingFactorSmoothing, 2, IGF_MAX_SFB ); set16_fx( hPrivateData->prevSFM_FIR_SFB_SB_fx, 0, IGF_MAX_SFB ); set16_fx( hPrivateData->prevSFB_FIR_TB_e, 15, IGF_MAX_SFB ); @@ -4011,7 +4520,11 @@ void IGFEncSetMode_ivas_fx( set16_fx( hPrivateData->SFM_sb_fx, 0, IGF_MAX_SFB ); set16_fx( hPrivateData->SFM_tb_fx, 0, IGF_MAX_SFB ); +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IF( IGFCommonFuncsIGFConfiguration( total_brate, bwidth, element_mode, &hPrivateData->igfInfo, rf_mode ) != 0 ) +#else IF( IGFCommonFuncsIGFConfiguration_ivas_fx( total_brate, bwidth, element_mode, &hPrivateData->igfInfo, rf_mode ) != 0 ) +#endif { IGFSCFEncoderOpen_fx( &hPrivateData->hIGFSCFArithEnc, &hPrivateData->igfInfo, total_brate, bwidth, element_mode, rf_mode ); @@ -4383,11 +4896,19 @@ ivas_error IGF_Reconfig( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hIGFEnc\n" ) ); } +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGFEncSetMode_fx( *hIGFEnc, brate, bwidth, element_mode, rf_mode ); +#else IGFEncSetMode_ivas_fx( *hIGFEnc, brate, bwidth, element_mode, rf_mode ); +#endif } ELSE IF( igf && reset ) { +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGFEncSetMode_fx( *hIGFEnc, brate, bwidth, element_mode, rf_mode ); +#else IGFEncSetMode_ivas_fx( *hIGFEnc, brate, bwidth, element_mode, rf_mode ); +#endif } ELSE IF( !igf && *hIGFEnc != NULL ) { diff --git a/lib_enc/igf_scf_enc.c b/lib_enc/igf_scf_enc.c deleted file mode 100644 index c9a549e5a383a37e05cae2b9700969e77afd7784..0000000000000000000000000000000000000000 --- a/lib_enc/igf_scf_enc.c +++ /dev/null @@ -1,327 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot_fx.h" -#include "stat_enc.h" -#include "stat_com.h" -#include "cnst.h" -#include "wmc_auto.h" -#include "prot_fx_enc.h" - - -/*---------------------------------------------------------------------* - * quant_ctx() - * - * - *---------------------------------------------------------------------*/ - -static Word16 quant_ctx( - const Word16 ctx ) -{ - /* - ctx ... -5 -4 -3 -2 -1 0 1 2 3 4 5 ... - Q(ctx)... -3 -3 -3 -2 -1 0 1 2 3 3 3 ... - */ - IF( LE_16( abs_s( ctx ), 3 ) ) - { - return ctx; - } - ELSE IF( GT_16( ctx, 3 ) ) - { - return 3; - } - ELSE /* ctx < -3 */ - { - return -3; - } -} - - -/*---------------------------------------------------------------------* - * arith_encode_bits() - * - * - *---------------------------------------------------------------------*/ - -static void arith_encode_bits( - IGFSCFENC_INSTANCE_HANDLE hPrivateData, /* i/o: instance handle */ - Word16 *ptr, /* i/o: pointer to expanded bit buffer, one bit in each Word16 */ - Word16 x, /* i: value to encode */ - Word16 nBits /* i: number of bits to encode */ -) -{ - Word16 i; - Word16 bit; - - - FOR( i = nBits - 1; i >= 0; --i ) /* nBits > 0 */ - { - bit = s_and( shr( x, i ), 1 ); - hPrivateData->ptrBitIndex = ari_encode_14bits_sign_ivas_fx( ptr, - hPrivateData->ptrBitIndex, - 32767, /* disable the bit count limitation */ - &hPrivateData->acState, - bit ); - move16(); - } -} - - -/*---------------------------------------------------------------------* - * arith_encode_residual() - * - * - *---------------------------------------------------------------------*/ - -static void arith_encode_residual( - IGFSCFENC_INSTANCE_HANDLE hPrivateData, /* i/o: instance handle */ - Word16 *ptr, /* i/o: pointer to expanded bit buffer, one bit in each Word16 */ - Word16 x, /* i: residual value to encode */ - const UWord16 *cumulativeFrequencyTable, /* i: cumulative frequency table to be used */ - Word16 tableOffset /* i: offset used to align the table */ -) -{ - Word16 extra; - Word16 extra_tmp; - Word16 extra_safety; - - - x = add( x, tableOffset ); - - test(); - IF( ( GE_16( x, IGF_MIN_ENC_SEPARATE ) ) && ( LE_16( x, IGF_MAX_ENC_SEPARATE ) ) ) - { - x = sub( x, IGF_MIN_ENC_SEPARATE - 1 ); /* (x - IGF_MIN_ENC_SEPARATE) + 1 */ - /* encode one of the IGF_SYMBOLS_IN_TABLE == 27 alphabet symbols using the new raw AC function */ - hPrivateData->ptrBitIndex = ari_encode_14bits_ext_ivas_fx( ptr, - hPrivateData->ptrBitIndex, - &hPrivateData->acState, - x, - cumulativeFrequencyTable ); - move16(); - return; - } - - IF( LT_16( x, IGF_MIN_ENC_SEPARATE ) ) - { - /* send escape code 0 to indicate x <= IGF_MIN_ENC_SEPARATE - 1 */ - extra = sub( IGF_MIN_ENC_SEPARATE - 1, x ); - hPrivateData->ptrBitIndex = ari_encode_14bits_ext_ivas_fx( ptr, - hPrivateData->ptrBitIndex, - &hPrivateData->acState, - 0, - cumulativeFrequencyTable ); - move16(); - } - ELSE /* x > IGF_MAX_ENC_SEPARATE */ - { - /* send escape code (IGF_SYMBOLS_IN_TABLE - 1) to indicate x >= IGF_MAX_ENC_SEPARATE + 1 */ - extra = sub( x, IGF_MAX_ENC_SEPARATE + 1 ); - hPrivateData->ptrBitIndex = ari_encode_14bits_ext_ivas_fx( ptr, - hPrivateData->ptrBitIndex, - &hPrivateData->acState, - IGF_SYMBOLS_IN_TABLE - 1, - cumulativeFrequencyTable ); - move16(); - } - - /* encode one of the tails of the distribution */ - extra_tmp = sub( extra, 15 ); - IF( extra_tmp < 0 ) - { - /* encode extra with 4 bits if extra < 15 */ - arith_encode_bits( hPrivateData, ptr, extra, 4 ); - } - ELSE /* extra >= 15 */ - { - /* send escape code 15 to indicate extra >= 15 */ - arith_encode_bits( hPrivateData, ptr, 15, 4 ); - - extra_safety = sub( extra_tmp, 63 ); - IF( extra_safety < 0 ) - { - /* encode additional extra with 6 bits */ - arith_encode_bits( hPrivateData, ptr, extra_tmp, 6 ); - } - ELSE - { /* extra_tmp >= 63 */ - arith_encode_bits( hPrivateData, ptr, 63, 6 ); - /* encode safety extra with 7 bits */ - arith_encode_bits( hPrivateData, ptr, extra_safety, 7 ); - } - } -} - - -/*---------------------------------------------------------------------* - * encode_sfe_vector() - * - * - *---------------------------------------------------------------------*/ -static void encode_sfe_vector( - IGFSCFENC_INSTANCE_HANDLE hPrivateData, /* i/o: instance handle */ - Word16 *ptr, /* i : pointer to expanded bit buffer, one bit in each short */ - const Word16 t, /* i : frame counter reset to 0 at each independent frame */ - Word16 *prev_x, /* i : previous vector */ - Word16 *x, /* i : current vector to encode */ - const Word16 length /* i : number of elements to encode */ -) -{ - /* - f - ^ - | d a x - | c b - | e --> t - */ - Word16 f; - Word16 pred; - Word16 ctx; - Word16 ctx_f; - Word16 ctx_t; - - FOR( f = 0; f < length; f++ ) - { - IF( t == 0 ) - { - IF( f == 0 ) - { - /* (t == 0) && (f == 0) */ - /* encode one of the IGF_SYMBOLS_IN_TABLE == 27 alphabet symbols using the new raw AC function */ - hPrivateData->ptrBitIndex = ari_encode_14bits_ext_ivas_fx( ptr, - hPrivateData->ptrBitIndex, - &hPrivateData->acState, - shr( x[f], 2 ), - (const UWord16 *) hPrivateData->cf_se00 ); - move16(); - arith_encode_bits( hPrivateData, ptr, x[f] & 3, 2 ); /* LSBs as 2 bit raw */ - } - ELSE IF( EQ_16( f, 1 ) ) - { - pred = x[f - 1]; /* pred = b */ - move16(); - arith_encode_residual( hPrivateData, ptr, x[f] - pred, hPrivateData->cf_se01, hPrivateData->cf_off_se01 ); - } - ELSE - { - /* f >= 2 */ - pred = x[f - 1]; /* pred = b */ - move16(); - ctx = quant_ctx( sub( x[f - 1], x[f - 2] ) ); /* Q(b - e) */ - arith_encode_residual( hPrivateData, ptr, sub( x[f], pred ), &hPrivateData->cf_se02[( IGF_SYMBOLS_IN_TABLE + 1 ) * ( IGF_CTX_OFFSET + ctx )], hPrivateData->cf_off_se02[IGF_CTX_OFFSET + ctx] ); - } - move16(); - } - ELSE - { - /* t == 1 */ - IF( f == 0 ) - { - pred = prev_x[f]; /* pred = a */ - move16(); - arith_encode_residual( hPrivateData, ptr, sub( x[f], pred ), hPrivateData->cf_se10, hPrivateData->cf_off_se10 ); - } - ELSE - { - /* (t == 1) && (f >= 1) */ - pred = add( prev_x[f], sub( x[f - 1], prev_x[f - 1] ) ); /* pred = a + b - c */ - ctx_f = quant_ctx( sub( prev_x[f], prev_x[f - 1] ) ); /* Q(a - c) */ - ctx_t = quant_ctx( sub( x[f - 1], prev_x[f - 1] ) ); /* Q(b - c) */ - arith_encode_residual( hPrivateData, ptr, x[f] - pred, &hPrivateData->cf_se11[( IGF_SYMBOLS_IN_TABLE + 1 ) * IGF_CTX_COUNT * ( IGF_CTX_OFFSET + ctx_t ) + ( IGF_SYMBOLS_IN_TABLE + 1 ) * ( IGF_CTX_OFFSET + ctx_f )], hPrivateData->cf_off_se11[IGF_CTX_COUNT * ( IGF_CTX_OFFSET + ctx_t ) + ( IGF_CTX_OFFSET + ctx_f )] ); - } - } - } - - return; -} - - -/*---------------------------------------------------------------------* - * IGFSCFEncoderEncode_ivas_fx() - * - * main IGF encoder function - *---------------------------------------------------------------------*/ -Word16 IGFSCFEncoderEncode_ivas_fx( - IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i/o: handle to public data or NULL in case there was no instance created */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 bitCount, /* i : offset to the first bit in bitbuffer which should be readed by iisArithDecoderDecode function */ - Word16 *sfe, /* i : ptr to an array which contain quantized scalefactor energies */ - const Word16 igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ - const Word16 indepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */ -) -{ - Word16 ptr[IGF_BITBUFSIZE]; /* temporary expanded bit buffer, one bit in each short */ - Word16 i; - - /* insert data: */ - hPublicData->ptrBitIndex = 0; - move16(); - hPublicData->bitCount = bitCount; - move16(); - ari_start_encoding_14bits_ivas_fx( &hPublicData->acState ); /* start AC encoding */ - - /* check if coder needs a reset and do it if necessary */ - IF( indepFlag != 0 ) - { - IGFSCFEncoderReset_fx( hPublicData ); - } - - encode_sfe_vector( hPublicData, ptr, hPublicData->t, hPublicData->prev, sfe, hPublicData->scfCountLongBlock[igfGridIdx] ); - - hPublicData->ptrBitIndex = ari_done_encoding_14bits_ivas_fx( ptr, hPublicData->ptrBitIndex, &hPublicData->acState ); /* finish AC encoding */ - hPublicData->bitCount = add( hPublicData->bitCount, hPublicData->ptrBitIndex ); - move16(); - move16(); - - /* advancing history: */ - Copy( sfe, hPublicData->prev, hPublicData->scfCountLongBlock[igfGridIdx] ); - hPublicData->t = add( hPublicData->t, 1 ); - move16(); - - /* copy the bits from the temporary bit buffer, if doRealEncoding is enabled */ - IF( hBstr ) - { - FOR( i = 0; i < hPublicData->ptrBitIndex; ++i ) - { - push_next_indice( hBstr, ptr[i], 1 ); - } - } - - /* return next bit offset in the stream */ - return hPublicData->bitCount; -} diff --git a/lib_enc/igf_scf_enc_fx.c b/lib_enc/igf_scf_enc_fx.c index d1341a98af3f27cc8846dcb3db7e735ea9597d7c..5b9d8d71d8873553845dd0375bbc9d10bf5e8979 100644 --- a/lib_enc/igf_scf_enc_fx.c +++ b/lib_enc/igf_scf_enc_fx.c @@ -1,3 +1,37 @@ +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS +/****************************************************************************************************** + + (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#endif /*==================================================================================== EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ @@ -83,7 +117,12 @@ static void arith_encode_bits( IGFSCFENC_INSTANCE_HANDLE hPrivateData, /* i/o: instance handle */ Word16 *ptr, /* i/o: pointer to expanded bit buffer, one bit in each Word16 */ Word16 x, /* i: value to encode */ - Word16 nBits /* i: number of bits to encode */ +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + Word16 nBits, /* i: number of bits to encode */ + Word16 element_mode /* i: IVAS element mode type */ +#else + Word16 nBits /* i: number of bits to encode */ +#endif ) { Word16 i; @@ -93,11 +132,30 @@ static void arith_encode_bits( FOR( i = nBits - 1; i >= 0; --i ) /* nBits > 0 */ { bit = s_and( shr( x, i ), 1 ); +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IF( EQ_16( element_mode, EVS_MONO ) ) + { + hPrivateData->ptrBitIndex = ari_encode_14bits_sign_fx( ptr, + hPrivateData->ptrBitIndex, + 32767, /* disable the bit count limitation */ + &hPrivateData->acState_fx, + bit ); + } + ELSE + { + hPrivateData->ptrBitIndex = ari_encode_14bits_sign_ivas_fx( ptr, + hPrivateData->ptrBitIndex, + 32767, /* disable the bit count limitation */ + &hPrivateData->acState, + bit ); + } +#else hPrivateData->ptrBitIndex = ari_encode_14bits_sign_fx( ptr, hPrivateData->ptrBitIndex, 32767, /* disable the bit count limitation */ &hPrivateData->acState_fx, bit ); +#endif move16(); } } @@ -107,7 +165,12 @@ static void arith_encode_residual( Word16 *ptr, /* i/o: pointer to expanded bit buffer, one bit in each Word16 */ Word16 x, /* i: residual value to encode */ const UWord16 *cumulativeFrequencyTable, /* i: cumulative frequency table to be used */ - Word16 tableOffset /* i: offset used to align the table */ +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + Word16 tableOffset, /* i: offset used to align the table */ + Word16 element_mode /* i: IVAS element mode type */ +#else + Word16 tableOffset /* i: offset used to align the table */ +#endif ) { Word16 extra; @@ -121,12 +184,31 @@ static void arith_encode_residual( IF( ( GE_16( x, IGF_MIN_ENC_SEPARATE ) ) && ( LE_16( x, IGF_MAX_ENC_SEPARATE ) ) ) { x = sub( x, IGF_MIN_ENC_SEPARATE - 1 ); /* (x - IGF_MIN_ENC_SEPARATE) + 1 */ - /* encode one of the IGF_SYMBOLS_IN_TABLE == 27 alphabet symbols using the new raw AC function */ + /* encode one of the IGF_SYMBOLS_IN_TABLE == 27 alphabet symbols using the new raw AC function */ +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IF( EQ_16( element_mode, EVS_MONO ) ) + { + hPrivateData->ptrBitIndex = ari_encode_14bits_ext_fx( ptr, + hPrivateData->ptrBitIndex, + &hPrivateData->acState_fx, + x, + cumulativeFrequencyTable ); + } + ELSE + { + hPrivateData->ptrBitIndex = ari_encode_14bits_ext_ivas_fx( ptr, + hPrivateData->ptrBitIndex, + &hPrivateData->acState, + x, + cumulativeFrequencyTable ); + } +#else hPrivateData->ptrBitIndex = ari_encode_14bits_ext_fx( ptr, hPrivateData->ptrBitIndex, &hPrivateData->acState_fx, x, cumulativeFrequencyTable ); +#endif move16(); return; } @@ -135,22 +217,60 @@ static void arith_encode_residual( { /* send escape code 0 to indicate x <= IGF_MIN_ENC_SEPARATE - 1 */ extra = sub( IGF_MIN_ENC_SEPARATE - 1, x ); +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IF( EQ_16( element_mode, EVS_MONO ) ) + { + hPrivateData->ptrBitIndex = ari_encode_14bits_ext_fx( ptr, + hPrivateData->ptrBitIndex, + &hPrivateData->acState_fx, + 0, + cumulativeFrequencyTable ); + } + ELSE + { + hPrivateData->ptrBitIndex = ari_encode_14bits_ext_ivas_fx( ptr, + hPrivateData->ptrBitIndex, + &hPrivateData->acState, + 0, + cumulativeFrequencyTable ); + } +#else hPrivateData->ptrBitIndex = ari_encode_14bits_ext_fx( ptr, hPrivateData->ptrBitIndex, &hPrivateData->acState_fx, 0, cumulativeFrequencyTable ); +#endif move16(); } ELSE /* x > IGF_MAX_ENC_SEPARATE */ { /* send escape code (IGF_SYMBOLS_IN_TABLE - 1) to indicate x >= IGF_MAX_ENC_SEPARATE + 1 */ extra = sub( x, IGF_MAX_ENC_SEPARATE + 1 ); +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IF( EQ_16( element_mode, EVS_MONO ) ) + { + hPrivateData->ptrBitIndex = ari_encode_14bits_ext_fx( ptr, + hPrivateData->ptrBitIndex, + &hPrivateData->acState_fx, + IGF_SYMBOLS_IN_TABLE - 1, + cumulativeFrequencyTable ); + } + ELSE + { + hPrivateData->ptrBitIndex = ari_encode_14bits_ext_ivas_fx( ptr, + hPrivateData->ptrBitIndex, + &hPrivateData->acState, + IGF_SYMBOLS_IN_TABLE - 1, + cumulativeFrequencyTable ); + } +#else hPrivateData->ptrBitIndex = ari_encode_14bits_ext_fx( ptr, hPrivateData->ptrBitIndex, &hPrivateData->acState_fx, IGF_SYMBOLS_IN_TABLE - 1, cumulativeFrequencyTable ); +#endif move16(); } @@ -159,28 +279,51 @@ static void arith_encode_residual( IF( extra_tmp < 0 ) { /* encode extra with 4 bits if extra < 15 */ +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + arith_encode_bits( hPrivateData, ptr, extra, 4, element_mode ); +#else arith_encode_bits( hPrivateData, ptr, extra, 4 ); +#endif } ELSE /* extra >= 15 */ { /* send escape code 15 to indicate extra >= 15 */ +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + arith_encode_bits( hPrivateData, ptr, 15, 4, element_mode ); +#else arith_encode_bits( hPrivateData, ptr, 15, 4 ); +#endif extra_safety = sub( extra_tmp, 63 ); IF( extra_safety < 0 ) { /* encode additional extra with 6 bits */ +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + arith_encode_bits( hPrivateData, ptr, extra_tmp, 6, element_mode ); +#else arith_encode_bits( hPrivateData, ptr, extra_tmp, 6 ); +#endif } ELSE { /* extra_tmp >= 63 */ +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IF( GT_16( element_mode, EVS_MONO ) ) + { + arith_encode_bits( hPrivateData, ptr, 63, 6, element_mode ); + } +#endif /* encode safety extra with 7 bits */ +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + arith_encode_bits( hPrivateData, ptr, extra_safety, 7, element_mode ); +#else arith_encode_bits( hPrivateData, ptr, extra_safety, 7 ); +#endif } } } +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS static void encode_sfe_vector( IGFSCFENC_INSTANCE_HANDLE hPrivateData, /* i/o: instance handle */ Word16 *ptr, /* i : pointer to expanded bit buffer, one bit in each short */ @@ -292,7 +435,101 @@ static void encode_sfe_vector( } } } +#else +/*---------------------------------------------------------------------* + * encode_sfe_vector() + * + * + *---------------------------------------------------------------------*/ +static void encode_sfe_vector( + IGFSCFENC_INSTANCE_HANDLE hPrivateData, /* i/o: instance handle */ + Word16 *ptr, /* i : pointer to expanded bit buffer, one bit in each short */ + const Word16 t, /* i : frame counter reset to 0 at each independent frame */ + Word16 *prev_x, /* i : previous vector */ + Word16 *x, /* i : current vector to encode */ + const Word16 length, /* i : number of elements to encode */ + const Word16 element_mode /* i : IVAS element mode type */ +) +{ + /* + f + ^ + | d a x + | c b + | e --> t + */ + Word16 f; + Word16 pred; + Word16 ctx; + Word16 ctx_f; + Word16 ctx_t; + FOR( f = 0; f < length; f++ ) + { + IF( t == 0 ) + { + IF( f == 0 ) + { + /* (t == 0) && (f == 0) */ + /* encode one of the IGF_SYMBOLS_IN_TABLE == 27 alphabet symbols using the new raw AC function */ + IF( EQ_16( element_mode, EVS_MONO ) ) + { + hPrivateData->ptrBitIndex = ari_encode_14bits_ext_fx( ptr, + hPrivateData->ptrBitIndex, + &hPrivateData->acState_fx, + shr( x[f], 2 ), + (const UWord16 *) hPrivateData->cf_se00 ); + } + ELSE + { + hPrivateData->ptrBitIndex = ari_encode_14bits_ext_ivas_fx( ptr, + hPrivateData->ptrBitIndex, + &hPrivateData->acState, + shr( x[f], 2 ), + (const UWord16 *) hPrivateData->cf_se00 ); + } + move16(); + arith_encode_bits( hPrivateData, ptr, x[f] & 3, 2, element_mode ); /* LSBs as 2 bit raw */ + } + ELSE IF( EQ_16( f, 1 ) ) + { + pred = x[f - 1]; /* pred = b */ + move16(); + arith_encode_residual( hPrivateData, ptr, x[f] - pred, hPrivateData->cf_se01, hPrivateData->cf_off_se01, element_mode ); + } + ELSE + { + /* f >= 2 */ + pred = x[f - 1]; /* pred = b */ + move16(); + ctx = quant_ctx( sub( x[f - 1], x[f - 2] ) ); /* Q(b - e) */ + arith_encode_residual( hPrivateData, ptr, sub( x[f], pred ), &hPrivateData->cf_se02[( IGF_SYMBOLS_IN_TABLE + 1 ) * ( IGF_CTX_OFFSET + ctx )], hPrivateData->cf_off_se02[IGF_CTX_OFFSET + ctx], element_mode ); + } + move16(); + } + ELSE + { + /* t == 1 */ + IF( f == 0 ) + { + pred = prev_x[f]; /* pred = a */ + move16(); + arith_encode_residual( hPrivateData, ptr, sub( x[f], pred ), hPrivateData->cf_se10, hPrivateData->cf_off_se10, element_mode ); + } + ELSE + { + /* (t == 1) && (f >= 1) */ + pred = add( prev_x[f], sub( x[f - 1], prev_x[f - 1] ) ); /* pred = a + b - c */ + ctx_f = quant_ctx( sub( prev_x[f], prev_x[f - 1] ) ); /* Q(a - c) */ + ctx_t = quant_ctx( sub( x[f - 1], prev_x[f - 1] ) ); /* Q(b - c) */ + arith_encode_residual( hPrivateData, ptr, x[f] - pred, &hPrivateData->cf_se11[( IGF_SYMBOLS_IN_TABLE + 1 ) * IGF_CTX_COUNT * ( IGF_CTX_OFFSET + ctx_t ) + ( IGF_SYMBOLS_IN_TABLE + 1 ) * ( IGF_CTX_OFFSET + ctx_f )], hPrivateData->cf_off_se11[IGF_CTX_COUNT * ( IGF_CTX_OFFSET + ctx_t ) + ( IGF_CTX_OFFSET + ctx_f )], element_mode ); + } + } + } + + return; +} +#endif /**********************************************************************/ /** resets the internal encoder memory (context memory) @@ -318,7 +555,10 @@ Word16 IGFSCFEncoderEncode_fx( const Word16 bitCount, /* i : offset to the first bit in bitbuffer which should be readed by iisArithDecoderDecode function */ Word16 *sfe, /* i : ptr to an array which contain quantized scalefactor energies */ const Word16 igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ - const Word16 indepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */ +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + const Word16 element_mode, /* i : IVAS element mode type */ +#endif + const Word16 indepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */ ) { Word16 ptr[IGF_BITBUFSIZE]; /* temporary expanded bit buffer, one bit in each Word16 */ @@ -330,7 +570,19 @@ Word16 IGFSCFEncoderEncode_fx( move16(); hPublicData->bitCount = bitCount; move16(); +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + /* start AC encoding */ + IF( EQ_16( element_mode, EVS_MONO ) ) + { + ari_start_encoding_14bits_fx( &hPublicData->acState_fx ); + } + ELSE + { + ari_start_encoding_14bits_ivas_fx( &hPublicData->acState ); + } +#else ari_start_encoding_14bits_fx( &hPublicData->acState_fx ); /* start AC encoding */ +#endif /* check if coder needs a reset and do it if necessary */ IF( indepFlag != 0 ) @@ -339,11 +591,27 @@ Word16 IGFSCFEncoderEncode_fx( IGFSCFEncoderReset_fx( hPublicData ); } +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + encode_sfe_vector( hPublicData, ptr, hPublicData->t, hPublicData->prev, sfe, hPublicData->scfCountLongBlock[igfGridIdx], element_mode ); +#else encode_sfe_vector( hPublicData, ptr, hPublicData->t, hPublicData->prev, sfe, hPublicData->scfCountLongBlock[igfGridIdx] ); +#endif +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + /* finish AC encoding */ + IF( EQ_16( element_mode, EVS_MONO ) ) + { + hPublicData->ptrBitIndex = ari_done_encoding_14bits_fx( ptr, hPublicData->ptrBitIndex, &hPublicData->acState_fx ); + } + ELSE + { + hPublicData->ptrBitIndex = ari_done_encoding_14bits_ivas_fx( ptr, hPublicData->ptrBitIndex, &hPublicData->acState ); + } +#else hPublicData->ptrBitIndex = ari_done_encoding_14bits_fx( ptr, hPublicData->ptrBitIndex, - &hPublicData->acState_fx ); /* finish AC encoding */ + &hPublicData->acState_fx ); +#endif hPublicData->bitCount = add( hPublicData->bitCount, hPublicData->ptrBitIndex ); move16(); move16(); diff --git a/lib_enc/ivas_mdct_core_enc_fx.c b/lib_enc/ivas_mdct_core_enc_fx.c index 560cd81bd4b542e53725da58e0a8d9c5ecb556d0..96777796c0520be831b702e5dccdd40fe42aae41 100644 --- a/lib_enc/ivas_mdct_core_enc_fx.c +++ b/lib_enc/ivas_mdct_core_enc_fx.c @@ -1096,11 +1096,19 @@ void enc_prm_igf_mdct( st->hIGFEnc->infoTotalBitsPerFrameWritten = 0; move16(); +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGFEncWriteBitstream_fx( st->hIGFEnc, hBstr, &st->hIGFEnc->infoTotalBitsPerFrameWritten, ( st->last_core == ACELP_CORE ) ? IGF_GRID_LB_TRAN : IGF_GRID_LB_NORM, 1, st->element_mode ); +#else IGFEncWriteBitstream_ivas_fx( st->hIGFEnc, hBstr, &st->hIGFEnc->infoTotalBitsPerFrameWritten, ( st->last_core == ACELP_CORE ) ? IGF_GRID_LB_TRAN : IGF_GRID_LB_NORM, 1 ); +#endif } ELSE { +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGFEncWriteConcatenatedBitstream_fx( st->hIGFEnc, hBstr ); +#else IGFEncWriteConcatenatedBitstream_ivas_fx( st->hIGFEnc, hBstr ); +#endif } total_nbbits = sub( hBstr->nb_bits_tot, nbits_start ); diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index d6b13aa6e409259de1d94a96f0661d0b3274297e..0fe1ebe0a194ebb72521185b655c304daeb97b83 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -2623,7 +2623,12 @@ Word16 IGFEncWriteBitstream_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ Word16 *pBitOffset, /**< in: | ptr to bitOffset counter */ const Word16 igfGridIdx, /**< in: Q0 | igf grid index see declaration of IGF_GRID_IDX for details */ - const Word16 isIndepFlag /**< in: Q0 | if 1 frame is independent, 0 = frame is coded with data from previous frame */ +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + const Word16 isIndepFlag, /**< in: Q0 | if 1 frame is independent, 0 = frame is coded with data from previous frame */ + const Word16 element_mode /**< in: | IVAS element mode type */ +#else + const Word16 isIndepFlag /**< in: Q0 | if 1 frame is independent, 0 = frame is coded with data from previous frame */ +#endif ); void ACcontextMapping_encode2_no_mem_s17_LC_fx( @@ -2641,12 +2646,13 @@ Word16 IGFEncWriteConcatenatedBitstream_fx( BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ ); +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS /**< out: Q0 | total number of bits written */ Word16 IGFEncWriteConcatenatedBitstream_ivas_fx( const IGF_ENC_INSTANCE_HANDLE hInstance, /* i : instance handle of IGF Encoder */ BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ ); - +#endif void signaling_enc_rf_fx( Encoder_State *st /* i : encoder state structure */ ); @@ -2749,13 +2755,23 @@ void IGF_UpdateInfo( /**< out: Q15| crest factor */ Word16 IGF_getCrest( - Word16 *crest_exp, /**< out: | exponent of crest factor */ - const Word32 *powerSpectrum, /**< in: Q31 | power spectrum */ + Word16 *crest_exp, /**< out: | exponent of crest factor */ + const Word32 *powerSpectrum, /**< in: Q31 | power spectrum */ +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + const Word16 *powerSpectrum_exp, /**< in: | exponent of power spectrum */ +#else const Word16 powerSpectrum_exp, /**< in: | exponent of power spectrum */ - const Word16 start, /**< in: Q0 | start subband index */ +#endif + const Word16 start, /**< in: Q0 | start subband index */ +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + const Word16 stop, /**< in: Q0 | stop subband index */ + const Word16 element_mode /**< in: | IVAS element mode type */ +#else const Word16 stop /**< in: Q0 | stop subband index */ +#endif ); +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS /**< out: Q15| crest factor */ Word16 IGF_getCrest_ivas( Word16 *crest_exp, /**< out: | exponent of crest factor */ @@ -2764,16 +2780,21 @@ Word16 IGF_getCrest_ivas( const Word16 start, /**< in: Q0 | start subband index */ const Word16 stop /**< in: Q0 | stop subband index */ ); - +#endif /**< out: Q15| SFM value */ Word16 IGF_getSFM( Word16 *SFM_exp, /**< out: | exponent of SFM Factor */ const Word32 *energy, /**< in: Q31| energies */ const Word16 *energy_exp, /**< in: | exponent of energies */ const Word16 start, /**< in: Q0 | start subband index */ - const Word16 stop /**< in: Q0 | stop subband index */ +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + const Word16 stop, /**< in: Q0 | stop subband index */ + const Word16 element_mode /**< in: | IVAS element mode type */ +#else + const Word16 stop /**< in: Q0 | stop subband index */ +#endif ); - +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS /**< out: Q15| SFM value */ Word16 IGF_getSFM_ivas_fx( Word16 *SFM_exp, /**< out: | exponent of SFM Factor */ @@ -2782,6 +2803,7 @@ Word16 IGF_getSFM_ivas_fx( const Word16 start, /**< in: Q0 | start subband index */ const Word16 stop /**< in: Q0 | stop subband index */ ); +#endif /* IGFEnc.c */ void IGF_ErodeSpectrum( @@ -2828,6 +2850,7 @@ void IGFEncApplyMono_ivas_fx( const Word16 vad_hover_flag /* i : VAD hangover flag */ ); +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS void IGFEncConcatenateBitstream_ivas_fx( const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ const Word16 bsBits, /* i : number of IGF bits written to list of indices */ @@ -2841,7 +2864,7 @@ void IGFEncConcatenateBitstream_fx( Word16 *nb_bits, /**< in/out: | total number of bits already written */ Indice *ind_list_fx /**< in: | pointer to list of indices */ ); - +#endif /*isf_msvq_ma.c, lsf_msvq_ma.c*/ void msvq_enc_fx( const Word16 *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) (0Q15) */ @@ -3021,7 +3044,10 @@ Word16 IGFSCFEncoderEncode_fx( const Word16 bitCount, /* i : offset to the first bit in bitbuffer which should be readed by iisArithDecoderDecode function */ Word16 *sfe, /* i : ptr to an array which contain quantized scalefactor energies */ const Word16 igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ - const Word16 indepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */ +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + const Word16 element_mode, /* i : IVAS element mode type */ +#endif + const Word16 indepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */ ); void IGFSCFEncoderSaveContextState_fx( diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index 9765655ba4d880bab90ca7e255273a39d60d3b79..2452e96b8252fa6cb0cb9cf399a5f9d73e6ff7ac 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -3809,17 +3809,29 @@ void ProcessIGF_fx( move16(); IF( isTCX20 ) { +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGFEncWriteBitstream_fx( hInstance, NULL, &hInstance->infoTotalBitsPerFrameWritten, igfGridIdx, isIndepFlag, st->element_mode ); +#else IGFEncWriteBitstream_fx( hInstance, NULL, &hInstance->infoTotalBitsPerFrameWritten, igfGridIdx, isIndepFlag ); +#endif } ELSE { pBsStart = hBstr->nb_ind_tot; move16(); +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGFEncWriteBitstream_fx( hIGFEnc, hBstr, &hIGFEnc->infoTotalBitsPerFrameWritten, igfGridIdx, isIndepFlag, st->element_mode ); +#else IGFEncWriteBitstream_ivas_fx( hIGFEnc, hBstr, &hIGFEnc->infoTotalBitsPerFrameWritten, igfGridIdx, isIndepFlag ); +#endif bsBits = sub( hBstr->nb_ind_tot, pBsStart ); +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGFEncConcatenateBitstream( hIGFEnc, bsBits, hBstr ); +#else IGFEncConcatenateBitstream_ivas_fx( hIGFEnc, bsBits, hBstr ); +#endif } } @@ -3929,17 +3941,29 @@ void ProcessIGF_ivas_fx( IF( isTCX20 ) { +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGFEncWriteBitstream_fx( hIGFEnc, NULL, &hIGFEnc->infoTotalBitsPerFrameWritten, igfGridIdx, isIndepFlag, st->element_mode ); +#else IGFEncWriteBitstream_ivas_fx( hIGFEnc, NULL, &hIGFEnc->infoTotalBitsPerFrameWritten, igfGridIdx, isIndepFlag ); +#endif } ELSE { pBsStart = hBstr->nb_ind_tot; move16(); +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGFEncWriteBitstream_fx( hIGFEnc, hBstr, &hIGFEnc->infoTotalBitsPerFrameWritten, igfGridIdx, isIndepFlag, st->element_mode ); +#else IGFEncWriteBitstream_ivas_fx( hIGFEnc, hBstr, &hIGFEnc->infoTotalBitsPerFrameWritten, igfGridIdx, isIndepFlag ); +#endif bsBits = sub( hBstr->nb_ind_tot, pBsStart ); +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGFEncConcatenateBitstream( hIGFEnc, bsBits, hBstr ); +#else IGFEncConcatenateBitstream_ivas_fx( hIGFEnc, bsBits, hBstr ); +#endif } return; @@ -4032,7 +4056,11 @@ void ProcessStereoIGF_fx( IF( EQ_16( sts[ch]->core, TCX_20_CORE ) ) { +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGFEncWriteBitstream_fx( hIGFEnc[ch], NULL, &hIGFEnc[ch]->infoTotalBitsPerFrameWritten, igfGridIdx, isIndepFlag, sts[ch]->element_mode ); +#else IGFEncWriteBitstream_ivas_fx( hIGFEnc[ch], NULL, &hIGFEnc[ch]->infoTotalBitsPerFrameWritten, igfGridIdx, isIndepFlag ); +#endif } ELSE { @@ -4044,10 +4072,18 @@ void ProcessStereoIGF_fx( { hBstr->ind_list = sts[0]->hBstr->ind_list + sts[0]->hBstr->nb_ind_tot; } +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGFEncWriteBitstream_fx( hIGFEnc[ch], hBstr, &hIGFEnc[ch]->infoTotalBitsPerFrameWritten, igfGridIdx, isIndepFlag, sts[ch]->element_mode ); +#else IGFEncWriteBitstream_ivas_fx( hIGFEnc[ch], hBstr, &hIGFEnc[ch]->infoTotalBitsPerFrameWritten, igfGridIdx, isIndepFlag ); +#endif bsBits = sub( hBstr->nb_ind_tot, pBsStart ); +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS + IGFEncConcatenateBitstream( hIGFEnc[ch], bsBits, hBstr ); +#else IGFEncConcatenateBitstream_ivas_fx( hIGFEnc[ch], bsBits, hBstr ); +#endif } } return;