Commit 27bf0e3e authored by vaclav's avatar vaclav
Browse files

port NONBE_1324_TC_BUFFER_MEMOERY_KEEP

parent e9646cab
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -114,6 +114,7 @@
#define FIX_NCHAN_BUFFERS                               /* VA: issue 1322: Correct the number of float buffers (channels) at the decoder */
#define FIX_RENDERER_STACK                              /* VA: issue 1322: reduction of renderers' buffers size */
#define JBM_MEMORY_OPT                                  /* VA: issue 916: optimization of RAM in the JBM decoder */
#define NONBE_1324_TC_BUFFER_MEMOERY_KEEP               /* VA: issue 1324: do not reset TSM memory in JBM bitrate switching */
#define FIX_1370_EXTERNAL_ORIENTATION_CHECK             /* Nokia: add sanity check for Euler angles for external orientations */


+34 −0
Original line number Diff line number Diff line
@@ -3910,6 +3910,10 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx(
    const Word16 n_samples_granularity     /* i  : new granularity of the renderer/buffer  */
)
{
#ifdef NONBE_1324_TC_BUFFER_MEMOERY_KEEP
    Word16 ch_idx, num_tc_buffer_mem, n_samples_still_available;
    Word32 tc_buffer_mem[MAX_INTERN_CHANNELS][L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES - 1];
#endif
#ifdef JBM_MEMORY_OPT
    ivas_error error;
#else
@@ -3921,6 +3925,28 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx(
    hTcBuffer = st_ivas->hTcBuffer;
    move16();

#ifdef NONBE_1324_TC_BUFFER_MEMOERY_KEEP
    num_tc_buffer_mem = 0;
    move16();
    n_samples_still_available = 0;
    move16();

    IF( st_ivas->hDecoderConfig->Opt_tsm )
    {
        /* save samples of the TC buffer from the previous frame */
        num_tc_buffer_mem = s_min( hTcBuffer->nchan_transport_internal, nchan_transport_internal );
        n_samples_still_available = sub( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_rendered );

        /* what is remaining from last frame needs always be smaller than the new granularity */
        assert( n_samples_still_available < n_samples_granularity );

        FOR( ch_idx = 0; ch_idx < num_tc_buffer_mem; ch_idx++ )
        {
            Copy32( hTcBuffer->tc_buffer_old_fx[ch_idx] + hTcBuffer->n_samples_flushed, tc_buffer_mem[ch_idx], n_samples_still_available );
        }
    }

#endif
    /* if granularity changes, adapt subframe_nb_slots */
    IF( NE_16( n_samples_granularity, hTcBuffer->n_samples_granularity ) )
    {
@@ -4031,6 +4057,14 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx(
    }
#endif

#ifdef NONBE_1324_TC_BUFFER_MEMOERY_KEEP
    /* propagate samples of the TC buffer from the previous frame */
    FOR( ch_idx = 0; ch_idx < num_tc_buffer_mem; ch_idx++ )
    {
        Copy32( tc_buffer_mem[ch_idx], hTcBuffer->tc_buffer_old_fx[ch_idx], n_samples_still_available );
    }

#endif
    return IVAS_ERR_OK;
}