libv4lconvert: Properly handle video processing when src fmt == dest fmt
authorHans de Goede <hdegoede@redhat.com>
Tue, 28 Dec 2010 22:36:40 +0000 (23:36 +0100)
committerHans de Goede <hdegoede@redhat.com>
Tue, 28 Dec 2010 22:36:40 +0000 (23:36 +0100)
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 <hdegoede@redhat.com>
lib/libv4lconvert/libv4lconvert.c

index 26a0978..0d8b29f 100644 (file)
@@ -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 ->