From 750b7c72fe8f19bdcbda9d02ffbb1816bdef507b Mon Sep 17 00:00:00 2001 From: Ognyan Tonchev Date: Wed, 17 Feb 2016 14:37:44 +0100 Subject: [PATCH] matroskademux: Simple implementation of TRICKMODE_KEY_UNITS When the trickmode key-units flag is set on the segment, simply skip any sample on a video stream that isn't a keyframe https://bugzilla.gnome.org/show_bug.cgi?id=762185 --- gst/matroska/matroska-demux.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/gst/matroska/matroska-demux.c b/gst/matroska/matroska-demux.c index 6b3efca022..fe9df563b8 100644 --- a/gst/matroska/matroska-demux.c +++ b/gst/matroska/matroska-demux.c @@ -3536,16 +3536,27 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux, } /* else duration is diff between timecode of this and next block */ - /* For SimpleBlock, look at the keyframe bit in flags. Otherwise, - a ReferenceBlock implies that this is not a keyframe. In either - case, it only makes sense for video streams. */ if (stream->type == GST_MATROSKA_TRACK_TYPE_VIDEO) { + /* For SimpleBlock, look at the keyframe bit in flags. Otherwise, + a ReferenceBlock implies that this is not a keyframe. In either + case, it only makes sense for video streams. */ if ((is_simpleblock && !(flags & 0x80)) || referenceblock) { delta_unit = TRUE; invisible_frame = ((flags & 0x08)) && (!strcmp (stream->codec_id, GST_MATROSKA_CODEC_ID_VIDEO_VP8) || !strcmp (stream->codec_id, GST_MATROSKA_CODEC_ID_VIDEO_VP9)); } + + /* If we're doing a keyframe-only trickmode, only push keyframes on video + * streams */ + if (delta_unit + && demux->common. + segment.flags & GST_SEGMENT_FLAG_TRICKMODE_KEY_UNITS) { + GST_LOG_OBJECT (demux, "Skipping non-keyframe on stream %d", + stream->index); + ret = GST_FLOW_OK; + goto done; + } } for (n = 0; n < laces; n++) {