mirror of
https://github.com/mpv-player/mpv
synced 2025-03-01 20:00:37 +00:00
audio: interpolate audio timestamps
Deal with jittering Matroska crap timestamps. This reuses the mechanism that is needed for frames without PTS, and adds a heuristic to it. If the interpolated timestamp is less than 1ms away from the real one, it might be due to Matroska timestamp rounding (or other file formats with such rounding, or files remuxed from Matroska). While there actually isn't much of a need to do this (audio PTS jittering by such a low amount doesn't negatively influence much), it helps with identifying jitter from other sources.
This commit is contained in:
parent
d91434756b
commit
0ff3ffb2be
@ -172,8 +172,18 @@ static int decode_new_frame(struct dec_audio *da)
|
||||
|
||||
if (da->waiting) {
|
||||
if (da->waiting->pts != MP_NOPTS_VALUE) {
|
||||
da->pts = da->waiting->pts;
|
||||
da->pts_offset = 0;
|
||||
if (da->pts != MP_NOPTS_VALUE) {
|
||||
da->pts += da->pts_offset / (double)da->waiting->rate;
|
||||
da->pts_offset = 0;
|
||||
}
|
||||
// Keep the interpolated timestamp if it doesn't deviate more
|
||||
// than 1 ms from the real one. (MKV rounded timestamps.)
|
||||
if (da->pts == MP_NOPTS_VALUE || da->pts_offset != 0 ||
|
||||
fabs(da->pts - da->waiting->pts) > 0.001)
|
||||
{
|
||||
da->pts = da->waiting->pts;
|
||||
da->pts_offset = 0;
|
||||
}
|
||||
}
|
||||
da->pts_offset += da->waiting->samples;
|
||||
da->decode_format = *da->waiting;
|
||||
|
Loading…
Reference in New Issue
Block a user