|
|
65a8849 |
From 4711194d75b412fe1ba092adbe3101f252ac77fb Mon Sep 17 00:00:00 2001
|
|
|
65a8849 |
From: Hans de Goede <hdegoede@redhat.com>
|
|
|
65a8849 |
Date: Thu, 13 Jun 2013 11:07:37 +0200
|
|
|
65a8849 |
Subject: [PATCH 14/35] cheese-camera-device: Make get_best_format smarter
|
|
|
65a8849 |
|
|
|
65a8849 |
If we've a device which can do 1600x900 at 10 fps and 1280x800 @ 25 fps,
|
|
|
65a8849 |
then 1600x900 is not really the best format, as 10 fps leads to a bad
|
|
|
65a8849 |
user experience.
|
|
|
65a8849 |
|
|
|
65a8849 |
So this patch makes get_best_format return the highest resolution at which
|
|
|
65a8849 |
the device can do atleast 15 fps.
|
|
|
65a8849 |
|
|
|
65a8849 |
Since some (older) cameras may have something like 640x480 @ 10 fps and
|
|
|
65a8849 |
320x240 @ 30 fps as modes, there is an additional check that the mode
|
|
|
65a8849 |
must also have a width of at least 640 pixels.
|
|
|
65a8849 |
|
|
|
65a8849 |
If no mode matching the widh >= 640 && frame_rate >= 15 criteria is found,
|
|
|
65a8849 |
get_best_format will behave as before as simply return the highest resolution
|
|
|
65a8849 |
mode.
|
|
|
65a8849 |
|
|
|
65a8849 |
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
|
65a8849 |
---
|
|
|
65a8849 |
libcheese/cheese-camera-device.c | 24 ++++++++++++++++++++----
|
|
|
65a8849 |
1 file changed, 20 insertions(+), 4 deletions(-)
|
|
|
65a8849 |
|
|
|
65a8849 |
diff --git a/libcheese/cheese-camera-device.c b/libcheese/cheese-camera-device.c
|
|
|
65a8849 |
index c23069d..402bbb8 100644
|
|
|
65a8849 |
--- a/libcheese/cheese-camera-device.c
|
|
|
65a8849 |
+++ b/libcheese/cheese-camera-device.c
|
|
|
65a8849 |
@@ -935,14 +935,30 @@ cheese_camera_device_get_device_node (CheeseCameraDevice *device)
|
|
|
65a8849 |
CheeseVideoFormat *
|
|
|
65a8849 |
cheese_camera_device_get_best_format (CheeseCameraDevice *device)
|
|
|
65a8849 |
{
|
|
|
65a8849 |
- CheeseVideoFormat *format;
|
|
|
65a8849 |
+ CheeseVideoFormatFull *format = NULL;
|
|
|
65a8849 |
+ GList *l;
|
|
|
65a8849 |
|
|
|
65a8849 |
g_return_val_if_fail (CHEESE_IS_CAMERA_DEVICE (device), NULL);
|
|
|
65a8849 |
|
|
|
65a8849 |
- format = g_boxed_copy (CHEESE_TYPE_VIDEO_FORMAT, device->priv->formats->data);
|
|
|
65a8849 |
+ /* First check for the highest res with width >= 640 and fps >= 15 */
|
|
|
65a8849 |
+ for (l = device->priv->formats; l != NULL; l = l->next)
|
|
|
65a8849 |
+ {
|
|
|
65a8849 |
+ CheeseVideoFormatFull *item = l->data;
|
|
|
65a8849 |
+ float frame_rate = (float)item->fr_numerator / (float)item->fr_denominator;
|
|
|
65a8849 |
+ if (item->width >= 640 && frame_rate >= 15)
|
|
|
65a8849 |
+ {
|
|
|
65a8849 |
+ format = item;
|
|
|
65a8849 |
+ break;
|
|
|
65a8849 |
+ }
|
|
|
65a8849 |
+ }
|
|
|
65a8849 |
+ /* Else simply return the highest res */
|
|
|
65a8849 |
+ if (!format)
|
|
|
65a8849 |
+ format = device->priv->formats->data;
|
|
|
65a8849 |
+
|
|
|
65a8849 |
+ GST_INFO ("%dx%d@%d/%d", format->width, format->height,
|
|
|
65a8849 |
+ format->fr_numerator, format->fr_denominator);
|
|
|
65a8849 |
|
|
|
65a8849 |
- GST_INFO ("%dx%d", format->width, format->height);
|
|
|
65a8849 |
- return format;
|
|
|
65a8849 |
+ return g_boxed_copy (CHEESE_TYPE_VIDEO_FORMAT, format);;
|
|
|
65a8849 |
}
|
|
|
65a8849 |
|
|
|
65a8849 |
/**
|
|
|
65a8849 |
--
|
|
|
65a8849 |
1.8.2.1
|
|
|
65a8849 |
|