From 7cd32ec29e9641362f4a14e4e1284040f9af9930 Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Thu, 20 Oct 2016 11:11:56 -0700 Subject: audio: force pts_reset only when pts jumps forward more than 5s i've seen several mpegts samples where pts jumps backwards and repeats itself. this usually happens on live tv streams from cable providers, particularly when the stream switches from one advertisement to another. --- player/audio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'player') diff --git a/player/audio.c b/player/audio.c index 3f173f140d..5c393f3d3a 100644 --- a/player/audio.c +++ b/player/audio.c @@ -840,8 +840,8 @@ static int filter_audio(struct MPContext *mpctx, struct mp_audio_buffer *outbuf, // Attempt to detect jumps in PTS. Even for the lowest sample rates // and with worst container rounded timestamp, this should be a // margin more than enough. - double desync = fabs(mpa->pts - ao_c->pts); - if (ao_c->pts != MP_NOPTS_VALUE && desync > 0.1) { + double desync = mpa->pts - ao_c->pts; + if (ao_c->pts != MP_NOPTS_VALUE && fabs(desync) > 0.1) { MP_WARN(ao_c, "Invalid audio PTS: %f -> %f\n", ao_c->pts, mpa->pts); if (desync >= 5) -- cgit v1.2.3