matroska-mux: Handle pixel-aspect-ratio caps field correctly when checking caps equality
authorSebastian Dröge <sebastian@centricular.com>
Tue, 1 Mar 2022 18:59:30 +0000 (20:59 +0200)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 2 Mar 2022 10:27:47 +0000 (10:27 +0000)
Not having this field is equivalent with it being 1/1 so consider
it like that. The generic caps functions are not aware of these
semantics and would consider the caps different, causing a negotiation
failure when caps are changing from caps with to caps without or the
other way around.

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

subprojects/gst-plugins-good/gst/matroska/matroska-mux.c

index bf172b4..e0d2a46 100644 (file)
@@ -1019,6 +1019,18 @@ check_field (GQuark field_id, const GValue * value, gpointer user_data)
     else if (field_id == g_quark_from_static_string ("bit-depth-luma"))
       return FALSE;
 
+    /* Remove pixel-aspect-ratio field if it contains 1/1 as that's considered
+     * equivalent to not having the field but are not considered equivalent
+     * by the generic caps functions
+     */
+    if (field_id == g_quark_from_static_string ("pixel-aspect-ratio")) {
+      gint par_n = gst_value_get_fraction_numerator (value);
+      gint par_d = gst_value_get_fraction_denominator (value);
+
+      if (par_n == 1 && par_d == 1)
+        return FALSE;
+    }
+
     /* Remove multiview-mode=mono and multiview-flags=0 fields as those are
      * equivalent with not having the fields but are not considered equivalent
      * by the generic caps functions.