Mercurial > mplayer.hg
annotate libvo/yuv2rgb_mmx.c @ 915:604a32fcb501
fixed bugs noticed by Jeremy Rosen <jeremy.rosen@enst-bretagne.fr>
author | eyck |
---|---|
date | Thu, 31 May 2001 09:04:33 +0000 |
parents | 1a016347010a |
children | ed6ac3915d59 |
rev | line source |
---|---|
1 | 1 |
2 /* | |
3 * yuv2rgb_mmx.c, Software YUV to RGB coverter with Intel MMX "technology" | |
4 * | |
5 * Copyright (C) 2000, Silicon Integrated System Corp. | |
6 * All Rights Reserved. | |
7 * | |
8 * Author: Olie Lho <ollie@sis.com.tw> | |
9 * | |
10 * This file is part of mpeg2dec, a free MPEG-2 video decoder | |
11 * | |
12 * mpeg2dec is free software; you can redistribute it and/or modify | |
13 * it under the terms of the GNU General Public License as published by | |
14 * the Free Software Foundation; either version 2, or (at your option) | |
15 * any later version. | |
16 * | |
17 * mpeg2dec is distributed in the hope that it will be useful, | |
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 * GNU General Public License for more details. | |
21 * | |
22 * You should have received a copy of the GNU General Public License | |
23 * along with GNU Make; see the file COPYING. If not, write to | |
24 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
25 * | |
26 */ | |
27 | |
28 #include <stdio.h> | |
29 #include <stdlib.h> | |
30 | |
31 #include "mmx.h" | |
32 //#include "libmpeg2/mpeg2.h" | |
33 //#include "libmpeg2/mpeg2_internal.h" | |
34 #include <inttypes.h> | |
35 | |
36 #include "yuv2rgb.h" | |
37 | |
38 /* hope these constant values are cache line aligned */ | |
39 uint64_t mmx_80w = 0x0080008000800080; | |
40 uint64_t mmx_10w = 0x1010101010101010; | |
41 uint64_t mmx_00ffw = 0x00ff00ff00ff00ff; | |
42 uint64_t mmx_Y_coeff = 0x253f253f253f253f; | |
43 | |
44 /* hope these constant values are cache line aligned */ | |
45 uint64_t mmx_U_green = 0xf37df37df37df37d; | |
46 uint64_t mmx_U_blue = 0x4093409340934093; | |
47 uint64_t mmx_V_red = 0x3312331233123312; | |
48 uint64_t mmx_V_green = 0xe5fce5fce5fce5fc; | |
49 | |
50 /* hope these constant values are cache line aligned */ | |
51 uint64_t mmx_redmask = 0xf8f8f8f8f8f8f8f8; | |
52 uint64_t mmx_grnmask = 0xfcfcfcfcfcfcfcfc; | |
53 uint64_t mmx_grnshift = 0x03; | |
54 uint64_t mmx_blueshift = 0x03; | |
55 | |
688
1a016347010a
movntq causes SIGILL on k6-3. Lets it be for K7, P3 cpus only
nickols_k
parents:
1
diff
changeset
|
56 #ifdef HAVE_MMX2 |
1a016347010a
movntq causes SIGILL on k6-3. Lets it be for K7, P3 cpus only
nickols_k
parents:
1
diff
changeset
|
57 #define movntq "movntq" // use this for K7 and p3 only |
1 | 58 #else |
59 #define movntq "movq" // for MMX-only processors | |
60 #endif | |
61 | |
62 static void yuv420_rgb16_mmx (uint8_t * image, uint8_t * py, | |
63 uint8_t * pu, uint8_t * pv, | |
64 int h_size, int v_size, | |
65 int rgb_stride, int y_stride, int uv_stride) | |
66 { | |
67 int even = 1; | |
68 int x = 0, y = 0; | |
69 | |
70 /* load data for first scan line */ | |
71 __asm__ ( | |
72 "movd (%1), %%mm0 # Load 4 Cb 00 00 00 00 u3 u2 u1 u0\n\t" | |
73 "movd (%2), %%mm1 # Load 4 Cr 00 00 00 00 v3 v2 v1 v0\n\t" | |
74 | |
75 "pxor %%mm4, %%mm4 # zero mm4\n\t" | |
76 "movq (%0), %%mm6 # Load 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0\n\t" | |
77 | |
78 //"movl $0, (%3) # cache preload for image\n\t" | |
79 : : "r" (py), "r" (pu), "r" (pv), "r" (image)); | |
80 | |
81 do { | |
82 do { | |
83 /* this mmx assembly code deals with SINGLE scan line at a time, it convert 8 | |
84 pixels in each iteration */ | |
85 __asm__ (".align 8 \n\t" | |
86 /* Do the multiply part of the conversion for even and odd pixels, | |
87 register usage: | |
88 mm0 -> Cblue, mm1 -> Cred, mm2 -> Cgreen even pixels, | |
89 mm3 -> Cblue, mm4 -> Cred, mm5 -> Cgreen odd pixels, | |
90 mm6 -> Y even, mm7 -> Y odd */ | |
91 /* convert the chroma part */ | |
92 "punpcklbw %%mm4, %%mm0 # scatter 4 Cb 00 u3 00 u2 00 u1 00 u0\n\t" | |
93 "punpcklbw %%mm4, %%mm1 # scatter 4 Cr 00 v3 00 v2 00 v1 00 v0\n\t" | |
94 | |
95 "psubsw mmx_80w, %%mm0 # Cb -= 128\n\t" | |
96 "psubsw mmx_80w, %%mm1 # Cr -= 128\n\t" | |
97 | |
98 "psllw $3, %%mm0 # Promote precision\n\t" | |
99 "psllw $3, %%mm1 # Promote precision\n\t" | |
100 | |
101 "movq %%mm0, %%mm2 # Copy 4 Cb 00 u3 00 u2 00 u1 00 u0\n\t" | |
102 "movq %%mm1, %%mm3 # Copy 4 Cr 00 v3 00 v2 00 v1 00 v0\n\t" | |
103 | |
104 "pmulhw mmx_U_green, %%mm2# Mul Cb with green coeff -> Cb green\n\t" | |
105 "pmulhw mmx_V_green, %%mm3# Mul Cr with green coeff -> Cr green\n\t" | |
106 | |
107 "pmulhw mmx_U_blue, %%mm0 # Mul Cb -> Cblue 00 b3 00 b2 00 b1 00 b0\n\t" | |
108 "pmulhw mmx_V_red, %%mm1 # Mul Cr -> Cred 00 r3 00 r2 00 r1 00 r0\n\t" | |
109 | |
110 "paddsw %%mm3, %%mm2 # Cb green + Cr green -> Cgreen\n\t" | |
111 | |
112 /* convert the luma part */ | |
113 "psubusb mmx_10w, %%mm6 # Y -= 16\n\t" | |
114 | |
115 "movq %%mm6, %%mm7 # Copy 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0\n\t" | |
116 "pand mmx_00ffw, %%mm6 # get Y even 00 Y6 00 Y4 00 Y2 00 Y0\n\t" | |
117 | |
118 "psrlw $8, %%mm7 # get Y odd 00 Y7 00 Y5 00 Y3 00 Y1\n\t" | |
119 | |
120 "psllw $3, %%mm6 # Promote precision\n\t" | |
121 "psllw $3, %%mm7 # Promote precision\n\t" | |
122 | |
123 "pmulhw mmx_Y_coeff, %%mm6# Mul 4 Y even 00 y6 00 y4 00 y2 00 y0\n\t" | |
124 "pmulhw mmx_Y_coeff, %%mm7# Mul 4 Y odd 00 y7 00 y5 00 y3 00 y1\n\t" | |
125 | |
126 /* Do the addition part of the conversion for even and odd pixels, | |
127 register usage: | |
128 mm0 -> Cblue, mm1 -> Cred, mm2 -> Cgreen even pixels, | |
129 mm3 -> Cblue, mm4 -> Cred, mm5 -> Cgreen odd pixels, | |
130 mm6 -> Y even, mm7 -> Y odd */ | |
131 "movq %%mm0, %%mm3 # Copy Cblue\n\t" | |
132 "movq %%mm1, %%mm4 # Copy Cred\n\t" | |
133 "movq %%mm2, %%mm5 # Copy Cgreen\n\t" | |
134 | |
135 "paddsw %%mm6, %%mm0 # Y even + Cblue 00 B6 00 B4 00 B2 00 B0\n\t" | |
136 "paddsw %%mm7, %%mm3 # Y odd + Cblue 00 B7 00 B5 00 B3 00 B1\n\t" | |
137 | |
138 "paddsw %%mm6, %%mm1 # Y even + Cred 00 R6 00 R4 00 R2 00 R0\n\t" | |
139 "paddsw %%mm7, %%mm4 # Y odd + Cred 00 R7 00 R5 00 R3 00 R1\n\t" | |
140 | |
141 "paddsw %%mm6, %%mm2 # Y even + Cgreen 00 G6 00 G4 00 G2 00 G0\n\t" | |
142 "paddsw %%mm7, %%mm5 # Y odd + Cgreen 00 G7 00 G5 00 G3 00 G1\n\t" | |
143 | |
144 /* Limit RGB even to 0..255 */ | |
145 "packuswb %%mm0, %%mm0 # B6 B4 B2 B0 | B6 B4 B2 B0\n\t" | |
146 "packuswb %%mm1, %%mm1 # R6 R4 R2 R0 | R6 R4 R2 R0\n\t" | |
147 "packuswb %%mm2, %%mm2 # G6 G4 G2 G0 | G6 G4 G2 G0\n\t" | |
148 | |
149 /* Limit RGB odd to 0..255 */ | |
150 "packuswb %%mm3, %%mm3 # B7 B5 B3 B1 | B7 B5 B3 B1\n\t" | |
151 "packuswb %%mm4, %%mm4 # R7 R5 R3 R1 | R7 R5 R3 R1\n\t" | |
152 "packuswb %%mm5, %%mm5 # G7 G5 G3 G1 | G7 G5 G3 G1\n\t" | |
153 | |
154 /* Interleave RGB even and odd */ | |
155 "punpcklbw %%mm3, %%mm0 # B7 B6 B5 B4 B3 B2 B1 B0\n\t" | |
156 "punpcklbw %%mm4, %%mm1 # R7 R6 R5 R4 R3 R2 R1 R0\n\t" | |
157 "punpcklbw %%mm5, %%mm2 # G7 G6 G5 G4 G3 G2 G1 G0\n\t" | |
158 | |
159 /* mask unneeded bits off */ | |
160 "pand mmx_redmask, %%mm0# b7b6b5b4 b3_0_0_0 b7b6b5b4 b3_0_0_0\n\t" | |
161 "pand mmx_grnmask, %%mm2# g7g6g5g4 g3g2_0_0 g7g6g5g4 g3g2_0_0\n\t" | |
162 "pand mmx_redmask, %%mm1# r7r6r5r4 r3_0_0_0 r7r6r5r4 r3_0_0_0\n\t" | |
163 | |
164 "psrlw mmx_blueshift,%%mm0#0_0_0_b7 b6b5b4b3 0_0_0_b7 b6b5b4b3\n\t" | |
165 "pxor %%mm4, %%mm4 # zero mm4\n\t" | |
166 | |
167 "movq %%mm0, %%mm5 # Copy B7-B0\n\t" | |
168 "movq %%mm2, %%mm7 # Copy G7-G0\n\t" | |
169 | |
170 /* convert rgb24 plane to rgb16 pack for pixel 0-3 */ | |
171 "punpcklbw %%mm4, %%mm2 # 0_0_0_0 0_0_0_0 g7g6g5g4 g3g2_0_0\n\t" | |
172 "punpcklbw %%mm1, %%mm0 # r7r6r5r4 r3_0_0_0 0_0_0_b7 b6b5b4b3\n\t" | |
173 | |
174 "psllw mmx_blueshift,%%mm2# 0_0_0_0 0_g7g6g5 g4g3g2_0 0_0_0_0\n\t" | |
175 "por %%mm2, %%mm0 # r7r6r5r4 r3g7g6g5 g4g3g2b7 b6b5b4b3\n\t" | |
176 | |
177 "movq 8 (%0), %%mm6 # Load 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0\n\t" | |
178 movntq " %%mm0, (%3) # store pixel 0-3\n\t" | |
179 | |
180 /* convert rgb24 plane to rgb16 pack for pixel 0-3 */ | |
181 "punpckhbw %%mm4, %%mm7 # 0_0_0_0 0_0_0_0 g7g6g5g4 g3g2_0_0\n\t" | |
182 "punpckhbw %%mm1, %%mm5 # r7r6r5r4 r3_0_0_0 0_0_0_b7 b6b5b4b3\n\t" | |
183 | |
184 "psllw mmx_blueshift,%%mm7# 0_0_0_0 0_g7g6g5 g4g3g2_0 0_0_0_0\n\t" | |
185 "movd 4 (%1), %%mm0 # Load 4 Cb 00 00 00 00 u3 u2 u1 u0\n\t" | |
186 | |
187 "por %%mm7, %%mm5 # r7r6r5r4 r3g7g6g5 g4g3g2b7 b6b5b4b3\n\t" | |
188 "movd 4 (%2), %%mm1 # Load 4 Cr 00 00 00 00 v3 v2 v1 v0\n\t" | |
189 | |
190 movntq " %%mm5, 8 (%3) # store pixel 4-7\n\t" | |
191 : : "r" (py), "r" (pu), "r" (pv), "r" (image)); | |
192 | |
193 py += 8; | |
194 pu += 4; | |
195 pv += 4; | |
196 image += 16; | |
197 x += 8; | |
198 } while (x < h_size); | |
199 | |
200 if (even) { | |
201 pu -= h_size/2; | |
202 pv -= h_size/2; | |
203 } else { | |
204 pu += (uv_stride - h_size/2); | |
205 pv += (uv_stride - h_size/2); | |
206 } | |
207 | |
208 py += (y_stride - h_size); | |
209 image += (rgb_stride - 2*h_size); | |
210 | |
211 /* load data for start of next scan line */ | |
212 __asm__ ( | |
213 "movd (%1), %%mm0 # Load 4 Cb 00 00 00 00 00 u3 u2 u1 u0\n\t" | |
214 "movd (%2), %%mm1 # Load 4 Cr 00 00 00 00 00 v2 v1 v0\n\t" | |
215 | |
216 //"movl $0, (%3) # cache preload for image\n\t" | |
217 "movq (%0), %%mm6 # Load 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0\n\t" | |
218 | |
219 : : "r" (py), "r" (pu), "r" (pv), "r" (image)); | |
220 | |
221 x = 0; | |
222 y += 1; | |
223 even = (!even); | |
224 } while (y < v_size) ; | |
225 | |
226 __asm__ ("emms\n\t"); | |
227 } | |
228 | |
229 static void yuv420_argb32_mmx (uint8_t * image, uint8_t * py, | |
230 uint8_t * pu, uint8_t * pv, | |
231 int h_size, int v_size, | |
232 int rgb_stride, int y_stride, int uv_stride) | |
233 { | |
234 int even = 1; | |
235 int x = 0, y = 0; | |
236 | |
237 __asm__ ( | |
238 ".align 8 \n\t" | |
239 "movd (%1), %%mm0 # Load 4 Cb 00 00 00 00 u3 u2 u1 u0\n\t" | |
240 //"movl $0, (%3) # cache preload for image\n\t" | |
241 | |
242 "movd (%2), %%mm1 # Load 4 Cr 00 00 00 00 v3 v2 v1 v0\n\t" | |
243 "pxor %%mm4, %%mm4 # zero mm4\n\t" | |
244 | |
245 "movq (%0), %%mm6 # Load 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0\n\t" | |
246 : : "r" (py), "r" (pu), "r" (pv), "r" (image)); | |
247 | |
248 do { | |
249 do { | |
250 /* this mmx assembly code deals with SINGLE scan line at a time, it convert 8 | |
251 pixels in each iteration */ | |
252 __asm__ ( | |
253 ".align 8 \n\t" | |
254 /* Do the multiply part of the conversion for even and odd pixels, | |
255 register usage: | |
256 mm0 -> Cblue, mm1 -> Cred, mm2 -> Cgreen even pixels, | |
257 mm3 -> Cblue, mm4 -> Cred, mm5 -> Cgreen odd pixels, | |
258 mm6 -> Y even, mm7 -> Y odd */ | |
259 | |
260 /* convert the chroma part */ | |
261 "punpcklbw %%mm4, %%mm0 # scatter 4 Cb 00 u3 00 u2 00 u1 00 u0\n\t" | |
262 "punpcklbw %%mm4, %%mm1 # scatter 4 Cr 00 v3 00 v2 00 v1 00 v0\n\t" | |
263 | |
264 "psubsw mmx_80w, %%mm0 # Cb -= 128\n\t" | |
265 "psubsw mmx_80w, %%mm1 # Cr -= 128\n\t" | |
266 | |
267 "psllw $3, %%mm0 # Promote precision\n\t" | |
268 "psllw $3, %%mm1 # Promote precision\n\t" | |
269 | |
270 "movq %%mm0, %%mm2 # Copy 4 Cb 00 u3 00 u2 00 u1 00 u0\n\t" | |
271 "movq %%mm1, %%mm3 # Copy 4 Cr 00 v3 00 v2 00 v1 00 v0\n\t" | |
272 | |
273 "pmulhw mmx_U_green, %%mm2# Mul Cb with green coeff -> Cb green\n\t" | |
274 "pmulhw mmx_V_green, %%mm3# Mul Cr with green coeff -> Cr green\n\t" | |
275 | |
276 "pmulhw mmx_U_blue, %%mm0 # Mul Cb -> Cblue 00 b3 00 b2 00 b1 00 b0\n\t" | |
277 "pmulhw mmx_V_red, %%mm1 # Mul Cr -> Cred 00 r3 00 r2 00 r1 00 r0\n\t" | |
278 | |
279 "paddsw %%mm3, %%mm2 # Cb green + Cr green -> Cgreen\n\t" | |
280 | |
281 /* convert the luma part */ | |
282 "psubusb mmx_10w, %%mm6 # Y -= 16\n\t" | |
283 | |
284 "movq %%mm6, %%mm7 # Copy 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0\n\t" | |
285 "pand mmx_00ffw, %%mm6 # get Y even 00 Y6 00 Y4 00 Y2 00 Y0\n\t" | |
286 | |
287 "psrlw $8, %%mm7 # get Y odd 00 Y7 00 Y5 00 Y3 00 Y1\n\t" | |
288 | |
289 "psllw $3, %%mm6 # Promote precision\n\t" | |
290 "psllw $3, %%mm7 # Promote precision\n\t" | |
291 | |
292 "pmulhw mmx_Y_coeff, %%mm6# Mul 4 Y even 00 y6 00 y4 00 y2 00 y0\n\t" | |
293 "pmulhw mmx_Y_coeff, %%mm7# Mul 4 Y odd 00 y7 00 y5 00 y3 00 y1\n\t" | |
294 | |
295 /* Do the addition part of the conversion for even and odd pixels, | |
296 register usage: | |
297 mm0 -> Cblue, mm1 -> Cred, mm2 -> Cgreen even pixels, | |
298 mm3 -> Cblue, mm4 -> Cred, mm5 -> Cgreen odd pixels, | |
299 mm6 -> Y even, mm7 -> Y odd */ | |
300 | |
301 "movq %%mm0, %%mm3 # Copy Cblue\n\t" | |
302 "movq %%mm1, %%mm4 # Copy Cred\n\t" | |
303 "movq %%mm2, %%mm5 # Copy Cgreen\n\t" | |
304 | |
305 "paddsw %%mm6, %%mm0 # Y even + Cblue 00 B6 00 B4 00 B2 00 B0\n\t" | |
306 "paddsw %%mm7, %%mm3 # Y odd + Cblue 00 B7 00 B5 00 B3 00 B1\n\t" | |
307 | |
308 "paddsw %%mm6, %%mm1 # Y even + Cred 00 R6 00 R4 00 R2 00 R0\n\t" | |
309 "paddsw %%mm7, %%mm4 # Y odd + Cred 00 R7 00 R5 00 R3 00 R1\n\t" | |
310 | |
311 "paddsw %%mm6, %%mm2 # Y even + Cgreen 00 G6 00 G4 00 G2 00 G0\n\t" | |
312 "paddsw %%mm7, %%mm5 # Y odd + Cgreen 00 G7 00 G5 00 G3 00 G1\n\t" | |
313 | |
314 /* Limit RGB even to 0..255 */ | |
315 "packuswb %%mm0, %%mm0 # B6 B4 B2 B0 B6 B4 B2 B0\n\t" | |
316 "packuswb %%mm1, %%mm1 # R6 R4 R2 R0 R6 R4 R2 R0\n\t" | |
317 "packuswb %%mm2, %%mm2 # G6 G4 G2 G0 G6 G4 G2 G0\n\t" | |
318 | |
319 /* Limit RGB odd to 0..255 */ | |
320 "packuswb %%mm3, %%mm3 # B7 B5 B3 B1 B7 B5 B3 B1\n\t" | |
321 "packuswb %%mm4, %%mm4 # R7 R5 R3 R1 R7 R5 R3 R1\n\t" | |
322 "packuswb %%mm5, %%mm5 # G7 G5 G3 G1 G7 G5 G3 G1\n\t" | |
323 | |
324 /* Interleave RGB even and odd */ | |
325 "punpcklbw %%mm3, %%mm0 # B7 B6 B5 B4 B3 B2 B1 B0\n\t" | |
326 "punpcklbw %%mm4, %%mm1 # R7 R6 R5 R4 R3 R2 R1 R0\n\t" | |
327 "punpcklbw %%mm5, %%mm2 # G7 G6 G5 G4 G3 G2 G1 G0\n\t" | |
328 | |
329 /* convert RGB plane to RGB packed format, | |
330 mm0 -> B, mm1 -> R, mm2 -> G, mm3 -> 0, | |
331 mm4 -> GB, mm5 -> AR pixel 4-7, | |
332 mm6 -> GB, mm7 -> AR pixel 0-3 */ | |
333 "pxor %%mm3, %%mm3 # zero mm3\n\t" | |
334 | |
335 "movq %%mm0, %%mm6 # B7 B6 B5 B4 B3 B2 B1 B0\n\t" | |
336 "movq %%mm1, %%mm7 # R7 R6 R5 R4 R3 R2 R1 R0\n\t" | |
337 | |
338 "movq %%mm0, %%mm4 # B7 B6 B5 B4 B3 B2 B1 B0\n\t" | |
339 "movq %%mm1, %%mm5 # R7 R6 R5 R4 R3 R2 R1 R0\n\t" | |
340 | |
341 "punpcklbw %%mm2, %%mm6 # G3 B3 G2 B2 G1 B1 G0 B0\n\t" | |
342 "punpcklbw %%mm3, %%mm7 # 00 R3 00 R2 00 R1 00 R0\n\t" | |
343 | |
344 "punpcklwd %%mm7, %%mm6 # 00 R1 B1 G1 00 R0 B0 G0\n\t" | |
345 movntq " %%mm6, (%3) # Store ARGB1 ARGB0\n\t" | |
346 | |
347 "movq %%mm0, %%mm6 # B7 B6 B5 B4 B3 B2 B1 B0\n\t" | |
348 "punpcklbw %%mm2, %%mm6 # G3 B3 G2 B2 G1 B1 G0 B0\n\t" | |
349 | |
350 "punpckhwd %%mm7, %%mm6 # 00 R3 G3 B3 00 R2 B3 G2\n\t" | |
351 movntq " %%mm6, 8 (%3) # Store ARGB3 ARGB2\n\t" | |
352 | |
353 "punpckhbw %%mm2, %%mm4 # G7 B7 G6 B6 G5 B5 G4 B4\n\t" | |
354 "punpckhbw %%mm3, %%mm5 # 00 R7 00 R6 00 R5 00 R4\n\t" | |
355 | |
356 "punpcklwd %%mm5, %%mm4 # 00 R5 B5 G5 00 R4 B4 G4\n\t" | |
357 movntq " %%mm4, 16 (%3) # Store ARGB5 ARGB4\n\t" | |
358 | |
359 "movq %%mm0, %%mm4 # B7 B6 B5 B4 B3 B2 B1 B0\n\t" | |
360 "punpckhbw %%mm2, %%mm4 # G7 B7 G6 B6 G5 B5 G4 B4\n\t" | |
361 | |
362 "punpckhwd %%mm5, %%mm4 # 00 R7 G7 B7 00 R6 B6 G6\n\t" | |
363 movntq " %%mm4, 24 (%3) # Store ARGB7 ARGB6\n\t" | |
364 | |
365 "movd 4 (%1), %%mm0 # Load 4 Cb 00 00 00 00 u3 u2 u1 u0\n\t" | |
366 "movd 4 (%2), %%mm1 # Load 4 Cr 00 00 00 00 v3 v2 v1 v0\n\t" | |
367 | |
368 "pxor %%mm4, %%mm4 # zero mm4\n\t" | |
369 "movq 8 (%0), %%mm6 # Load 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0\n\t" | |
370 | |
371 : : "r" (py), "r" (pu), "r" (pv), "r" (image)); | |
372 | |
373 py += 8; | |
374 pu += 4; | |
375 pv += 4; | |
376 image += 32; | |
377 x += 8; | |
378 } while (x < h_size); | |
379 | |
380 if (even) { | |
381 pu -= h_size/2; | |
382 pv -= h_size/2; | |
383 } else { | |
384 pu += (uv_stride - h_size/2); | |
385 pv += (uv_stride - h_size/2); | |
386 } | |
387 | |
388 py += (y_stride - h_size); | |
389 image += (rgb_stride - 4*h_size); | |
390 | |
391 /* load data for start of next scan line */ | |
392 __asm__ | |
393 ( | |
394 ".align 8 \n\t" | |
395 "movd (%1), %%mm0 # Load 4 Cb 00 00 00 00 u3 u2 u1 u0\n\t" | |
396 "movd (%2), %%mm1 # Load 4 Cr 00 00 00 00 v3 v2 v1 v0\n\t" | |
397 | |
398 //"movl $0, (%3) # cache preload for image\n\t" | |
399 "movq (%0), %%mm6 # Load 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0\n\t" | |
400 : : "r" (py), "r" (pu), "r" (pv), "r" (image) | |
401 ); | |
402 | |
403 | |
404 x = 0; | |
405 y += 1; | |
406 even = (!even); | |
407 } while ( y < v_size) ; | |
408 | |
409 __asm__ ("emms\n\t"); | |
410 } | |
411 | |
412 yuv2rgb_fun yuv2rgb_init_mmx (int bpp, int mode) | |
413 { | |
414 // if (bpp == 15 || bpp == 16) { | |
415 if (bpp == 16 && mode == MODE_RGB) return yuv420_rgb16_mmx; | |
416 if (bpp == 32 && mode == MODE_RGB) return yuv420_argb32_mmx; | |
417 return NULL; // Fallback to C. | |
418 } | |
419 |