summaryrefslogtreecommitdiffstats
path: root/demux
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-02-09 19:00:06 +0100
committerwm4 <wm4@nowhere>2014-02-09 20:50:24 +0100
commit4dbd5df174f323b2b4cd6048d8df38a6168ba73c (patch)
tree000e688bef2bef3914055614fa40509bdfd10311 /demux
parentad782a53ef38c673c677ca637baf6e875c7c1bd0 (diff)
downloadmpv-4dbd5df174f323b2b4cd6048d8df38a6168ba73c.tar.bz2
mpv-4dbd5df174f323b2b4cd6048d8df38a6168ba73c.tar.xz
demux_mkv: improve audio-only seeking
v_skip_to_keyframe is set to true while non-keyframe video packets are skipped. Until now, audio packets were also skipped when doing this. I can't see any good reason why this would be done, but for now I want to keep the old logic when audio+video seeks are done. However, for audio-only mode, do proper seeking, which also fixes behavior when trying to seek past the end of the file: playback is terminated properly, instead of starting playback on the start of the last cluster. Note that a_no_timecode_check is used only for audio+video seek. I'm not sure what this is needed for, but it might influence A/V sync after seeking.
Diffstat (limited to 'demux')
-rw-r--r--demux/demux_mkv.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/demux/demux_mkv.c b/demux/demux_mkv.c
index dac134e4ec..5b30bc8d35 100644
--- a/demux/demux_mkv.c
+++ b/demux/demux_mkv.c
@@ -190,7 +190,7 @@ typedef struct mkv_demuxer {
int num_headers;
uint64_t skip_to_timecode;
- int v_skip_to_keyframe, a_skip_to_keyframe;
+ int v_skip_to_keyframe, a_skip_to_keyframe, a_no_timecode_check;
int subtitle_preroll;
} mkv_demuxer_t;
@@ -2351,11 +2351,10 @@ static int handle_block(demuxer_t *demuxer, struct block_info *block_info)
current_pts = tc / 1e9;
if (track->type == MATROSKA_TRACK_AUDIO) {
- use_this_block = 1;
+ if (mkv_d->a_no_timecode_check)
+ use_this_block = !mkv_d->v_skip_to_keyframe;
if (mkv_d->a_skip_to_keyframe)
- use_this_block = keyframe;
- if (mkv_d->v_skip_to_keyframe)
- use_this_block = 0;
+ use_this_block &= keyframe;
} else if (track->type == MATROSKA_TRACK_SUBTITLE) {
if (!use_this_block && mkv_d->subtitle_preroll)
use_this_block = 1;
@@ -2739,6 +2738,10 @@ static void demux_mkv_seek(demuxer_t *demuxer, float rel_seek_secs, int flags)
mkv_d->v_skip_to_keyframe = st_active[STREAM_VIDEO];
mkv_d->a_skip_to_keyframe = st_active[STREAM_AUDIO];
+
+ // This is probably not needed, but can't be sure.
+ mkv_d->a_no_timecode_check = st_active[STREAM_VIDEO];
+
if (flags & SEEK_FORWARD) {
mkv_d->skip_to_timecode = target_timecode;
} else {