[MPlayer-dev-eng] [PATCH] more swscale altivec fixes
Alan Curry
pacman at theworld.com
Mon Apr 24 21:29:15 CEST 2006
Rich Felker writes the following:
>
>Scale must accept unaligned input. Consider the case where the input
>comes from vf_crop or similar...
>
Looking at vf_crop makes it all clear.
swscale, my old nemesis, how many more bugs have you?
At least 3 more. There are 2 cases of assuming stride==width and 1 case of
expecting the Y plane to be aligned at 16 bytes. They're independent bugs,
but they all appear in the DEFCSP420_CVT macro which defines the functions
altivec_yuv2_{argb,bgra,rgb24,...}.
--- postproc/yuv2rgb_altivec.c 2006-04-24 13:34:23.000000000 -0500
+++ postproc/yuv2rgb_altivec.c 2006-04-24 13:34:31.000000000 -0500
@@ -304,7 +304,7 @@
(oplanes[0]+srcSliceY*outstrides[0]+outstrides[0]); \
\
\
- instrides_scl[0] = instrides[0]; \
+ instrides_scl[0] = instrides[0]*2-w; /* the loop moves y{1,2}i by w */ \
instrides_scl[1] = instrides[1]-w/2; /* the loop moves ui by w/2 */ \
instrides_scl[2] = instrides[2]-w/2; /* the loop moves vi by w/2 */ \
\
--- postproc/yuv2rgb_altivec.c 2006-04-24 13:34:31.000000000 -0500
+++ postproc/yuv2rgb_altivec.c 2006-04-24 13:34:36.000000000 -0500
@@ -292,7 +292,7 @@
vector unsigned short lCSHIFT = c->CSHIFT; \
\
ubyte *y1i = in[0]; \
- ubyte *y2i = in[0]+w; \
+ ubyte *y2i = in[0]+instrides[0]; \
ubyte *ui = in[1]; \
ubyte *vi = in[2]; \
\
--- postproc/yuv2rgb_altivec.c 2006-04-24 13:34:36.000000000 -0500
+++ postproc/yuv2rgb_altivec.c 2006-04-24 13:35:55.000000000 -0500
@@ -278,7 +278,7 @@
vector signed short R1,G1,B1; \
vector unsigned char R,G,B; \
\
- vector unsigned char *uivP, *vivP; \
+ vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP; \
vector unsigned char align_perm; \
\
vector signed short \
@@ -315,11 +315,17 @@
\
for (j=0;j<w/16;j++) { \
\
- y0 = vec_ldl (0,y1i); \
- y1 = vec_ldl (0,y2i); \
+ y1ivP = (vector unsigned char *)y1i; \
+ y2ivP = (vector unsigned char *)y2i; \
uivP = (vector unsigned char *)ui; \
vivP = (vector unsigned char *)vi; \
\
+ align_perm = vec_lvsl (0, y1i); \
+ y0 = (vector unsigned char)vec_perm (y1ivP[0], y1ivP[1], align_perm);\
+ \
+ align_perm = vec_lvsl (0, y2i); \
+ y1 = (vector unsigned char)vec_perm (y2ivP[0], y2ivP[1], align_perm);\
+ \
align_perm = vec_lvsl (0, ui); \
u = (vector signed char)vec_perm (uivP[0], uivP[1], align_perm); \
\
More information about the MPlayer-dev-eng
mailing list