gstsmartencoder: don't make calculations for invalid DTS
authorMathieu Duponchelle <mathieu@centricular.com>
Fri, 21 Jan 2022 00:02:52 +0000 (01:02 +0100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Tue, 2 Aug 2022 15:48:12 +0000 (15:48 +0000)
Instead, as the current code relies on having a valid DTS (for lining
up passed through and re-encoded segments), simply compute a DTS
from the PTS if the DTS was invalid.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1549>

subprojects/gst-plugins-base/gst/encoding/gstsmartencoder.c

index ea14388..db55af7 100644 (file)
@@ -91,9 +91,12 @@ translate_timestamp_from_internal_to_src (GstSmartEncoder * self,
 static GstFlowReturn
 gst_smart_encoder_finish_buffer (GstSmartEncoder * self, GstBuffer * buf)
 {
+  if (!GST_CLOCK_TIME_IS_VALID (GST_BUFFER_DTS (buf)))
+    GST_BUFFER_DTS (buf) = GST_BUFFER_PTS (buf);
+
   translate_timestamp_from_internal_to_src (self, &GST_BUFFER_PTS (buf));
   translate_timestamp_from_internal_to_src (self, &GST_BUFFER_DTS (buf));
-  GST_BUFFER_DTS (buf) = GST_BUFFER_DTS (buf);
+
   if (self->last_dts > GST_BUFFER_DTS (buf)) {
     /* Hack to always produces dts increasing DTS-s that are close to what the
      * encoder produced. */