From: Víctor Manuel Jáquez Leal Date: Tue, 5 Oct 2021 18:15:09 +0000 (+0200) Subject: vapostproc: Simplify fixate. X-Git-Tag: 1.19.3~255 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b53446ddc9a9bdb8ee9a7e7d8c506f15385c823b;p=platform%2Fupstream%2Fgstreamer.git vapostproc: Simplify fixate. The first approach to fixate was simply a copy&paste of both videoconvert and videoscale, trying to keep their logic as isolated as possible. But that brought duplicated and sparse logic. This patch merge both approaches simplifying the fixate operation. Part-of: --- diff --git a/subprojects/gst-plugins-bad/sys/va/gstvavpp.c b/subprojects/gst-plugins-bad/sys/va/gstvavpp.c index 50d749d..4eddcb2 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvavpp.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvavpp.c @@ -991,8 +991,6 @@ gst_va_vpp_fixate_format (GstVaVpp * self, GstCaps * caps, GstCaps * result) tests = gst_caps_get_structure (result, i); format = gst_structure_get_value (tests, "format"); - gst_structure_remove_fields (tests, "height", "width", "pixel-aspect-ratio", - "display-aspect-ratio", NULL); /* should not happen */ if (format == NULL) continue; @@ -1022,32 +1020,6 @@ gst_va_vpp_fixate_format (GstVaVpp * self, GstCaps * caps, GstCaps * result) } static GstCaps * -gst_va_vpp_get_fixed_format (GstVaVpp * self, GstPadDirection direction, - GstCaps * caps, GstCaps * othercaps) -{ - GstCaps *result; - - result = gst_caps_intersect (othercaps, caps); - if (gst_caps_is_empty (result)) { - gst_caps_unref (result); - result = gst_caps_copy (othercaps); - } - - gst_va_vpp_fixate_format (self, caps, result); - - /* fixate remaining fields */ - result = gst_caps_fixate (result); - - if (direction == GST_PAD_SINK) { - if (gst_caps_is_subset (caps, result)) { - gst_caps_replace (&result, caps); - } - } - - return result; -} - -static GstCaps * gst_va_vpp_fixate_size (GstVaVpp * self, GstPadDirection direction, GstCaps * caps, GstCaps * othercaps) { @@ -1507,56 +1479,48 @@ gst_va_vpp_fixate_caps (GstBaseTransform * trans, GstPadDirection direction, GstCaps * caps, GstCaps * othercaps) { GstVaVpp *self = GST_VA_VPP (trans); - GstCaps *format; + GstCaps *result; GST_DEBUG_OBJECT (self, "trying to fixate othercaps %" GST_PTR_FORMAT " based on caps %" GST_PTR_FORMAT, othercaps, caps); - format = gst_va_vpp_get_fixed_format (self, direction, caps, othercaps); - - if (gst_caps_is_empty (format)) { - GST_ERROR_OBJECT (self, "Could not convert formats"); - return format; + result = gst_caps_intersect (othercaps, caps); + if (gst_caps_is_empty (result)) { + gst_caps_unref (result); + result = gst_caps_copy (othercaps); } - othercaps = gst_va_vpp_fixate_size (self, direction, caps, othercaps); - if (gst_caps_get_size (othercaps) == 1) { - gint i; - const gchar *format_fields[] = { "format", "colorimetry", "chroma-site" }; - GstStructure *format_struct = gst_caps_get_structure (format, 0); - GstStructure *fixated_struct; - - othercaps = gst_caps_make_writable (othercaps); - fixated_struct = gst_caps_get_structure (othercaps, 0); - - for (i = 0; i < G_N_ELEMENTS (format_fields); i++) { - if (gst_structure_has_field (format_struct, format_fields[i])) { - gst_structure_set (fixated_struct, format_fields[i], G_TYPE_STRING, - gst_structure_get_string (format_struct, format_fields[i]), NULL); - } else { - gst_structure_remove_field (fixated_struct, format_fields[i]); - } + gst_va_vpp_fixate_format (self, caps, result); + result = gst_va_vpp_fixate_size (self, direction, caps, result); + + /* fixate remaining fields */ + result = gst_caps_fixate (result); + + /* copy the framerate */ + { + GstStructure *fixated_struct = gst_caps_get_structure (result, 0); + const GValue *framerate = + gst_structure_get_value (fixated_struct, "framerate"); + + if (!(framerate && gst_value_is_fixed (framerate))) { + GstStructure *orig_struct = gst_caps_get_structure (caps, 0); + const GValue *orig_framerate = + gst_structure_get_value (orig_struct, "framerate"); + + gst_structure_set_value (fixated_struct, "framerate", orig_framerate); } + } - /* copy the framerate */ - { - const GValue *framerate = - gst_structure_get_value (fixated_struct, "framerate"); - if (framerate && !gst_value_is_fixed (framerate)) { - GstStructure *st = gst_caps_get_structure (caps, 0); - const GValue *fixated_framerate = - gst_structure_get_value (st, "framerate"); - gst_structure_set_value (fixated_struct, "framerate", - fixated_framerate); - } + if (direction == GST_PAD_SINK) { + if (gst_caps_is_subset (caps, result)) { + gst_caps_replace (&result, caps); } } - gst_caps_unref (format); - GST_DEBUG_OBJECT (self, "fixated othercaps to %" GST_PTR_FORMAT, othercaps); + GST_DEBUG_OBJECT (self, "fixated othercaps to %" GST_PTR_FORMAT, result); - return othercaps; + return result; } static void