flacparse: set both pts and dts so baseparse doesn't make up wrong dts after a seek
authorTim-Philipp Müller <tim@centricular.com>
Fri, 4 Sep 2015 18:34:41 +0000 (19:34 +0100)
committerTim-Philipp Müller <tim@centricular.com>
Sun, 6 Sep 2015 15:36:44 +0000 (16:36 +0100)
flac contains the sample offset in the frame header, so after a seek
without index flacparse will know the exact position we landed on and
timestamp buffers accordingly. It only set the pts though, which means
the baseparse-set dts which was set to the seek position prevails, and
since the seek was based on an estimate, there's likely a discrepancy
between where we wanted to land and where we did land, so from here on
that dts/pts difference will be maintained, with dts possibly multiple
seconds ahead of pts, which is just wrong. The easiest way to fix this
is to just set both pts and dts based on the sample offset, but perhaps
parsed audio should just not have dts set at all.

https://bugzilla.gnome.org/show_bug.cgi?id=752106

gst/audioparsers/gstflacparse.c

index 6db5d59..bf598c7 100644 (file)
@@ -1645,16 +1645,18 @@ gst_flac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame,
 
     /* also cater for oggmux metadata */
     if (flacparse->blocking_strategy == 0) {
-      GST_BUFFER_TIMESTAMP (buffer) =
+      GST_BUFFER_PTS (buffer) =
           gst_util_uint64_scale (flacparse->sample_number,
           flacparse->block_size * GST_SECOND, flacparse->samplerate);
+      GST_BUFFER_DTS (buffer) = GST_BUFFER_PTS (buffer);
       GST_BUFFER_OFFSET_END (buffer) =
           flacparse->sample_number * flacparse->block_size +
           flacparse->block_size;
     } else {
-      GST_BUFFER_TIMESTAMP (buffer) =
+      GST_BUFFER_PTS (buffer) =
           gst_util_uint64_scale (flacparse->sample_number, GST_SECOND,
           flacparse->samplerate);
+      GST_BUFFER_DTS (buffer) = GST_BUFFER_PTS (buffer);
       GST_BUFFER_OFFSET_END (buffer) =
           flacparse->sample_number + flacparse->block_size;
     }
@@ -1662,7 +1664,7 @@ gst_flac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame,
         gst_util_uint64_scale (GST_BUFFER_OFFSET_END (buffer), GST_SECOND,
         flacparse->samplerate);
     GST_BUFFER_DURATION (buffer) =
-        GST_BUFFER_OFFSET (buffer) - GST_BUFFER_TIMESTAMP (buffer);
+        GST_BUFFER_OFFSET (buffer) - GST_BUFFER_PTS (buffer);
 
     /* To simplify, we just assume that it's a fixed size header and ignore
      * subframe headers. The first could lead us to being off by 88 bits and