annotate libswscale/yuv2rgb_altivec.c @ 20019:0ab333ee888c

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