diff --git a/lib_com/options.h b/lib_com/options.h index 0f0d57d6d0a508f07dbffedd197ec0220bea6037..2ea2901adfb0460fddb7cd666716cb0ea753dca2 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -150,6 +150,7 @@ #define DIRAC_DRCT_GAIN_TUNING /* issue 64: tuning of DirAC energy-compensation gains */ #define MDFT_ROM_OPTIMIZE /*Optimise ROM tables for MDFT/iMDFT*/ #define LFE_NO_ENTROPY_CODING /* issue 65: changes to add no entropy coding in LFE */ +#define FIX_79_MASA2TC_BITRATE_SWITCHING /* Nokia: Fix issue 79 on MASA 2TC bitrate switching crash in decoder. */ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c index 2d2e4dc214dcc2eb499cd8b51170e4de7609d8cf..c2c4319e647e180332f9359196ab37900755e46e 100644 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -108,7 +108,6 @@ ivas_error ivas_cpe_dec( return error; } - /*------------------------------------------------------------------* * Initialization *-----------------------------------------------------------------*/ @@ -399,7 +398,6 @@ ivas_error ivas_cpe_dec( return error; } - /* DFT Stereo residual decoding */ if ( hCPE->hStereoDft->res_cod_band_max > 0 && !st_ivas->bfi ) { @@ -583,7 +581,6 @@ ivas_error create_cpe_dec( hCPE->hStereoMdct = NULL; hCPE->hStereoTCA = NULL; hCPE->hStereoICBWE = NULL; - hCPE->hStereoCng = NULL; hCPE->stereo_switching_counter = 10; @@ -789,6 +786,7 @@ ivas_error create_cpe_dec( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Stereo MDCT\n" ) ); } + if ( st_ivas->ivas_format == STEREO_FORMAT && hCPE->element_brate <= MAX_MDCT_ITD_BRATE ) { hCPE->hStereoMdct->use_itd = 1; @@ -797,6 +795,7 @@ ivas_error create_cpe_dec( { hCPE->hStereoMdct->use_itd = 0; } + hCPE->hStereoMdct->reverse_dmx = 0; hCPE->hStereoMdct->smooth_ratio = 1.f; set_s( hCPE->hStereoMdct->prev_ms_mask[0], 0, MAX_SFB ); diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index e4c5021dbc03c5eaf3e9a668b28db5dfc90f2ca9..80bd618dd87626eb3eab4f977e284a875103c14f 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -891,6 +891,14 @@ ivas_error stereo_memory_dec( count_free( hCPE->prev_synth_chs[1] ); hCPE->prev_synth_chs[1] = NULL; } +#ifdef FIX_79_MASA2TC_BITRATE_SWITCHING + + if ( hCPE->hStereoTCA != NULL ) + { + count_free( hCPE->hStereoTCA ); + hCPE->hStereoTCA = NULL; + } +#endif } else /* nchan_out == 2 */ { @@ -909,6 +917,44 @@ ivas_error stereo_memory_dec( } set_zero( hCPE->prev_synth_chs[1], NS2SA( st->output_Fs, FRAME_SIZE_NS ) ); } +#ifdef FIX_79_MASA2TC_BITRATE_SWITCHING + + if ( hCPE->hStereoICBWE == NULL && hCPE->element_mode == IVAS_CPE_DFT ) + { + if ( ( hCPE->hStereoICBWE = (STEREO_ICBWE_DEC_HANDLE) count_malloc( sizeof( STEREO_ICBWE_DEC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Stereo ICBWE \n" ) ); + } + + stereo_icBWE_init_dec( hCPE->hStereoICBWE ); + } + + if ( hCPE->hStereoTCA == NULL && ( hCPE->element_mode == IVAS_CPE_DFT || hCPE->element_mode == IVAS_CPE_TD ) ) + { + if ( ( hCPE->hStereoTCA = (STEREO_TCA_DEC_HANDLE) count_malloc( sizeof( STEREO_TCA_DEC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Stereo TCA\n" ) ); + } + + stereo_tca_init_dec( hCPE->hStereoTCA ); + } + + if ( hCPE->element_mode == IVAS_CPE_MDCT ) + { + if( hCPE->hStereoTCA != NULL ) + { + /* note: in MASA, hCPE->hStereoMdct->itd = 0 */ + count_free( hCPE->hStereoTCA ); + hCPE->hStereoTCA = NULL; + } + + if ( hCPE->hStereoICBWE != NULL ) + { + count_free( hCPE->hStereoICBWE ); + hCPE->hStereoICBWE = NULL; + } + } +#endif } } diff --git a/scripts/config/self_test.prm b/scripts/config/self_test.prm index 8a5a0245f791a07f44bab643a1ab1c6af7f6b24a..ffafdb3776df6912396c384375c28e06ceccb30c 100644 --- a/scripts/config/self_test.prm +++ b/scripts/config/self_test.prm @@ -702,6 +702,14 @@ ../IVAS_cod -dtx -masa 2 testv/stv_IVASMASA_1dir2TC_DTX.met 32000 48 testv/stv_IVASMASA_1dir2TC_DTX.pcm bit ../IVAS_dec 5_1 48 bit testv/stv_IVASMASA_1dir2TC_DTX.pcm_32000_48-48_DTX_5_1.tst +// MASA 1dir 1TC bitrate switching from 13.2 kbps to 128 kbps, 48kHz in, 48kHz out, 5_1 out +../IVAS_cod -masa 1 testv/stv_IVASMASA_1dir1TC_DTX.met ../scripts/switchPaths/sw_13k2_to_128k_10fr.bin 48 testv/stv_IVASMASA_1dir1TC_DTX.pcm bit +../IVAS_dec 5_1 48 bit testv/stv_IVASMASA_1dir1TC_DTX.pcm_sw_48-48_5_1.tst + +// MASA 1dir 2TC bitrate switching from 13.2 kbps to 512 kbps, 48kHz in, 48kHz out, BINAURAL out +../IVAS_cod -masa 2 testv/stv_IVASMASA_1dir2TC_DTX.met ../scripts/switchPaths/sw_13k2_512k.bin 48 testv/stv_IVASMASA_1dir2TC_DTX.pcm bit +../IVAS_dec BINAURAL 48 bit testv/stv_IVASMASA_1dir2TC_DTX.pcm_sw_48-48_BINAURAL.tst + // Multi-channel 5_1 at 13.2 kbps, 48kHz in, 48kHz out ../IVAS_cod -mc 5_1 13200 48 testv/stv51MC48c.pcm bit