summaryrefslogtreecommitdiff
path: root/v4l2-apps/libv4l/libv4lconvert/libv4lconvert.c
diff options
context:
space:
mode:
authorhans@rhel5-devel.localdomain <hans@rhel5-devel.localdomain>2009-05-22 11:40:31 +0200
committerhans@rhel5-devel.localdomain <hans@rhel5-devel.localdomain>2009-05-22 11:40:31 +0200
commitb152107391374bfc61ea21d1731fd349352bedf2 (patch)
tree6efea876e59de3c12dd63061782b4793e8e6f38c /v4l2-apps/libv4l/libv4lconvert/libv4lconvert.c
parent5a77f99540d308be03bced1c0dea4f480cd50894 (diff)
downloadmediapointer-dvb-s2-b152107391374bfc61ea21d1731fd349352bedf2.tar.gz
mediapointer-dvb-s2-b152107391374bfc61ea21d1731fd349352bedf2.tar.bz2
libv4l: add support for adding black borders (reverse cropping)
From: Hans de Goede <hdegoede@redhat.com> Add the capability to provide 320x240 to apps if the cam can only do 320x232 (some zc3xx cams) by adding black borders. And more in general the capability to make certain standard resolutions available by adding black borders to slightly smaller resolutions, in case we encounter more cams which have a hardware limitation which makes them do a resolution slightly smaller then the standard ones. Priority: normal Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'v4l2-apps/libv4l/libv4lconvert/libv4lconvert.c')
-rw-r--r--v4l2-apps/libv4l/libv4lconvert/libv4lconvert.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/v4l2-apps/libv4l/libv4lconvert/libv4lconvert.c b/v4l2-apps/libv4l/libv4lconvert/libv4lconvert.c
index 1a94b53ba..afb0c854c 100644
--- a/v4l2-apps/libv4l/libv4lconvert/libv4lconvert.c
+++ b/v4l2-apps/libv4l/libv4lconvert/libv4lconvert.c
@@ -373,7 +373,8 @@ int v4lconvert_try_format(struct v4lconvert_data *data,
/* In case of a non exact resolution match, see if this is a well known
resolution some apps are hardcoded too and try to give the app what it
- asked for by cropping a slightly larger resolution */
+ asked for by cropping a slightly larger resolution or adding a small
+ black border to a slightly smaller resolution */
if (try_dest.fmt.pix.width != desired_width ||
try_dest.fmt.pix.height != desired_height) {
for (i = 0; i < ARRAY_SIZE(v4lconvert_crop_res); i++) {
@@ -387,13 +388,20 @@ int v4lconvert_try_format(struct v4lconvert_data *data,
try2_dest.fmt.pix.height = desired_height * 124 / 100;
result = v4lconvert_do_try_format(data, &try2_dest, &try2_src);
if (result == 0 &&
- ((try2_dest.fmt.pix.width >= desired_width &&
+ (/* Add a small black border of max 16 pixels */
+ (try2_dest.fmt.pix.width >= desired_width - 16 &&
+ try2_dest.fmt.pix.width <= desired_width &&
+ try2_dest.fmt.pix.height >= desired_height - 16 &&
+ try2_dest.fmt.pix.height <= desired_height) ||
+ /* Standard cropping to max 80% of actual width / height */
+ (try2_dest.fmt.pix.width >= desired_width &&
try2_dest.fmt.pix.width <= desired_width * 5 / 4 &&
try2_dest.fmt.pix.height >= desired_height &&
try2_dest.fmt.pix.height <= desired_height * 5 / 4) ||
+ /* Downscale 2x + cropping to max 80% of actual width / height */
(try2_dest.fmt.pix.width >= desired_width * 2 &&
try2_dest.fmt.pix.width <= desired_width * 5 / 2 &&
- try2_dest.fmt.pix.height >= desired_height &&
+ try2_dest.fmt.pix.height >= desired_height * 2 &&
try2_dest.fmt.pix.height <= desired_height * 5 / 2))) {
/* Success! */
try2_dest.fmt.pix.width = desired_width;