Commit c8df4f07 authored by vaclav's avatar vaclav
Browse files

call ivas_jbm_dec_set_discard_samples() at one common place and only in JBM + revert some renamings

parent e7a94f0a
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -791,7 +791,7 @@ void ivas_apply_non_diegetic_panning(
 * decoder->rendering TC buffer prototypes
 *----------------------------------------------------------------------------------*/

ivas_error ivas_dec_flush_renderer(
ivas_error ivas_jbm_dec_flush_renderer(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                                      */
    const int16_t tc_granularity_new,                           /* i  : new renderer granularity                                    */
    const RENDERER_TYPE renderer_type_old,                      /* i  : old renderer type                                           */
@@ -815,7 +815,7 @@ void ivas_dec_prepare_renderer(
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder structure                                      */
);

ivas_error ivas_dec_set_discard_samples(
ivas_error ivas_jbm_dec_set_discard_samples(
    Decoder_Struct *st_ivas                                     /* i/o: main IVAS decoder structre                                  */
);

@@ -865,9 +865,16 @@ TC_BUFFER_MODE ivas_dec_get_tc_buffer_mode(
);

/*! r: render granularity */
#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS
int16_t ivas_dec_get_render_granularity(
#else
int16_t ivas_jbm_dec_get_render_granularity(
#endif
    const RENDERER_TYPE rendererType,                           /* i  : renderer type                                               */
    const IVAS_FORMAT ivas_format,                              /* i  : ivas format                                                 */
#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS
    const ISM_MODE ism_mode,                                    /* i  : ISM mode                                                    */
#endif
    const MC_MODE mc_mode,                                      /* i  : MC mode                                                     */
    const int32_t output_Fs                                     /* i  : sampling rate                                               */
);
+18 −14
Original line number Diff line number Diff line
@@ -111,7 +111,7 @@ static ivas_error ivas_ism_bitrate_switching_dec(
#ifndef NONBE_1200_ISM_JBM_BRATE_SW_FLUSH
    {
#endif
        /* transfer subframe info from DirAC or ParamMC to central TC buffer */
        /* transfer subframe info from ParamISM to central TC buffer */
        /* only do this if we are not having done everything already in the TC decoding part and having only played out from the TC buffer */
        if ( last_ism_mode == ISM_MODE_PARAM && st_ivas->hSpatParamRendCom != NULL && st_ivas->hTcBuffer->tc_buffer_mode != TC_BUFFER_MODE_BUFFER )
        {
@@ -122,22 +122,26 @@ static ivas_error ivas_ism_bitrate_switching_dec(
            mvs2s( st_ivas->hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
        }

        /* when granularity goes down (e.g. Discrete ISM with TD Obj Renderer -> ParamISM with binaural fastconv
#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS
        tc_granularity_new = ivas_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->ism_mode, MC_MODE_NONE, st_ivas->hDecoderConfig->output_Fs );
#else
    /* 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_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs );
    tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs );

    if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity )
    {
        /* flush already done in IVAS_DEC_ReadFormat() */
    }
        /* when granularity goes up set samples to discard at the beginning of the frame */
    /* 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_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK )
        if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK )
        {
            return error;
        }
    }
#endif
#ifndef NONBE_1200_ISM_JBM_BRATE_SW_FLUSH
    }
#endif
+26 −12
Original line number Diff line number Diff line
@@ -1482,12 +1482,12 @@ ivas_error ivas_dec_render(


/*--------------------------------------------------------------------------*
 * ivas_dec_flush_renderer()
 * ivas_jbm_dec_flush_renderer()
 *
 * Flush samples if renderer granularity changes on a bitrate change
 * Flush samples if renderer granularity changes on a bitrate change in JBM
 *--------------------------------------------------------------------------*/

ivas_error ivas_dec_flush_renderer(
ivas_error ivas_jbm_dec_flush_renderer(
    Decoder_Struct *st_ivas,                     /* i/o: IVAS decoder structure    */
    const int16_t tc_granularity_new,            /* i  : new renderer granularity  */
    const RENDERER_TYPE renderer_type_old,       /* i  : old renderer type         */
@@ -1746,13 +1746,13 @@ ivas_error ivas_dec_flush_renderer(


/*--------------------------------------------------------------------------*
 * ivas_dec_set_discard_samples()
 * ivas_jbm_dec_set_discard_samples()
 *
 * Set number of samples to discard in the first subframe
 * if the renderer granularity changes on a bitrate change
 * if the renderer granularity changes on a bitrate change in JBM processing
 *--------------------------------------------------------------------------*/

ivas_error ivas_dec_set_discard_samples(
ivas_error ivas_jbm_dec_set_discard_samples(
    Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */
)
{
@@ -1785,24 +1785,24 @@ void ivas_dec_get_adapted_linear_interpolator(
    float *interpolator                  /* o  : the interpolator                                */
)
{
    int16_t jbm_segment_len, idx;
    int16_t segment_len, idx;
    float dec;
#ifdef DEBUGGING
    assert( default_interp_length % 2 == 0 );
#endif

    jbm_segment_len = ( default_interp_length >> 1 );
    segment_len = ( default_interp_length >> 1 );
    dec = 1.0f / default_interp_length;

    interpolator[interp_length - 1] = 1.0f;
    for ( idx = interp_length - 2; idx >= jbm_segment_len; idx-- )
    for ( idx = interp_length - 2; idx >= segment_len; idx-- )
    {
        interpolator[idx] = max( 0.0f, interpolator[idx + 1] - dec );
    }

    if ( interpolator[idx + 1] > 0.0f )
    {
        dec = interpolator[idx + 1] / ( jbm_segment_len + 1 );
        dec = interpolator[idx + 1] / ( segment_len + 1 );
        for ( ; idx >= 0; idx-- )
        {
            interpolator[idx] = interpolator[idx + 1] - dec;
@@ -2195,9 +2195,16 @@ static void ivas_jbm_dec_copy_tc(
 *--------------------------------------------------------------------------*/

/*! r: render granularity */
#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS
int16_t ivas_dec_get_render_granularity(
#else
int16_t ivas_jbm_dec_get_render_granularity(
#endif
    const RENDERER_TYPE rendererType, /* i  : renderer type     */
    const IVAS_FORMAT ivas_format,    /* i  : ivas format       */
#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS
    const ISM_MODE ism_mode, /* i  : ISM mode          */
#endif
    const MC_MODE mc_mode,  /* i  : MC mode           */
    const int32_t output_Fs /* i  : sampling rate     */
)
@@ -2215,6 +2222,13 @@ int16_t ivas_dec_get_render_granularity(
            render_granularity = NS2SA( output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES );
        }
    }
#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS
    else if ( ivas_format == MASA_ISM_FORMAT && rendererType == RENDERER_BINAURAL_PARAMETRIC && ism_mode == ISM_MASA_MODE_DISC )
    {
        render_granularity = NS2SA( output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); /* Use the same granularity as TDrend */
    }

#endif
    else
    {
        render_granularity = NS2SA( output_Fs, CLDFB_SLOT_NS );
+7 −2
Original line number Diff line number Diff line
@@ -1474,7 +1474,11 @@ ivas_error ivas_masa_dec_reconfigure(
        TC_BUFFER_MODE buffer_mode_new;
        int16_t n_samples_granularity;

#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS
        n_samples_granularity = ivas_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->ism_mode, MC_MODE_NONE, st_ivas->hDecoderConfig->output_Fs );
#else
        n_samples_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS );
#endif
        buffer_mode_new = ivas_dec_get_tc_buffer_mode( st_ivas );
        tc_nchan_transport = ivas_dec_get_num_tc_channels( st_ivas );

@@ -1489,13 +1493,13 @@ ivas_error ivas_masa_dec_reconfigure(
            {
                tc_nchan_to_allocate = 2 * BINAURAL_CHANNELS;
            }

#ifndef UNIFIED_DECODING_PATHS_LEFTOVERS
            if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC )
            {
                n_samples_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); /* Use the same granularity as tdrend */
                if ( n_samples_granularity > st_ivas->hTcBuffer->n_samples_granularity )
                {
                    if ( ( error = ivas_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK )
                    if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK )
                    {
                        return error;
                    }
@@ -1508,6 +1512,7 @@ ivas_error ivas_masa_dec_reconfigure(
                    /* 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 ) )
        {
+11 −7
Original line number Diff line number Diff line
@@ -791,21 +791,25 @@ static ivas_error ivas_mc_dec_reconfig(
        }
    }

    /* when granularity goes down (e.g. MCT with CREND -> ParamMC with binaural fastconv
#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS
    tc_granularity_new = ivas_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, ISM_MODE_NONE, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs );
#else
    /* 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_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs );
    if ( tc_granularity_new < hTcBuffer->n_samples_granularity )
    tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs );
    if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity )
    {
        /* flush already done in IVAS_DEC_ReadFormat() */
    }
    /* when granularity goes up set samples to discard at the beginning of the frame */
    else if ( tc_granularity_new > hTcBuffer->n_samples_granularity )
    /* 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_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK )
        if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK )
        {
            return error;
        }
    }
#endif

    if ( st_ivas->mc_mode == MC_MODE_MCT )
    {
Loading