Commit 974ffbd7 authored by sagnowski's avatar sagnowski
Browse files

Merge branch '1321-jbm-decoder-assert' into 'main'

Resolve "JBM decoder assert"

See merge request !2229
parents 7382184b 9b0fb3ff
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -177,7 +177,7 @@
#define NONBE_1244_FIX_SWB_BWE_MEMORY                   /* VA: issue 1244: fix to SWB BWE memory in case of switching from FB coding - pending a review by Huawei */ 
#define NONBE_1122_KEEP_EVS_MODE_UNCHANGED              /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR.  */
#define NONBE_1328_FIX_NON_LINEARITY                    /* VA: Fix possible issue when computing bwe_exc_extended and previous frame were almost 0  */

#define NONBE_1321_JBM_ASSERT_BITRATE_SWITCHING         /* FhG: Fix assert being hit in JBM code during rate switching */
/* ##################### End NON-BE switches ########################### */

/* ################## End DEVELOPMENT switches ######################### */
+21 −0
Original line number Diff line number Diff line
@@ -128,6 +128,25 @@ static ivas_error ivas_ism_bitrate_switching_dec(
        mvs2s( st_ivas->hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
    }

#ifdef NONBE_1321_JBM_ASSERT_BITRATE_SWITCHING
    /* JBM: when granularity goes down (e.g. Discrete ISM with TD Obj Renderer -> ParamISM with binaural fastconv
        render what still fits in the new granularity */
    tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs );

    if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity )
    {
        /* flush already done in IVAS_DEC_ReadFormat() */
    }
    /* JBM: when granularity goes up set samples to discard at the beginning of the frame */
    else if ( tc_granularity_new > st_ivas->hTcBuffer->n_samples_granularity )
    {
        if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK )
        {
            return error;
        }
    }

#endif
    if ( st_ivas->ism_mode != last_ism_mode )
    {
        /* EFAP handle */
@@ -295,7 +314,9 @@ static ivas_error ivas_ism_bitrate_switching_dec(
    tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels( st_ivas );
    tc_nchan_allocate_new = tc_nchan_tc_new;
    tc_nchan_full_new = tc_nchan_tc_new;
#ifndef NONBE_1321_JBM_ASSERT_BITRATE_SWITCHING
    tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs );
#endif

    if ( st_ivas->ism_mode == ISM_MODE_PARAM && ( st_ivas->renderer_type != RENDERER_MONO_DOWNMIX && st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM ) )
    {
+19 −0
Original line number Diff line number Diff line
@@ -1509,6 +1509,25 @@ ivas_error ivas_masa_dec_reconfigure(
                    tc_nchan_to_allocate = 2 * BINAURAL_CHANNELS;
                }
            }
#ifdef NONBE_1321_JBM_ASSERT_BITRATE_SWITCHING
            if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC )
            {
                if ( n_samples_granularity > st_ivas->hTcBuffer->n_samples_granularity )
                {
                    if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK )
                    {
                        return error;
                    }
                }
            }
            else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode != ISM_MASA_MODE_DISC )
            {
                if ( n_samples_granularity < st_ivas->hTcBuffer->n_samples_granularity )
                {
                    /* flush already done in IVAS_DEC_ReadFormat() */
                }
            }
#endif
        }
        else if ( st_ivas->nchan_transport == 1 && ( st_ivas->renderer_type == RENDERER_DIRAC && st_ivas->hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) )
        {
+21 −0
Original line number Diff line number Diff line
@@ -795,6 +795,25 @@ static ivas_error ivas_mc_dec_reconfig(
        }
    }

#ifdef NONBE_1321_JBM_ASSERT_BITRATE_SWITCHING
    /* JBM: when granularity goes down (e.g. MCT with CREND -> ParamMC with binaural fastconv
           render what still fits in the new granularity */
    tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs );

    if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity )
    {
        /* flush already done in IVAS_DEC_ReadFormat() */
    }
    /* JBM: when granularity goes up set samples to discard at the beginning of the frame */
    else if ( tc_granularity_new > st_ivas->hTcBuffer->n_samples_granularity )
    {
        if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK )
        {
            return error;
        }
    }

#endif
    if ( st_ivas->mc_mode == MC_MODE_MCT )
    {
        st_ivas->nchan_transport = ivas_mc_ls_setup_get_num_channels( ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ) );
@@ -1303,7 +1322,9 @@ static ivas_error ivas_mc_dec_reconfig(
        tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels( st_ivas );
        tc_nchan_allocate_new = tc_nchan_tc_new;
        tc_nchan_full_new = tc_nchan_tc_new;
#ifndef NONBE_1321_JBM_ASSERT_BITRATE_SWITCHING
        tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs );
#endif

        if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC )
        {
+22 −0
Original line number Diff line number Diff line
@@ -173,6 +173,27 @@ ivas_error ivas_sba_dec_reconfigure(
        /* determine new granularity */
        granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, ivas_renderer_secondary_select( st_ivas ), st_ivas->hDecoderConfig->output_Fs );

#ifdef NONBE_1321_JBM_ASSERT_BITRATE_SWITCHING
        /* flush renderer on granularity change form 5ms to 1.25ms, again only possible for binaural rendering */
        if ( granularity_new < st_ivas->hTcBuffer->n_samples_granularity )
        {
            /* flush already done in IVAS_DEC_ReadFormat() */
        }
        else if ( granularity_new > st_ivas->hTcBuffer->n_samples_granularity )
        {
            if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK )
            {
                return error;
            }

            /* make sure the changed number of slots in the last subframe is not lost in the following steps */
            if ( st_ivas->hSpatParamRendCom != NULL )
            {
                st_ivas->hSpatParamRendCom->subframe_nbslots[st_ivas->hSpatParamRendCom->nb_subframes - 1] = st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1];
            }
            st_ivas->hSpar->subframe_nbslots[st_ivas->hSpar->nb_subframes - 1] = st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1];
        }
#else
        if ( granularity_new > st_ivas->hTcBuffer->n_samples_granularity )
        {
            /* make sure the changed number of slots in the last subframe is not lost in the following steps */
@@ -182,6 +203,7 @@ ivas_error ivas_sba_dec_reconfigure(
            }
            st_ivas->hSpar->subframe_nbslots[st_ivas->hSpar->nb_subframes - 1] = st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1];
        }
#endif
    }

    /* save old */
Loading