annotate postproc/yuv2rgb_altivec.c @ 18196:f7f6984638f8

finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
author nicodvb
date Sat, 22 Apr 2006 17:47:53 +0000
parents 194a848d907f
children 62cdcca26777
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
1 /*
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
2 marc.hoffman@analog.com March 8, 2004
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
3
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
4 Altivec Acceleration for Color Space Conversion revision 0.2
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
5
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
6 convert I420 YV12 to RGB in various formats,
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
7 it rejects images that are not in 420 formats
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
8 it rejects images that don't have widths of multiples of 16
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
9 it rejects images that don't have heights of multiples of 2
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
10 reject defers to C simulation codes.
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
11
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
12 lots of optimizations to be done here
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
13
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
14 1. need to fix saturation code, I just couldn't get it to fly with packs and adds.
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
15 so we currently use max min to clip
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
16
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
17 2. the inefficient use of chroma loading needs a bit of brushing up
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
18
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
19 3. analysis of pipeline stalls needs to be done, use shark to identify pipeline stalls
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
20
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
21
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
22 MODIFIED to calculate coeffs from currently selected color space.
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
23 MODIFIED core to be a macro which you spec the output format.
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
24 ADDED UYVY conversion which is never called due to some thing in SWSCALE.
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
25 CORRECTED algorithim selection to be strict on input formats.
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
26 ADDED runtime detection of altivec.
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
27
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
28 ADDED altivec_yuv2packedX vertical scl + RGB converter
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
29
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
30 March 27,2004
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
31 PERFORMANCE ANALYSIS
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
32
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
33 The C version use 25% of the processor or ~250Mips for D1 video rawvideo used as test
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
34 The ALTIVEC version uses 10% of the processor or ~100Mips for D1 video same sequence
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
35
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
36 720*480*30 ~10MPS
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
37
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
38 so we have roughly 10clocks per pixel this is too high something has to be wrong.
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
39
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
40 OPTIMIZED clip codes to utilize vec_max and vec_packs removing the need for vec_min.
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
41
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
42 OPTIMIZED DST OUTPUT cache/dma controls. we are pretty much
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
43 guaranteed to have the input video frame it was just decompressed so
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
44 it probably resides in L1 caches. However we are creating the
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
45 output video stream this needs to use the DSTST instruction to
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
46 optimize for the cache. We couple this with the fact that we are
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
47 not going to be visiting the input buffer again so we mark it Least
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
48 Recently Used. This shaves 25% of the processor cycles off.
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
49
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
50 Now MEMCPY is the largest mips consumer in the system, probably due
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
51 to the inefficient X11 stuff.
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
52
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
53 GL libraries seem to be very slow on this machine 1.33Ghz PB running
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
54 Jaguar, this is not the case for my 1Ghz PB. I thought it might be
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
55 a versioning issues, however i have libGL.1.2.dylib for both
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
56 machines. ((We need to figure this out now))
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
57
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
58 GL2 libraries work now with patch for RGB32
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
59
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
60 NOTE quartz vo driver ARGB32_to_RGB24 consumes 30% of the processor
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
61
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
62 Integrated luma prescaling adjustment for saturation/contrast/brightness adjustment.
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
63
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
64 */
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
65 #include <stdio.h>
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
66 #include <stdlib.h>
12836
9a310b31359f some fixes
alex
parents: 12698
diff changeset
67 #include <string.h>
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
68 #include <inttypes.h>
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
69 #include <assert.h>
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
70 #include "config.h"
17558
ad90899eeee6 AltiVec operations need to have memory aligned on 16-byte boundaries.
diego
parents: 17557
diff changeset
71 #ifdef HAVE_MALLOC_H
ad90899eeee6 AltiVec operations need to have memory aligned on 16-byte boundaries.
diego
parents: 17557
diff changeset
72 #include <malloc.h>
ad90899eeee6 AltiVec operations need to have memory aligned on 16-byte boundaries.
diego
parents: 17557
diff changeset
73 #endif
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
74 #include "rgb2rgb.h"
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
75 #include "swscale.h"
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
76 #include "swscale_internal.h"
16985
08cac43f1e38 Unify include paths, -I.. is in CFLAGS.
diego
parents: 13564
diff changeset
77 #include "mangle.h"
08cac43f1e38 Unify include paths, -I.. is in CFLAGS.
diego
parents: 13564
diff changeset
78 #include "libvo/img_format.h" //FIXME try to reduce dependency of such stuff
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
79
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
80 #undef PROFILE_THE_BEAST
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
81 #undef INC_SCALING
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
82
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
83 typedef unsigned char ubyte;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
84 typedef signed char sbyte;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
85
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
86
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
87 /* RGB interleaver, 16 planar pels 8-bit samples per channel in
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
88 homogeneous vector registers x0,x1,x2 are interleaved with the
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
89 following technique:
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
90
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
91 o0 = vec_mergeh (x0,x1);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
92 o1 = vec_perm (o0, x2, perm_rgb_0);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
93 o2 = vec_perm (o0, x2, perm_rgb_1);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
94 o3 = vec_mergel (x0,x1);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
95 o4 = vec_perm (o3,o2,perm_rgb_2);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
96 o5 = vec_perm (o3,o2,perm_rgb_3);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
97
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
98 perm_rgb_0: o0(RG).h v1(B) --> o1*
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
99 0 1 2 3 4
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
100 rgbr|gbrg|brgb|rgbr
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
101 0010 0100 1001 0010
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
102 0102 3145 2673 894A
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
103
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
104 perm_rgb_1: o0(RG).h v1(B) --> o2
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
105 0 1 2 3 4
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
106 gbrg|brgb|bbbb|bbbb
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
107 0100 1001 1111 1111
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
108 B5CD 6EF7 89AB CDEF
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
109
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
110 perm_rgb_2: o3(RG).l o2(rgbB.l) --> o4*
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
111 0 1 2 3 4
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
112 gbrg|brgb|rgbr|gbrg
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
113 1111 1111 0010 0100
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
114 89AB CDEF 0182 3945
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
115
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
116 perm_rgb_2: o3(RG).l o2(rgbB.l) ---> o5*
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
117 0 1 2 3 4
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
118 brgb|rgbr|gbrg|brgb
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
119 1001 0010 0100 1001
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
120 a67b 89cA BdCD eEFf
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
121
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
122 */
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
123 static
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
124 const vector unsigned char
13564
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
125 perm_rgb_0 = (const vector unsigned char)AVV(0x00,0x01,0x10,0x02,0x03,0x11,0x04,0x05,
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
126 0x12,0x06,0x07,0x13,0x08,0x09,0x14,0x0a),
13564
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
127 perm_rgb_1 = (const vector unsigned char)AVV(0x0b,0x15,0x0c,0x0d,0x16,0x0e,0x0f,0x17,
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
128 0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f),
13564
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
129 perm_rgb_2 = (const vector unsigned char)AVV(0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
130 0x00,0x01,0x18,0x02,0x03,0x19,0x04,0x05),
13564
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
131 perm_rgb_3 = (const vector unsigned char)AVV(0x1a,0x06,0x07,0x1b,0x08,0x09,0x1c,0x0a,
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
132 0x0b,0x1d,0x0c,0x0d,0x1e,0x0e,0x0f,0x1f);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
133
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
134 #define vec_merge3(x2,x1,x0,y0,y1,y2) \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
135 do { \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
136 typeof(x0) o0,o2,o3; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
137 o0 = vec_mergeh (x0,x1); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
138 y0 = vec_perm (o0, x2, perm_rgb_0);\
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
139 o2 = vec_perm (o0, x2, perm_rgb_1);\
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
140 o3 = vec_mergel (x0,x1); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
141 y1 = vec_perm (o3,o2,perm_rgb_2); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
142 y2 = vec_perm (o3,o2,perm_rgb_3); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
143 } while(0)
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
144
17563
8084bcdb4898 Correct RGB vs. BGR confusion, the macros vec_mstrgb24 and vec_mstbgr24 each
diego
parents: 17560
diff changeset
145 #define vec_mstbgr24(x0,x1,x2,ptr) \
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
146 do { \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
147 typeof(x0) _0,_1,_2; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
148 vec_merge3 (x0,x1,x2,_0,_1,_2); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
149 vec_st (_0, 0, ptr++); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
150 vec_st (_1, 0, ptr++); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
151 vec_st (_2, 0, ptr++); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
152 } while (0);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
153
17563
8084bcdb4898 Correct RGB vs. BGR confusion, the macros vec_mstrgb24 and vec_mstbgr24 each
diego
parents: 17560
diff changeset
154 #define vec_mstrgb24(x0,x1,x2,ptr) \
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
155 do { \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
156 typeof(x0) _0,_1,_2; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
157 vec_merge3 (x2,x1,x0,_0,_1,_2); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
158 vec_st (_0, 0, ptr++); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
159 vec_st (_1, 0, ptr++); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
160 vec_st (_2, 0, ptr++); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
161 } while (0);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
162
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
163 /* pack the pixels in rgb0 format
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
164 msb R
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
165 lsb 0
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
166 */
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
167 #define vec_mstrgb32(T,x0,x1,x2,x3,ptr) \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
168 do { \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
169 T _0,_1,_2,_3; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
170 _0 = vec_mergeh (x0,x1); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
171 _1 = vec_mergeh (x2,x3); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
172 _2 = (T)vec_mergeh ((vector unsigned short)_0,(vector unsigned short)_1); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
173 _3 = (T)vec_mergel ((vector unsigned short)_0,(vector unsigned short)_1); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
174 vec_st (_2, 0*16, (T *)ptr); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
175 vec_st (_3, 1*16, (T *)ptr); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
176 _0 = vec_mergel (x0,x1); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
177 _1 = vec_mergel (x2,x3); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
178 _2 = (T)vec_mergeh ((vector unsigned short)_0,(vector unsigned short)_1); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
179 _3 = (T)vec_mergel ((vector unsigned short)_0,(vector unsigned short)_1); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
180 vec_st (_2, 2*16, (T *)ptr); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
181 vec_st (_3, 3*16, (T *)ptr); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
182 ptr += 4; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
183 } while (0);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
184
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
185 /*
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
186
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
187 | 1 0 1.4021 | | Y |
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
188 | 1 -0.3441 -0.7142 |x| Cb|
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
189 | 1 1.7718 0 | | Cr|
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
190
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
191
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
192 Y: [-128 127]
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
193 Cb/Cr : [-128 127]
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
194
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
195 typical yuv conversion work on Y: 0-255 this version has been optimized for jpeg decode.
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
196
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
197 */
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
198
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
199
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
200
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
201
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
202 #define vec_unh(x) \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
203 (vector signed short) \
13564
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
204 vec_perm(x,(typeof(x))AVV(0),\
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
205 (vector unsigned char)AVV(0x10,0x00,0x10,0x01,0x10,0x02,0x10,0x03,\
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
206 0x10,0x04,0x10,0x05,0x10,0x06,0x10,0x07))
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
207 #define vec_unl(x) \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
208 (vector signed short) \
13564
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
209 vec_perm(x,(typeof(x))AVV(0),\
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
210 (vector unsigned char)AVV(0x10,0x08,0x10,0x09,0x10,0x0A,0x10,0x0B,\
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
211 0x10,0x0C,0x10,0x0D,0x10,0x0E,0x10,0x0F))
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
212
17638
ee8d71a1b7ba Fix vec_clip for gcc's that don't handle (vector signed short){16} according
pacman
parents: 17588
diff changeset
213 #define vec_clip_s16(x) \
ee8d71a1b7ba Fix vec_clip for gcc's that don't handle (vector signed short){16} according
pacman
parents: 17588
diff changeset
214 vec_max (vec_min (x, (vector signed short)AVV(235,235,235,235,235,235,235,235)),\
ee8d71a1b7ba Fix vec_clip for gcc's that don't handle (vector signed short){16} according
pacman
parents: 17588
diff changeset
215 (vector signed short)AVV(16, 16, 16, 16, 16, 16, 16, 16 ))
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
216
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
217 #define vec_packclp(x,y) \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
218 (vector unsigned char)vec_packs \
13564
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
219 ((vector unsigned short)vec_max (x,(vector signed short) AVV(0)), \
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
220 (vector unsigned short)vec_max (y,(vector signed short) AVV(0)))
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
221
13564
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
222 //#define out_pixels(a,b,c,ptr) vec_mstrgb32(typeof(a),((typeof (a))AVV(0)),a,a,a,ptr)
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
223
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
224
12836
9a310b31359f some fixes
alex
parents: 12698
diff changeset
225 static inline void cvtyuvtoRGB (SwsContext *c,
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
226 vector signed short Y, vector signed short U, vector signed short V,
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
227 vector signed short *R, vector signed short *G, vector signed short *B)
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
228 {
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
229 vector signed short vx,ux,uvx;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
230
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
231 Y = vec_mradds (Y, c->CY, c->OY);
13564
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
232 U = vec_sub (U,(vector signed short)
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
233 vec_splat((vector signed short)AVV(128),0));
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
234 V = vec_sub (V,(vector signed short)
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
235 vec_splat((vector signed short)AVV(128),0));
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
236
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
237 // ux = (CBU*(u<<c->CSHIFT)+0x4000)>>15;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
238 ux = vec_sl (U, c->CSHIFT);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
239 *B = vec_mradds (ux, c->CBU, Y);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
240
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
241 // vx = (CRV*(v<<c->CSHIFT)+0x4000)>>15;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
242 vx = vec_sl (V, c->CSHIFT);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
243 *R = vec_mradds (vx, c->CRV, Y);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
244
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
245 // uvx = ((CGU*u) + (CGV*v))>>15;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
246 uvx = vec_mradds (U, c->CGU, Y);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
247 *G = vec_mradds (V, c->CGV, uvx);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
248 }
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
249
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
250
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
251 /*
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
252 ------------------------------------------------------------------------------
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
253 CS converters
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
254 ------------------------------------------------------------------------------
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
255 */
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
256
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
257
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
258 #define DEFCSP420_CVT(name,out_pixels) \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
259 static int altivec_##name (SwsContext *c, \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
260 unsigned char **in, int *instrides, \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
261 int srcSliceY, int srcSliceH, \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
262 unsigned char **oplanes, int *outstrides) \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
263 { \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
264 int w = c->srcW; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
265 int h = srcSliceH; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
266 int i,j; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
267 int instrides_scl[3]; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
268 vector unsigned char y0,y1; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
269 \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
270 vector signed char u,v; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
271 \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
272 vector signed short Y0,Y1,Y2,Y3; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
273 vector signed short U,V; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
274 vector signed short vx,ux,uvx; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
275 vector signed short vx0,ux0,uvx0; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
276 vector signed short vx1,ux1,uvx1; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
277 vector signed short R0,G0,B0; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
278 vector signed short R1,G1,B1; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
279 vector unsigned char R,G,B; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
280 \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
281 vector unsigned char *uivP, *vivP; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
282 vector unsigned char align_perm; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
283 \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
284 vector signed short \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
285 lCY = c->CY, \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
286 lOY = c->OY, \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
287 lCRV = c->CRV, \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
288 lCBU = c->CBU, \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
289 lCGU = c->CGU, \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
290 lCGV = c->CGV; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
291 \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
292 vector unsigned short lCSHIFT = c->CSHIFT; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
293 \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
294 ubyte *y1i = in[0]; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
295 ubyte *y2i = in[0]+w; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
296 ubyte *ui = in[1]; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
297 ubyte *vi = in[2]; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
298 \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
299 vector unsigned char *oute \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
300 = (vector unsigned char *) \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
301 (oplanes[0]+srcSliceY*outstrides[0]); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
302 vector unsigned char *outo \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
303 = (vector unsigned char *) \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
304 (oplanes[0]+srcSliceY*outstrides[0]+outstrides[0]); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
305 \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
306 \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
307 instrides_scl[0] = instrides[0]; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
308 instrides_scl[1] = instrides[1]-w/2; /* the loop moves ui by w/2 */ \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
309 instrides_scl[2] = instrides[2]-w/2; /* the loop moves vi by w/2 */ \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
310 \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
311 \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
312 for (i=0;i<h/2;i++) { \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
313 vec_dstst (outo, (0x02000002|(((w*3+32)/32)<<16)), 0); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
314 vec_dstst (oute, (0x02000002|(((w*3+32)/32)<<16)), 1); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
315 \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
316 for (j=0;j<w/16;j++) { \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
317 \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
318 y0 = vec_ldl (0,y1i); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
319 y1 = vec_ldl (0,y2i); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
320 uivP = (vector unsigned char *)ui; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
321 vivP = (vector unsigned char *)vi; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
322 \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
323 align_perm = vec_lvsl (0, ui); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
324 u = (vector signed char)vec_perm (uivP[0], uivP[1], align_perm); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
325 \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
326 align_perm = vec_lvsl (0, vi); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
327 v = (vector signed char)vec_perm (vivP[0], vivP[1], align_perm); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
328 \
13564
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
329 u = (vector signed char) \
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
330 vec_sub (u,(vector signed char) \
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
331 vec_splat((vector signed char)AVV(128),0));\
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
332 v = (vector signed char) \
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
333 vec_sub (v,(vector signed char) \
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
334 vec_splat((vector signed char)AVV(128),0));\
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
335 \
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
336 U = vec_unpackh (u); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
337 V = vec_unpackh (v); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
338 \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
339 \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
340 Y0 = vec_unh (y0); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
341 Y1 = vec_unl (y0); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
342 Y2 = vec_unh (y1); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
343 Y3 = vec_unl (y1); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
344 \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
345 Y0 = vec_mradds (Y0, lCY, lOY); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
346 Y1 = vec_mradds (Y1, lCY, lOY); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
347 Y2 = vec_mradds (Y2, lCY, lOY); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
348 Y3 = vec_mradds (Y3, lCY, lOY); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
349 \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
350 /* ux = (CBU*(u<<CSHIFT)+0x4000)>>15 */ \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
351 ux = vec_sl (U, lCSHIFT); \
13564
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
352 ux = vec_mradds (ux, lCBU, (vector signed short)AVV(0)); \
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
353 ux0 = vec_mergeh (ux,ux); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
354 ux1 = vec_mergel (ux,ux); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
355 \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
356 /* vx = (CRV*(v<<CSHIFT)+0x4000)>>15; */ \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
357 vx = vec_sl (V, lCSHIFT); \
13564
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
358 vx = vec_mradds (vx, lCRV, (vector signed short)AVV(0)); \
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
359 vx0 = vec_mergeh (vx,vx); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
360 vx1 = vec_mergel (vx,vx); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
361 \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
362 /* uvx = ((CGU*u) + (CGV*v))>>15 */ \
13564
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
363 uvx = vec_mradds (U, lCGU, (vector signed short)AVV(0)); \
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
364 uvx = vec_mradds (V, lCGV, uvx); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
365 uvx0 = vec_mergeh (uvx,uvx); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
366 uvx1 = vec_mergel (uvx,uvx); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
367 \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
368 R0 = vec_add (Y0,vx0); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
369 G0 = vec_add (Y0,uvx0); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
370 B0 = vec_add (Y0,ux0); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
371 R1 = vec_add (Y1,vx1); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
372 G1 = vec_add (Y1,uvx1); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
373 B1 = vec_add (Y1,ux1); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
374 \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
375 R = vec_packclp (R0,R1); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
376 G = vec_packclp (G0,G1); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
377 B = vec_packclp (B0,B1); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
378 \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
379 out_pixels(R,G,B,oute); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
380 \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
381 R0 = vec_add (Y2,vx0); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
382 G0 = vec_add (Y2,uvx0); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
383 B0 = vec_add (Y2,ux0); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
384 R1 = vec_add (Y3,vx1); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
385 G1 = vec_add (Y3,uvx1); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
386 B1 = vec_add (Y3,ux1); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
387 R = vec_packclp (R0,R1); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
388 G = vec_packclp (G0,G1); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
389 B = vec_packclp (B0,B1); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
390 \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
391 \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
392 out_pixels(R,G,B,outo); \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
393 \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
394 y1i += 16; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
395 y2i += 16; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
396 ui += 8; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
397 vi += 8; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
398 \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
399 } \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
400 \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
401 outo += (outstrides[0])>>4; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
402 oute += (outstrides[0])>>4; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
403 \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
404 ui += instrides_scl[1]; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
405 vi += instrides_scl[2]; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
406 y1i += instrides_scl[0]; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
407 y2i += instrides_scl[0]; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
408 } \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
409 return srcSliceH; \
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
410 }
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
411
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
412
13564
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
413 #define out_abgr(a,b,c,ptr) vec_mstrgb32(typeof(a),((typeof (a))AVV(0)),c,b,a,ptr)
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
414 #define out_bgra(a,b,c,ptr) vec_mstrgb32(typeof(a),c,b,a,((typeof (a))AVV(0)),ptr)
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
415 #define out_rgba(a,b,c,ptr) vec_mstrgb32(typeof(a),a,b,c,((typeof (a))AVV(0)),ptr)
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
416 #define out_argb(a,b,c,ptr) vec_mstrgb32(typeof(a),((typeof (a))AVV(0)),a,b,c,ptr)
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
417 #define out_rgb24(a,b,c,ptr) vec_mstrgb24(a,b,c,ptr)
17563
8084bcdb4898 Correct RGB vs. BGR confusion, the macros vec_mstrgb24 and vec_mstbgr24 each
diego
parents: 17560
diff changeset
418 #define out_bgr24(a,b,c,ptr) vec_mstbgr24(a,b,c,ptr)
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
419
17844
194a848d907f Support all 4 of ARGB/RGBA/BGRA/ABGR unscaled conversions, with more
pacman
parents: 17642
diff changeset
420 DEFCSP420_CVT (yuv2_abgr, out_abgr)
13564
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
421 #if 1
17844
194a848d907f Support all 4 of ARGB/RGBA/BGRA/ABGR unscaled conversions, with more
pacman
parents: 17642
diff changeset
422 DEFCSP420_CVT (yuv2_bgra, out_bgra)
13564
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
423 #else
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
424 static int altivec_yuv2_bgra32 (SwsContext *c,
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
425 unsigned char **in, int *instrides,
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
426 int srcSliceY, int srcSliceH,
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
427 unsigned char **oplanes, int *outstrides)
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
428 {
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
429 int w = c->srcW;
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
430 int h = srcSliceH;
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
431 int i,j;
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
432 int instrides_scl[3];
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
433 vector unsigned char y0,y1;
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
434
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
435 vector signed char u,v;
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
436
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
437 vector signed short Y0,Y1,Y2,Y3;
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
438 vector signed short U,V;
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
439 vector signed short vx,ux,uvx;
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
440 vector signed short vx0,ux0,uvx0;
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
441 vector signed short vx1,ux1,uvx1;
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
442 vector signed short R0,G0,B0;
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
443 vector signed short R1,G1,B1;
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
444 vector unsigned char R,G,B;
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
445
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
446 vector unsigned char *uivP, *vivP;
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
447 vector unsigned char align_perm;
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
448
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
449 vector signed short
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
450 lCY = c->CY,
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
451 lOY = c->OY,
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
452 lCRV = c->CRV,
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
453 lCBU = c->CBU,
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
454 lCGU = c->CGU,
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
455 lCGV = c->CGV;
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
456
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
457 vector unsigned short lCSHIFT = c->CSHIFT;
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
458
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
459 ubyte *y1i = in[0];
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
460 ubyte *y2i = in[0]+w;
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
461 ubyte *ui = in[1];
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
462 ubyte *vi = in[2];
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
463
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
464 vector unsigned char *oute
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
465 = (vector unsigned char *)
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
466 (oplanes[0]+srcSliceY*outstrides[0]);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
467 vector unsigned char *outo
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
468 = (vector unsigned char *)
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
469 (oplanes[0]+srcSliceY*outstrides[0]+outstrides[0]);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
470
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
471
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
472 instrides_scl[0] = instrides[0];
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
473 instrides_scl[1] = instrides[1]-w/2; /* the loop moves ui by w/2 */
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
474 instrides_scl[2] = instrides[2]-w/2; /* the loop moves vi by w/2 */
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
475
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
476
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
477 for (i=0;i<h/2;i++) {
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
478 vec_dstst (outo, (0x02000002|(((w*3+32)/32)<<16)), 0);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
479 vec_dstst (oute, (0x02000002|(((w*3+32)/32)<<16)), 1);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
480
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
481 for (j=0;j<w/16;j++) {
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
482
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
483 y0 = vec_ldl (0,y1i);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
484 y1 = vec_ldl (0,y2i);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
485 uivP = (vector unsigned char *)ui;
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
486 vivP = (vector unsigned char *)vi;
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
487
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
488 align_perm = vec_lvsl (0, ui);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
489 u = (vector signed char)vec_perm (uivP[0], uivP[1], align_perm);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
490
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
491 align_perm = vec_lvsl (0, vi);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
492 v = (vector signed char)vec_perm (vivP[0], vivP[1], align_perm);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
493 u = (vector signed char)
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
494 vec_sub (u,(vector signed char)
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
495 vec_splat((vector signed char)AVV(128),0));
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
496
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
497 v = (vector signed char)
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
498 vec_sub (v, (vector signed char)
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
499 vec_splat((vector signed char)AVV(128),0));
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
500
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
501 U = vec_unpackh (u);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
502 V = vec_unpackh (v);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
503
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
504
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
505 Y0 = vec_unh (y0);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
506 Y1 = vec_unl (y0);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
507 Y2 = vec_unh (y1);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
508 Y3 = vec_unl (y1);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
509
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
510 Y0 = vec_mradds (Y0, lCY, lOY);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
511 Y1 = vec_mradds (Y1, lCY, lOY);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
512 Y2 = vec_mradds (Y2, lCY, lOY);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
513 Y3 = vec_mradds (Y3, lCY, lOY);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
514
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
515 /* ux = (CBU*(u<<CSHIFT)+0x4000)>>15 */
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
516 ux = vec_sl (U, lCSHIFT);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
517 ux = vec_mradds (ux, lCBU, (vector signed short)AVV(0));
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
518 ux0 = vec_mergeh (ux,ux);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
519 ux1 = vec_mergel (ux,ux);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
520
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
521 /* vx = (CRV*(v<<CSHIFT)+0x4000)>>15; */
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
522 vx = vec_sl (V, lCSHIFT);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
523 vx = vec_mradds (vx, lCRV, (vector signed short)AVV(0));
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
524 vx0 = vec_mergeh (vx,vx);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
525 vx1 = vec_mergel (vx,vx);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
526 /* uvx = ((CGU*u) + (CGV*v))>>15 */
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
527 uvx = vec_mradds (U, lCGU, (vector signed short)AVV(0));
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
528 uvx = vec_mradds (V, lCGV, uvx);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
529 uvx0 = vec_mergeh (uvx,uvx);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
530 uvx1 = vec_mergel (uvx,uvx);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
531 R0 = vec_add (Y0,vx0);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
532 G0 = vec_add (Y0,uvx0);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
533 B0 = vec_add (Y0,ux0);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
534 R1 = vec_add (Y1,vx1);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
535 G1 = vec_add (Y1,uvx1);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
536 B1 = vec_add (Y1,ux1);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
537 R = vec_packclp (R0,R1);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
538 G = vec_packclp (G0,G1);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
539 B = vec_packclp (B0,B1);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
540
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
541 out_argb(R,G,B,oute);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
542 R0 = vec_add (Y2,vx0);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
543 G0 = vec_add (Y2,uvx0);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
544 B0 = vec_add (Y2,ux0);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
545 R1 = vec_add (Y3,vx1);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
546 G1 = vec_add (Y3,uvx1);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
547 B1 = vec_add (Y3,ux1);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
548 R = vec_packclp (R0,R1);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
549 G = vec_packclp (G0,G1);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
550 B = vec_packclp (B0,B1);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
551
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
552 out_argb(R,G,B,outo);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
553 y1i += 16;
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
554 y2i += 16;
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
555 ui += 8;
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
556 vi += 8;
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
557
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
558 }
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
559
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
560 outo += (outstrides[0])>>4;
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
561 oute += (outstrides[0])>>4;
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
562
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
563 ui += instrides_scl[1];
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
564 vi += instrides_scl[2];
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
565 y1i += instrides_scl[0];
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
566 y2i += instrides_scl[0];
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
567 }
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
568 return srcSliceH;
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
569 }
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
570
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
571 #endif
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
572
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
573
17844
194a848d907f Support all 4 of ARGB/RGBA/BGRA/ABGR unscaled conversions, with more
pacman
parents: 17642
diff changeset
574 DEFCSP420_CVT (yuv2_rgba, out_rgba)
194a848d907f Support all 4 of ARGB/RGBA/BGRA/ABGR unscaled conversions, with more
pacman
parents: 17642
diff changeset
575 DEFCSP420_CVT (yuv2_argb, out_argb)
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
576 DEFCSP420_CVT (yuv2_rgb24, out_rgb24)
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
577 DEFCSP420_CVT (yuv2_bgr24, out_bgr24)
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
578
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
579
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
580 // uyvy|uyvy|uyvy|uyvy
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
581 // 0123 4567 89ab cdef
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
582 static
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
583 const vector unsigned char
13564
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
584 demux_u = (const vector unsigned char)AVV(0x10,0x00,0x10,0x00,
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
585 0x10,0x04,0x10,0x04,
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
586 0x10,0x08,0x10,0x08,
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
587 0x10,0x0c,0x10,0x0c),
13564
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
588 demux_v = (const vector unsigned char)AVV(0x10,0x02,0x10,0x02,
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
589 0x10,0x06,0x10,0x06,
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
590 0x10,0x0A,0x10,0x0A,
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
591 0x10,0x0E,0x10,0x0E),
13564
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
592 demux_y = (const vector unsigned char)AVV(0x10,0x01,0x10,0x03,
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
593 0x10,0x05,0x10,0x07,
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
594 0x10,0x09,0x10,0x0B,
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
595 0x10,0x0D,0x10,0x0F);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
596
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
597 /*
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
598 this is so I can play live CCIR raw video
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
599 */
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
600 static int altivec_uyvy_rgb32 (SwsContext *c,
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
601 unsigned char **in, int *instrides,
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
602 int srcSliceY, int srcSliceH,
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
603 unsigned char **oplanes, int *outstrides)
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
604 {
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
605 int w = c->srcW;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
606 int h = srcSliceH;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
607 int i,j;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
608 vector unsigned char uyvy;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
609 vector signed short Y,U,V;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
610 vector signed short vx,ux,uvx;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
611 vector signed short R0,G0,B0,R1,G1,B1;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
612 vector unsigned char R,G,B;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
613 vector unsigned char *out;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
614 ubyte *img;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
615
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
616 img = in[0];
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
617 out = (vector unsigned char *)(oplanes[0]+srcSliceY*outstrides[0]);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
618
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
619 for (i=0;i<h;i++) {
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
620 for (j=0;j<w/16;j++) {
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
621 uyvy = vec_ld (0, img);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
622 U = (vector signed short)
13564
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
623 vec_perm (uyvy, (vector unsigned char)AVV(0), demux_u);
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
624
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
625 V = (vector signed short)
13564
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
626 vec_perm (uyvy, (vector unsigned char)AVV(0), demux_v);
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
627
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
628 Y = (vector signed short)
13564
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
629 vec_perm (uyvy, (vector unsigned char)AVV(0), demux_y);
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
630
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
631 cvtyuvtoRGB (c, Y,U,V,&R0,&G0,&B0);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
632
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
633 uyvy = vec_ld (16, img);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
634 U = (vector signed short)
13564
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
635 vec_perm (uyvy, (vector unsigned char)AVV(0), demux_u);
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
636
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
637 V = (vector signed short)
13564
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
638 vec_perm (uyvy, (vector unsigned char)AVV(0), demux_v);
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
639
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
640 Y = (vector signed short)
13564
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
641 vec_perm (uyvy, (vector unsigned char)AVV(0), demux_y);
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
642
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
643 cvtyuvtoRGB (c, Y,U,V,&R1,&G1,&B1);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
644
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
645 R = vec_packclp (R0,R1);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
646 G = vec_packclp (G0,G1);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
647 B = vec_packclp (B0,B1);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
648
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
649 // vec_mstbgr24 (R,G,B, out);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
650 out_rgba (R,G,B,out);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
651
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
652 img += 32;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
653 }
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
654 }
12836
9a310b31359f some fixes
alex
parents: 12698
diff changeset
655 return srcSliceH;
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
656 }
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
657
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
658
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
659
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
660 /* Ok currently the acceleration routine only supports
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
661 inputs of widths a multiple of 16
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
662 and heights a multiple 2
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
663
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
664 So we just fall back to the C codes for this.
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
665 */
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
666 SwsFunc yuv2rgb_init_altivec (SwsContext *c)
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
667 {
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
668 if (!(c->flags & SWS_CPU_CAPS_ALTIVEC))
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
669 return NULL;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
670
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
671 /*
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
672 and this seems not to matter too much I tried a bunch of
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
673 videos with abnormal widths and mplayer crashes else where.
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
674 mplayer -vo x11 -rawvideo on:w=350:h=240 raw-350x240.eyuv
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
675 boom with X11 bad match.
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
676
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
677 */
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
678 if ((c->srcW & 0xf) != 0) return NULL;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
679
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
680 switch (c->srcFormat) {
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
681 case IMGFMT_YVU9:
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
682 case IMGFMT_IF09:
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
683 case IMGFMT_YV12:
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
684 case IMGFMT_I420:
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
685 case IMGFMT_IYUV:
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
686 case IMGFMT_CLPL:
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
687 case IMGFMT_Y800:
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
688 case IMGFMT_Y8:
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
689 case IMGFMT_NV12:
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
690 case IMGFMT_NV21:
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
691 if ((c->srcH & 0x1) != 0)
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
692 return NULL;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
693
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
694 switch(c->dstFormat){
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
695 case IMGFMT_RGB24:
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
696 MSG_WARN("ALTIVEC: Color Space RGB24\n");
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
697 return altivec_yuv2_rgb24;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
698 case IMGFMT_BGR24:
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
699 MSG_WARN("ALTIVEC: Color Space BGR24\n");
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
700 return altivec_yuv2_bgr24;
17844
194a848d907f Support all 4 of ARGB/RGBA/BGRA/ABGR unscaled conversions, with more
pacman
parents: 17642
diff changeset
701 case IMGFMT_ARGB:
194a848d907f Support all 4 of ARGB/RGBA/BGRA/ABGR unscaled conversions, with more
pacman
parents: 17642
diff changeset
702 MSG_WARN("ALTIVEC: Color Space ARGB\n");
194a848d907f Support all 4 of ARGB/RGBA/BGRA/ABGR unscaled conversions, with more
pacman
parents: 17642
diff changeset
703 return altivec_yuv2_argb;
194a848d907f Support all 4 of ARGB/RGBA/BGRA/ABGR unscaled conversions, with more
pacman
parents: 17642
diff changeset
704 case IMGFMT_ABGR:
194a848d907f Support all 4 of ARGB/RGBA/BGRA/ABGR unscaled conversions, with more
pacman
parents: 17642
diff changeset
705 MSG_WARN("ALTIVEC: Color Space ABGR\n");
194a848d907f Support all 4 of ARGB/RGBA/BGRA/ABGR unscaled conversions, with more
pacman
parents: 17642
diff changeset
706 return altivec_yuv2_abgr;
194a848d907f Support all 4 of ARGB/RGBA/BGRA/ABGR unscaled conversions, with more
pacman
parents: 17642
diff changeset
707 case IMGFMT_RGBA:
194a848d907f Support all 4 of ARGB/RGBA/BGRA/ABGR unscaled conversions, with more
pacman
parents: 17642
diff changeset
708 MSG_WARN("ALTIVEC: Color Space RGBA\n");
194a848d907f Support all 4 of ARGB/RGBA/BGRA/ABGR unscaled conversions, with more
pacman
parents: 17642
diff changeset
709 return altivec_yuv2_rgba;
194a848d907f Support all 4 of ARGB/RGBA/BGRA/ABGR unscaled conversions, with more
pacman
parents: 17642
diff changeset
710 case IMGFMT_BGRA:
194a848d907f Support all 4 of ARGB/RGBA/BGRA/ABGR unscaled conversions, with more
pacman
parents: 17642
diff changeset
711 MSG_WARN("ALTIVEC: Color Space BGRA\n");
194a848d907f Support all 4 of ARGB/RGBA/BGRA/ABGR unscaled conversions, with more
pacman
parents: 17642
diff changeset
712 return altivec_yuv2_bgra;
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
713 default: return NULL;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
714 }
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
715 break;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
716
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
717 case IMGFMT_UYVY:
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
718 switch(c->dstFormat){
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
719 case IMGFMT_RGB32:
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
720 MSG_WARN("ALTIVEC: Color Space UYVY -> RGB32\n");
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
721 return altivec_uyvy_rgb32;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
722 default: return NULL;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
723 }
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
724 break;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
725
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
726 }
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
727 return NULL;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
728 }
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
729
13564
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
730 static uint16_t roundToInt16(int64_t f){
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
731 int r= (f + (1<<15))>>16;
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
732 if(r<-0x7FFF) return 0x8000;
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
733 else if(r> 0x7FFF) return 0x7FFF;
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
734 else return r;
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
735 }
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
736
13564
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
737 void yuv2rgb_altivec_init_tables (SwsContext *c, const int inv_table[4],int brightness,int contrast, int saturation)
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
738 {
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
739 union {
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
740 signed short tmp[8] __attribute__ ((aligned(16)));
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
741 vector signed short vec;
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
742 } buf;
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
743
13564
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
744 buf.tmp[0] = ( (0xffffLL) * contrast>>8 )>>9; //cy
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
745 buf.tmp[1] = -256*brightness; //oy
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
746 buf.tmp[2] = (inv_table[0]>>3) *(contrast>>16)*(saturation>>16); //crv
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
747 buf.tmp[3] = (inv_table[1]>>3) *(contrast>>16)*(saturation>>16); //cbu
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
748 buf.tmp[4] = -((inv_table[2]>>1)*(contrast>>16)*(saturation>>16)); //cgu
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
749 buf.tmp[5] = -((inv_table[3]>>1)*(contrast>>16)*(saturation>>16)); //cgv
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
750
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
751
17638
ee8d71a1b7ba Fix vec_clip for gcc's that don't handle (vector signed short){16} according
pacman
parents: 17588
diff changeset
752 c->CSHIFT = (vector unsigned short)vec_splat_u16(2);
13564
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
753 c->CY = vec_splat ((vector signed short)buf.vec, 0);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
754 c->OY = vec_splat ((vector signed short)buf.vec, 1);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
755 c->CRV = vec_splat ((vector signed short)buf.vec, 2);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
756 c->CBU = vec_splat ((vector signed short)buf.vec, 3);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
757 c->CGU = vec_splat ((vector signed short)buf.vec, 4);
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
758 c->CGV = vec_splat ((vector signed short)buf.vec, 5);
12836
9a310b31359f some fixes
alex
parents: 12698
diff changeset
759 #if 0
13564
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
760 {
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
761 int i;
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
762 char *v[6]={"cy","oy","crv","cbu","cgu","cgv"};
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
763 for (i=0; i<6;i++)
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
764 printf("%s %d ", v[i],buf.tmp[i] );
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
765 printf("\n");
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
766 }
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
767 #endif
12836
9a310b31359f some fixes
alex
parents: 12698
diff changeset
768 return;
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
769 }
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
770
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
771
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
772 void
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
773 altivec_yuv2packedX (SwsContext *c,
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
774 int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
775 int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
776 uint8_t *dest, int dstW, int dstY)
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
777 {
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
778 int i,j;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
779 short *f;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
780 vector signed short X,X0,X1,Y0,U0,V0,Y1,U1,V1,U,V;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
781 vector signed short R0,G0,B0,R1,G1,B1;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
782
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
783 vector unsigned char R,G,B,pels[3];
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
784 vector unsigned char *out,*nout;
13564
992960f68af0 postproc/yuv2rgb_altivec.c compile fix
michael
parents: 12837
diff changeset
785
17638
ee8d71a1b7ba Fix vec_clip for gcc's that don't handle (vector signed short){16} according
pacman
parents: 17588
diff changeset
786 vector signed short RND = vec_splat_s16(1<<3);
ee8d71a1b7ba Fix vec_clip for gcc's that don't handle (vector signed short){16} according
pacman
parents: 17588
diff changeset
787 vector unsigned short SCL = vec_splat_u16(4);
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
788 unsigned long scratch[16] __attribute__ ((aligned (16)));
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
789
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
790 vector signed short *YCoeffs, *CCoeffs;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
791
17588
79081ba52e00 Move the v{Y,C}CoeffsBank vectors into the SwsContext, filling them in just
diego
parents: 17563
diff changeset
792 YCoeffs = c->vYCoeffsBank+dstY*lumFilterSize;
79081ba52e00 Move the v{Y,C}CoeffsBank vectors into the SwsContext, filling them in just
diego
parents: 17563
diff changeset
793 CCoeffs = c->vCCoeffsBank+dstY*chrFilterSize;
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
794
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
795 out = (vector unsigned char *)dest;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
796
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
797 for(i=0; i<dstW; i+=16){
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
798 Y0 = RND;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
799 Y1 = RND;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
800 /* extract 16 coeffs from lumSrc */
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
801 for(j=0; j<lumFilterSize; j++) {
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
802 X0 = vec_ld (0, &lumSrc[j][i]);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
803 X1 = vec_ld (16, &lumSrc[j][i]);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
804 Y0 = vec_mradds (X0, YCoeffs[j], Y0);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
805 Y1 = vec_mradds (X1, YCoeffs[j], Y1);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
806 }
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
807
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
808 U = RND;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
809 V = RND;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
810 /* extract 8 coeffs from U,V */
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
811 for(j=0; j<chrFilterSize; j++) {
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
812 X = vec_ld (0, &chrSrc[j][i/2]);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
813 U = vec_mradds (X, CCoeffs[j], U);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
814 X = vec_ld (0, &chrSrc[j][i/2+2048]);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
815 V = vec_mradds (X, CCoeffs[j], V);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
816 }
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
817
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
818 /* scale and clip signals */
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
819 Y0 = vec_sra (Y0, SCL);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
820 Y1 = vec_sra (Y1, SCL);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
821 U = vec_sra (U, SCL);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
822 V = vec_sra (V, SCL);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
823
17638
ee8d71a1b7ba Fix vec_clip for gcc's that don't handle (vector signed short){16} according
pacman
parents: 17588
diff changeset
824 Y0 = vec_clip_s16 (Y0);
ee8d71a1b7ba Fix vec_clip for gcc's that don't handle (vector signed short){16} according
pacman
parents: 17588
diff changeset
825 Y1 = vec_clip_s16 (Y1);
ee8d71a1b7ba Fix vec_clip for gcc's that don't handle (vector signed short){16} according
pacman
parents: 17588
diff changeset
826 U = vec_clip_s16 (U);
ee8d71a1b7ba Fix vec_clip for gcc's that don't handle (vector signed short){16} according
pacman
parents: 17588
diff changeset
827 V = vec_clip_s16 (V);
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
828
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
829 /* now we have
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
830 Y0= y0 y1 y2 y3 y4 y5 y6 y7 Y1= y8 y9 y10 y11 y12 y13 y14 y15
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
831 U= u0 u1 u2 u3 u4 u5 u6 u7 V= v0 v1 v2 v3 v4 v5 v6 v7
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
832
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
833 Y0= y0 y1 y2 y3 y4 y5 y6 y7 Y1= y8 y9 y10 y11 y12 y13 y14 y15
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
834 U0= u0 u0 u1 u1 u2 u2 u3 u3 U1= u4 u4 u5 u5 u6 u6 u7 u7
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
835 V0= v0 v0 v1 v1 v2 v2 v3 v3 V1= v4 v4 v5 v5 v6 v6 v7 v7
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
836 */
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
837
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
838 U0 = vec_mergeh (U,U);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
839 V0 = vec_mergeh (V,V);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
840
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
841 U1 = vec_mergel (U,U);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
842 V1 = vec_mergel (V,V);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
843
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
844 cvtyuvtoRGB (c, Y0,U0,V0,&R0,&G0,&B0);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
845 cvtyuvtoRGB (c, Y1,U1,V1,&R1,&G1,&B1);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
846
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
847 R = vec_packclp (R0,R1);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
848 G = vec_packclp (G0,G1);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
849 B = vec_packclp (B0,B1);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
850
17560
1a54f39404b9 altivec_yuv2packedX() ignores the requested output format and unconditionally
diego
parents: 17558
diff changeset
851 switch(c->dstFormat) {
1a54f39404b9 altivec_yuv2packedX() ignores the requested output format and unconditionally
diego
parents: 17558
diff changeset
852 case IMGFMT_ABGR: out_abgr (R,G,B,out); break;
1a54f39404b9 altivec_yuv2packedX() ignores the requested output format and unconditionally
diego
parents: 17558
diff changeset
853 case IMGFMT_BGRA: out_bgra (R,G,B,out); break;
1a54f39404b9 altivec_yuv2packedX() ignores the requested output format and unconditionally
diego
parents: 17558
diff changeset
854 case IMGFMT_RGBA: out_rgba (R,G,B,out); break;
1a54f39404b9 altivec_yuv2packedX() ignores the requested output format and unconditionally
diego
parents: 17558
diff changeset
855 case IMGFMT_ARGB: out_argb (R,G,B,out); break;
1a54f39404b9 altivec_yuv2packedX() ignores the requested output format and unconditionally
diego
parents: 17558
diff changeset
856 case IMGFMT_RGB24: out_rgb24 (R,G,B,out); break;
1a54f39404b9 altivec_yuv2packedX() ignores the requested output format and unconditionally
diego
parents: 17558
diff changeset
857 case IMGFMT_BGR24: out_bgr24 (R,G,B,out); break;
1a54f39404b9 altivec_yuv2packedX() ignores the requested output format and unconditionally
diego
parents: 17558
diff changeset
858 default:
1a54f39404b9 altivec_yuv2packedX() ignores the requested output format and unconditionally
diego
parents: 17558
diff changeset
859 {
17642
64e5c4e34f07 Just a comment update, replacing a FIXME to reflect the new expectation of
pacman
parents: 17638
diff changeset
860 /* If this is reached, the caller should have called yuv2packedXinC
64e5c4e34f07 Just a comment update, replacing a FIXME to reflect the new expectation of
pacman
parents: 17638
diff changeset
861 instead. */
17560
1a54f39404b9 altivec_yuv2packedX() ignores the requested output format and unconditionally
diego
parents: 17558
diff changeset
862 static int printed_error_message;
1a54f39404b9 altivec_yuv2packedX() ignores the requested output format and unconditionally
diego
parents: 17558
diff changeset
863 if(!printed_error_message) {
1a54f39404b9 altivec_yuv2packedX() ignores the requested output format and unconditionally
diego
parents: 17558
diff changeset
864 MSG_ERR("altivec_yuv2packedX doesn't support %s output\n",
1a54f39404b9 altivec_yuv2packedX() ignores the requested output format and unconditionally
diego
parents: 17558
diff changeset
865 vo_format_name(c->dstFormat));
1a54f39404b9 altivec_yuv2packedX() ignores the requested output format and unconditionally
diego
parents: 17558
diff changeset
866 printed_error_message=1;
1a54f39404b9 altivec_yuv2packedX() ignores the requested output format and unconditionally
diego
parents: 17558
diff changeset
867 }
1a54f39404b9 altivec_yuv2packedX() ignores the requested output format and unconditionally
diego
parents: 17558
diff changeset
868 return;
1a54f39404b9 altivec_yuv2packedX() ignores the requested output format and unconditionally
diego
parents: 17558
diff changeset
869 }
1a54f39404b9 altivec_yuv2packedX() ignores the requested output format and unconditionally
diego
parents: 17558
diff changeset
870 }
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
871 }
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
872
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
873 if (i < dstW) {
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
874 i -= 16;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
875
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
876 Y0 = RND;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
877 Y1 = RND;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
878 /* extract 16 coeffs from lumSrc */
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
879 for(j=0; j<lumFilterSize; j++) {
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
880 X0 = vec_ld (0, &lumSrc[j][i]);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
881 X1 = vec_ld (16, &lumSrc[j][i]);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
882 Y0 = vec_mradds (X0, YCoeffs[j], Y0);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
883 Y1 = vec_mradds (X1, YCoeffs[j], Y1);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
884 }
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
885
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
886 U = RND;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
887 V = RND;
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
888 /* extract 8 coeffs from U,V */
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
889 for(j=0; j<chrFilterSize; j++) {
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
890 X = vec_ld (0, &chrSrc[j][i/2]);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
891 U = vec_mradds (X, CCoeffs[j], U);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
892 X = vec_ld (0, &chrSrc[j][i/2+2048]);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
893 V = vec_mradds (X, CCoeffs[j], V);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
894 }
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
895
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
896 /* scale and clip signals */
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
897 Y0 = vec_sra (Y0, SCL);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
898 Y1 = vec_sra (Y1, SCL);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
899 U = vec_sra (U, SCL);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
900 V = vec_sra (V, SCL);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
901
17638
ee8d71a1b7ba Fix vec_clip for gcc's that don't handle (vector signed short){16} according
pacman
parents: 17588
diff changeset
902 Y0 = vec_clip_s16 (Y0);
ee8d71a1b7ba Fix vec_clip for gcc's that don't handle (vector signed short){16} according
pacman
parents: 17588
diff changeset
903 Y1 = vec_clip_s16 (Y1);
ee8d71a1b7ba Fix vec_clip for gcc's that don't handle (vector signed short){16} according
pacman
parents: 17588
diff changeset
904 U = vec_clip_s16 (U);
ee8d71a1b7ba Fix vec_clip for gcc's that don't handle (vector signed short){16} according
pacman
parents: 17588
diff changeset
905 V = vec_clip_s16 (V);
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
906
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
907 /* now we have
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
908 Y0= y0 y1 y2 y3 y4 y5 y6 y7 Y1= y8 y9 y10 y11 y12 y13 y14 y15
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
909 U= u0 u1 u2 u3 u4 u5 u6 u7 V= v0 v1 v2 v3 v4 v5 v6 v7
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
910
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
911 Y0= y0 y1 y2 y3 y4 y5 y6 y7 Y1= y8 y9 y10 y11 y12 y13 y14 y15
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
912 U0= u0 u0 u1 u1 u2 u2 u3 u3 U1= u4 u4 u5 u5 u6 u6 u7 u7
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
913 V0= v0 v0 v1 v1 v2 v2 v3 v3 V1= v4 v4 v5 v5 v6 v6 v7 v7
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
914 */
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
915
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
916 U0 = vec_mergeh (U,U);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
917 V0 = vec_mergeh (V,V);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
918
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
919 U1 = vec_mergel (U,U);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
920 V1 = vec_mergel (V,V);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
921
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
922 cvtyuvtoRGB (c, Y0,U0,V0,&R0,&G0,&B0);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
923 cvtyuvtoRGB (c, Y1,U1,V1,&R1,&G1,&B1);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
924
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
925 R = vec_packclp (R0,R1);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
926 G = vec_packclp (G0,G1);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
927 B = vec_packclp (B0,B1);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
928
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
929 nout = (vector unsigned char *)scratch;
17560
1a54f39404b9 altivec_yuv2packedX() ignores the requested output format and unconditionally
diego
parents: 17558
diff changeset
930 switch(c->dstFormat) {
1a54f39404b9 altivec_yuv2packedX() ignores the requested output format and unconditionally
diego
parents: 17558
diff changeset
931 case IMGFMT_ABGR: out_abgr (R,G,B,nout); break;
1a54f39404b9 altivec_yuv2packedX() ignores the requested output format and unconditionally
diego
parents: 17558
diff changeset
932 case IMGFMT_BGRA: out_bgra (R,G,B,nout); break;
1a54f39404b9 altivec_yuv2packedX() ignores the requested output format and unconditionally
diego
parents: 17558
diff changeset
933 case IMGFMT_RGBA: out_rgba (R,G,B,nout); break;
1a54f39404b9 altivec_yuv2packedX() ignores the requested output format and unconditionally
diego
parents: 17558
diff changeset
934 case IMGFMT_ARGB: out_argb (R,G,B,nout); break;
1a54f39404b9 altivec_yuv2packedX() ignores the requested output format and unconditionally
diego
parents: 17558
diff changeset
935 case IMGFMT_RGB24: out_rgb24 (R,G,B,nout); break;
1a54f39404b9 altivec_yuv2packedX() ignores the requested output format and unconditionally
diego
parents: 17558
diff changeset
936 case IMGFMT_BGR24: out_bgr24 (R,G,B,nout); break;
1a54f39404b9 altivec_yuv2packedX() ignores the requested output format and unconditionally
diego
parents: 17558
diff changeset
937 default:
1a54f39404b9 altivec_yuv2packedX() ignores the requested output format and unconditionally
diego
parents: 17558
diff changeset
938 /* Unreachable, I think. */
1a54f39404b9 altivec_yuv2packedX() ignores the requested output format and unconditionally
diego
parents: 17558
diff changeset
939 MSG_ERR("altivec_yuv2packedX doesn't support %s output\n",
1a54f39404b9 altivec_yuv2packedX() ignores the requested output format and unconditionally
diego
parents: 17558
diff changeset
940 vo_format_name(c->dstFormat));
1a54f39404b9 altivec_yuv2packedX() ignores the requested output format and unconditionally
diego
parents: 17558
diff changeset
941 return;
1a54f39404b9 altivec_yuv2packedX() ignores the requested output format and unconditionally
diego
parents: 17558
diff changeset
942 }
12698
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
943
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
944 memcpy (&((uint32_t*)dest)[i], scratch, (dstW-i)/4);
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
945 }
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
946
d2aef091743c altivec yuv->rgb converter
michael
parents:
diff changeset
947 }