diff --git a/lib_com/options.h b/lib_com/options.h index 2fb4ac04b2d41a15624b99a3f6e530cbce912f92..7745853825673f115ecb693bce6854061c460a56 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -48,7 +48,7 @@ /* ################### Start DEBUGGING switches ########################### */ #ifndef RELEASE -/*#define DEBUGGING*/ /* Activate debugging part of the code */ +/*#define DEBUGGING*/ /* Activate debugging part of the code */ #endif /*#define WMOPS*/ /* Activate complexity and memory counters */ /*#define WMOPS_PER_FRAME*/ /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */ @@ -58,7 +58,7 @@ #ifdef DEBUGGING /*#define DBG_BITSTREAM_ANALYSIS*/ /* Write bitstream with annotations to a text file */ -/*#define DEBUG_MODE_INFO*/ /* output most important parameters to the subdirectory "res/" */ +/*#define DEBUG_MODE_INFO*/ /* output most important parameters to the subdirectory "res/" */ #ifdef DEBUG_MODE_INFO /*#define DEBUG_MODE_ACELP*/ /* output most important ACELP core parameters to the subdirectory "res/" */ /*#define DEBUG_MODE_TCX*/ /* output most important TCX core parameters to the subdirectory "res/" */ @@ -77,7 +77,8 @@ #endif #ifdef DEBUG_MODE_MDCT -/*#define DEBUG_PLOT_BITS*/ +#define DEBUG_PLOT_BITS +#define DEBUG_OSBA_MD_BITS #endif #ifdef DEBUG_MODE_DFT @@ -174,6 +175,7 @@ #define NONBE_1244_FIX_SWB_BWE_MEMORY /* VA: issue 1244: fix to SWB BWE memory in case of switching from FB coding - pending a review by Huawei */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define NONBE_FIX_1337_MISSING_DIRECTIVITY_DISTATT_EXTREND /* Eri: issue 1337: Missing directivity setting and distance attenuation in external renderer IVAS_rend */ +#define NONBE_1329_FIX_OSBA_CRASH /* FhG: issue 1329: prevent assert when bit budget is low*/ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_enc/enc_prm.c b/lib_enc/enc_prm.c index fb1a338ee6b9e86dc0cd728e9f0e59f42624e6b1..951ae35b70ddaf5b2c5937ed790f0ee92ca14330 100644 --- a/lib_enc/enc_prm.c +++ b/lib_enc/enc_prm.c @@ -565,6 +565,12 @@ void writeTCXparam( nbits_tcx, NPRM_RESQ * st->hTcxCfg->resq, flag_ctx_hm ? &hm_cfg[k] : NULL ); } } +#ifdef DEBUG_PLOT_BITS + if ( core == TCX_10_CORE ) + { + dbgwrite( &nbits_tcx, sizeof( int16_t ), 1, 1, "./res/bits_RC" ); + } +#endif } } #ifdef DEBUG_PLOT_BITS @@ -576,6 +582,15 @@ void writeTCXparam( dbgwrite( &tmp, sizeof( int16_t ), 1, 1, "./res/bits_TNS" ); } } + else + { + if ( nSubframes == 1 ) + { + tmp = 0; + dbgwrite( &nbits_tcx, sizeof( int16_t ), 1, 1, "./res/bits_RC" ); + dbgwrite( &tmp, sizeof( int16_t ), 1, 1, "./res/bits_RC" ); + } + } #endif return; diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index db2e60fada703ae07198684798ebe0859e058598..8f6eb68b96a4efa2f43c9f3e87361b48b2a11ff0 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -412,6 +412,11 @@ ivas_error ivas_enc( /* get SBA TCs */ ivas_sba_getTCs( &data_f[n], st_ivas, input_frame ); } +#ifdef DEBUG_OSBA_MD_BITS + { + dbgwrite( &nb_bits_metadata[0], sizeof( int16_t ), hEncoderConfig->nchan_ism + 1, 1, "./res/osba_md_bits" ); + } +#endif /* core-coding of transport channels */ if ( st_ivas->nSCE == 1 ) diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index 27f1a0ad3ce7f4ca30c6d4861bd4e261ad1b0bed..4a46bd7b2f7045b8568f50b98bf97c8e550a9707 100644 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -471,6 +471,10 @@ void ivas_mct_core_enc( /*write IGF data to bitstream*/ for ( ch = 0; ch < nChannels; ch++ ) { +#ifdef DEBUG_PLOT_BITS + int16_t tmp = hBstr->nb_bits_tot; +#endif + st = sts[ch]; if ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) @@ -478,6 +482,10 @@ void ivas_mct_core_enc( continue; } enc_prm_igf_mdct( st, hBstr ); +#ifdef DEBUG_PLOT_BITS + tmp = hBstr->nb_bits_tot - tmp; + dbgwrite( &tmp, sizeof( int16_t ), 1, 1, "./res/bits_IGF" ); +#endif } } diff --git a/lib_enc/ivas_mdct_core_enc.c b/lib_enc/ivas_mdct_core_enc.c index 8085fea23142b6919af287743b44bb40d653b2aa..0c669b581a4010aa9552aa087aee536e14ea5723 100644 --- a/lib_enc/ivas_mdct_core_enc.c +++ b/lib_enc/ivas_mdct_core_enc.c @@ -1146,6 +1146,9 @@ void ivas_mdct_core_whitening_enc( skipped_first_channel = 0; for ( ch = 0; ch < CPE_CHANNELS; ch++ ) { +#ifdef DEBUG_PLOT_BITS + int16_t tmp = hBstr->nb_bits_tot; +#endif st = sts[ch]; if ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) @@ -1170,6 +1173,11 @@ void ivas_mdct_core_whitening_enc( } encode_lpc_avq( hBstr, num_sns, param_lpc[ch], st->core, st->element_mode ); +#ifdef DEBUG_PLOT_BITS + tmp = hBstr->nb_bits_tot - tmp; + dbgwrite( &tmp, sizeof( int16_t ), 1, 1, "./res/bits_SNS" ); +#endif + st->side_bits_frame_channel += hBstr->nb_bits_tot - nbits_start_sns; } } diff --git a/lib_enc/ivas_stereo_mdct_stereo_enc.c b/lib_enc/ivas_stereo_mdct_stereo_enc.c index fa97984539101d7e80145469c21457c2f5532687..d7cdd4786a1b214a14e7e929c7f0cc7f01236fd5 100755 --- a/lib_enc/ivas_stereo_mdct_stereo_enc.c +++ b/lib_enc/ivas_stereo_mdct_stereo_enc.c @@ -411,17 +411,30 @@ void stereo_coder_tcx( nAvailBitsMS[k] = ( ( mct_on ? 2 * sts[0]->bits_frame_channel : sts[0]->bits_frame_nominal ) - sts[0]->side_bits_frame_channel - sts[1]->side_bits_frame_channel - ( nSubframes == 2 ? OFFSET_BITS_TCX10 : OFFSET_BITS_TCX20 ) ) / nSubframes; - MsStereoDecision( sfbConf, sts[0]->hTcxEnc->spectrum[k], sts[1]->hTcxEnc->spectrum[k], inv_spectrum[0][k], inv_spectrum[1][k], &hStereoMdct->mdct_stereo_mode[k], &ms_mask[k][0], nAvailBitsMS[k] ); - - if ( sts[0]->igf ) +#ifdef NONBE_1329_FIX_OSBA_CRASH + if ( mct_on && nAvailBitsMS[k] <= 0 ) /*Force M/S when bit-budget is low for MCT*/ { - IGFEncStereoEncoder( sfbConf, sts[0]->hIGFEnc, sts[0]->hTcxEnc->spectrum[k], sts[1]->hTcxEnc->spectrum[k], &ms_mask[k][0], - &hStereoMdct->IGFStereoMode[k], hStereoMdct->mdct_stereo_mode[k], sts[0]->core == TCX_20_CORE, sts[0]->last_core == ACELP_CORE ); + hStereoMdct->mdct_stereo_mode[k] = 1; + hStereoMdct->IGFStereoMode[k] = 1; + set_s( ms_mask[k], 1, sfbConf->sfbCnt ); } else { - hStereoMdct->IGFStereoMode[k] = hStereoMdct->mdct_stereo_mode[k]; +#endif + MsStereoDecision( sfbConf, sts[0]->hTcxEnc->spectrum[k], sts[1]->hTcxEnc->spectrum[k], inv_spectrum[0][k], inv_spectrum[1][k], &hStereoMdct->mdct_stereo_mode[k], &ms_mask[k][0], nAvailBitsMS[k] ); + + if ( sts[0]->igf ) + { + IGFEncStereoEncoder( sfbConf, sts[0]->hIGFEnc, sts[0]->hTcxEnc->spectrum[k], sts[1]->hTcxEnc->spectrum[k], &ms_mask[k][0], + &hStereoMdct->IGFStereoMode[k], hStereoMdct->mdct_stereo_mode[k], sts[0]->core == TCX_20_CORE, sts[0]->last_core == ACELP_CORE ); + } + else + { + hStereoMdct->IGFStereoMode[k] = hStereoMdct->mdct_stereo_mode[k]; + } +#ifdef NONBE_1329_FIX_OSBA_CRASH } +#endif if ( hStereoMdct->mdct_stereo_mode[k] != SMDCT_DUAL_MONO || hStereoMdct->IGFStereoMode[k] != SMDCT_DUAL_MONO ) {