mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-20 00:31:13 +00:00
videoscale: Optimize transform_caps()
If the second and next caps structures are a subset of the already existing transformed caps we can safely skip them because we would transform them to the same caps again.
This commit is contained in:
parent
da4e79bb6b
commit
0c99ab5806
1 changed files with 9 additions and 5 deletions
|
@ -328,18 +328,21 @@ gst_video_scale_transform_caps (GstBaseTransform * trans,
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
gint i, n;
|
gint i, n;
|
||||||
|
|
||||||
/* this function is always called with a simple caps */
|
|
||||||
g_return_val_if_fail (GST_CAPS_IS_SIMPLE (caps), NULL);
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (trans,
|
GST_DEBUG_OBJECT (trans,
|
||||||
"Transforming caps %" GST_PTR_FORMAT " in direction %s", caps,
|
"Transforming caps %" GST_PTR_FORMAT " in direction %s", caps,
|
||||||
(direction == GST_PAD_SINK) ? "sink" : "src");
|
(direction == GST_PAD_SINK) ? "sink" : "src");
|
||||||
|
|
||||||
ret = gst_caps_copy (caps);
|
ret = gst_caps_new_empty ();
|
||||||
n = gst_caps_get_size (caps);
|
n = gst_caps_get_size (caps);
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
structure = gst_caps_get_structure (ret, i);
|
structure = gst_caps_get_structure (caps, i);
|
||||||
|
|
||||||
|
/* If this is already expressed by the existing caps
|
||||||
|
* skip this structure */
|
||||||
|
if (i > 0 && gst_caps_is_subset_structure (ret, structure))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
structure = gst_structure_copy (structure);
|
||||||
gst_structure_set (structure,
|
gst_structure_set (structure,
|
||||||
"width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
|
"width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
|
||||||
"height", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
|
"height", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
|
||||||
|
@ -349,6 +352,7 @@ gst_video_scale_transform_caps (GstBaseTransform * trans,
|
||||||
gst_structure_set (structure, "pixel-aspect-ratio",
|
gst_structure_set (structure, "pixel-aspect-ratio",
|
||||||
GST_TYPE_FRACTION_RANGE, 1, G_MAXINT, G_MAXINT, 1, NULL);
|
GST_TYPE_FRACTION_RANGE, 1, G_MAXINT, G_MAXINT, 1, NULL);
|
||||||
}
|
}
|
||||||
|
gst_caps_append_structure (ret, structure);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter) {
|
if (filter) {
|
||||||
|
|
Loading…
Reference in a new issue