From 3d03298e86866ce86b4a489d78c7564a275f6a3c Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 5 Jan 2016 22:08:51 +0100 Subject: audio: update outdated comment --- player/audio.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'player/audio.c') diff --git a/player/audio.c b/player/audio.c index 96345366fd..37d194833c 100644 --- a/player/audio.c +++ b/player/audio.c @@ -361,9 +361,10 @@ double written_audio_pts(struct MPContext *mpctx) if (a_pts == MP_NOPTS_VALUE) return MP_NOPTS_VALUE; - // d_audio->pts is the timestamp of the latest input packet with - // known pts that the decoder has decoded. d_audio->pts_bytes is - // the amount of bytes the decoder has written after that timestamp. + // d_audio->pts is the timestamp of the first sample of the latest frame + // the with a known pts that the decoder has returned. d_audio->pts_offset + // is the amount of samples the decoder has returned after that timestamp + // (includes the frame size). a_pts += d_audio->pts_offset / (double)in_format.rate; // Now a_pts hopefully holds the pts for end of audio from decoder. -- cgit v1.2.3 From bd5a02d080076b6de6cc4696795a24a5326c6d4f Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 9 Jan 2016 20:27:03 +0100 Subject: player: detect audio PTS jumps, make video PTS heuristic less aggressive This is another attempt at making files with sparse video frames work better. The problem is that you generally can't know whether a jump in video timestamps is just a (very) long video frame, or a timestamp reset. Due to the existence of files with sparse video frames (new frame only every few seconds or longer), every heuristic will be arbitrary (in general, at least). But we can use the fact that if video is continuous, audio should also be continuous. Audio discontinuities can be easily detected, and if that happens, reset some of the playback state. The way the playback state is reset is rather radical (resets decoders as well), but it's just better not to cause too much obscure stuff to happen here. If the A/V sync code were to be rewritten, it should probably strictly use PTS values (not this strange time_frame/delay stuff), which would make it much easier to detect such situations and to react to them. --- player/audio.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'player/audio.c') diff --git a/player/audio.c b/player/audio.c index 37d194833c..cc166ae0d3 100644 --- a/player/audio.c +++ b/player/audio.c @@ -487,11 +487,12 @@ static bool get_sync_samples(struct MPContext *mpctx, int *skip) double ptsdiff = written_pts - sync_pts; // Missing timestamp, or PTS reset, or just broken. - if (written_pts == MP_NOPTS_VALUE || fabs(ptsdiff) > 3600) { + if (written_pts == MP_NOPTS_VALUE) { MP_WARN(mpctx, "Failed audio resync.\n"); mpctx->audio_status = STATUS_FILLING; return true; } + ptsdiff = MPCLAMP(ptsdiff, -3600, 3600); int align = af_format_sample_alignment(out_format.format); *skip = (int)(-ptsdiff * play_samplerate) / align * align; @@ -544,6 +545,13 @@ void fill_audio_out_buffers(struct MPContext *mpctx, double endpts) return; // try again next iteration } + if (mpctx->d_video && d_audio->pts_reset) { + MP_VERBOSE(mpctx, "Reset playback due to audio timestamp reset.\n"); + reset_playback_state(mpctx); + mpctx->sleeptime = 0; + return; + } + struct mp_audio out_format = {0}; ao_get_format(mpctx->ao, &out_format); double play_samplerate = out_format.rate / mpctx->audio_speed; -- cgit v1.2.3 From ea442fa047819ec2e48a3dbe8ea21959ac3d70b0 Mon Sep 17 00:00:00 2001 From: "Dmitrij D. Czarkoff" Date: Mon, 11 Jan 2016 19:03:40 +0100 Subject: mpv_talloc.h: rename from talloc.h This change helps avoiding conflict with talloc.h from libtalloc. --- player/audio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'player/audio.c') diff --git a/player/audio.c b/player/audio.c index cc166ae0d3..8cbdb5aefa 100644 --- a/player/audio.c +++ b/player/audio.c @@ -23,7 +23,7 @@ #include #include "config.h" -#include "talloc.h" +#include "mpv_talloc.h" #include "common/msg.h" #include "common/encode.h" -- cgit v1.2.3 From 671df54e4dcf0675c335483d26f7f6ff9baaf76a Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 12 Jan 2016 23:48:19 +0100 Subject: demux: merge sh_video/sh_audio/sh_sub This is mainly a refactor. I'm hoping it will make some things easier in the future due to cleanly separating codec metadata and stream metadata. Also, declare that the "codec" field can not be NULL anymore. demux.c will set it to "" if it's NULL when added. This gets rid of a corner case everything had to handle, but which rarely happened. --- player/audio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'player/audio.c') diff --git a/player/audio.c b/player/audio.c index 8cbdb5aefa..0655dda51e 100644 --- a/player/audio.c +++ b/player/audio.c @@ -218,7 +218,7 @@ void reinit_audio_chain(struct MPContext *mpctx) mpctx->d_audio->header = sh; mpctx->d_audio->pool = mp_audio_pool_create(mpctx->d_audio); mpctx->d_audio->afilter = af_new(mpctx->global); - mpctx->d_audio->afilter->replaygain_data = sh->audio->replaygain_data; + mpctx->d_audio->afilter->replaygain_data = sh->codec->replaygain_data; mpctx->d_audio->spdif_passthrough = true; mpctx->ao_buffer = mp_audio_buffer_create(NULL); if (!audio_init_best_codec(mpctx->d_audio)) -- cgit v1.2.3 From 4195a345a51e52337bc972aacbce0fd6e88ebb5d Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 17 Jan 2016 18:07:50 +0100 Subject: player: refactor: eliminate MPContext.d_video Eventually we want the VO be driven by a A->V filter, so a decoder doesn't even have to exist. Some features definitely require a decoder though (like reporting the decoder in use, hardware decoding, etc.), so for each thing which accessed d_video, it has to be redecided if and how it can access decoder state. At least the "framedrop" property slightly changes semantics: you can now always set this property, even if no video is active. Some untested changes in this commit, but our bio-based distributed test suite has to take care of this. --- player/audio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'player/audio.c') diff --git a/player/audio.c b/player/audio.c index 0655dda51e..a7a5f727c7 100644 --- a/player/audio.c +++ b/player/audio.c @@ -468,7 +468,7 @@ static bool get_sync_samples(struct MPContext *mpctx, int *skip) if (written_pts == MP_NOPTS_VALUE && !mp_audio_buffer_samples(mpctx->ao_buffer)) return false; // no audio read yet - bool sync_to_video = mpctx->d_video && mpctx->sync_audio_to_video && + bool sync_to_video = mpctx->vo_chain && mpctx->sync_audio_to_video && mpctx->video_status != STATUS_EOF; double sync_pts = MP_NOPTS_VALUE; @@ -545,7 +545,7 @@ void fill_audio_out_buffers(struct MPContext *mpctx, double endpts) return; // try again next iteration } - if (mpctx->d_video && d_audio->pts_reset) { + if (mpctx->vo_chain && d_audio->pts_reset) { MP_VERBOSE(mpctx, "Reset playback due to audio timestamp reset.\n"); reset_playback_state(mpctx); mpctx->sleeptime = 0; -- cgit v1.2.3