qtmux: Don't need to update track per GstCaps if it's not changed
authorSeungha Yang <seungha@centricular.com>
Wed, 30 Jun 2021 14:52:26 +0000 (23:52 +0900)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Fri, 2 Jul 2021 06:22:41 +0000 (06:22 +0000)
Skip GstQTMuxPad::set_caps() call for duplicated caps.
All the processing done in set_caps() method for duplicated caps
are redundant.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/1019>

gst/isomp4/gstqtmux.c

index a4d949c..dc30d71 100644 (file)
@@ -6860,7 +6860,19 @@ gst_qt_mux_sink_event (GstAggregator * agg, GstAggregatorPad * agg_pad,
       /* find stream data */
       g_assert (qtmux_pad->set_caps);
 
-      ret = qtmux_pad->set_caps (qtmux_pad, caps);
+      /* depending on codec (h264/h265 for example), muxer will append a new
+       * stsd entry per set_caps(), but it's not ideal if referenced fields
+       * in caps is not updated from previous one.
+       * Each set_caps() implementation can be more enhanced
+       * so that we can avoid duplicated atoms though, this identical caps
+       * case is one we can skip obviously */
+      if (qtmux_pad->configured_caps &&
+          gst_caps_is_equal (qtmux_pad->configured_caps, caps)) {
+        GST_DEBUG_OBJECT (qtmux_pad, "Ignore duplicated caps %" GST_PTR_FORMAT,
+            caps);
+      } else {
+        ret = qtmux_pad->set_caps (qtmux_pad, caps);
+      }
 
       if (ret)
         gst_caps_replace (&qtmux_pad->configured_caps, caps);