libv4l1 bug in RGB24/32 formats

Luigi Rizzo rizzo at iet.unipi.it
Sat Jan 8 23:16:52 UTC 2011


I noticed that a couple of my webcams, when used with libv4l,
claim to return RGB24 data but red and blue are swapped.

Looking at the code in
/usr/ports/multimedia/libv4l/work/v4l-utils-0.8.1/lib/libv4l1/libv4l1.c
it seems that the two routines that do conversion format
incorrectly map RGB* to BGR* .

The attached patch fixes the problem, I think it could be committed
to the port.
I am not sure if the code modified by the patch was
inserted deliberately (one mistake may happen, but two complementary
ones are really unlikely).

cheers
luigi
-------------- next part --------------
--- lib/libv4l1/libv4l1.c.orig	2011-01-09 02:13:49.000000000 +0100
+++ lib/libv4l1/libv4l1.c	2011-01-09 02:14:23.000000000 +0100
@@ -87,9 +87,9 @@
 	case VIDEO_PALETTE_RGB565:
 		return V4L2_PIX_FMT_RGB565;
 	case VIDEO_PALETTE_RGB24:
-		return V4L2_PIX_FMT_BGR24;
+		return V4L2_PIX_FMT_RGB24;
 	case VIDEO_PALETTE_RGB32:
-		return V4L2_PIX_FMT_BGR32;
+		return V4L2_PIX_FMT_RGB32;
 	case VIDEO_PALETTE_YUYV:
 		return V4L2_PIX_FMT_YUYV;
 	case VIDEO_PALETTE_YUV422:
@@ -118,9 +118,9 @@
 		return VIDEO_PALETTE_RGB555;
 	case V4L2_PIX_FMT_RGB565:
 		return VIDEO_PALETTE_RGB565;
-	case V4L2_PIX_FMT_BGR24:
+	case V4L2_PIX_FMT_RGB24:
 		return VIDEO_PALETTE_RGB24;
-	case V4L2_PIX_FMT_BGR32:
+	case V4L2_PIX_FMT_RGB32:
 		return VIDEO_PALETTE_RGB32;
 	case V4L2_PIX_FMT_YUYV:
 		return VIDEO_PALETTE_YUYV;


More information about the freebsd-multimedia mailing list