Commit bded7cf2 authored by bayers's avatar bayers
Browse files

fix #826, MASA CNA and CNG handling for JBM not in sync with non-JBM decoding

parent eb805eab
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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 ######################### */
+33 −4
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,12 +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
            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;
@@ -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 )
+13 −0
Original line number Diff line number Diff line
@@ -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 );