Commit 5b8204ff authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

[cleanup] accept JBM_MEMORY_OPT

parent c0fa3972
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -192,13 +192,8 @@ typedef enum
#define JBM_CLDFB_SLOTS_IN_SUBFRAME_LOG2        2                           /* To be used for shift operation instead of division */
#define MAX_JBM_CLDFB_TIMESLOTS                 32
#define DEFAULT_JBM_CLDFB_TIMESLOTS             16
#ifdef JBM_MEMORY_OPT
#define MAX_JBM_L_FRAME48k                      ( IVAS_MAX_FRAME_SIZE * 2 ) /* 1920:  max. time-scaled frame buffer length (per channel) in samples */
#define MAX_JBM_L_FRAME_NS                      40000000L                   /* 40 ms: time-scaled frame size in ns, proportional to MAX_JBM_L_FRAME48k  */
#else
#define MAX_JBM_L_FRAME48k                      1920
#define MAX_JBM_L_FRAME_NS                      40000000L
#endif
#define MAX_SPAR_INTERNAL_CHANNELS              IVAS_SPAR_MAX_CH
#define MAX_CLDFB_DIGEST_CHANNELS               3                           /* == maximum of ParamISM TCs and ParamMC TCs */

+0 −14
Original line number Diff line number Diff line
@@ -2079,7 +2079,6 @@ UWord32 ivas_syn_output_fx(
    Word16 *synth_out                                           /* o  : integer 16 bits synthesis signal            */
);

