mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 22:36:33 +00:00
ffmpegcolorspace: 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
a2162b07ad
commit
da4e79bb6b
1 changed files with 12 additions and 10 deletions
|
@ -101,13 +101,20 @@ gst_ffmpegcsp_caps_remove_format_info (GstCaps * caps)
|
||||||
{
|
{
|
||||||
GstStructure *yuvst, *rgbst, *grayst;
|
GstStructure *yuvst, *rgbst, *grayst;
|
||||||
gint i, n;
|
gint i, n;
|
||||||
|
GstCaps *res;
|
||||||
|
|
||||||
caps = gst_caps_copy (caps);
|
res = 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++) {
|
||||||
yuvst = gst_caps_get_structure (caps, i);
|
yuvst = 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 (res, yuvst))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
yuvst = gst_structure_copy (yuvst);
|
||||||
gst_structure_set_name (yuvst, "video/x-raw-yuv");
|
gst_structure_set_name (yuvst, "video/x-raw-yuv");
|
||||||
gst_structure_remove_fields (yuvst, "format", "endianness", "depth",
|
gst_structure_remove_fields (yuvst, "format", "endianness", "depth",
|
||||||
"bpp", "red_mask", "green_mask", "blue_mask", "alpha_mask",
|
"bpp", "red_mask", "green_mask", "blue_mask", "alpha_mask",
|
||||||
|
@ -120,11 +127,12 @@ gst_ffmpegcsp_caps_remove_format_info (GstCaps * caps)
|
||||||
grayst = gst_structure_copy (rgbst);
|
grayst = gst_structure_copy (rgbst);
|
||||||
gst_structure_set_name (grayst, "video/x-raw-gray");
|
gst_structure_set_name (grayst, "video/x-raw-gray");
|
||||||
|
|
||||||
gst_caps_merge_structure (caps, rgbst);
|
gst_caps_append_structure (res, yuvst);
|
||||||
gst_caps_merge_structure (caps, grayst);
|
gst_caps_append_structure (res, rgbst);
|
||||||
|
gst_caps_append_structure (res, grayst);
|
||||||
}
|
}
|
||||||
|
|
||||||
return caps;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The caps can be transformed into any other caps with format info removed.
|
/* The caps can be transformed into any other caps with format info removed.
|
||||||
|
@ -134,17 +142,11 @@ static GstCaps *
|
||||||
gst_ffmpegcsp_transform_caps (GstBaseTransform * btrans,
|
gst_ffmpegcsp_transform_caps (GstBaseTransform * btrans,
|
||||||
GstPadDirection direction, GstCaps * caps, GstCaps * filter)
|
GstPadDirection direction, GstCaps * caps, GstCaps * filter)
|
||||||
{
|
{
|
||||||
GstCaps *template;
|
|
||||||
GstCaps *tmp, *tmp2;
|
GstCaps *tmp, *tmp2;
|
||||||
GstCaps *result;
|
GstCaps *result;
|
||||||
|
|
||||||
template = gst_static_pad_template_get_caps (&gst_ffmpegcsp_src_template);
|
|
||||||
|
|
||||||
/* Get all possible caps that we can transform to */
|
/* Get all possible caps that we can transform to */
|
||||||
tmp = gst_ffmpegcsp_caps_remove_format_info (caps);
|
tmp = gst_ffmpegcsp_caps_remove_format_info (caps);
|
||||||
tmp2 = gst_caps_intersect_full (tmp, template, GST_CAPS_INTERSECT_FIRST);
|
|
||||||
gst_caps_unref (tmp);
|
|
||||||
tmp = tmp2;
|
|
||||||
|
|
||||||
if (filter) {
|
if (filter) {
|
||||||
tmp2 = gst_caps_intersect_full (filter, tmp, GST_CAPS_INTERSECT_FIRST);
|
tmp2 = gst_caps_intersect_full (filter, tmp, GST_CAPS_INTERSECT_FIRST);
|
||||||
|
|
Loading…
Reference in a new issue