summaryrefslogtreecommitdiff
path: root/v4l2-apps/libv4l
diff options
context:
space:
mode:
authorhans@rhel5-devel.localdomain <hans@rhel5-devel.localdomain>2009-03-11 13:08:30 +0100
committerhans@rhel5-devel.localdomain <hans@rhel5-devel.localdomain>2009-03-11 13:08:30 +0100
commit212f306971b622a70b8b3a20c61df11af814635a (patch)
tree5d06eba0a07dadd2c2e9523329dd2375fc0c71bd /v4l2-apps/libv4l
parentddf0a05516ddaefd3c473a3cc2bf5d6e170e5698 (diff)
downloadmediapointer-dvb-s2-212f306971b622a70b8b3a20c61df11af814635a.tar.gz
mediapointer-dvb-s2-212f306971b622a70b8b3a20c61df11af814635a.tar.bz2
libv4l: buffers only contain half of the lines with V4L2_FIELD_ALTERNATE
From: Hans de Goede <hdegoede@redhat.com> Take into account that the buffers only contain half of the lines when field is V4L2_FIELD_ALTERNATE Priority: normal Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'v4l2-apps/libv4l')
-rw-r--r--v4l2-apps/libv4l/ChangeLog2
-rw-r--r--v4l2-apps/libv4l/libv4lconvert/libv4lconvert.c37
2 files changed, 26 insertions, 13 deletions
diff --git a/v4l2-apps/libv4l/ChangeLog b/v4l2-apps/libv4l/ChangeLog
index c68c05445..fa18321f4 100644
--- a/v4l2-apps/libv4l/ChangeLog
+++ b/v4l2-apps/libv4l/ChangeLog
@@ -9,6 +9,8 @@ libv4l-0.5.2
* Only check width, height and pixelformat when checking if we are doing
conversion, instead of doing a memcmp, as that are the only things which
the convert code checks
+* Take into account that the buffers only contain half of the lines when
+ field is V4L2_FIELD_ALTERNATE
libv4l-0.5.1
------------
diff --git a/v4l2-apps/libv4l/libv4lconvert/libv4lconvert.c b/v4l2-apps/libv4l/libv4lconvert/libv4lconvert.c
index daced73dd..4725e638f 100644
--- a/v4l2-apps/libv4l/libv4lconvert/libv4lconvert.c
+++ b/v4l2-apps/libv4l/libv4lconvert/libv4lconvert.c
@@ -587,6 +587,7 @@ int v4lconvert_convert(struct v4lconvert_data *data,
unsigned char *convert_dest = dest, *rotate_src = src, *rotate_dest = dest;
unsigned char *crop_src = src;
struct v4l2_format my_src_fmt = *src_fmt;
+ struct v4l2_format my_dest_fmt = *dest_fmt;
/* Special case when no conversion is needed */
if (!v4lconvert_needs_conversion(data, src_fmt, dest_fmt)) {
@@ -595,16 +596,25 @@ int v4lconvert_convert(struct v4lconvert_data *data,
return to_copy;
}
+ /* When field is V4L2_FIELD_ALTERNATE, each buffer only contains half the
+ lines */
+ if (my_src_fmt.fmt.pix.field == V4L2_FIELD_ALTERNATE) {
+ my_src_fmt.fmt.pix.height /= 2;
+ my_dest_fmt.fmt.pix.height /= 2;
+ }
+
/* sanity check, is the dest buffer large enough? */
- switch (dest_fmt->fmt.pix.pixelformat) {
+ switch (my_dest_fmt.fmt.pix.pixelformat) {
case V4L2_PIX_FMT_RGB24:
case V4L2_PIX_FMT_BGR24:
- dest_needed = dest_fmt->fmt.pix.width * dest_fmt->fmt.pix.height * 3;
- temp_needed = src_fmt->fmt.pix.width * src_fmt->fmt.pix.height * 3;
+ dest_needed = my_dest_fmt.fmt.pix.width * my_dest_fmt.fmt.pix.height * 3;
+ temp_needed = my_src_fmt.fmt.pix.width * my_src_fmt.fmt.pix.height * 3;
break;
case V4L2_PIX_FMT_YUV420:
- dest_needed = dest_fmt->fmt.pix.width * dest_fmt->fmt.pix.height * 3 / 2;
- temp_needed = src_fmt->fmt.pix.width * src_fmt->fmt.pix.height * 3 / 2;
+ dest_needed =
+ my_dest_fmt.fmt.pix.width * my_dest_fmt.fmt.pix.height * 3 / 2;
+ temp_needed =
+ my_src_fmt.fmt.pix.width * my_src_fmt.fmt.pix.height * 3 / 2;
break;
default:
V4LCONVERT_ERR("Unknown dest format in conversion\n");
@@ -618,7 +628,7 @@ int v4lconvert_convert(struct v4lconvert_data *data,
return -1;
}
- if (dest_fmt->fmt.pix.pixelformat != src_fmt->fmt.pix.pixelformat)
+ if (my_dest_fmt.fmt.pix.pixelformat != my_src_fmt.fmt.pix.pixelformat)
convert = 1;
if (data->flags & V4LCONVERT_ROTATE_90)
@@ -626,8 +636,8 @@ int v4lconvert_convert(struct v4lconvert_data *data,
if (data->flags & V4LCONVERT_ROTATE_180)
rotate += 180;
- if (dest_fmt->fmt.pix.width != src_fmt->fmt.pix.width ||
- dest_fmt->fmt.pix.height != src_fmt->fmt.pix.height)
+ if (my_dest_fmt.fmt.pix.width != my_src_fmt.fmt.pix.width ||
+ my_dest_fmt.fmt.pix.height != my_src_fmt.fmt.pix.height)
crop = 1;
/* convert_pixfmt -> rotate -> crop, all steps are optional */
@@ -642,14 +652,15 @@ int v4lconvert_convert(struct v4lconvert_data *data,
}
if (convert) {
- res = v4lconvert_convert_pixfmt(data, src_fmt->fmt.pix.pixelformat,
- dest_fmt->fmt.pix.pixelformat,
- src_fmt->fmt.pix.width, src_fmt->fmt.pix.height,
+ res = v4lconvert_convert_pixfmt(data, my_src_fmt.fmt.pix.pixelformat,
+ my_dest_fmt.fmt.pix.pixelformat,
+ my_src_fmt.fmt.pix.width,
+ my_src_fmt.fmt.pix.height,
src, src_size, convert_dest);
if (res)
return res;
- my_src_fmt.fmt.pix.pixelformat = dest_fmt->fmt.pix.pixelformat;
+ my_src_fmt.fmt.pix.pixelformat = my_dest_fmt.fmt.pix.pixelformat;
v4lconvert_fixup_fmt(&my_src_fmt);
}
@@ -659,7 +670,7 @@ int v4lconvert_convert(struct v4lconvert_data *data,
my_src_fmt.fmt.pix.pixelformat, rotate);
if (crop)
- v4lconvert_crop(crop_src, dest, &my_src_fmt, dest_fmt);
+ v4lconvert_crop(crop_src, dest, &my_src_fmt, &my_dest_fmt);
return dest_needed;
}