Commit 6f1eff3b authored by vaclav's avatar vaclav
Browse files

ivas_dec_feed_tc_to_renderer() changes for ParamMC

parent b3143cdb
Loading
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1102,6 +1102,7 @@ void ivas_param_ism_dec_prepare_renderer(
    const uint16_t nCldfbSlots                                  /* i  : number of CLDFB slots in transport channels */
);

#ifndef UNIFIED_DECODING_PATHS_LEFTOVERS
void ivas_ism_param_dec_tc_gain_ajust(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder handle                         */
    const uint16_t nSamples,                                    /* i  : number of samples to be compensate          */
@@ -1109,6 +1110,7 @@ void ivas_ism_param_dec_tc_gain_ajust(
    float *transport_channels_f[]                               /* i  : synthesized core-coder transport channels/DirAC output  */
);

#endif
void ivas_param_ism_dec_render(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder handle                         */
    const uint16_t nSamplesAsked,                               /* i  : number of CLDFB slots requested             */
+84 −35
Original line number Diff line number Diff line
@@ -45,6 +45,15 @@
#include "wmc_auto.h"


#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS
/*-----------------------------------------------------------------------*
 * Local function declarations
 *-----------------------------------------------------------------------*/

static void ivas_ism_param_dec_tc_gain_adjust( Decoder_Struct *st_ivas, const int16_t nSamples, const int16_t nFadeLength, float *transport_channels_f[] );

#endif

/*-----------------------------------------------------------------------*
 * Local function definitions
 *-----------------------------------------------------------------------*/
@@ -799,6 +808,37 @@ void ivas_param_ism_dec_digest_tc(
    const uint16_t nCldfbSlots,   /* i  : number of CLDFB slots in transport channels               */
    float *transport_channels_f[] /* i/o: synthesized core-coder transport channels/DirAC output    */
)
{
#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS
    int16_t ch, nchan_transport, num_freq_bands, slot_idx, cldfb_ch, n_ch_cldfb;
    int16_t output_frame;
    float *cldfb_real_buffer;
    float *cldfb_imag_buffer;

    /* Initialization */
    num_freq_bands = st_ivas->hSpatParamRendCom->num_freq_bands;
    output_frame = nCldfbSlots * num_freq_bands;
    nchan_transport = st_ivas->nchan_transport;
    n_ch_cldfb = st_ivas->hTcBuffer->nchan_transport_rend - st_ivas->hTcBuffer->nchan_buffer_full;

    cldfb_real_buffer = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc;
    cldfb_imag_buffer = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc;

    /* Adjust TCs energy */
    ivas_ism_param_dec_tc_gain_adjust( st_ivas, output_frame, output_frame / 2, transport_channels_f );

    /* CLDFB Analysis */
    for ( ch = 0, cldfb_ch = 0; cldfb_ch < n_ch_cldfb; cldfb_ch++, ch++ )
    {
        for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ )
        {
            cldfbAnalysis_ts( &( transport_channels_f[ch][num_freq_bands * slot_idx] ),
                              &cldfb_real_buffer[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands],
                              &cldfb_imag_buffer[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands],
                              num_freq_bands, st_ivas->cldfbAnaDec[cldfb_ch] );
        }
    }
#else
    {
        int16_t ch, nchan_transport;
        int16_t slot_idx;
@@ -844,6 +884,7 @@ void ivas_param_ism_dec_digest_tc(


        pop_wmops();
#endif

    return;
}
@@ -1004,18 +1045,26 @@ void ivas_param_ism_dec_prepare_renderer(


/*-------------------------------------------------------------------------*
 * ivas_ism_param_dec_tc_gain_ajust()
 *
 * ivas_ism_param_dec_tc_gain_adjust()
 *
 * Adjust TCs energy
 *-------------------------------------------------------------------------*/

#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS
static void ivas_ism_param_dec_tc_gain_adjust(
    Decoder_Struct *st_ivas,      /* i/o: IVAS decoder handle                                   */
    const int16_t nSamples,       /* i  : number of samples to be compensate                    */
    const int16_t nFadeLength,    /* i  : length of the crossfade in samples                    */
    float *transport_channels_f[] /* i  : synthesized core-coder transport channels/DirAC output*/
)
#else
    void ivas_ism_param_dec_tc_gain_ajust(
        Decoder_Struct * st_ivas,     /* i/o: IVAS decoder handle                                   */
        const uint16_t nSamples,      /* i  : number of samples to be compensate                    */
        const uint16_t nFadeLength,   /* i  : length of the crossfade in samples                    */
        float *transport_channels_f[] /* i  : synthesized core-coder transport channels/DirAC output*/
    )

#endif
{
    int16_t i;
    float gain, ene_tc, ene_sum, grad;
+7 −57
Original line number Diff line number Diff line
@@ -794,41 +794,12 @@ void ivas_dec_feed_tc_to_renderer(
    float data_f[MAX_CLDFB_DIGEST_CHANNELS][MAX_JBM_L_FRAME48k]; /* 'float' buffer for transport channels that will be directly converted with the CLDFB */
    float *p_data_f[MAX_CLDFB_DIGEST_CHANNELS];
    int16_t n, n_render_timeslots, n_ch_cldfb;
    int16_t ch, output_frame;
    int16_t ch;
    DECODER_TC_BUFFER_HANDLE hTcBuffer;
    float *cldfb_real_buffer;
    float *cldfb_imag_buffer;
    int16_t cldfb_ch, slot_idx, num_freq_bands;

    hTcBuffer = st_ivas->hTcBuffer;
    n_ch_cldfb = hTcBuffer->nchan_transport_rend - hTcBuffer->nchan_buffer_full;

    cldfb_real_buffer = NULL;
    cldfb_imag_buffer = NULL;
    num_freq_bands = 0;

    if ( n_ch_cldfb > 0 )
    {
        if ( st_ivas->ivas_format == ISM_FORMAT )
        {
            cldfb_real_buffer = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc;
            cldfb_imag_buffer = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc;
            num_freq_bands = st_ivas->hSpatParamRendCom->num_freq_bands;
        }
        else if ( st_ivas->ivas_format == MC_FORMAT )
        {
            cldfb_real_buffer = st_ivas->hParamMC->Cldfb_RealBuffer_tc;
            cldfb_imag_buffer = st_ivas->hParamMC->Cldfb_ImagBuffer_tc;
            num_freq_bands = st_ivas->hParamMC->num_freq_bands;
        }
#ifdef DEBUGGING
        else
        {
            assert( 0 && "Residual (direct CLDFB transport channels) only possible for ParamMC/ParamISM!" );
        }
#endif
    }

    if ( st_ivas->hDecoderConfig->Opt_tsm )
    {
        int16_t n_samples_still_available, m;
@@ -872,7 +843,6 @@ void ivas_dec_feed_tc_to_renderer(
        }

        n_render_timeslots = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity;
        output_frame = n_render_timeslots * num_freq_bands;
    }
    else
    {
@@ -885,38 +855,18 @@ void ivas_dec_feed_tc_to_renderer(
        hTcBuffer->n_samples_available = hTcBuffer->n_samples_buffered;
        *nSamplesResidual = 0;

        output_frame = nSamplesForRendering;
        n_render_timeslots = DEFAULT_JBM_CLDFB_TIMESLOTS;
    }

    /* CLDFB analysis for ParamMC/ParamISM */
    if ( n_ch_cldfb > 0 )
    {
        // if ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM && ( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) )
        if ( st_ivas->ivas_format == ISM_FORMAT )
        {
            ivas_ism_param_dec_tc_gain_ajust( st_ivas, output_frame, output_frame / 2, p_data_f );

            for ( ch = 0, cldfb_ch = 0; cldfb_ch < n_ch_cldfb; cldfb_ch++, ch++ )
            {
                /* CLDFB Analysis */
                for ( slot_idx = 0; slot_idx < n_render_timeslots; slot_idx++ )
    if ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM && ( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) )
    {
                    cldfbAnalysis_ts( &( p_data_f[ch][num_freq_bands * slot_idx] ),
                                      &cldfb_real_buffer[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands],
                                      &cldfb_imag_buffer[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands],
                                      num_freq_bands, st_ivas->cldfbAnaDec[cldfb_ch] );
                }
            }
        ivas_param_ism_dec_digest_tc( st_ivas, n_render_timeslots, p_data_f );
    }
        else if ( st_ivas->ivas_format == MC_FORMAT )
        {
            if ( st_ivas->mc_mode == MC_MODE_PARAMMC && st_ivas->hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_RENDERER )
    else if ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_PARAMMC && st_ivas->hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_RENDERER )
    {
        ivas_param_mc_dec_digest_tc( st_ivas, (uint8_t) n_render_timeslots, p_data_f );
    }
        }
    }

    hTcBuffer->n_samples_rendered = 0;
    hTcBuffer->subframes_rendered = 0;
+34 −0
Original line number Diff line number Diff line
@@ -1320,6 +1320,39 @@ void ivas_param_mc_dec_read_BS(
 *
 *------------------------------------------------------------------------*/

#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS
void ivas_param_mc_dec_digest_tc(
    Decoder_Struct *st_ivas,      /* i/o: IVAS decoder handle                                       */
    const uint8_t nCldfbSlots,    /* i  : number of CLDFB slots in transport channels               */
    float *transport_channels_f[] /* i/o: synthesized core-coder transport channels/DirAC output    */
)
{
    int16_t ch, nchan_transport, num_freq_bands, slot_idx, cldfb_ch, n_ch_cldfb;
    float *cldfb_real_buffer;
    float *cldfb_imag_buffer;

    num_freq_bands = st_ivas->hParamMC->num_freq_bands;
    nchan_transport = st_ivas->nchan_transport;
    n_ch_cldfb = st_ivas->hTcBuffer->nchan_transport_rend - st_ivas->hTcBuffer->nchan_buffer_full;

    cldfb_real_buffer = st_ivas->hParamMC->Cldfb_RealBuffer_tc;
    cldfb_imag_buffer = st_ivas->hParamMC->Cldfb_ImagBuffer_tc;

    /* CLDFB Analysis */
    for ( ch = 0, cldfb_ch = 0; cldfb_ch < n_ch_cldfb; cldfb_ch++, ch++ )
    {
        for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ )
        {
            cldfbAnalysis_ts( &( transport_channels_f[ch][num_freq_bands * slot_idx] ),
                              &cldfb_real_buffer[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands],
                              &cldfb_imag_buffer[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands],
                              num_freq_bands, st_ivas->cldfbAnaDec[cldfb_ch] );
        }
    }

    return;
}
#else
void ivas_param_mc_dec_digest_tc(
    Decoder_Struct *st_ivas,      /* i/o: IVAS decoder handle                                       */
    const uint8_t nCldfbSlots,    /* i  : number of CLDFB slots in transport channels               */
@@ -1360,6 +1393,7 @@ void ivas_param_mc_dec_digest_tc(

    return;
}
#endif


/*-------------------------------------------------------------------------
+13 −3
Original line number Diff line number Diff line
@@ -450,12 +450,12 @@ void ivas_mc_paramupmix_dec_close(


/*-------------------------------------------------------------------------
 * paramupmix_td_decorr_process_jbm()
 * paramupmix_td_decorr_process()
 *
 *
 *------------------------------------------------------------------------*/

static void paramupmix_td_decorr_process_jbm(
static void paramupmix_td_decorr_process(
    ivas_td_decorr_state_t *hTdDecorr[], /* i/o: SPAR Covar. decoder handle   */
    float *pcm_in[],                     /* i  : input audio channels         */
    float **pp_out_pcm,                  /* o  : output audio channels        */
@@ -528,6 +528,16 @@ static void ivas_param_upmix_dec_decorr_subframes(
    nSamplesLeftForTD = nSamplesForRendering;
    nchan_internal = MC_PARAMUPMIX_COMBINATIONS;

#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS
    if ( !st_ivas->hDecoderConfig->Opt_tsm )
    {
        for ( ch = 0; ch < ivas_get_nchan_buffers_dec( st_ivas, -1, st_ivas->hDecoderConfig->ivas_total_brate ); ch++ )
        {
            st_ivas->hTcBuffer->tc[ch] = st_ivas->p_output_f[ch];
        }
    }

#endif
    for ( ch = 0; ch < nchan_internal; ch++ )
    {
        pPcm_tmp[ch] = st_ivas->hTcBuffer->tc[ch + 8];
@@ -538,7 +548,7 @@ static void ivas_param_upmix_dec_decorr_subframes(
    {
        int16_t nSamplesToDecorr = min( nSamplesLeftForTD, default_frame );

        paramupmix_td_decorr_process_jbm( hMCParamUpmix->hTdDecorr, p_tc, pPcm_tmp, nSamplesToDecorr );
        paramupmix_td_decorr_process( hMCParamUpmix->hTdDecorr, p_tc, pPcm_tmp, nSamplesToDecorr );

        for ( ch = 0; ch < nchan_internal; ch++ )
        {