diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 80d17233157489675edbb2e714179fa3bc8b81a8..b1f03e2bf2afb7abdfed40dcb1d77c4c762a7b29 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -860,10 +860,6 @@ void stereo_enc_itd_init( void stereo_dft_enc_update( STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: encoder DFT stereo handle */ const int16_t max_bwidth /* i : maximum encoded bandwidth */ -#ifdef DEBUG_MODE_DFT - , - const int16_t res_code_bits /* i : bits for residual coding */ -#endif ); void stereo_dft_enc_destroy( @@ -2000,10 +1996,6 @@ void decoder_tcx_tns( const int16_t bfi, /* i : Bad frame indicator */ const int16_t frame_cnt, /* i : frame counter in the super frame */ const int16_t whitenedDomain -#ifdef FIX_I13_TCX_TNS_ISSUE - , - const int16_t isEvsMono /*i: EVS mono flag */ -#endif ); void decoder_tcx_imdct( diff --git a/lib_com/prot.h b/lib_com/prot.h index ce686bd77370ff0419bb5b99f5043b9d1dc6b17b..cffd699e46502be723d8fecc9df3a68f39ca844a 100755 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -7137,8 +7137,7 @@ void lsf_weight_2st( const float *lsfq, float *w, const int16_t mode, - const int32_t sr_core -); + const int32_t sr_core ); void mdct_window_sine( float *window, @@ -7886,10 +7885,6 @@ void decoder_tcx( const int16_t bfi, /* i : Bad frame indicator */ const int16_t frame_cnt, /* i : frame counter in the super_frame */ const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ -#ifdef FIX_I13_TCX_TNS_ISSUE - , - const int16_t isEvsMono /*i: EVS mono flag */ -#endif ); void decoder_tcx_post( diff --git a/lib_dec/dec_LPD.c b/lib_dec/dec_LPD.c index c1a01a1ca4c248d9ddbe2f00c8093d111a8e116e..a28630886e53ebbfbbe27405a53494f90ed6d3c4 100644 --- a/lib_dec/dec_LPD.c +++ b/lib_dec/dec_LPD.c @@ -595,12 +595,7 @@ void decoder_LPD( } /* TCX decoder */ - decoder_tcx( st, prm, Aq, Aind, &synth[0], &synthFB[0], bfi, 0, 0 -#ifdef FIX_I13_TCX_TNS_ISSUE - , - 1 -#endif - ); + decoder_tcx( st, prm, Aq, Aind, &synth[0], &synthFB[0], bfi, 0, 0 ); } /*--------------------------------------------------------------------------------* @@ -626,12 +621,7 @@ void decoder_LPD( IGFDecRestoreTCX10SubFrameData( st->hIGFDec, k ); /* TCX decoder */ - decoder_tcx( st, prm, Aq, Aind, &synth[k * L_frame / 2], &synthFB[k * L_frameTCX / 2], bfi, k, 0 -#ifdef FIX_I13_TCX_TNS_ISSUE - , - 1 -#endif - ); + decoder_tcx( st, prm, Aq, Aind, &synth[k * L_frame / 2], &synthFB[k * L_frameTCX / 2], bfi, k, 0 ); } } diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index f83a415a9cd7930d6cddc702e9f3d7ec0aa79863..2934a2309c4c30a601e40b35860553e84188f7a8 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -68,10 +68,6 @@ void decoder_tcx( const int16_t bfi, /* i : Bad frame indicator */ const int16_t frame_cnt, /* i : frame counter in the super frame */ const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ -#ifdef FIX_I13_TCX_TNS_ISSUE - , - const int16_t isEvsMono /*i: EVS mono flag */ -#endif ) { float x[N_MAX]; @@ -112,12 +108,7 @@ void decoder_tcx( decoder_tcx_noiseshaping_igf( st, L_spec, L_frame, L_frameTCX, left_rect, &x[0], &gainlpc2[0], &tmp_concealment_method, bfi ); - decoder_tcx_tns( st, L_frame_glob, L_spec, L_frame, L_frameTCX, &x[0], fUseTns, &tnsData, bfi, frame_cnt, 0 -#ifdef FIX_I13_TCX_TNS_ISSUE - , - isEvsMono -#endif - ); + decoder_tcx_tns( st, L_frame_glob, L_spec, L_frame, L_frameTCX, &x[0], fUseTns, &tnsData, bfi, frame_cnt, 0 ); decoder_tcx_imdct( st, L_frame_glob, L_frameTCX_glob, L_spec, tcx_offset, tcx_offsetFB, L_frame, L_frameTCX, left_rect, &x[0], &xn_buf[0], MDCT_IV, fUseTns, &synth[0], &synthFB[0], bfi, frame_cnt, 0, sba_dirac_stereo_flag ); @@ -1497,12 +1488,7 @@ void decoder_tcx_tns( STnsData *tnsData, const int16_t bfi, /* i : Bad frame indicator */ const int16_t frame_cnt, /* i : frame counter in the super frame */ - const int16_t whitenedDomain -#ifdef FIX_I13_TCX_TNS_ISSUE - , - const int16_t isEvsMono /*i: EVS mono flag */ -#endif -) + const int16_t whitenedDomain ) { int16_t index, isTCX5, L; TCX_CONFIG_HANDLE hTcxCfg = st->hTcxCfg; @@ -1573,7 +1559,7 @@ void decoder_tcx_tns( #ifndef FIX_I13_TCX_TNS_ISSUE tcx5TnsUngrouping( L_frameTCX >> 1, hTcxCfg->tnsConfig[0][0].iFilterBorders[0] >> 1, x, DEC ); #else - if ( isEvsMono ) /*tbc: this is temporary to maintain EVS BE, this is a bug and should be fixed also for EVS (see issue 13) */ + if ( st->element_mode == EVS_MONO ) /* TBC: this is temporary to maintain EVS BE, this is a bug and should be fixed also for EVS (see issue 13) */ { tcx5TnsUngrouping( L_frameTCX >> 1, hTcxCfg->tnsConfig[0][0].iFilterBorders[0] >> 1, x, DEC ); } diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index 9003098fb6118cea8eea6f15ee7412896ca699ce..a495aed93490ce04afaa30671ef49a8340ad44f1 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -1112,23 +1112,13 @@ void ivas_mdct_core_tns_ns( } decoder_tcx_tns( st, L_frame_global[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], &x[ch][k][0], - fUseTns[ch][k], &tnsData[ch][k], bfi, k, 1 -#ifdef FIX_I13_TCX_TNS_ISSUE - , - 0 -#endif - ); + fUseTns[ch][k], &tnsData[ch][k], bfi, k, 1 ); sns_shape_spectrum( x[ch][k], st->hTcxCfg->psychParamsCurrent, &sns_int_scf[0], st->hTcxCfg->psychParamsCurrent->nBins ); v_multc( x[ch][k] + st->hTcxCfg->psychParamsCurrent->nBins, sns_int_scf[FDNS_NPTS - 1], x[ch][k] + st->hTcxCfg->psychParamsCurrent->nBins, L_spec[ch] - st->hTcxCfg->psychParamsCurrent->nBins ); decoder_tcx_tns( st, L_frame_global[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], &x[ch][k][0], - fUseTns[ch][k], &tnsData[ch][k], bfi, k, 0 -#ifdef FIX_I13_TCX_TNS_ISSUE - , - 0 -#endif - ); + fUseTns[ch][k], &tnsData[ch][k], bfi, k, 0 ); } if ( bfi && st->tonal_mdct_plc_active ) diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c index 02ae4b6064e629621563cc96ace2fa013b09504f..e46c32ddbbfde5dc0860c95b5e147de28f1b7480 100644 --- a/lib_dec/ivas_tcx_core_dec.c +++ b/lib_dec/ivas_tcx_core_dec.c @@ -528,12 +528,7 @@ void stereo_tcx_core_dec( } /* TCX decoder */ - decoder_tcx( st, prm, Aq, Aind, &synth[0], &synthFB[0], bfi, 0, sba_dirac_stereo_flag -#ifdef FIX_I13_TCX_TNS_ISSUE - , - 0 -#endif - ); + decoder_tcx( st, prm, Aq, Aind, &synth[0], &synthFB[0], bfi, 0, sba_dirac_stereo_flag ); } /*--------------------------------------------------------------------------------* @@ -561,12 +556,7 @@ void stereo_tcx_core_dec( } /* TCX decoder */ - decoder_tcx( st, prm, Aq, Aind, &synth[k * st->L_frame / 2], &synthFB[k * hTcxDec->L_frameTCX / 2], bfi, k, sba_dirac_stereo_flag -#ifdef FIX_I13_TCX_TNS_ISSUE - , - 0 -#endif - ); + decoder_tcx( st, prm, Aq, Aind, &synth[k * st->L_frame / 2], &synthFB[k * hTcxDec->L_frameTCX / 2], bfi, k, sba_dirac_stereo_flag ); } } diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index d4f7eef6487186d274aa3dfd9c5f6ef5d36c09b7..d56916a200a391afd2141a56b677692c4e93d37d 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -342,14 +342,11 @@ ivas_error ivas_cpe_enc( stereo_dft_enc_analyze( sts, CPE_CHANNELS, input_frame, hCPE->hStereoDft, NULL, hCPE->hStereoDft->DFT, hCPE->input_mem ); sts[0]->total_brate = ( sts[0]->bits_frame_nominal + 10 ) * FRAMES_PER_SEC; /* add small overhead; st[0]->total_brate used in coder_type_modif() */ - - /* Update DFT Stereo memories */ - stereo_dft_enc_update( hCPE->hStereoDft, sts[0]->max_bwidth #ifdef DEBUG_MODE_DFT - , - (int16_t) ( ( hCPE->element_brate ) / FRAMES_PER_SEC - 0.8f * sts[0]->bits_frame_nominal ) + hCPE->hStereoDft->res_cod_bits = (int16_t) ( ( hCPE->element_brate ) / FRAMES_PER_SEC - 0.8f * sts[0]->bits_frame_nominal ); #endif - ); + /* Update DFT Stereo memories */ + stereo_dft_enc_update( hCPE->hStereoDft, sts[0]->max_bwidth ); /* DFT stereo processing */ stereo_dft_enc_process( hCPE, input_frame ); @@ -561,13 +558,11 @@ ivas_error ivas_cpe_enc( } stereo_dft_cng_side_gain( hCPE->hStereoDft, hCPE->hStereoCng, sts[0]->core_brate, sts[0]->last_core_brate, sts[0]->bwidth ); - - stereo_dft_enc_update( hCPE->hStereoDft, min( SWB, sts[0]->max_bwidth ) #ifdef DEBUG_MODE_DFT - , - 0 + hCPE->hStereoDft->res_cod_bits = 0; #endif - ); + + stereo_dft_enc_update( hCPE->hStereoDft, min( SWB, sts[0]->max_bwidth ) ); } else { diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index 1a30b231e1f2fdb83d0783be702132c362bc74e3..d2397d587a75619f08d88cc599ead8452f2d8e5b 100644 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -51,23 +51,23 @@ *----------------------------------------------------------*/ static void FindChannelRatio( - MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */ - Encoder_State **sts, /* i/o: encoder state structure */ - int16_t chBitRatios[MCT_MAX_CHANNELS], - const int16_t nchan /* i : number of channels */ + MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */ + Encoder_State **sts, /* i/o: encoder state structure */ + int16_t chBitRatios[MCT_MAX_CHANNELS], /* o : bit-disctribution channel ratios */ + const int16_t nChannels /* i : number of channels to be coded */ ) { - float sum_nrg = 0; - float chRatio; + float sum_nrg, chRatio; int16_t i; - float nrg[MCT_MAX_CHANNELS] = { 0 }; + float nrg[MCT_MAX_CHANNELS]; set_f( nrg, 0, MCT_MAX_CHANNELS ); - getChannelEnergies( sts, nrg, nchan ); + getChannelEnergies( sts, nrg, nChannels ); /*calculate total energy without LFE*/ - for ( i = 0; i < nchan; i++ ) + sum_nrg = 0; + for ( i = 0; i < nChannels; i++ ) { if ( sts[i]->mct_chan_mode != MCT_CHAN_MODE_IGNORE && sts[i]->mct_chan_mode != MCT_CHAN_MODE_LFE ) { @@ -76,7 +76,7 @@ static void FindChannelRatio( } sum_nrg = 1.0f / max( sum_nrg, EPSILON ); - for ( i = 0; i < nchan; i++ ) + for ( i = 0; i < nChannels; i++ ) { if ( sts[i]->mct_chan_mode != MCT_CHAN_MODE_IGNORE && sts[i]->mct_chan_mode != MCT_CHAN_MODE_LFE ) { @@ -106,14 +106,20 @@ static void FindChannelRatio( } +/*----------------------------------------------------------* + * AdjustChannelRatios() + * + * adjust ratio of channels for bit distribution + *----------------------------------------------------------*/ + static void AdjustChannelRatios( - int16_t chBitRatios[MCT_MAX_CHANNELS], - const int16_t nchan /* i : number of channels */ + int16_t chBitRatios[MCT_MAX_CHANNELS], /* o : bit-disctribution channel ratios */ + const int16_t nChannels /* i/o: number of channels */ #ifdef FIX_I1_113 , - const int32_t ivas_total_brate, - const int16_t nAvailBits, - const int16_t sba_order + const int32_t ivas_total_brate, /* i : IVAS total bitrate */ + const int16_t nAvailBits, /* i : number of available bits */ + const int16_t sba_order /* i : Ambisonic (SBA) order */ #endif ) { @@ -148,12 +154,12 @@ static void AdjustChannelRatios( ratio_diff = 0; sum_ratio = 0.0f; sum_tar_ratio = 0.0f; - for ( i = 0; i < nchan; i++ ) + for ( i = 0; i < nChannels; i++ ) { sum_ratio += (float) chBitRatios[i]; sum_tar_ratio += (float) force_ch_bit_ratios[i]; } - for ( i = 3; i < nchan; i++ ) + for ( i = 3; i < nChannels; i++ ) { cur_ratio = (float) chBitRatios[i] / sum_ratio; tar_ratio = (float) force_ch_bit_ratios[i] / sum_tar_ratio; @@ -164,7 +170,8 @@ static void AdjustChannelRatios( assert( chBitRatios[i] < ( BITRATE_MCT_RATIO_RANGE - 1 ) ); ratio_diff += force_ch_bit_ratios[i] - chBitRatios[i]; } - for ( i = 0; i < min( 3, nchan ); i++ ) + + for ( i = 0; i < min( 3, nChannels ); i++ ) { assert( force_ch_bit_ratios[i] >= 0 ); chBitRatios[i] = min( BITRATE_MCT_RATIO_RANGE - 1, force_ch_bit_ratios[i] ); @@ -174,7 +181,7 @@ static void AdjustChannelRatios( #ifdef FIX_I1_113 /* make sure final ratios are within range*/ sum_ratio = 0.0f; - for ( i = 0; i < nchan; i++ ) + for ( i = 0; i < nChannels; i++ ) { sum_ratio += (float) chBitRatios[i]; } @@ -187,6 +194,8 @@ static void AdjustChannelRatios( return; } + + /*-------------------------------------------------------------------* * ivas_mct_core_enc() * @@ -207,7 +216,7 @@ void ivas_mct_core_enc( #endif ) { - int16_t ch, nSubframes, L_subframeTCX; + int16_t ch, ch_core, nSubframes, L_subframeTCX; int16_t i, cpe_id, n, nAvailBits; int16_t nCPE; float *orig_spectrum[MCT_MAX_CHANNELS][2]; /* Pointers to MDCT output for a short block (L/R) */ @@ -284,7 +293,7 @@ void ivas_mct_core_enc( for ( ch = 0; ch < (int16_t) ( hMCT->nchan_out_woLFE * 0.5 ); ch++ ) { - int16_t ch_core = ch * CPE_CHANNELS; + ch_core = ch * CPE_CHANNELS; if ( switch_bw ) { diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index 2169cac9bd811ea28984e6ba0cb454691bc881c8..fd204e18c50194bd7e65fe2473095a2a241aa072 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -278,6 +278,7 @@ typedef struct stereo_dft_enc_data_struct int16_t flip_sign; #ifdef DEBUG_MODE_DFT int16_t verbose; + int16_t res_cod_bits; #endif } STEREO_DFT_ENC_DATA, *STEREO_DFT_ENC_DATA_HANDLE;