mirror of
https://github.com/mpv-player/mpv
synced 2025-02-26 18:32:08 +00:00
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.
This commit is contained in:
parent
289edadb8d
commit
9ee340c3af
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user