annotate libswscale/ppc/yuv2rgb_altivec.c @ 29265:8f7e539305a0

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