[cheese] Preserve video/x-raw over image/jpeg
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cheese] Preserve video/x-raw over image/jpeg
- Date: Mon, 21 Sep 2020 10:26:50 +0000 (UTC)
commit 1c1e7fa0c4608331fd89683ccb342ed3518acccc
Author: Jakub Adam <jakub adam collabora com>
Date: Tue Sep 3 16:57:00 2019 +0200
Preserve video/x-raw over image/jpeg
gst_caps_simplify() doesn't preserve the original order of caps, so when
called on the full set of caps, collected from all supported_formats, it
may end up preferring image/jpeg caps even when video/x-raw with
identical resolution and framerate is available.
Simplify the caps coming from each of supported_formats separately, so
that video/x-raw always comes first in the result GstCaps.
We prefer raw camera output whenever possible in order to avoid decoding
MJPEG.
libcheese/cheese-camera-device.c | 38 +++++++++++++++++++++-----------------
1 file changed, 21 insertions(+), 17 deletions(-)
---
diff --git a/libcheese/cheese-camera-device.c b/libcheese/cheese-camera-device.c
index 34b846a5..efcb0459 100644
--- a/libcheese/cheese-camera-device.c
+++ b/libcheese/cheese-camera-device.c
@@ -893,10 +893,9 @@ cheese_camera_device_get_caps_for_format (CheeseCameraDevice *device,
CheeseVideoFormat *format)
{
CheeseCameraDevicePrivate *priv;
- CheeseVideoFormatFull *full_format;
- GstCaps *desired_caps;
- GstCaps *subset_caps;
- gsize i;
+ CheeseVideoFormatFull *full_format;
+ GstCaps *result_caps;
+ gsize i;
g_return_val_if_fail (CHEESE_IS_CAMERA_DEVICE (device), NULL);
@@ -913,21 +912,26 @@ cheese_camera_device_get_caps_for_format (CheeseCameraDevice *device,
full_format->width, full_format->height,
full_format->fr_numerator, full_format->fr_denominator);
- desired_caps = gst_caps_new_empty ();
+ priv = cheese_camera_device_get_instance_private (device);
- for (i = 0; supported_formats[i] != NULL; i++)
- {
- gst_caps_append (desired_caps,
- cheese_camera_device_format_to_caps (supported_formats[i],
- full_format));
- }
+ result_caps = gst_caps_new_empty ();
- priv = cheese_camera_device_get_instance_private (device);
- subset_caps = gst_caps_intersect (desired_caps, priv->caps);
- subset_caps = gst_caps_simplify (subset_caps);
- gst_caps_unref (desired_caps);
+ for (i = 0; supported_formats[i] != NULL; i++)
+ {
+ GstCaps *desired_caps;
+ GstCaps *subset_caps;
+
+ desired_caps = cheese_camera_device_format_to_caps (supported_formats[i],
+ full_format);
+ subset_caps = gst_caps_intersect (desired_caps, priv->caps);
+ subset_caps = gst_caps_simplify (subset_caps);
+
+ gst_caps_append (result_caps, subset_caps);
+
+ gst_caps_unref (desired_caps);
+ }
- GST_INFO ("Got %" GST_PTR_FORMAT, subset_caps);
+ GST_INFO ("Got %" GST_PTR_FORMAT, result_caps);
- return subset_caps;
+ return result_caps;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]