From 4f2fbe4bc265eb2deb9de5e11625e7267d2c97fc Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Tue, 28 Dec 2010 23:36:40 +0100 Subject: [PATCH] libv4lconvert: Properly handle video processing when src fmt == dest fmt When video processing is enabled (ie software whitebalancing) and the src_fmt == dst_fmt (ie rgb24) and not cropping, flipping, or rotating the video processing would be done directly on the src data and the data would never get copied to the destination buffer. This patch fixes this. Signed-off-By: Hans de Goede --- lib/libv4lconvert/libv4lconvert.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/libv4lconvert/libv4lconvert.c b/lib/libv4lconvert/libv4lconvert.c index 26a0978..0d8b29f 100644 --- a/lib/libv4lconvert/libv4lconvert.c +++ b/lib/libv4lconvert/libv4lconvert.c @@ -881,6 +881,9 @@ static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data, case V4L2_PIX_FMT_RGB24: switch (dest_pix_fmt) { + case V4L2_PIX_FMT_RGB24: + memcpy(dest, src, width * height * 3); + break; case V4L2_PIX_FMT_BGR24: v4lconvert_swap_rgb(src, dest, width, height); break; @@ -903,6 +906,9 @@ static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data, case V4L2_PIX_FMT_RGB24: v4lconvert_swap_rgb(src, dest, width, height); break; + case V4L2_PIX_FMT_BGR24: + memcpy(dest, src, width * height * 3); + break; case V4L2_PIX_FMT_YUV420: v4lconvert_rgb24_to_yuv420(src, dest, fmt, 1, 0); break; @@ -927,6 +933,9 @@ static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data, v4lconvert_yuv420_to_bgr24(src, dest, width, height, 0); break; + case V4L2_PIX_FMT_YUV420: + memcpy(dest, src, width * height * 3 / 2); + break; case V4L2_PIX_FMT_YVU420: v4lconvert_swap_uv(src, dest, fmt); break; @@ -951,6 +960,9 @@ static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data, case V4L2_PIX_FMT_YUV420: v4lconvert_swap_uv(src, dest, fmt); break; + case V4L2_PIX_FMT_YVU420: + memcpy(dest, src, width * height * 3 / 2); + break; } if (src_size < (width * height * 3 / 2)) { V4LCONVERT_ERR("short yvu420 data frame\n"); @@ -1115,7 +1127,13 @@ int v4lconvert_convert(struct v4lconvert_data *data, my_src_fmt.fmt.pix.pixelformat, my_dest_fmt.fmt.pix.pixelformat)) convert = 2; - else if (my_dest_fmt.fmt.pix.pixelformat != my_src_fmt.fmt.pix.pixelformat) + else if (my_dest_fmt.fmt.pix.pixelformat != + my_src_fmt.fmt.pix.pixelformat || + /* Special case if we do not need to do conversion, but we + are not doing any other step involving copying either, + force going through convert_pixfmt to copy the data from + source to dest */ + (!rotate90 && !hflip && !vflip && !crop)) convert = 1; /* convert_pixfmt (only if convert == 2) -> processing -> convert_pixfmt -> -- 2.7.4