diff --git a/lib_com/options.h b/lib_com/options.h index 2b6116bf4e64328f5cd0e288c1e5b73484433f92..715489a10bb649775ec088853036981fc539df5f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -193,6 +193,7 @@ #define NONBE_FIX_846_JBM_MASA_SIDSTART /* FhG: Issue #846: fix JBM for MASA DTX when the first frame is a SID frame */ #define NONBE_FIX_841_MC_RS_TDOBJ_RENDERER /* FhG: Issue #841: [Non-BE] Resolve "MC RS HRFT handle not set to NULL" */ #define NONBE_FIX_840_PARAMMC_RS /* FhG: Issue #840: Resolve "MC RS ParamMC hoa encoder wrongly set to zero" */ +#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 ########################### */ diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 37cff3347e5b70f7de3bef37605564b2d6ddde07..14db7fadf49b0281767da513c546ebb0d23eb87f 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,13 +642,32 @@ 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; } +#ifdef NONBE_FIX_826_JBM_MASA_CNA_CNG + else if ( st_ivas->nchan_transport == 1 && ( st_ivas->renderer_type == RENDERER_DIRAC ) ) + { + /* 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 { return error; } @@ -1494,7 +1516,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 7b2b73977d6c2d0e754a17b1ff45812591478d0b..d91c44212333a44a657ccff57207ce098464a099 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -778,6 +778,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; @@ -842,7 +845,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->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 { 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 );