Commit 8740438c authored by vaclav's avatar vaclav
Browse files

Merge branch '1330-jbm-audio-channels-memory-reduction' into 'main'

Memory reduction for audio channels in JBM decoder

See merge request !2186
parents e36cb3c3 b40d46c2
Loading
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -308,8 +308,14 @@ ivas_error ivas_init_decoder(

ivas_error ivas_output_buff_dec(
    float *p_output_f[],                                        /* i/o: output audio buffers                    */
#ifdef FIX_1330_JBM_MEMORY
    const int16_t nchan_out_buff,                               /* i  : number of output channels               */
    const int16_t Opt_tsm,                                      /* i  : TSM option flag                         */
    DECODER_TC_BUFFER_HANDLE hTcBuffer                          /* i  : TSM buffer handle                       */
#else
    const int16_t nchan_out_buff_old,                           /* i  : previous frame number of output channels*/
    const int16_t nchan_out_buff                                /* i  : number of output channels               */
#endif
);

ivas_error stereo_dmx_evs_init_encoder(
@@ -5823,8 +5829,12 @@ void ivas_omasa_separate_object_render_jbm(
    const uint16_t nSamplesRendered,                            /* i  : number of samples rendered              */
    float input_f[][L_FRAME48k],                                /* i  : separated object signal                 */
    float *output_f[],                                          /* o  : rendered time signal                    */
#ifdef FIX_1330_JBM_MEMORY
    const int16_t subframes_rendered                            /* i  : number of subframes rendered            */
#else
    const int16_t subframes_rendered,                           /* i  : number of subframes rendered            */
    const int16_t slots_rendered                                /* i  : number of CLDFB slots rendered          */
#endif
);

void ivas_omasa_encode_masa_to_total(
+12 −0
Original line number Diff line number Diff line
@@ -198,12 +198,24 @@ void ivas_buffer_deinterleaved_to_interleaved(
)
{
    int16_t ch, m;
#ifdef FIX_1330_JBM_MEMORY
    float buffer[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k]; /* temp buffer needed when "*audio[]" and "*audio_out[]" are the same */

    for ( ch = 0; ch < n_channels; ch++ )
    {
        mvr2r( audio[ch], buffer[ch], frame_length );
    }
#endif

    for ( ch = 0; ch < n_channels; ch++ )
    {
        for ( m = 0; m < frame_length; m++ )
        {
#ifdef FIX_1330_JBM_MEMORY
            audio_out[m * n_channels + ch] = buffer[ch][m];
#else
            audio_out[m * n_channels + ch] = audio[ch][m];
#endif
        }
    }

+1 −0
Original line number Diff line number Diff line
@@ -166,6 +166,7 @@
#define FIX_1348_OVERFLOW                               /* FhG: fix BASOP overflow in hq_lr_dec(), brings floating-point code inline with FX */
#define FIX_1369_HQ_LR_OVERFLOW                         /* FhG: fix BASOP overflow in hq_lr_enc(), brings floating-point code inline with FX */
#define FIX_1376_MISSING_ISM_METADATA                   /* FhG: IVAS_rend: throw error if there exists an ISM input without a corresponding metadata file path */
#define FIX_1330_JBM_MEMORY                             /* VA: issue 1330: memory savings in the JBM decoder */

/* #################### End BE switches ################################## */

+21 −5
Original line number Diff line number Diff line
@@ -1252,6 +1252,9 @@ ivas_error ivas_init_decoder(
    int16_t sce_id, cpe_id;
    int16_t numCldfbAnalyses, numCldfbSyntheses;
    int16_t granularity, n_channels_transport_jbm;
#ifdef FIX_1330_JBM_MEMORY
    int16_t nchan_out_buff;
#endif
    int32_t output_Fs, ivas_total_brate;
    int32_t delay_ns;
    AUDIO_CONFIG output_config;
@@ -2371,7 +2374,7 @@ ivas_error ivas_init_decoder(
        }
    }

    if ( ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && st_ivas->hDecoderConfig->Opt_tsm )
    if ( ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && hDecoderConfig->Opt_tsm )
    {
        if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL )
        {
@@ -2386,7 +2389,14 @@ ivas_error ivas_init_decoder(
     * Allocate floating-point output audio buffers
     *-----------------------------------------------------------------*/

    k = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate );
#ifdef FIX_1330_JBM_MEMORY
    nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, ivas_total_brate );
    if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff, hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK )
    {
        return error;
    }
#else
    k = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, ivas_total_brate );
    for ( n = 0; n < k; n++ )
    {
        /* note: these are intra-frame heap memories */
@@ -2400,9 +2410,9 @@ ivas_error ivas_init_decoder(
    {
        st_ivas->p_output_f[n] = NULL;
    }
#endif


    return error;
    return IVAS_ERR_OK;
}


@@ -2857,12 +2867,14 @@ void ivas_destroy_dec(
    /* Limiter struct */
    ivas_limiter_close( &( st_ivas->hLimiter ) );

    /* Decoder configuration structure */
    if ( st_ivas->hDecoderConfig != NULL )
    {
        free( st_ivas->hDecoderConfig );
        st_ivas->hDecoderConfig = NULL;
    }

    /* JBM TC buffer structure */
    ivas_jbm_dec_tc_buffer_close( &st_ivas->hTcBuffer );

    if ( st_ivas->hJbmMetadata != NULL )
@@ -2874,11 +2886,15 @@ void ivas_destroy_dec(
    /* floating-point output audio buffers */
    for ( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ )
    {
#ifdef FIX_1330_JBM_MEMORY
        st_ivas->p_output_f[i] = NULL;
#else
        if ( st_ivas->p_output_f[i] != NULL )
        {
            free( st_ivas->p_output_f[i] );
            st_ivas->p_output_f[i] = NULL;
        }
#endif
    }

    /* main IVAS handle */
+20 −2
Original line number Diff line number Diff line
@@ -60,7 +60,11 @@ static ivas_error ivas_ism_bitrate_switching_dec(
    int16_t tc_nchan_tc_new;
    int16_t tc_nchan_allocate_new;
    int16_t tc_granularity_new;
#ifdef FIX_1330_JBM_MEMORY
    int16_t nchan_out_buff;
#else
    int16_t nchan_out_buff, nchan_out_buff_old;
#endif

    nCPE_old = st_ivas->nCPE;
    nSCE_old = st_ivas->nSCE;
@@ -70,7 +74,9 @@ static ivas_error ivas_ism_bitrate_switching_dec(
    st_ivas->ism_mode = last_ism_mode;
    ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old );
    st_ivas->ism_mode = ism_mode;
#ifndef FIX_1330_JBM_MEMORY
    nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 );
#endif

    if ( ( error = ivas_ism_config( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->nchan_ism, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, 0 ) ) != IVAS_ERR_OK )
    {
@@ -266,17 +272,17 @@ static ivas_error ivas_ism_bitrate_switching_dec(
        return error;
    }

#ifndef FIX_1330_JBM_MEMORY
    /*-----------------------------------------------------------------*
     * floating-point output audio buffers
     *-----------------------------------------------------------------*/

    nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 );

    if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK )
    {
        return error;
    }

#endif
    /*-----------------------------------------------------------------*
     * JBM TC buffers
     *-----------------------------------------------------------------*/
@@ -316,6 +322,18 @@ static ivas_error ivas_ism_bitrate_switching_dec(

        mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
    }
#ifdef FIX_1330_JBM_MEMORY

    /*-----------------------------------------------------------------*
     * floating-point output audio buffers
     *-----------------------------------------------------------------*/

    nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 );
    if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff, st_ivas->hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK )
    {
        return error;
    }
#endif

    return IVAS_ERR_OK;
}
Loading