diff options
author | wm4 <wm4@nowhere> | 2016-02-22 20:10:38 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-02-22 20:10:38 +0100 |
commit | 9ee340c3af5c23c2ac877b6559e11bd70c3052ac (patch) | |
tree | cab36886b3431d7dc25f79d979c5f4c7d5400ac7 /audio | |
parent | 289edadb8d28a3a73bf6930306dd2cb9a6777470 (diff) | |
download | mpv-9ee340c3af5c23c2ac877b6559e11bd70c3052ac.tar.bz2 mpv-9ee340c3af5c23c2ac877b6559e11bd70c3052ac.tar.xz |
ad_lavc: skip AVCodecContext.delay samples at beginning
Fixes correctness_trimming_nobeeps.opus. One nasty thing is that this
mechanism interferes with the container-signalled mechanism with
AV_FRAME_DATA_SKIP_SAMPLES. So apply it only if that is apparently not
present. It's a mess, and it's still broken in FFmpeg CLI, so I'm sure
this will get fucked up later again.
Diffstat (limited to 'audio')
-rw-r--r-- | audio/decode/ad_lavc.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/audio/decode/ad_lavc.c b/audio/decode/ad_lavc.c index 93c297b009..64095b0018 100644 --- a/audio/decode/ad_lavc.c +++ b/audio/decode/ad_lavc.c @@ -43,6 +43,7 @@ struct priv { struct mp_audio frame; bool force_channel_map; uint32_t skip_samples, trim_samples; + bool preroll_done; double next_pts; }; @@ -168,6 +169,7 @@ static int control(struct dec_audio *da, int cmd, void *arg) avcodec_flush_buffers(ctx->avctx); ctx->skip_samples = 0; ctx->trim_samples = 0; + ctx->preroll_done = false; ctx->next_pts = MP_NOPTS_VALUE; return CONTROL_TRUE; } @@ -242,6 +244,13 @@ static int decode_packet(struct dec_audio *da, struct demux_packet *mpkt, } #endif + if (!priv->preroll_done) { + // Skip only if this isn't already handled by AV_FRAME_DATA_SKIP_SAMPLES. + if (!priv->skip_samples) + priv->skip_samples = avctx->delay; + priv->preroll_done = true; + } + uint32_t skip = MPMIN(priv->skip_samples, mpframe->samples); if (skip) { mp_audio_skip_samples(mpframe, skip); |