diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 4502f8dd6aab5d936d01759564800c00da57030c..a554ff3408757a91d32c7fa831795e98983b82aa 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -1925,8 +1925,10 @@ void stereo_icBWE_decproc( /*! r: element mode */ int16_t select_stereo_mode( CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const int32_t ivas_total_brate /* i : IVAS total brate */ + const IVAS_FORMAT ivas_format /* i : IVAS format */ +#ifndef NONBE_FIX_874_OMASA_BRSW_2TD + ,const int32_t ivas_total_brate /* i : IVAS total brate */ + #endif ); void stereo_classifier_init( diff --git a/lib_com/ivas_stereo_td_bit_alloc.c b/lib_com/ivas_stereo_td_bit_alloc.c index 87d3f7dd3edf1b74a115273074f8a939f078d322..7af235e813f8624494ac0bffb1ac3b89a38425ae 100644 --- a/lib_com/ivas_stereo_td_bit_alloc.c +++ b/lib_com/ivas_stereo_td_bit_alloc.c @@ -307,7 +307,7 @@ void tdm_bit_alloc( else { *total_brate_sec = min( *total_brate_sec, element_brate_wo_meta - ( 5900 + BWE_brate ) ); - +#ifndef NONBE_FIX_874_OMASA_BRSW_2TD if ( coder_type == INACTIVE ) { *total_brate_sec = max( *total_brate_sec, tdm_bit_allc_tbl[0][0] ); /* sanity check to ensure the secondary channel always gets the minimal bitrate it needs */ @@ -316,7 +316,19 @@ void tdm_bit_alloc( { *total_brate_sec = max( *total_brate_sec, 3500 ); /* sanity check to ensure the secondary channel always gets the minimal bitrate it needs */ } +#endif + } + +#ifdef NONBE_FIX_874_OMASA_BRSW_2TD + if ( coder_type == INACTIVE ) + { + *total_brate_sec = max( *total_brate_sec, tdm_bit_allc_tbl[0][0] ); /* sanity check to ensure the secondary channel always gets the minimal bitrate it needs */ } + else + { + *total_brate_sec = max( *total_brate_sec, 3500 ); /* sanity check to ensure the secondary channel always gets the minimal bitrate it needs */ + } +#endif /* Secondary channel bitrate adjusment */ /* First, adjust the bitrate depending of what is transmitted */ diff --git a/lib_com/options.h b/lib_com/options.h index 20d8ccce146423c3171ea7cf62a3a80bbebf8df6..34ba3158266bcf95b4fd117d44c7d95fc12608c1 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -162,6 +162,7 @@ #define NONBE_FIX_856_TCX_LTP_SYNTH_FILTER /* FhG: issue 856: correct filtering length for tcx-ltp synth filtering*/ #define NONBE_UNIFIED_DECODING_PATHS /* FhG: unify decoding paths */ #define NONBE_FIX_836_PARAMUPMIX_HEADROT /* Dlb: issue #836: Resolve "ParamUpmix MC to SBA conversion done on the already binaurlized output" */ +#define NONBE_FIX_874_OMASA_BRSW_2TD /* Nokia: issue 874: Fixes the crashes with the long test vectors that prompted switching to TD*/ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 6243d4d579603a7918acb829915ba09e282c9a17..3e7bb68a546b962e663cc3ffb71aafbc95a85486 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -200,6 +200,7 @@ ivas_error ivas_jbm_dec_tc( { set_s( nb_bits_metadata, 0, MAX_SCE ); + /* read parameters from the bitstream */ if ( st_ivas->ivas_format == MASA_FORMAT && st_ivas->hQMetaData != NULL ) { @@ -225,6 +226,9 @@ ivas_error ivas_jbm_dec_tc( if ( st_ivas->nchan_transport == CPE_CHANNELS && st_ivas->nCPE >= 1 ) { +#ifdef NONBE_FIX_874_OMASA_BRSW_2TD + st_ivas->hCPE[0]->brate_surplus = 0; +#endif st_ivas->hCPE[0]->element_brate = ivas_total_brate; } diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 38508a70f078add0b9d130346c64c8b97dc11910..fc810042699ec3c9ed71de402695342e9b352a04 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -176,7 +176,11 @@ ivas_error ivas_cpe_enc( if ( sts[0]->ini_frame > 0 && st_ivas->hMCT == NULL ) { +#ifdef NONBE_FIX_874_OMASA_BRSW_2TD + hCPE->element_mode = select_stereo_mode( hCPE, ivas_format ); +#else hCPE->element_mode = select_stereo_mode( hCPE, ivas_format, ivas_total_brate ); +#endif } stereo_mode_combined_format_enc( st_ivas, hCPE ); diff --git a/lib_enc/ivas_stereo_classifier.c b/lib_enc/ivas_stereo_classifier.c index 4735aaa5829fdc8de811f4a8cf1b6d8b81b3df4f..5649423bc203b09164935e0f967ab8c9d28c1dff 100644 --- a/lib_enc/ivas_stereo_classifier.c +++ b/lib_enc/ivas_stereo_classifier.c @@ -87,9 +87,12 @@ static float redge_detect( const float *inp, const int16_t len, const float inp_ /*! r: element mode */ int16_t select_stereo_mode( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ + CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ + const IVAS_FORMAT ivas_format /* i : IVAS format */ +#ifndef NONBE_FIX_874_OMASA_BRSW_2TD + , const int32_t ivas_total_brate /* i : IVAS total brate */ +#endif ) { int16_t element_mode; @@ -112,7 +115,11 @@ int16_t select_stereo_mode( stereo_switching_flag = 1; +#ifdef NONBE_FIX_874_OMASA_BRSW_2TD + if ( hCPE->element_brate >= MIN_BRATE_MDCT_STEREO || ( ( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT ) && hCPE->element_brate < MASA_STEREO_MIN_BITRATE ) +#else if ( hCPE->element_brate >= MIN_BRATE_MDCT_STEREO || ( ( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT ) && ivas_total_brate < MASA_STEREO_MIN_BITRATE ) +#endif #ifdef DEBUGGING || ( hCPE->stereo_mode_cmdl == IVAS_CPE_DFT || hCPE->stereo_mode_cmdl == IVAS_CPE_TD ) #endif @@ -148,6 +155,12 @@ int16_t select_stereo_mode( { if ( stereo_switching_flag == 0 ) { +#ifdef NONBE_FIX_874_OMASA_BRSW_2TD + if ( ( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT ) && hCPE->element_brate < MASA_STEREO_MIN_BITRATE ) + { + element_mode = IVAS_CPE_DFT; + } +#endif #ifdef DEBUGGING if ( hCPE->stereo_mode_cmdl > 1 ) {