mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
v4l2codecs: decoder: Generalize size enumeration caps
By reducing the generated caps to the minimal number of fields and using intersections instead of merges. This will allow us to reuse the result in the future. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5890>
This commit is contained in:
parent
65896dab75
commit
73b69d8ca0
1 changed files with 12 additions and 4 deletions
|
@ -398,8 +398,7 @@ gst_v4l2_decoder_enum_size_for_format (GstV4l2Decoder * self,
|
|||
size.discrete.width, size.discrete.height, index,
|
||||
GST_FOURCC_ARGS (pixelformat));
|
||||
|
||||
return gst_caps_new_simple ("video/x-raw", "format", G_TYPE_STRING,
|
||||
gst_video_format_to_string (format),
|
||||
return gst_caps_new_simple ("video/x-raw",
|
||||
"width", G_TYPE_INT, size.discrete.width,
|
||||
"height", G_TYPE_INT, size.discrete.height, NULL);
|
||||
}
|
||||
|
@ -409,7 +408,7 @@ gst_v4l2_decoder_probe_caps_for_format (GstV4l2Decoder * self,
|
|||
guint32 pixelformat, gint unscaled_width, gint unscaled_height)
|
||||
{
|
||||
gint index = 0;
|
||||
GstCaps *caps, *tmp;
|
||||
GstCaps *caps, *tmp, *size_caps;
|
||||
GstVideoFormat format;
|
||||
|
||||
GST_DEBUG_OBJECT (self, "enumerate size for %" GST_FOURCC_FORMAT,
|
||||
|
@ -421,11 +420,20 @@ gst_v4l2_decoder_probe_caps_for_format (GstV4l2Decoder * self,
|
|||
caps = gst_caps_new_simple ("video/x-raw", "format", G_TYPE_STRING,
|
||||
gst_video_format_to_string (format), NULL);
|
||||
|
||||
size_caps = gst_caps_new_empty ();
|
||||
while ((tmp = gst_v4l2_decoder_enum_size_for_format (self, pixelformat,
|
||||
index++, unscaled_width, unscaled_height))) {
|
||||
caps = gst_caps_merge (caps, tmp);
|
||||
size_caps = gst_caps_merge (size_caps, tmp);
|
||||
}
|
||||
|
||||
if (!gst_caps_is_empty (size_caps)) {
|
||||
tmp = caps;
|
||||
caps = gst_caps_intersect_full (tmp, size_caps, GST_CAPS_INTERSECT_FIRST);
|
||||
gst_caps_unref (tmp);
|
||||
}
|
||||
|
||||
gst_caps_unref (size_caps);
|
||||
|
||||
return caps;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue