From d52b2981c0cdc88c6679262f26dd097c2eb4df83 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 22 Feb 2016 19:50:09 +0100 Subject: ad_lavc: move skipping logic out of the HAVE_AVFRAME_SKIP_SAMPLES block --- audio/decode/ad_lavc.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'audio') diff --git a/audio/decode/ad_lavc.c b/audio/decode/ad_lavc.c index 5cd335b44c..96625cae2f 100644 --- a/audio/decode/ad_lavc.c +++ b/audio/decode/ad_lavc.c @@ -231,25 +231,28 @@ static int decode_packet(struct dec_audio *da, struct demux_packet *mpkt, if (mpframe->pts != MP_NOPTS_VALUE) priv->next_pts = mpframe->pts + mpframe->samples / (double)mpframe->rate; + uint32_t pad = 0; + #if HAVE_AVFRAME_SKIP_SAMPLES AVFrameSideData *sd = av_frame_get_side_data(priv->avframe, AV_FRAME_DATA_SKIP_SAMPLES); if (sd && sd->size >= 10) { char *d = sd->data; priv->skip_samples += AV_RL32(d + 0); - uint32_t pad = AV_RL32(d + 4); - uint32_t skip = MPMIN(priv->skip_samples, mpframe->samples); - if (skip) { - mp_audio_skip_samples(mpframe, skip); - if (mpframe->pts != MP_NOPTS_VALUE) - mpframe->pts += skip / (double)mpframe->rate; - priv->skip_samples -= skip; - } - if (pad <= mpframe->samples) - mpframe->samples -= pad; + pad = AV_RL32(d + 4); } #endif + uint32_t skip = MPMIN(priv->skip_samples, mpframe->samples); + if (skip) { + mp_audio_skip_samples(mpframe, skip); + if (mpframe->pts != MP_NOPTS_VALUE) + mpframe->pts += skip / (double)mpframe->rate; + priv->skip_samples -= skip; + } + if (pad <= mpframe->samples) + mpframe->samples -= pad; + *out = mpframe; av_frame_unref(priv->avframe); -- cgit v1.2.3