Commit cbc671c9 authored by Adam Mills's avatar Adam Mills
Browse files

Fixing the delay compensation

parent 7b75c757
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -5525,7 +5525,7 @@ void ivas_lfe_enc(
ivas_error ivas_create_lfe_dec( 
    LFE_DEC_HANDLE *hLFE_out,                                   /* o  : IVAS LFE decoder structure              */
    const int32_t output_Fs,                                    /* i  : output sampling rate                    */
    const int32_t binauralization_delay_ns                      /* i  : additional LFE delay to sync with binaural renderer */
    const int32_t delay_ns                                      /* i  : additional LFE delay to sync other channel outputs */
);

void ivas_lfe_dec_close( 
+18 −9
Original line number Diff line number Diff line
@@ -1127,7 +1127,7 @@ ivas_error ivas_init_decoder(
    int16_t numCldfbAnalyses, numCldfbSyntheses;
    int16_t granularity, n_channels_transport_jbm;
    int32_t output_Fs, ivas_total_brate;
    int32_t binauralization_delay_ns;
    int32_t delay_ns;
    AUDIO_CONFIG output_config;
    DECODER_CONFIG_HANDLE hDecoderConfig;
    ivas_error error;
@@ -1747,10 +1747,6 @@ ivas_error ivas_init_decoder(
    }
    else if ( st_ivas->ivas_format == MC_FORMAT )
    {
        if ( ( error = ivas_create_lfe_lpf_dec( &st_ivas->hLfeLpf, hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
        {
            return error;
        }

        if ( st_ivas->mc_mode == MC_MODE_MCT )
        {
@@ -1789,6 +1785,11 @@ ivas_error ivas_init_decoder(
        }
        else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX )
        {
            if ( ( error = ivas_create_lfe_lpf_dec( &st_ivas->hLfeLpf, hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
            {
                return error;
            }

            /* init EFAP for custom LS setup */
            if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM )
            {
@@ -2203,7 +2204,7 @@ ivas_error ivas_init_decoder(

    if ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX )
    {
        binauralization_delay_ns = st_ivas->binaural_latency_ns;
        delay_ns = st_ivas->binaural_latency_ns;
        if ( st_ivas->hBinRenderer != NULL )
        {
            if ( st_ivas->hBinRenderer->render_lfe )
@@ -2213,16 +2214,24 @@ ivas_error ivas_init_decoder(
#endif
                {
                    /* Account for filterbank delay */
                    binauralization_delay_ns += IVAS_FB_DEC_DELAY_NS;
                    delay_ns += IVAS_FB_DEC_DELAY_NS;
                }
            }
            else
            {
                binauralization_delay_ns = 0;
                delay_ns = 0;
            }
        }
        else
        {
            delay_ns = IVAS_FB_DEC_DELAY_NS;
            if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX )
            {
                delay_ns += 3500000L; /* 3.5 ms */
            }
        }

        if ( ( error = ivas_create_lfe_dec( &st_ivas->hLFE, output_Fs, binauralization_delay_ns ) ) != IVAS_ERR_OK )
        if ( ( error = ivas_create_lfe_dec( &st_ivas->hLFE, output_Fs, delay_ns ) ) != IVAS_ERR_OK )
        {
            return error;
        }
+3 −3
Original line number Diff line number Diff line
@@ -647,6 +647,9 @@ ivas_error ivas_jbm_dec_tc(
            {
                ivas_ls_setup_conversion( st_ivas, st_ivas->nchan_transport, output_frame, p_output, p_output );
            }

            /* LFE low pass filter */
            ivas_lfe_lpf_dec_apply( st_ivas->hLfeLpf, p_output[LFE_CHANNEL], output_frame );
        }
        else if ( st_ivas->mc_mode == MC_MODE_MCMASA )
        {
@@ -725,9 +728,6 @@ ivas_error ivas_jbm_dec_tc(
                ivas_mono_stereo_downmix_mcmasa( st_ivas, p_output, output_frame );
            }
        }

        /* LFE low pass filter */
        ivas_lfe_lpf_dec_apply( st_ivas->hLfeLpf, p_output[LFE_CHANNEL], output_frame );
    }

    /*----------------------------------------------------------------*
+2 −2
Original line number Diff line number Diff line
@@ -352,7 +352,7 @@ void ivas_lfe_dec(
ivas_error ivas_create_lfe_dec(
    LFE_DEC_HANDLE *hLFE_out,              /* o  : IVAS LFE decoder structure                           */
    const int32_t output_Fs,               /* i  : output sampling rate                                 */
    const int32_t binauralization_delay_ns /* i  : additional LFE delay to sync with binaural renderer  */
    const int32_t delay_ns                 /* i  : additional LFE delay to sync other channel outputs */
)
{
    float low_pass_delay_dec_out, block_offset_s;
@@ -411,7 +411,7 @@ ivas_error ivas_create_lfe_dec(

    lfe_addl_delay_s = block_offset_s - hLFE->lfe_block_delay_s;
    lfe_addl_delay_s = max( 0.0f, lfe_addl_delay_s );
    add_delay_sa = (int16_t) roundf( (float) binauralization_delay_ns * output_Fs / 1000000000.f );
    add_delay_sa = (int16_t) roundf( (float) delay_ns * output_Fs / 1000000000.f );
    hLFE->lfe_addl_delay = (int16_t) ( lfe_addl_delay_s * output_Fs ) + add_delay_sa;
    hLFE->lfe_block_delay_s += lfe_addl_delay_s + add_delay_sa / output_Fs;

+12 −4
Original line number Diff line number Diff line
@@ -1117,21 +1117,29 @@ static ivas_error ivas_mc_dec_reconfig(

    if ( ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) && st_ivas->hLFE == NULL )
    {
        int32_t binauralization_delay_ns = st_ivas->binaural_latency_ns;
        int32_t delay_ns = st_ivas->binaural_latency_ns;
        if ( st_ivas->hBinRenderer != NULL )
        {
            if ( st_ivas->hBinRenderer->render_lfe )
            {
                /* Account for filterbank delay */
                binauralization_delay_ns += IVAS_FB_DEC_DELAY_NS;
                delay_ns += IVAS_FB_DEC_DELAY_NS;
            }
            else
            {
                binauralization_delay_ns = 0;
                delay_ns = 0;
            }
        }
        else
        {
            delay_ns = IVAS_FB_DEC_DELAY_NS;
            if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX )
            {
                delay_ns += 3500000L; /* 3.5 ms */
            }
        }

        if ( ( error = ivas_create_lfe_dec( &st_ivas->hLFE, st_ivas->hDecoderConfig->output_Fs, binauralization_delay_ns ) ) != IVAS_ERR_OK )
        if ( ( error = ivas_create_lfe_dec( &st_ivas->hLFE, st_ivas->hDecoderConfig->output_Fs, delay_ns ) ) != IVAS_ERR_OK )
        {
            return error;
        }