matroskademux: V_MS/VFW/FOURCC streams have DTS instead of PTS
authorMatej Knopp <matej.knopp@gmail.com>
Thu, 26 Feb 2015 01:12:18 +0000 (02:12 +0100)
committerSebastian Dröge <sebastian@centricular.com>
Thu, 26 Feb 2015 09:12:34 +0000 (11:12 +0200)
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
gst/matroska/matroska-ids.h

index 9eb7aed..3199540 100644 (file)
@@ -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);
index 2aec1b4..6994b83 100644 (file)
@@ -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 {