From fa283f407f3de4a31ecf756f6cdd02aeb9d162d3 Mon Sep 17 00:00:00 2001 From: Matej Knopp Date: Thu, 26 Feb 2015 02:12:18 +0100 Subject: [PATCH] matroskademux: V_MS/VFW/FOURCC streams have DTS instead of PTS When such stream is present demuxer should set DTS on buffers instead of PTS. This is consistent with how VLC and libav/ffmpeg handle VFW streams. Sample file https://s3.amazonaws.com/MatejK/Samples/Matroska-VFW-DTS-Only.mkv https://bugzilla.gnome.org/show_bug.cgi?id=745192 --- gst/matroska/matroska-demux.c | 11 ++++++++++- gst/matroska/matroska-ids.h | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/gst/matroska/matroska-demux.c b/gst/matroska/matroska-demux.c index 9eb7aed..3199540 100644 --- a/gst/matroska/matroska-demux.c +++ b/gst/matroska/matroska-demux.c @@ -3467,7 +3467,10 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux, goto next_lace; } - GST_BUFFER_TIMESTAMP (sub) = lace_time; + if (!stream->dts_only) + GST_BUFFER_PTS (sub) = lace_time; + else + GST_BUFFER_DTS (sub) = lace_time; if (GST_CLOCK_TIME_IS_VALID (lace_time)) { GstClockTime last_stop_end; @@ -3616,6 +3619,10 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux, stream->pos = GST_BUFFER_PTS (sub); if (GST_BUFFER_DURATION_IS_VALID (sub)) stream->pos += GST_BUFFER_DURATION (sub); + } else if (GST_BUFFER_DTS_IS_VALID (sub)) { + stream->pos = GST_BUFFER_DTS (sub); + if (GST_BUFFER_DURATION_IS_VALID (sub)) + stream->pos += GST_BUFFER_DURATION (sub); } ret = gst_pad_push (stream->pad, sub); @@ -4816,6 +4823,8 @@ gst_matroska_demux_video_caps (GstMatroskaTrackVideoContext * memcpy (vids, data, size); } + context->dts_only = TRUE; /* VFW files only store DTS */ + /* little-endian -> byte-order */ vids->size = GUINT32_FROM_LE (vids->size); vids->width = GUINT32_FROM_LE (vids->width); diff --git a/gst/matroska/matroska-ids.h b/gst/matroska/matroska-ids.h index 2aec1b4..6994b83 100644 --- a/gst/matroska/matroska-ids.h +++ b/gst/matroska/matroska-ids.h @@ -552,6 +552,9 @@ struct _GstMatroskaTrackContext { /* any alignment we need our output buffers to have */ gint alignment; + + /* for compatibility with VFW files, where timestamp represents DTS */ + gboolean dts_only; }; typedef struct _GstMatroskaTrackVideoContext { -- 2.7.4