[MPlayer-dev-eng] altivec patch 4/5: RGB/BGR confusion
Alan Curry
pacman at world.std.com
Tue Feb 7 11:54:56 CET 2006
This patch corrects RGB vs. BGR confusion in yuv2rgb_altivec.c
First, the macros vec_mstrgb24 and vec_mstbgr24 each do the opposite of what
they say. (Although it's hard to be sure what they were intended to do since
the arguments are named "x0,x1,x2" rather than "r,g,b").
vec_mstrgb24(r,g,b,ptr) actually generates output conforming to IMGFMT_BGR24,
and vice versa. To fix this, I have simply switched the names.
The next one is even weirder. Look at these 2 macros, before my patch:
#define out_rgb24(a,b,c,ptr) vec_mstrgb24(a,b,c,ptr)
#define out_bgr24(a,b,c,ptr) vec_mstbgr24(c,b,a,ptr)
Regardless of whether vec_mstrgb24 and vec_mstbgr24 are named correctly or
not, they are definitely opposites of each other. So how does out_bgr24
compare to out_rgb24? It is reversed in 2 ways: the a,b,c arguments are
reversed and the opposite vec_mst* macro is called. Those 2 reversals cancel
each other and out_bgr24 actually does the exact same thing as out_rgb24.
(Before this patch, they both generate output conforming to IMGFMT_BGR24.)
This can be easily seen in the output of -vo jpeg, in which blue and red are
reversed.
-------------- next part --------------
diff -u postproc/yuv2rgb_altivec.c postproc/yuv2rgb_altivec.c
--- postproc/yuv2rgb_altivec.c 6 Feb 2006 22:04:17 -0000
+++ postproc/yuv2rgb_altivec.c 6 Feb 2006 23:10:31 -0000
@@ -142,7 +142,7 @@
y2 = vec_perm (o3,o2,perm_rgb_3); \
} while(0)
-#define vec_mstrgb24(x0,x1,x2,ptr) \
+#define vec_mstbgr24(x0,x1,x2,ptr) \
do { \
typeof(x0) _0,_1,_2; \
vec_merge3 (x0,x1,x2,_0,_1,_2); \
@@ -151,7 +151,7 @@
vec_st (_2, 0, ptr++); \
} while (0);
-#define vec_mstbgr24(x0,x1,x2,ptr) \
+#define vec_mstrgb24(x0,x1,x2,ptr) \
do { \
typeof(x0) _0,_1,_2; \
vec_merge3 (x2,x1,x0,_0,_1,_2); \
@@ -418,7 +418,7 @@
#define out_rgba(a,b,c,ptr) vec_mstrgb32(typeof(a),a,b,c,((typeof (a))AVV(0)),ptr)
#define out_argb(a,b,c,ptr) vec_mstrgb32(typeof(a),((typeof (a))AVV(0)),a,b,c,ptr)
#define out_rgb24(a,b,c,ptr) vec_mstrgb24(a,b,c,ptr)
-#define out_bgr24(a,b,c,ptr) vec_mstbgr24(c,b,a,ptr)
+#define out_bgr24(a,b,c,ptr) vec_mstbgr24(a,b,c,ptr)
DEFCSP420_CVT (yuv2_abgr32, out_abgr)
#if 1
More information about the MPlayer-dev-eng
mailing list