summaryrefslogtreecommitdiff
path: root/v4l2-apps/libv4l/libv4lconvert/flip.c
diff options
context:
space:
mode:
authorhans@rhel5-devel.localdomain <hans@rhel5-devel.localdomain>2009-03-11 13:06:14 +0100
committerhans@rhel5-devel.localdomain <hans@rhel5-devel.localdomain>2009-03-11 13:06:14 +0100
commit222cbd6fd0bec2c2e4566a251729f1329e031a22 (patch)
treed788833d126a894b444e222123600d5d4cb01ec1 /v4l2-apps/libv4l/libv4lconvert/flip.c
parent24ef92f0974bf26cf8ca949b7ae21286cbca3fd3 (diff)
downloadmediapointer-dvb-s2-222cbd6fd0bec2c2e4566a251729f1329e031a22.tar.gz
mediapointer-dvb-s2-222cbd6fd0bec2c2e4566a251729f1329e031a22.tar.bz2
libv4l: Add software cropping from CIF to VGA modes (fix skype)
From: Hans de Goede <hdegoede@redhat.com> * Add support for software cropping from 352x288 -> 320x240 / 176x144 -> 160x120, so that apps which will only work with vga resolutions like 320x240 (Skype!) will work with cams/drivers which do not support cropping CIF resolutions to VGA resolutions in hardware. This makes all 2.6.27 gspca supported cams, except for the pac7302 which only does 640x480 (and skype wants 320x240), work with skype * The v4lconvert_convert function was becoming a bit of a mess, so split the functionailiy into seperate v4lconvert_convert_pixfmt, v4lconvert_rotate and v4lconvert_crop functions, and make v4lconvert_convert a frontend to these Priority: normal Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'v4l2-apps/libv4l/libv4lconvert/flip.c')
-rw-r--r--v4l2-apps/libv4l/libv4lconvert/flip.c49
1 files changed, 41 insertions, 8 deletions
diff --git a/v4l2-apps/libv4l/libv4lconvert/flip.c b/v4l2-apps/libv4l/libv4lconvert/flip.c
index cd3468a89..5a108c8d9 100644
--- a/v4l2-apps/libv4l/libv4lconvert/flip.c
+++ b/v4l2-apps/libv4l/libv4lconvert/flip.c
@@ -22,8 +22,8 @@
#include "libv4lconvert-priv.h"
-void v4lconvert_rotate180_rgbbgr24(const unsigned char *src, unsigned char *dst,
- int width, int height)
+static void v4lconvert_rotate180_rgbbgr24(const unsigned char *src,
+ unsigned char *dst, int width, int height)
{
int i;
@@ -38,8 +38,8 @@ void v4lconvert_rotate180_rgbbgr24(const unsigned char *src, unsigned char *dst,
}
}
-void v4lconvert_rotate180_yuv420(const unsigned char *src, unsigned char *dst,
- int width, int height)
+static void v4lconvert_rotate180_yuv420(const unsigned char *src,
+ unsigned char *dst, int width, int height)
{
int i;
@@ -59,8 +59,8 @@ void v4lconvert_rotate180_yuv420(const unsigned char *src, unsigned char *dst,
*dst++ = *src--;
}
-void v4lconvert_rotate90_rgbbgr24(const unsigned char *src, unsigned char *dst,
- int destwidth, int destheight)
+static void v4lconvert_rotate90_rgbbgr24(const unsigned char *src,
+ unsigned char *dst, int destwidth, int destheight)
{
int x, y;
#define srcwidth destheight
@@ -75,8 +75,8 @@ void v4lconvert_rotate90_rgbbgr24(const unsigned char *src, unsigned char *dst,
}
}
-void v4lconvert_rotate90_yuv420(const unsigned char *src, unsigned char *dst,
- int destwidth, int destheight)
+static void v4lconvert_rotate90_yuv420(const unsigned char *src,
+ unsigned char *dst, int destwidth, int destheight)
{
int x, y;
@@ -105,3 +105,36 @@ void v4lconvert_rotate90_yuv420(const unsigned char *src, unsigned char *dst,
*dst++ = src[offset];
}
}
+
+void v4lconvert_rotate(unsigned char *src, unsigned char *dest,
+ int width, int height, unsigned int pix_fmt, int rotate)
+{
+ switch (rotate) {
+ case 0:
+ break;
+ case 90:
+ switch (pix_fmt) {
+ case V4L2_PIX_FMT_RGB24:
+ case V4L2_PIX_FMT_BGR24:
+ v4lconvert_rotate90_rgbbgr24(src, dest, width, height);
+ break;
+ case V4L2_PIX_FMT_YUV420:
+ v4lconvert_rotate90_yuv420(src, dest, width, height);
+ break;
+ }
+ break;
+ case 180:
+ switch (pix_fmt) {
+ case V4L2_PIX_FMT_RGB24:
+ case V4L2_PIX_FMT_BGR24:
+ v4lconvert_rotate180_rgbbgr24(src, dest, width, height);
+ break;
+ case V4L2_PIX_FMT_YUV420:
+ v4lconvert_rotate180_yuv420(src, dest, width, height);
+ break;
+ }
+ break;
+ default:
+ printf("FIXME add %d degrees rotation\n", rotate);
+ }
+}