#ifdef JBM_MEMORY_OPT
void ivas_buffer_interleaved_to_deinterleaved_fx(
    Word32 *audio,                                              /* i/o: audio buffer                                */
    const Word16 n_channels,                                    /* i  : number of channels                          */
@@ -2094,7 +2093,6 @@ void ivas_buffer_deinterleaved_to_interleaved_fx(
    Word32 *audio_out                                           /* o  : interleaved audio buffer                    */
);

#endif
void stereo_tcx_core_dec_fx(
    Decoder_State *st,                                          /* i/o: decoder state structure                     */
    const FRAME_MODE frameMode,                                 /* i  : Decoder frame mode                          */
@@ -4000,14 +3998,6 @@ void inverseMS_fx(
    const Word32 norm_fac                                       /* i  : normalization factor                     Q31*/
);

#ifndef JBM_MEMORY_OPT
void ivas_syn_output_f_fx(
    Word32 *synth[],                                            /* i/o: Word32 synthesis signal                     */
    const Word16 output_frame,                                  /* i  : output frame length (one channel)           */
    const Word16 n_channels,                                    /* i  : number of output channels                   */
    Word32 *synth_out                                           /* o  : integer 16 bits synthesis signal            */
);
#endif
ivas_error ivas_init_encoder_fx(
    Encoder_Struct *st_ivas                                     /* i/o: IVAS encoder structure                      */
);
@@ -6186,10 +6176,6 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                                      */
    const Word16 nSamplesForRendering,                          /* i  : number of TC samples available for rendering                */
    Word16 *nSamplesResidual                                    /* o  : number of samples not fitting into the renderer grid and buffer for the next call*/
#ifndef JBM_MEMORY_OPT
    ,
    Word32 *data_fx                                             /* i/o: transport channels/output synthesis signal                  */
#endif
);

void ivas_dec_prepare_renderer_fx(
+0 −37
Original line number Diff line number Diff line
@@ -149,7 +149,6 @@ UWord32 ivas_syn_output_fx(
    return noClipping; /*Q0*/
}

#ifdef JBM_MEMORY_OPT

/*-------------------------------------------------------------------*
 * ivas_buffer_interleaved_to_deinterleaved()
@@ -228,42 +227,6 @@ void ivas_buffer_deinterleaved_to_interleaved_fx(
    return;
}

#else

/*-------------------------------------------------------------------*
 * ivas_syn_output_f()
 *
 * Output ivas synthesis signal with compensation for saturation
 * returns number of clipped samples
 *-------------------------------------------------------------------*/

/*! r: number of clipped samples */
void ivas_syn_output_f_fx(
    Word32 *synth[],           /* i/o: float synthesis signal              Q11*/
    const Word16 output_frame, /* i  : output frame length (one channel)   Q0*/
    const Word16 n_channels,   /* i  : number of output channels           Q0*/
    Word32 *synth_out          /* o  : integer 16 bits synthesis signal    Q11*/
)
{
    Word16 i, n;

    /*-----------------------------------------------------------------*
     * float to integer conversion with saturation control
     *-----------------------------------------------------------------*/

    FOR( n = 0; n < n_channels; n++ )
    {
        FOR( i = 0; i < output_frame; i++ )
        {
            synth_out[( ( i * n_channels ) + n )] = synth[n][i]; /*Q11*/
            move16();
        }
    }

    return;
}

#endif

/*-------------------------------------------------------------------*
 * mvr2r_inc()
+0 −1
Original line number Diff line number Diff line
@@ -132,7 +132,6 @@
#define FIX_1384_MSAN_ivas_spar_dec_open                /* VA: issue 1386: fix use-of-uninitialized value in ivas_spar_dec_open() */
#define FIX_1388_MSAN_ivas_init_decoder                 /* VA: issue 1388: fix use-of-uninitialized value in ivas_init_decoder() */
#define FIX_1288_SPLIT_REND_XSAN                        /* Dlb: Fix asan, msan and usan issues in split rendering mode*/
#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 */
#define FIX_1413_IGF_INIT_PRINTOUT                      /* FhG: use correct variable for IGF initiliazation */
+0 −247
Original line number Diff line number Diff line
@@ -1520,19 +1520,10 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx(
    Decoder_Struct *st_ivas,           /* i/o: IVAS decoder structure                          */
    const Word16 nSamplesForRendering, /* i  : number of TC samples available for rendering    */
    Word16 *nSamplesResidual           /* o  : number of samples not fitting into the renderer grid and buffer for the next call*/
#ifndef JBM_MEMORY_OPT
    ,
    Word32 *data /* i  : transport channels                              */
#endif
)
{
#ifdef JBM_MEMORY_OPT
    Word32 tmp_buf_fx[MAX_JBM_L_FRAME48k];
    Word32 *p_data_fx[FOA_CHANNELS + MAX_NUM_OBJECTS];
#else
    Word32 data_fx[MAX_CLDFB_DIGEST_CHANNELS][MAX_JBM_L_FRAME48k]; /* buffer for transport channels that will be directly converted with the CLDFB */
    Word32 *p_data_fx[MAX_CLDFB_DIGEST_CHANNELS];
#endif
    Word16 n, n_render_timeslots, n_ch_cldfb;
#ifdef FIX_1330_JBM_MEMORY
    Word16 ch, offset, len_offset;
@@ -1550,7 +1541,6 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx(

    IF( st_ivas->hDecoderConfig->Opt_tsm )
    {
#ifdef JBM_MEMORY_OPT
        Word16 n_samples_still_available;
        Word16 n_ch_full_copy, n_ch_res_copy;

@@ -1604,52 +1594,6 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx(
                Copy32( tmp_buf_fx + nSamplesForRendering - *nSamplesResidual, hTcBuffer->tc_buffer_old_fx[ch], *nSamplesResidual );
            }
        }
#else
        Word16 n_samples_still_available, m;
        Word16 n_ch_full_copy;
        Word16 n_ch_res_copy;

        FOR( n = 0; n < n_ch_cldfb; n++ )
        {
            p_data_fx[n] = &data_fx[n][0];
        }

        n_samples_still_available = sub( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_rendered );
        hTcBuffer->n_samples_buffered = add( add( n_samples_still_available, nSamplesForRendering ), hTcBuffer->n_samples_discard );
        hTcBuffer->n_samples_available = i_mult( hTcBuffer->n_samples_granularity, idiv1616( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_granularity ) );
        *nSamplesResidual = sub( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_available );
        move16();
        move16();
        move16();
        n_ch_full_copy = s_min( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full );
        n_ch_res_copy = sub( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full );

        FOR( ch = 0; ch < n_ch_full_copy; ch++ )
        {
            set32_fx( hTcBuffer->tc_fx[ch], 0, hTcBuffer->n_samples_discard );
            Copy32( hTcBuffer->tc_fx[ch] + hTcBuffer->n_samples_rendered, hTcBuffer->tc_fx[ch] + hTcBuffer->n_samples_discard, n_samples_still_available );
            FOR( m = 0; m < nSamplesForRendering; m++ )
            {
                hTcBuffer->tc_fx[ch][n_samples_still_available + hTcBuffer->n_samples_discard + m] = data[m * hTcBuffer->nchan_transport_jbm + ch];
                move32();
            }
        }

        IF( n_ch_res_copy > 0 )
        {
            FOR( ; ch < hTcBuffer->nchan_transport_jbm; ch++ )
            {
                Copy32( hTcBuffer->tc_fx[ch], p_data_fx[ch], n_samples_still_available );

                FOR( m = 0; m < nSamplesForRendering; m++ )
                {
                    p_data_fx[ch][n_samples_still_available + m] = data[m * hTcBuffer->nchan_transport_jbm + ch];
                    move32();
                }
                Copy32( p_data_fx[ch] + hTcBuffer->n_samples_available, hTcBuffer->tc_fx[ch], *nSamplesResidual );
            }
        }
#endif

        n_render_timeslots = idiv1616( st_ivas->hTcBuffer->n_samples_available, st_ivas->hTcBuffer->n_samples_granularity );
    }
@@ -1661,11 +1605,7 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx(
            move16();
        }

#ifdef JBM_MEMORY_OPT
        ch = s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full );
#else
        ch = ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate );
#endif
        FOR( n = 0; n < ch; n++ )
        {
            hTcBuffer->tc_fx[n] = st_ivas->p_output_fx[n]; /* note: buffers needed in the TD decorellator */
@@ -1759,11 +1699,7 @@ ivas_error ivas_jbm_dec_render_fx(

    IF( !st_ivas->hDecoderConfig->Opt_tsm )
    {
#ifdef JBM_MEMORY_OPT
        FOR( n = 0; n < MAX_INTERN_CHANNELS; n++ )
#else
        FOR( n = 0; n < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; n++ )
#endif
        {
            st_ivas->hTcBuffer->tc_fx[n] = st_ivas->p_output_fx[n];
        }
@@ -2643,7 +2579,6 @@ ivas_error ivas_jbm_dec_flush_renderer_fx(
    {
        Word16 ch_idx;

#ifdef JBM_MEMORY_OPT
        /* render available full slots (with new lower granularity) */
        FOR( ch_idx = 0; ch_idx < s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); ch_idx++ )
        {
@@ -2655,16 +2590,6 @@ ivas_error ivas_jbm_dec_flush_renderer_fx(
            set_zero_fx( hTcBuffer->tc_fx[ch_idx] + n_samples_to_render, hTcBuffer->n_samples_granularity - n_samples_to_render );
#endif
        }
#else
        /* render what is still there with zero padding */
        FOR( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ )
        {
            /* move it at the beginning of the TC buffer with zero padding */
            Copy32( hTcBuffer->tc_fx[ch_idx] + hTcBuffer->n_samples_rendered, hTcBuffer->tc_fx[ch_idx], n_samples_to_render );
            set_zero_fx( hTcBuffer->tc_fx[ch_idx] + n_samples_to_render, hTcBuffer->n_samples_granularity - n_samples_to_render );
            Copy32( hTcBuffer->tc_fx[ch_idx] + hTcBuffer->n_samples_rendered + n_samples_to_render, hTcBuffer->tc_fx[ch_idx] + hTcBuffer->n_samples_granularity, n_samples_still_available );
        }
#endif

        /* simple change of the slot info */
        hTcBuffer->num_slots = 1;
@@ -3466,7 +3391,6 @@ Word16 ivas_jbm_dec_get_render_granularity_fx(
    return render_granularity;
}

#ifdef JBM_MEMORY_OPT

/*--------------------------------------------------------------------------*
 * ivas_jbm_dec_tc_audio_allocate()
@@ -3615,7 +3539,6 @@ static void ivas_jbm_dec_tc_audio_deallocate_fx(

    return;
}
#endif

/*--------------------------------------------------------------------------*
 * ivas_jbm_dec_tc_buffer_open()
@@ -3632,17 +3555,9 @@ ivas_error ivas_jbm_dec_tc_buffer_open_fx(
    const Word16 n_samples_granularity     /* i  : granularity of the renderer/buffer  */
)
{
#ifndef JBM_MEMORY_OPT
    Word16 nsamp_to_allocate;
#endif
    DECODER_TC_BUFFER_HANDLE hTcBuffer;
    Word16 nMaxSlotsPerSubframe;
#ifdef JBM_MEMORY_OPT
    ivas_error error;
#else
    Word16 nchan_residual;
    Word16 ch_idx;
#endif
    Word16 tmp, tmp_e;
    Word32 tmp32;

@@ -3663,9 +3578,6 @@ ivas_error ivas_jbm_dec_tc_buffer_open_fx(
    move16();
    hTcBuffer->nchan_buffer_full = nchan_full;
    move16();
#ifndef JBM_MEMORY_OPT
    nchan_residual = sub( nchan_transport_internal, nchan_full );
#endif
    hTcBuffer->n_samples_granularity = n_samples_granularity;
    move16();
    hTcBuffer->n_samples_available = 0;
@@ -3684,10 +3596,6 @@ ivas_error ivas_jbm_dec_tc_buffer_open_fx(
    move16();
    hTcBuffer->nb_subframes = MAX_PARAM_SPATIAL_SUBFRAMES;
    move16();
#ifndef JBM_MEMORY_OPT
    nsamp_to_allocate = 0;
    move16();
#endif

    tmp32 = L_mult0( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES, hTcBuffer->n_samples_granularity ); // Q0
    tmp = BASOP_Util_Divide3232_Scale( st_ivas->hDecoderConfig->output_Fs, tmp32, &tmp_e );
@@ -3699,75 +3607,10 @@ ivas_error ivas_jbm_dec_tc_buffer_open_fx(
    set16_fx( hTcBuffer->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS );
    set16_fx( hTcBuffer->subframe_nbslots, nMaxSlotsPerSubframe, MAX_PARAM_SPATIAL_SUBFRAMES );

#ifdef JBM_MEMORY_OPT
    IF( ( error = ivas_jbm_dec_tc_audio_allocate_fx( hTcBuffer, st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->Opt_tsm ) ) != IVAS_ERR_OK )
    {
        return error;
    }
#else
    {
        Word16 n_samp_full, n_samp_residual;
        Word32 offset;
        IF( st_ivas->hDecoderConfig->Opt_tsm )
        {
            n_samp_full = add( NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ), sub( hTcBuffer->n_samples_granularity, 1 ) );
            n_samp_residual = sub( hTcBuffer->n_samples_granularity, 1 );
        }
        ELSE
        {
            /* n_samp_full = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); */
            n_samp_full = extract_l( Mpy_32_32( st_ivas->hDecoderConfig->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) );
            n_samp_residual = 0;
            move16();
        }

        nsamp_to_allocate = mult0( hTcBuffer->nchan_buffer_full, n_samp_full );
        nsamp_to_allocate = add( nsamp_to_allocate, mult0( nchan_residual, n_samp_residual ) );

        IF( nsamp_to_allocate == 0 )
        {
            hTcBuffer->tc_buffer_fx = NULL;

            FOR( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ )
            {
                hTcBuffer->tc_fx[ch_idx] = NULL;
            }
        }
        ELSE
        {
            IF( st_ivas->hDecoderConfig->Opt_tsm )
            {
                /* note: the maximum buffer length is for OSBA DISC mode with ISMs -> 15*(1920+239)=32385 samples */
                IF( ( hTcBuffer->tc_buffer_fx = (Word32 *) malloc( nsamp_to_allocate * sizeof( Word32 ) ) ) == NULL )
                {
                    return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) );
                }
                set32_fx( hTcBuffer->tc_buffer_fx, 0, nsamp_to_allocate );

                offset = 0;
                move16();
                FOR( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ )
                {
                    hTcBuffer->tc_fx[ch_idx] = &hTcBuffer->tc_buffer_fx[offset];
                    offset = L_add( offset, n_samp_full );
                }
                FOR( ; ch_idx < hTcBuffer->nchan_transport_internal; ch_idx++ )
                {
                    hTcBuffer->tc_fx[ch_idx] = &hTcBuffer->tc_buffer_fx[offset];
                    offset = L_add( offset, n_samp_residual );
                }
                FOR( ; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ )
                {
                    hTcBuffer->tc_fx[ch_idx] = NULL;
                }
            }
            ELSE
            {
                hTcBuffer->tc_buffer_fx = NULL;
            }
        }
    }
#endif

    st_ivas->hTcBuffer = hTcBuffer;

@@ -3794,12 +3637,7 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx(
    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
    Word16 nsamp_to_allocate, n_samp_full, n_samp_residual, offset, nchan_residual;
    Word16 ch_idx;
#endif
    DECODER_TC_BUFFER_HANDLE hTcBuffer;

    hTcBuffer = st_ivas->hTcBuffer;
@@ -3857,13 +3695,9 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx(
    move16();
    hTcBuffer->nchan_buffer_full = nchan_full;
    move16();
#ifndef JBM_MEMORY_OPT
    nchan_residual = sub( nchan_transport_internal, nchan_full );
#endif
    hTcBuffer->n_samples_granularity = n_samples_granularity;
    move16();

#ifdef JBM_MEMORY_OPT
    /* reallocate TC audio buffers */

    ivas_jbm_dec_tc_audio_deallocate_fx( hTcBuffer );
@@ -3872,70 +3706,6 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx(
    {
        return error;
    }
#else
    /* realloc buffers */
    IF( hTcBuffer->tc_buffer_fx != NULL )
    {
        free( hTcBuffer->tc_buffer_fx );
        hTcBuffer->tc_buffer_fx = NULL;
    }

    IF( st_ivas->hDecoderConfig->Opt_tsm )
    {
        n_samp_full = ( add( NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ), sub( hTcBuffer->n_samples_granularity, 1 ) ) );
        n_samp_residual = sub( hTcBuffer->n_samples_granularity, 1 );
    }
    ELSE
    {
        n_samp_full = extract_l( Mult_32_16( st_ivas->hDecoderConfig->output_Fs, INV_FRAME_PER_SEC_Q15 ) );
        n_samp_residual = 0;
        move16();
    }

    nsamp_to_allocate = imult1616( hTcBuffer->nchan_buffer_full, n_samp_full );
    nsamp_to_allocate = add( nsamp_to_allocate, imult1616( nchan_residual, n_samp_residual ) );

    IF( nsamp_to_allocate == 0 )
    {
        hTcBuffer->tc_buffer_fx = NULL;
        FOR( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ )
        {
            hTcBuffer->tc_fx[ch_idx] = NULL;
        }
    }
    ELSE
    {
        IF( st_ivas->hDecoderConfig->Opt_tsm )
        {
            IF( ( hTcBuffer->tc_buffer_fx = (Word32 *) malloc( nsamp_to_allocate * sizeof( Word32 ) ) ) == NULL )
            {
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory FOR JBM TC Buffer\n" ) );
            }
            set32_fx( hTcBuffer->tc_buffer_fx, 0, nsamp_to_allocate );

            offset = 0;
            move16();
            FOR( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ )
            {
                hTcBuffer->tc_fx[ch_idx] = &hTcBuffer->tc_buffer_fx[offset];
                offset = add( offset, n_samp_full );
            }
            FOR( ; ch_idx < hTcBuffer->nchan_transport_internal; ch_idx++ )
            {
                hTcBuffer->tc_fx[ch_idx] = &hTcBuffer->tc_buffer_fx[offset];
                offset = add( offset, n_samp_residual );
            }
            FOR( ; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ )
            {
                hTcBuffer->tc_fx[ch_idx] = NULL;
            }
        }
        ELSE
        {
            hTcBuffer->tc_buffer_fx = NULL;
        }
    }
#endif

#ifdef NONBE_1324_TC_BUFFER_MEMOERY_KEEP
    /* propagate samples of the TC buffer from the previous frame */
@@ -4016,26 +3786,9 @@ void ivas_jbm_dec_tc_buffer_close_fx(
    DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */
)
{
#ifndef JBM_MEMORY_OPT
    Word16 i;
#endif
    IF( *phTcBuffer != NULL )
    {
#ifdef JBM_MEMORY_OPT
        ivas_jbm_dec_tc_audio_deallocate_fx( *phTcBuffer );
#else

        FOR( i = 0; i < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; i++ )
        {
            ( *phTcBuffer )->tc_fx[i] = NULL;
        }

        IF( ( *phTcBuffer )->tc_buffer_fx != NULL )
        {
            free( ( *phTcBuffer )->tc_buffer_fx );
            ( *phTcBuffer )->tc_buffer_fx = NULL;
        }
#endif

        free( *phTcBuffer );
        *phTcBuffer = NULL;
Loading