Commit a59902ab authored by bayers's avatar bayers
Browse files

Merge branch '826-jbm-masa-cna-and-cng-not-in-sync-with-non-jbm-decoding' into 'main'

[Non-BE] Resolve "JBM MASA: CNA and CNG not in sync with non-JBM decoding"

See merge request !1112
parents eac7bb1f 36739d3e
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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 ########################### */

+29 −1
Original line number Diff line number Diff line
@@ -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 )
+13 −0
Original line number Diff line number Diff line
@@ -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 );