From bded7cf2242909879e4ade4b4e97aec6f64bd016 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Tue, 26 Sep 2023 13:52:21 +0200 Subject: [PATCH 1/3] fix #826, MASA CNA and CNG handling for JBM not in sync with non-JBM decoding --- lib_com/options.h | 2 +- lib_dec/ivas_masa_dec.c | 37 +++++++++++++++++++++++++++++++++---- lib_dec/ivas_sba_dec.c | 13 +++++++++++++ 3 files changed, 47 insertions(+), 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 99120b3e3d..1ca9716702 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -213,7 +213,7 @@ #define NONBE_FIX_797_OMASA_INACTIVE_SEP_OBJ /* VA: issue 797: fix of crash when the separated object is inactive and the MASA metadata is using very few bits */ #define NONBE_FIX_798_OSBA_MC_DEC_CRASH #define NONBE_FIX_806_OMASA_ONE_SEP_TRANSPORT_MIX /* Nokia: issue 806: fix one separated object mode transport mix of the separated object */ - +#define NONBE_FIX_826_JBM_MASA_CNA_CNG /* FhG: issue #826: Resolve "JBM MASA: CNA and CNG not in sync with non-JBM decoding" */ /* ##################### End NON-BE switches ########################### */ /* ################## End DEVELOPMENT switches ######################### */ diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 37cff3347e..dea1b9710d 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -628,6 +628,9 @@ ivas_error ivas_masa_dec_open( { int16_t nchan_to_allocate; TC_BUFFER_MODE buffer_mode; +#ifdef NONBE_FIX_826_JBM_MASA_CNA_CNG + int16_t nchan_transport; +#endif buffer_mode = TC_BUFFER_MODE_RENDERER; if ( st_ivas->mc_mode == MC_MODE_MCMASA && ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO ) ) @@ -639,16 +642,36 @@ ivas_error ivas_masa_dec_open( buffer_mode = TC_BUFFER_MODE_BUFFER; } +#ifdef NONBE_FIX_826_JBM_MASA_CNA_CNG + nchan_transport = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + nchan_to_allocate = nchan_transport; +#else nchan_to_allocate = ivas_jbm_dec_get_num_tc_channels( st_ivas ); +#endif if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) { +#ifdef NONBE_FIX_826_JBM_MASA_CNA_CNG + nchan_transport = 1; +#endif nchan_to_allocate = 1; } - - if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_to_allocate, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) +#ifdef NONBE_FIX_826_JBM_MASA_CNA_CNG + else if ( st_ivas->nchan_transport == 1 && ( st_ivas->renderer_type == RENDERER_DIRAC ) ) { - return error; + /* addtl channel for CNG */ + nchan_to_allocate++; } +#endif + +#ifdef NONBE_FIX_826_JBM_MASA_CNA_CNG + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_transport, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_to_allocate, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) +#endif + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_to_allocate, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) + { + return error; + } } return error; @@ -1494,7 +1517,13 @@ ivas_error ivas_masa_dec_reconfigure( } } } - +#ifdef NONBE_FIX_826_JBM_MASA_CNA_CNG + else if ( st_ivas->nchan_transport == 1 && ( st_ivas->renderer_type == RENDERER_DIRAC && st_ivas->hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) ) + { + /* addtl channel for CNG */ + tc_nchan_to_allocate++; + } +#endif if ( tc_nchan_transport != st_ivas->hTcBuffer->nchan_transport_jbm || tc_nchan_to_allocate != st_ivas->hTcBuffer->nchan_transport_internal || buffer_mode_new != st_ivas->hTcBuffer->tc_buffer_mode ) { if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas, buffer_mode_new, tc_nchan_transport, tc_nchan_to_allocate, tc_nchan_to_allocate, n_samples_granularity ) ) != IVAS_ERR_OK ) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index e1a58a6a8e..9d8882ba80 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -627,6 +627,9 @@ ivas_error ivas_sba_dec_digest_tc( { int16_t ch_idx; ivas_error error; +#ifdef NONBE_FIX_826_JBM_MASA_CNA_CNG + int16_t nchan_transport; +#endif error = IVAS_ERR_OK; @@ -687,7 +690,17 @@ ivas_error ivas_sba_dec_digest_tc( } /* if we have a late CNG generation, do it here */ +#ifdef NONBE_FIX_826_JBM_MASA_CNA_CNG + nchan_transport = st_ivas->nchan_transport; + if ( st_ivas->ivas_format == MASA_FORMAT && st_ivas->hDecoderConfig->ivas_total_brate < MASA_STEREO_MIN_BITRATE && ( st_ivas->hDecoderConfig->ivas_total_brate > IVAS_SID_5k2 || ( st_ivas->hDecoderConfig->ivas_total_brate <= IVAS_SID_5k2 && st_ivas->nCPE > 0 && st_ivas->hCPE[0]->nchan_out == 1 ) ) ) + { + nchan_transport = 1; /* Only one channel transported */ + } + if ( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag ) || + ( nchan_transport == 1 && st_ivas->nchan_transport != 2 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ) ) +#else if ( st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && st_ivas->ivas_format == SBA_FORMAT ) +#endif { Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; generate_masking_noise_lb_dirac( st->hFdCngDec->hFdCngCom, st_ivas->hTcBuffer->tc[1], nCldfbSlots, st->cna_dirac_flag && st->flag_cna ); -- GitLab From 71237ffe94bf4601e1583253afcea1fa843d4f88 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Tue, 26 Sep 2023 13:53:45 +0200 Subject: [PATCH 2/3] fix small copy/paste error --- lib_dec/ivas_masa_dec.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index dea1b9710d..14db7fadf4 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -668,10 +668,9 @@ ivas_error ivas_masa_dec_open( #else if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_to_allocate, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) #endif - if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_to_allocate, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) - { - return error; - } + { + return error; + } } return error; -- GitLab From 6393d0e857112797f3ebe8b2e881023a01827f4f Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Wed, 4 Oct 2023 08:10:00 +0200 Subject: [PATCH 3/3] amend fir for #826, needed a few more conditions to be inline with non-JBM decoding --- lib_dec/ivas_sba_dec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 9d8882ba80..fdbf6c5d72 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -696,8 +696,8 @@ ivas_error ivas_sba_dec_digest_tc( { nchan_transport = 1; /* Only one channel transported */ } - if ( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag ) || - ( nchan_transport == 1 && st_ivas->nchan_transport != 2 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ) ) + if ( ( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) && st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag ) || + ( ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) && ( nchan_transport == 1 && st_ivas->nchan_transport != 2 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ) ) ) #else if ( st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && st_ivas->ivas_format == SBA_FORMAT ) #endif -- GitLab