Commit 2bda0a75 authored by PLAINSI's avatar PLAINSI
Browse files

Align delay for MONO and STEREO renders

parent d7c931c5
Loading
Loading
Loading
Loading
Loading
+93 −73
Original line number Diff line number Diff line
@@ -153,7 +153,7 @@ void ivas_mc_paramupmix_dec_read_BS(
 *------------------------------------------------------------------------*/
void ivas_mc_paramupmix_dec(
    Decoder_Struct *st_ivas,     /* i/o: IVAS decoder handle                                     */
    float output_f[][L_FRAME48k] /* i/o: synthesized core-coder transport channels/DirAC output  */
    float output_f[][L_FRAME48k] /* i/o: synthesized core-coder transport channels               */
)
{
    MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix;
@@ -170,6 +170,7 @@ void ivas_mc_paramupmix_dec(
    float Pcm_decorr[MC_PARAMUPMIX_COMBINATIONS][L_FRAME48k]; /* decorrelated channels */
    float *pPcm_temp[MC_PARAMUPMIX_COMBINATIONS * 2];         /* decorrelated and undecorrelated*/
    int16_t noparamupmix_delay;
    AUDIO_CONFIG output_config;

    hMCParamUpmix = st_ivas->hMCParamUpmix;
    assert( hMCParamUpmix );
@@ -180,8 +181,27 @@ void ivas_mc_paramupmix_dec(
    nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe;
    set_s( channel_active, 1, nchan_out_transport ); /* change to nchan_out_transport */
    output_Fs = st_ivas->hDecoderConfig->output_Fs;

    output_config = st_ivas->hDecoderConfig->output_config;
    output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC );

    if ( ( output_config == AUDIO_CONFIG_STEREO ) || ( output_config == AUDIO_CONFIG_MONO ) )
    {
        first_empty_channel = 8; /* Don't upmix */
        /* adjust delay of all channels */
        noparamupmix_delay = NS2SA( output_Fs, IVAS_FB_DEC_DELAY_NS );
        for ( ch = 0; ch < MC_PARAMUPMIX_MAX_TRANSPORT_CHANS; ch++ )
        {
            float tmp_buf[L_SUBFRAME5MS_48k];
            mvr2r( &output_f[ch][output_frame - noparamupmix_delay], tmp_buf, noparamupmix_delay );
            mvr2r( output_f[ch], &output_f[ch][noparamupmix_delay], output_frame - noparamupmix_delay );
            mvr2r( hMCParamUpmix->pcm_delay[ch], output_f[ch], noparamupmix_delay );
            mvr2r( tmp_buf, hMCParamUpmix->pcm_delay[ch], noparamupmix_delay );
        }
    }
    else
    {
        first_empty_channel = 12;

        for ( i = 0; i < MC_PARAMUPMIX_COMBINATIONS; i++ )
        {
            pPcm_temp[i] = Pcm_decorr[i]; /* decorrelated */
@@ -268,8 +288,8 @@ void ivas_mc_paramupmix_dec(
            mvr2r( hMCParamUpmix->pcm_delay[ch], output_f[ch], noparamupmix_delay );
            mvr2r( tmp_buf, hMCParamUpmix->pcm_delay[ch], noparamupmix_delay );
        }
    }

    first_empty_channel = 12;
    for ( ch = first_empty_channel; ch < MAX_OUTPUT_CHANNELS; ch++ )
    {
        set_f( output_f[ch], 0.0, L_FRAME48k );
@@ -346,7 +366,7 @@ ivas_error ivas_mc_paramupmix_dec_open(
        ivas_td_decorr_dec_open( &( hMCParamUpmix->hTdDecorr[i] ), output_Fs, 2, 1 );
    }

    for ( i = 0; i < MC_PARAMUPMIX_COMBINATIONS; i++ )
    for ( i = 0; i < MC_PARAMUPMIX_MAX_TRANSPORT_CHANS; i++ )
    {
        if ( ( hMCParamUpmix->pcm_delay[i] = (float *) malloc( 240 * sizeof( float ) ) ) == NULL )
        {
@@ -380,7 +400,7 @@ void ivas_mc_paramupmix_dec_close(
    {
        ivas_td_decorr_dec_close( &( ( *hMCParamUpmix )->hTdDecorr[i] ) );
    }
    for ( i = 0; i < MC_PARAMUPMIX_COMBINATIONS; i++ )
    for ( i = 0; i < MC_PARAMUPMIX_MAX_TRANSPORT_CHANS; i++ )
    {
        if ( ( *hMCParamUpmix )->pcm_delay[i] != NULL )
        {
+1 −1
Original line number Diff line number Diff line
@@ -790,7 +790,7 @@ typedef struct ivas_mc_paramupmix_dec_data_structure
    int32_t alpha_quant[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS];
    int32_t beta_quant[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS];
    bool first_frame;
    float *pcm_delay[4];
    float *pcm_delay[MC_PARAMUPMIX_MAX_TRANSPORT_CHANS];

} MC_PARAMUPMIX_DEC_DATA, *MC_PARAMUPMIX_DEC_HANDLE;
#endif