Mercurial > libavcodec.hg
annotate x86/h264dsp_mmx.c @ 11003:72c026446d67 libavcodec
100l, correct wrong H.264+adaptive MBAFF decoding
Fixes several FATE tests.
author | astrange |
---|---|
date | Mon, 25 Jan 2010 01:56:13 +0000 |
parents | 34a65026fa06 |
children | aa10bb3c244c |
rev | line source |
---|---|
8430 | 1 /* |
2 * Copyright (c) 2004-2005 Michael Niedermayer, Loren Merritt | |
3 * | |
4 * This file is part of FFmpeg. | |
5 * | |
6 * FFmpeg is free software; you can redistribute it and/or | |
7 * modify it under the terms of the GNU Lesser General Public | |
8 * License as published by the Free Software Foundation; either | |
9 * version 2.1 of the License, or (at your option) any later version. | |
10 * | |
11 * FFmpeg is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 * Lesser General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU Lesser General Public | |
17 * License along with FFmpeg; if not, write to the Free Software | |
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
19 */ | |
20 | |
21 #include "dsputil_mmx.h" | |
22 | |
23 DECLARE_ALIGNED_8 (static const uint64_t, ff_pb_3_1 ) = 0x0103010301030103ULL; | |
24 DECLARE_ALIGNED_8 (static const uint64_t, ff_pb_7_3 ) = 0x0307030703070307ULL; | |
25 | |
26 /***********************************/ | |
27 /* IDCT */ | |
28 | |
29 #define SUMSUB_BADC( a, b, c, d ) \ | |
30 "paddw "#b", "#a" \n\t"\ | |
31 "paddw "#d", "#c" \n\t"\ | |
32 "paddw "#b", "#b" \n\t"\ | |
33 "paddw "#d", "#d" \n\t"\ | |
34 "psubw "#a", "#b" \n\t"\ | |
35 "psubw "#c", "#d" \n\t" | |
36 | |
37 #define SUMSUBD2_AB( a, b, t ) \ | |
38 "movq "#b", "#t" \n\t"\ | |
39 "psraw $1 , "#b" \n\t"\ | |
40 "paddw "#a", "#b" \n\t"\ | |
41 "psraw $1 , "#a" \n\t"\ | |
42 "psubw "#t", "#a" \n\t" | |
43 | |
44 #define IDCT4_1D( s02, s13, d02, d13, t ) \ | |
45 SUMSUB_BA ( s02, d02 )\ | |
46 SUMSUBD2_AB( s13, d13, t )\ | |
47 SUMSUB_BADC( d13, s02, s13, d02 ) | |
48 | |
49 #define STORE_DIFF_4P( p, t, z ) \ | |
50 "psraw $6, "#p" \n\t"\ | |
51 "movd (%0), "#t" \n\t"\ | |
52 "punpcklbw "#z", "#t" \n\t"\ | |
53 "paddsw "#t", "#p" \n\t"\ | |
54 "packuswb "#z", "#p" \n\t"\ | |
55 "movd "#p", (%0) \n\t" | |
56 | |
57 static void ff_h264_idct_add_mmx(uint8_t *dst, int16_t *block, int stride) | |
58 { | |
59 /* Load dct coeffs */ | |
60 __asm__ volatile( | |
61 "movq (%0), %%mm0 \n\t" | |
62 "movq 8(%0), %%mm1 \n\t" | |
63 "movq 16(%0), %%mm2 \n\t" | |
64 "movq 24(%0), %%mm3 \n\t" | |
65 :: "r"(block) ); | |
66 | |
67 __asm__ volatile( | |
68 /* mm1=s02+s13 mm2=s02-s13 mm4=d02+d13 mm0=d02-d13 */ | |
69 IDCT4_1D( %%mm2, %%mm1, %%mm0, %%mm3, %%mm4 ) | |
70 | |
71 "movq %0, %%mm6 \n\t" | |
72 /* in: 1,4,0,2 out: 1,2,3,0 */ | |
73 TRANSPOSE4( %%mm3, %%mm1, %%mm0, %%mm2, %%mm4 ) | |
74 | |
75 "paddw %%mm6, %%mm3 \n\t" | |
76 | |
77 /* mm2=s02+s13 mm3=s02-s13 mm4=d02+d13 mm1=d02-d13 */ | |
78 IDCT4_1D( %%mm4, %%mm2, %%mm3, %%mm0, %%mm1 ) | |
79 | |
80 "pxor %%mm7, %%mm7 \n\t" | |
81 :: "m"(ff_pw_32)); | |
82 | |
83 __asm__ volatile( | |
84 STORE_DIFF_4P( %%mm0, %%mm1, %%mm7) | |
85 "add %1, %0 \n\t" | |
86 STORE_DIFF_4P( %%mm2, %%mm1, %%mm7) | |
87 "add %1, %0 \n\t" | |
88 STORE_DIFF_4P( %%mm3, %%mm1, %%mm7) | |
89 "add %1, %0 \n\t" | |
90 STORE_DIFF_4P( %%mm4, %%mm1, %%mm7) | |
91 : "+r"(dst) | |
92 : "r" ((x86_reg)stride) | |
93 ); | |
94 } | |
95 | |
96 static inline void h264_idct8_1d(int16_t *block) | |
97 { | |
98 __asm__ volatile( | |
99 "movq 112(%0), %%mm7 \n\t" | |
100 "movq 80(%0), %%mm0 \n\t" | |
101 "movq 48(%0), %%mm3 \n\t" | |
102 "movq 16(%0), %%mm5 \n\t" | |
103 | |
104 "movq %%mm0, %%mm4 \n\t" | |
105 "movq %%mm5, %%mm1 \n\t" | |
106 "psraw $1, %%mm4 \n\t" | |
107 "psraw $1, %%mm1 \n\t" | |
108 "paddw %%mm0, %%mm4 \n\t" | |
109 "paddw %%mm5, %%mm1 \n\t" | |
110 "paddw %%mm7, %%mm4 \n\t" | |
111 "paddw %%mm0, %%mm1 \n\t" | |
112 "psubw %%mm5, %%mm4 \n\t" | |
113 "paddw %%mm3, %%mm1 \n\t" | |
114 | |
115 "psubw %%mm3, %%mm5 \n\t" | |
116 "psubw %%mm3, %%mm0 \n\t" | |
117 "paddw %%mm7, %%mm5 \n\t" | |
118 "psubw %%mm7, %%mm0 \n\t" | |
119 "psraw $1, %%mm3 \n\t" | |
120 "psraw $1, %%mm7 \n\t" | |
121 "psubw %%mm3, %%mm5 \n\t" | |
122 "psubw %%mm7, %%mm0 \n\t" | |
123 | |
124 "movq %%mm4, %%mm3 \n\t" | |
125 "movq %%mm1, %%mm7 \n\t" | |
126 "psraw $2, %%mm1 \n\t" | |
127 "psraw $2, %%mm3 \n\t" | |
128 "paddw %%mm5, %%mm3 \n\t" | |
129 "psraw $2, %%mm5 \n\t" | |
130 "paddw %%mm0, %%mm1 \n\t" | |
131 "psraw $2, %%mm0 \n\t" | |
132 "psubw %%mm4, %%mm5 \n\t" | |
133 "psubw %%mm0, %%mm7 \n\t" | |
134 | |
135 "movq 32(%0), %%mm2 \n\t" | |
136 "movq 96(%0), %%mm6 \n\t" | |
137 "movq %%mm2, %%mm4 \n\t" | |
138 "movq %%mm6, %%mm0 \n\t" | |
139 "psraw $1, %%mm4 \n\t" | |
140 "psraw $1, %%mm6 \n\t" | |
141 "psubw %%mm0, %%mm4 \n\t" | |
142 "paddw %%mm2, %%mm6 \n\t" | |
143 | |
144 "movq (%0), %%mm2 \n\t" | |
145 "movq 64(%0), %%mm0 \n\t" | |
146 SUMSUB_BA( %%mm0, %%mm2 ) | |
147 SUMSUB_BA( %%mm6, %%mm0 ) | |
148 SUMSUB_BA( %%mm4, %%mm2 ) | |
149 SUMSUB_BA( %%mm7, %%mm6 ) | |
150 SUMSUB_BA( %%mm5, %%mm4 ) | |
151 SUMSUB_BA( %%mm3, %%mm2 ) | |
152 SUMSUB_BA( %%mm1, %%mm0 ) | |
153 :: "r"(block) | |
154 ); | |
155 } | |
156 | |
157 static void ff_h264_idct8_add_mmx(uint8_t *dst, int16_t *block, int stride) | |
158 { | |
159 int i; | |
10961
34a65026fa06
Move array specifiers outside DECLARE_ALIGNED() invocations
mru
parents:
10955
diff
changeset
|
160 DECLARE_ALIGNED_8(int16_t, b2)[64]; |
8430 | 161 |
162 block[0] += 32; | |
163 | |
164 for(i=0; i<2; i++){ | |
165 DECLARE_ALIGNED_8(uint64_t, tmp); | |
166 | |
167 h264_idct8_1d(block+4*i); | |
168 | |
169 __asm__ volatile( | |
170 "movq %%mm7, %0 \n\t" | |
171 TRANSPOSE4( %%mm0, %%mm2, %%mm4, %%mm6, %%mm7 ) | |
172 "movq %%mm0, 8(%1) \n\t" | |
173 "movq %%mm6, 24(%1) \n\t" | |
174 "movq %%mm7, 40(%1) \n\t" | |
175 "movq %%mm4, 56(%1) \n\t" | |
176 "movq %0, %%mm7 \n\t" | |
177 TRANSPOSE4( %%mm7, %%mm5, %%mm3, %%mm1, %%mm0 ) | |
178 "movq %%mm7, (%1) \n\t" | |
179 "movq %%mm1, 16(%1) \n\t" | |
180 "movq %%mm0, 32(%1) \n\t" | |
181 "movq %%mm3, 48(%1) \n\t" | |
182 : "=m"(tmp) | |
183 : "r"(b2+32*i) | |
184 : "memory" | |
185 ); | |
186 } | |
187 | |
188 for(i=0; i<2; i++){ | |
189 h264_idct8_1d(b2+4*i); | |
190 | |
191 __asm__ volatile( | |
192 "psraw $6, %%mm7 \n\t" | |
193 "psraw $6, %%mm6 \n\t" | |
194 "psraw $6, %%mm5 \n\t" | |
195 "psraw $6, %%mm4 \n\t" | |
196 "psraw $6, %%mm3 \n\t" | |
197 "psraw $6, %%mm2 \n\t" | |
198 "psraw $6, %%mm1 \n\t" | |
199 "psraw $6, %%mm0 \n\t" | |
200 | |
201 "movq %%mm7, (%0) \n\t" | |
202 "movq %%mm5, 16(%0) \n\t" | |
203 "movq %%mm3, 32(%0) \n\t" | |
204 "movq %%mm1, 48(%0) \n\t" | |
205 "movq %%mm0, 64(%0) \n\t" | |
206 "movq %%mm2, 80(%0) \n\t" | |
207 "movq %%mm4, 96(%0) \n\t" | |
208 "movq %%mm6, 112(%0) \n\t" | |
209 :: "r"(b2+4*i) | |
210 : "memory" | |
211 ); | |
212 } | |
213 | |
214 add_pixels_clamped_mmx(b2, dst, stride); | |
215 } | |
216 | |
217 #define STORE_DIFF_8P( p, d, t, z )\ | |
218 "movq "#d", "#t" \n"\ | |
219 "psraw $6, "#p" \n"\ | |
220 "punpcklbw "#z", "#t" \n"\ | |
221 "paddsw "#t", "#p" \n"\ | |
222 "packuswb "#p", "#p" \n"\ | |
223 "movq "#p", "#d" \n" | |
224 | |
225 #define H264_IDCT8_1D_SSE2(a,b,c,d,e,f,g,h)\ | |
226 "movdqa "#c", "#a" \n"\ | |
227 "movdqa "#g", "#e" \n"\ | |
228 "psraw $1, "#c" \n"\ | |
229 "psraw $1, "#g" \n"\ | |
230 "psubw "#e", "#c" \n"\ | |
231 "paddw "#a", "#g" \n"\ | |
232 "movdqa "#b", "#e" \n"\ | |
233 "psraw $1, "#e" \n"\ | |
234 "paddw "#b", "#e" \n"\ | |
235 "paddw "#d", "#e" \n"\ | |
236 "paddw "#f", "#e" \n"\ | |
237 "movdqa "#f", "#a" \n"\ | |
238 "psraw $1, "#a" \n"\ | |
239 "paddw "#f", "#a" \n"\ | |
240 "paddw "#h", "#a" \n"\ | |
241 "psubw "#b", "#a" \n"\ | |
242 "psubw "#d", "#b" \n"\ | |
243 "psubw "#d", "#f" \n"\ | |
244 "paddw "#h", "#b" \n"\ | |
245 "psubw "#h", "#f" \n"\ | |
246 "psraw $1, "#d" \n"\ | |
247 "psraw $1, "#h" \n"\ | |
248 "psubw "#d", "#b" \n"\ | |
249 "psubw "#h", "#f" \n"\ | |
250 "movdqa "#e", "#d" \n"\ | |
251 "movdqa "#a", "#h" \n"\ | |
252 "psraw $2, "#d" \n"\ | |
253 "psraw $2, "#h" \n"\ | |
254 "paddw "#f", "#d" \n"\ | |
255 "paddw "#b", "#h" \n"\ | |
256 "psraw $2, "#f" \n"\ | |
257 "psraw $2, "#b" \n"\ | |
258 "psubw "#f", "#e" \n"\ | |
259 "psubw "#a", "#b" \n"\ | |
260 "movdqa 0x00(%1), "#a" \n"\ | |
261 "movdqa 0x40(%1), "#f" \n"\ | |
262 SUMSUB_BA(f, a)\ | |
263 SUMSUB_BA(g, f)\ | |
264 SUMSUB_BA(c, a)\ | |
265 SUMSUB_BA(e, g)\ | |
266 SUMSUB_BA(b, c)\ | |
267 SUMSUB_BA(h, a)\ | |
268 SUMSUB_BA(d, f) | |
269 | |
270 static void ff_h264_idct8_add_sse2(uint8_t *dst, int16_t *block, int stride) | |
271 { | |
272 __asm__ volatile( | |
273 "movdqa 0x10(%1), %%xmm1 \n" | |
274 "movdqa 0x20(%1), %%xmm2 \n" | |
275 "movdqa 0x30(%1), %%xmm3 \n" | |
276 "movdqa 0x50(%1), %%xmm5 \n" | |
277 "movdqa 0x60(%1), %%xmm6 \n" | |
278 "movdqa 0x70(%1), %%xmm7 \n" | |
279 H264_IDCT8_1D_SSE2(%%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm6, %%xmm7) | |
280 TRANSPOSE8(%%xmm4, %%xmm1, %%xmm7, %%xmm3, %%xmm5, %%xmm0, %%xmm2, %%xmm6, (%1)) | |
281 "paddw %4, %%xmm4 \n" | |
282 "movdqa %%xmm4, 0x00(%1) \n" | |
283 "movdqa %%xmm2, 0x40(%1) \n" | |
284 H264_IDCT8_1D_SSE2(%%xmm4, %%xmm0, %%xmm6, %%xmm3, %%xmm2, %%xmm5, %%xmm7, %%xmm1) | |
285 "movdqa %%xmm6, 0x60(%1) \n" | |
286 "movdqa %%xmm7, 0x70(%1) \n" | |
287 "pxor %%xmm7, %%xmm7 \n" | |
288 STORE_DIFF_8P(%%xmm2, (%0), %%xmm6, %%xmm7) | |
289 STORE_DIFF_8P(%%xmm0, (%0,%2), %%xmm6, %%xmm7) | |
290 STORE_DIFF_8P(%%xmm1, (%0,%2,2), %%xmm6, %%xmm7) | |
291 STORE_DIFF_8P(%%xmm3, (%0,%3), %%xmm6, %%xmm7) | |
292 "lea (%0,%2,4), %0 \n" | |
293 STORE_DIFF_8P(%%xmm5, (%0), %%xmm6, %%xmm7) | |
294 STORE_DIFF_8P(%%xmm4, (%0,%2), %%xmm6, %%xmm7) | |
295 "movdqa 0x60(%1), %%xmm0 \n" | |
296 "movdqa 0x70(%1), %%xmm1 \n" | |
297 STORE_DIFF_8P(%%xmm0, (%0,%2,2), %%xmm6, %%xmm7) | |
298 STORE_DIFF_8P(%%xmm1, (%0,%3), %%xmm6, %%xmm7) | |
299 :"+r"(dst) | |
300 :"r"(block), "r"((x86_reg)stride), "r"((x86_reg)3L*stride), "m"(ff_pw_32) | |
301 ); | |
302 } | |
303 | |
304 static void ff_h264_idct_dc_add_mmx2(uint8_t *dst, int16_t *block, int stride) | |
305 { | |
306 int dc = (block[0] + 32) >> 6; | |
307 __asm__ volatile( | |
308 "movd %0, %%mm0 \n\t" | |
309 "pshufw $0, %%mm0, %%mm0 \n\t" | |
310 "pxor %%mm1, %%mm1 \n\t" | |
311 "psubw %%mm0, %%mm1 \n\t" | |
312 "packuswb %%mm0, %%mm0 \n\t" | |
313 "packuswb %%mm1, %%mm1 \n\t" | |
314 ::"r"(dc) | |
315 ); | |
316 __asm__ volatile( | |
317 "movd %0, %%mm2 \n\t" | |
318 "movd %1, %%mm3 \n\t" | |
319 "movd %2, %%mm4 \n\t" | |
320 "movd %3, %%mm5 \n\t" | |
321 "paddusb %%mm0, %%mm2 \n\t" | |
322 "paddusb %%mm0, %%mm3 \n\t" | |
323 "paddusb %%mm0, %%mm4 \n\t" | |
324 "paddusb %%mm0, %%mm5 \n\t" | |
325 "psubusb %%mm1, %%mm2 \n\t" | |
326 "psubusb %%mm1, %%mm3 \n\t" | |
327 "psubusb %%mm1, %%mm4 \n\t" | |
328 "psubusb %%mm1, %%mm5 \n\t" | |
329 "movd %%mm2, %0 \n\t" | |
330 "movd %%mm3, %1 \n\t" | |
331 "movd %%mm4, %2 \n\t" | |
332 "movd %%mm5, %3 \n\t" | |
333 :"+m"(*(uint32_t*)(dst+0*stride)), | |
334 "+m"(*(uint32_t*)(dst+1*stride)), | |
335 "+m"(*(uint32_t*)(dst+2*stride)), | |
336 "+m"(*(uint32_t*)(dst+3*stride)) | |
337 ); | |
338 } | |
339 | |
340 static void ff_h264_idct8_dc_add_mmx2(uint8_t *dst, int16_t *block, int stride) | |
341 { | |
342 int dc = (block[0] + 32) >> 6; | |
343 int y; | |
344 __asm__ volatile( | |
345 "movd %0, %%mm0 \n\t" | |
346 "pshufw $0, %%mm0, %%mm0 \n\t" | |
347 "pxor %%mm1, %%mm1 \n\t" | |
348 "psubw %%mm0, %%mm1 \n\t" | |
349 "packuswb %%mm0, %%mm0 \n\t" | |
350 "packuswb %%mm1, %%mm1 \n\t" | |
351 ::"r"(dc) | |
352 ); | |
353 for(y=2; y--; dst += 4*stride){ | |
354 __asm__ volatile( | |
355 "movq %0, %%mm2 \n\t" | |
356 "movq %1, %%mm3 \n\t" | |
357 "movq %2, %%mm4 \n\t" | |
358 "movq %3, %%mm5 \n\t" | |
359 "paddusb %%mm0, %%mm2 \n\t" | |
360 "paddusb %%mm0, %%mm3 \n\t" | |
361 "paddusb %%mm0, %%mm4 \n\t" | |
362 "paddusb %%mm0, %%mm5 \n\t" | |
363 "psubusb %%mm1, %%mm2 \n\t" | |
364 "psubusb %%mm1, %%mm3 \n\t" | |
365 "psubusb %%mm1, %%mm4 \n\t" | |
366 "psubusb %%mm1, %%mm5 \n\t" | |
367 "movq %%mm2, %0 \n\t" | |
368 "movq %%mm3, %1 \n\t" | |
369 "movq %%mm4, %2 \n\t" | |
370 "movq %%mm5, %3 \n\t" | |
371 :"+m"(*(uint64_t*)(dst+0*stride)), | |
372 "+m"(*(uint64_t*)(dst+1*stride)), | |
373 "+m"(*(uint64_t*)(dst+2*stride)), | |
374 "+m"(*(uint64_t*)(dst+3*stride)) | |
375 ); | |
376 } | |
377 } | |
378 | |
379 //FIXME this table is a duplicate from h264data.h, and will be removed once the tables from, h264 have been split | |
380 static const uint8_t scan8[16 + 2*4]={ | |
381 4+1*8, 5+1*8, 4+2*8, 5+2*8, | |
382 6+1*8, 7+1*8, 6+2*8, 7+2*8, | |
383 4+3*8, 5+3*8, 4+4*8, 5+4*8, | |
384 6+3*8, 7+3*8, 6+4*8, 7+4*8, | |
385 1+1*8, 2+1*8, | |
386 1+2*8, 2+2*8, | |
387 1+4*8, 2+4*8, | |
388 1+5*8, 2+5*8, | |
389 }; | |
390 | |
391 static void ff_h264_idct_add16_mmx(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){ | |
392 int i; | |
393 for(i=0; i<16; i++){ | |
394 if(nnzc[ scan8[i] ]) | |
395 ff_h264_idct_add_mmx(dst + block_offset[i], block + i*16, stride); | |
396 } | |
397 } | |
398 | |
399 static void ff_h264_idct8_add4_mmx(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){ | |
400 int i; | |
401 for(i=0; i<16; i+=4){ | |
402 if(nnzc[ scan8[i] ]) | |
403 ff_h264_idct8_add_mmx(dst + block_offset[i], block + i*16, stride); | |
404 } | |
405 } | |
406 | |
407 | |
408 static void ff_h264_idct_add16_mmx2(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){ | |
409 int i; | |
410 for(i=0; i<16; i++){ | |
411 int nnz = nnzc[ scan8[i] ]; | |
412 if(nnz){ | |
413 if(nnz==1 && block[i*16]) ff_h264_idct_dc_add_mmx2(dst + block_offset[i], block + i*16, stride); | |
414 else ff_h264_idct_add_mmx (dst + block_offset[i], block + i*16, stride); | |
415 } | |
416 } | |
417 } | |
418 | |
419 static void ff_h264_idct_add16intra_mmx(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){ | |
420 int i; | |
421 for(i=0; i<16; i++){ | |
422 if(nnzc[ scan8[i] ] || block[i*16]) | |
423 ff_h264_idct_add_mmx(dst + block_offset[i], block + i*16, stride); | |
424 } | |
425 } | |
426 | |
427 static void ff_h264_idct_add16intra_mmx2(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){ | |
428 int i; | |
429 for(i=0; i<16; i++){ | |
430 if(nnzc[ scan8[i] ]) ff_h264_idct_add_mmx (dst + block_offset[i], block + i*16, stride); | |
431 else if(block[i*16]) ff_h264_idct_dc_add_mmx2(dst + block_offset[i], block + i*16, stride); | |
432 } | |
433 } | |
434 | |
435 static void ff_h264_idct8_add4_mmx2(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){ | |
436 int i; | |
437 for(i=0; i<16; i+=4){ | |
438 int nnz = nnzc[ scan8[i] ]; | |
439 if(nnz){ | |
440 if(nnz==1 && block[i*16]) ff_h264_idct8_dc_add_mmx2(dst + block_offset[i], block + i*16, stride); | |
441 else ff_h264_idct8_add_mmx (dst + block_offset[i], block + i*16, stride); | |
442 } | |
443 } | |
444 } | |
445 | |
446 static void ff_h264_idct8_add4_sse2(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){ | |
447 int i; | |
448 for(i=0; i<16; i+=4){ | |
449 int nnz = nnzc[ scan8[i] ]; | |
450 if(nnz){ | |
451 if(nnz==1 && block[i*16]) ff_h264_idct8_dc_add_mmx2(dst + block_offset[i], block + i*16, stride); | |
452 else ff_h264_idct8_add_sse2 (dst + block_offset[i], block + i*16, stride); | |
453 } | |
454 } | |
455 } | |
456 | |
457 static void ff_h264_idct_add8_mmx(uint8_t **dest, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){ | |
458 int i; | |
459 for(i=16; i<16+8; i++){ | |
460 if(nnzc[ scan8[i] ] || block[i*16]) | |
461 ff_h264_idct_add_mmx (dest[(i&4)>>2] + block_offset[i], block + i*16, stride); | |
462 } | |
463 } | |
464 | |
465 static void ff_h264_idct_add8_mmx2(uint8_t **dest, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){ | |
466 int i; | |
467 for(i=16; i<16+8; i++){ | |
468 if(nnzc[ scan8[i] ]) | |
469 ff_h264_idct_add_mmx (dest[(i&4)>>2] + block_offset[i], block + i*16, stride); | |
470 else if(block[i*16]) | |
471 ff_h264_idct_dc_add_mmx2(dest[(i&4)>>2] + block_offset[i], block + i*16, stride); | |
472 } | |
473 } | |
474 | |
8590 | 475 #if CONFIG_GPL && HAVE_YASM |
8510
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
476 static void ff_h264_idct_dc_add8_mmx2(uint8_t *dst, int16_t *block, int stride) |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
477 { |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
478 __asm__ volatile( |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
479 "movd %0, %%mm0 \n\t" // 0 0 X D |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
480 "punpcklwd %1, %%mm0 \n\t" // x X d D |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
481 "paddsw %2, %%mm0 \n\t" |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
482 "psraw $6, %%mm0 \n\t" |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
483 "punpcklwd %%mm0, %%mm0 \n\t" // d d D D |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
484 "pxor %%mm1, %%mm1 \n\t" // 0 0 0 0 |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
485 "psubw %%mm0, %%mm1 \n\t" // -d-d-D-D |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
486 "packuswb %%mm1, %%mm0 \n\t" // -d-d-D-D d d D D |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
487 "pshufw $0xFA, %%mm0, %%mm1 \n\t" // -d-d-d-d-D-D-D-D |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
488 "punpcklwd %%mm0, %%mm0 \n\t" // d d d d D D D D |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
489 ::"m"(block[ 0]), |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
490 "m"(block[16]), |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
491 "m"(ff_pw_32) |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
492 ); |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
493 __asm__ volatile( |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
494 "movq %0, %%mm2 \n\t" |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
495 "movq %1, %%mm3 \n\t" |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
496 "movq %2, %%mm4 \n\t" |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
497 "movq %3, %%mm5 \n\t" |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
498 "paddusb %%mm0, %%mm2 \n\t" |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
499 "paddusb %%mm0, %%mm3 \n\t" |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
500 "paddusb %%mm0, %%mm4 \n\t" |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
501 "paddusb %%mm0, %%mm5 \n\t" |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
502 "psubusb %%mm1, %%mm2 \n\t" |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
503 "psubusb %%mm1, %%mm3 \n\t" |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
504 "psubusb %%mm1, %%mm4 \n\t" |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
505 "psubusb %%mm1, %%mm5 \n\t" |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
506 "movq %%mm2, %0 \n\t" |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
507 "movq %%mm3, %1 \n\t" |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
508 "movq %%mm4, %2 \n\t" |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
509 "movq %%mm5, %3 \n\t" |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
510 :"+m"(*(uint64_t*)(dst+0*stride)), |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
511 "+m"(*(uint64_t*)(dst+1*stride)), |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
512 "+m"(*(uint64_t*)(dst+2*stride)), |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
513 "+m"(*(uint64_t*)(dst+3*stride)) |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
514 ); |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
515 } |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
516 |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
517 extern void ff_x264_add8x4_idct_sse2(uint8_t *dst, int16_t *block, int stride); |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
518 |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
519 static void ff_h264_idct_add16_sse2(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){ |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
520 int i; |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
521 for(i=0; i<16; i+=2) |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
522 if(nnzc[ scan8[i+0] ]|nnzc[ scan8[i+1] ]) |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
523 ff_x264_add8x4_idct_sse2 (dst + block_offset[i], block + i*16, stride); |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
524 } |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
525 |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
526 static void ff_h264_idct_add16intra_sse2(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){ |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
527 int i; |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
528 for(i=0; i<16; i+=2){ |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
529 if(nnzc[ scan8[i+0] ]|nnzc[ scan8[i+1] ]) |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
530 ff_x264_add8x4_idct_sse2 (dst + block_offset[i], block + i*16, stride); |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
531 else if(block[i*16]|block[i*16+16]) |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
532 ff_h264_idct_dc_add8_mmx2(dst + block_offset[i], block + i*16, stride); |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
533 } |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
534 } |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
535 |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
536 static void ff_h264_idct_add8_sse2(uint8_t **dest, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){ |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
537 int i; |
8758
93980b03673e
fix typo in h264dsp_mmx (no effect currently as the function is not used), approved by Dark Shikari on IRC
bcoudurier
parents:
8590
diff
changeset
|
538 for(i=16; i<16+8; i+=2){ |
8510
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
539 if(nnzc[ scan8[i+0] ]|nnzc[ scan8[i+1] ]) |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
540 ff_x264_add8x4_idct_sse2 (dest[(i&4)>>2] + block_offset[i], block + i*16, stride); |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
541 else if(block[i*16]|block[i*16+16]) |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
542 ff_h264_idct_dc_add8_mmx2(dest[(i&4)>>2] + block_offset[i], block + i*16, stride); |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
543 } |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
544 } |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
545 #endif |
cea216e44ee3
Add x264 SSE2 iDCT functions to H.264 decoder.
darkshikari
parents:
8430
diff
changeset
|
546 |
8430 | 547 /***********************************/ |
548 /* deblocking */ | |
549 | |
550 // out: o = |x-y|>a | |
551 // clobbers: t | |
552 #define DIFF_GT_MMX(x,y,a,o,t)\ | |
553 "movq "#y", "#t" \n\t"\ | |
554 "movq "#x", "#o" \n\t"\ | |
555 "psubusb "#x", "#t" \n\t"\ | |
556 "psubusb "#y", "#o" \n\t"\ | |
557 "por "#t", "#o" \n\t"\ | |
558 "psubusb "#a", "#o" \n\t" | |
559 | |
560 // out: o = |x-y|>a | |
561 // clobbers: t | |
562 #define DIFF_GT2_MMX(x,y,a,o,t)\ | |
563 "movq "#y", "#t" \n\t"\ | |
564 "movq "#x", "#o" \n\t"\ | |
565 "psubusb "#x", "#t" \n\t"\ | |
566 "psubusb "#y", "#o" \n\t"\ | |
567 "psubusb "#a", "#t" \n\t"\ | |
568 "psubusb "#a", "#o" \n\t"\ | |
569 "pcmpeqb "#t", "#o" \n\t"\ | |
570 | |
571 // in: mm0=p1 mm1=p0 mm2=q0 mm3=q1 | |
572 // out: mm5=beta-1, mm7=mask | |
573 // clobbers: mm4,mm6 | |
574 #define H264_DEBLOCK_MASK(alpha1, beta1) \ | |
575 "pshufw $0, "#alpha1", %%mm4 \n\t"\ | |
576 "pshufw $0, "#beta1 ", %%mm5 \n\t"\ | |
577 "packuswb %%mm4, %%mm4 \n\t"\ | |
578 "packuswb %%mm5, %%mm5 \n\t"\ | |
579 DIFF_GT_MMX(%%mm1, %%mm2, %%mm4, %%mm7, %%mm6) /* |p0-q0| > alpha-1 */\ | |
580 DIFF_GT_MMX(%%mm0, %%mm1, %%mm5, %%mm4, %%mm6) /* |p1-p0| > beta-1 */\ | |
581 "por %%mm4, %%mm7 \n\t"\ | |
582 DIFF_GT_MMX(%%mm3, %%mm2, %%mm5, %%mm4, %%mm6) /* |q1-q0| > beta-1 */\ | |
583 "por %%mm4, %%mm7 \n\t"\ | |
584 "pxor %%mm6, %%mm6 \n\t"\ | |
585 "pcmpeqb %%mm6, %%mm7 \n\t" | |
586 | |
587 // in: mm0=p1 mm1=p0 mm2=q0 mm3=q1 mm7=(tc&mask) | |
588 // out: mm1=p0' mm2=q0' | |
589 // clobbers: mm0,3-6 | |
590 #define H264_DEBLOCK_P0_Q0(pb_01, pb_3f)\ | |
591 "movq %%mm1 , %%mm5 \n\t"\ | |
592 "pxor %%mm2 , %%mm5 \n\t" /* p0^q0*/\ | |
593 "pand "#pb_01" , %%mm5 \n\t" /* (p0^q0)&1*/\ | |
594 "pcmpeqb %%mm4 , %%mm4 \n\t"\ | |
595 "pxor %%mm4 , %%mm3 \n\t"\ | |
596 "pavgb %%mm0 , %%mm3 \n\t" /* (p1 - q1 + 256)>>1*/\ | |
597 "pavgb "MANGLE(ff_pb_3)" , %%mm3 \n\t" /*(((p1 - q1 + 256)>>1)+4)>>1 = 64+2+(p1-q1)>>2*/\ | |
598 "pxor %%mm1 , %%mm4 \n\t"\ | |
599 "pavgb %%mm2 , %%mm4 \n\t" /* (q0 - p0 + 256)>>1*/\ | |
600 "pavgb %%mm5 , %%mm3 \n\t"\ | |
601 "paddusb %%mm4 , %%mm3 \n\t" /* d+128+33*/\ | |
602 "movq "MANGLE(ff_pb_A1)" , %%mm6 \n\t"\ | |
603 "psubusb %%mm3 , %%mm6 \n\t"\ | |
604 "psubusb "MANGLE(ff_pb_A1)" , %%mm3 \n\t"\ | |
605 "pminub %%mm7 , %%mm6 \n\t"\ | |
606 "pminub %%mm7 , %%mm3 \n\t"\ | |
607 "psubusb %%mm6 , %%mm1 \n\t"\ | |
608 "psubusb %%mm3 , %%mm2 \n\t"\ | |
609 "paddusb %%mm3 , %%mm1 \n\t"\ | |
610 "paddusb %%mm6 , %%mm2 \n\t" | |
611 | |
612 // in: mm0=p1 mm1=p0 mm2=q0 mm3=q1 mm7=(tc&mask) %8=ff_bone | |
613 // out: (q1addr) = av_clip( (q2+((p0+q0+1)>>1))>>1, q1-tc0, q1+tc0 ) | |
614 // clobbers: q2, tmp, tc0 | |
615 #define H264_DEBLOCK_Q1(p1, q2, q2addr, q1addr, tc0, tmp)\ | |
616 "movq %%mm1, "#tmp" \n\t"\ | |
617 "pavgb %%mm2, "#tmp" \n\t"\ | |
618 "pavgb "#tmp", "#q2" \n\t" /* avg(p2,avg(p0,q0)) */\ | |
619 "pxor "q2addr", "#tmp" \n\t"\ | |
10955
fdddf3d4238f
Use two separate memory arguments since 8+() is invalid gas syntax
conrad
parents:
10953
diff
changeset
|
620 "pand %9, "#tmp" \n\t" /* (p2^avg(p0,q0))&1 */\ |
8430 | 621 "psubusb "#tmp", "#q2" \n\t" /* (p2+((p0+q0+1)>>1))>>1 */\ |
622 "movq "#p1", "#tmp" \n\t"\ | |
623 "psubusb "#tc0", "#tmp" \n\t"\ | |
624 "paddusb "#p1", "#tc0" \n\t"\ | |
625 "pmaxub "#tmp", "#q2" \n\t"\ | |
626 "pminub "#tc0", "#q2" \n\t"\ | |
627 "movq "#q2", "q1addr" \n\t" | |
628 | |
629 static inline void h264_loop_filter_luma_mmx2(uint8_t *pix, int stride, int alpha1, int beta1, int8_t *tc0) | |
630 { | |
10961
34a65026fa06
Move array specifiers outside DECLARE_ALIGNED() invocations
mru
parents:
10955
diff
changeset
|
631 DECLARE_ALIGNED_8(uint64_t, tmp0)[2]; |
8430 | 632 |
633 __asm__ volatile( | |
10955
fdddf3d4238f
Use two separate memory arguments since 8+() is invalid gas syntax
conrad
parents:
10953
diff
changeset
|
634 "movq (%2,%4), %%mm0 \n\t" //p1 |
fdddf3d4238f
Use two separate memory arguments since 8+() is invalid gas syntax
conrad
parents:
10953
diff
changeset
|
635 "movq (%2,%4,2), %%mm1 \n\t" //p0 |
fdddf3d4238f
Use two separate memory arguments since 8+() is invalid gas syntax
conrad
parents:
10953
diff
changeset
|
636 "movq (%3), %%mm2 \n\t" //q0 |
fdddf3d4238f
Use two separate memory arguments since 8+() is invalid gas syntax
conrad
parents:
10953
diff
changeset
|
637 "movq (%3,%4), %%mm3 \n\t" //q1 |
fdddf3d4238f
Use two separate memory arguments since 8+() is invalid gas syntax
conrad
parents:
10953
diff
changeset
|
638 H264_DEBLOCK_MASK(%7, %8) |
8430 | 639 |
10955
fdddf3d4238f
Use two separate memory arguments since 8+() is invalid gas syntax
conrad
parents:
10953
diff
changeset
|
640 "movd %6, %%mm4 \n\t" |
8430 | 641 "punpcklbw %%mm4, %%mm4 \n\t" |
642 "punpcklwd %%mm4, %%mm4 \n\t" | |
643 "pcmpeqb %%mm3, %%mm3 \n\t" | |
644 "movq %%mm4, %%mm6 \n\t" | |
645 "pcmpgtb %%mm3, %%mm4 \n\t" | |
10955
fdddf3d4238f
Use two separate memory arguments since 8+() is invalid gas syntax
conrad
parents:
10953
diff
changeset
|
646 "movq %%mm6, %1 \n\t" |
8430 | 647 "pand %%mm4, %%mm7 \n\t" |
648 "movq %%mm7, %0 \n\t" | |
649 | |
650 /* filter p1 */ | |
10955
fdddf3d4238f
Use two separate memory arguments since 8+() is invalid gas syntax
conrad
parents:
10953
diff
changeset
|
651 "movq (%2), %%mm3 \n\t" //p2 |
8430 | 652 DIFF_GT2_MMX(%%mm1, %%mm3, %%mm5, %%mm6, %%mm4) // |p2-p0|>beta-1 |
653 "pand %%mm7, %%mm6 \n\t" // mask & |p2-p0|<beta | |
10955
fdddf3d4238f
Use two separate memory arguments since 8+() is invalid gas syntax
conrad
parents:
10953
diff
changeset
|
654 "pand %1, %%mm7 \n\t" // mask & tc0 |
8430 | 655 "movq %%mm7, %%mm4 \n\t" |
656 "psubb %%mm6, %%mm7 \n\t" | |
657 "pand %%mm4, %%mm6 \n\t" // mask & |p2-p0|<beta & tc0 | |
10955
fdddf3d4238f
Use two separate memory arguments since 8+() is invalid gas syntax
conrad
parents:
10953
diff
changeset
|
658 H264_DEBLOCK_Q1(%%mm0, %%mm3, "(%2)", "(%2,%4)", %%mm6, %%mm4) |
8430 | 659 |
660 /* filter q1 */ | |
10955
fdddf3d4238f
Use two separate memory arguments since 8+() is invalid gas syntax
conrad
parents:
10953
diff
changeset
|
661 "movq (%3,%4,2), %%mm4 \n\t" //q2 |
8430 | 662 DIFF_GT2_MMX(%%mm2, %%mm4, %%mm5, %%mm6, %%mm3) // |q2-q0|>beta-1 |
663 "pand %0, %%mm6 \n\t" | |
10955
fdddf3d4238f
Use two separate memory arguments since 8+() is invalid gas syntax
conrad
parents:
10953
diff
changeset
|
664 "movq %1, %%mm5 \n\t" // can be merged with the and below but is slower then |
8430 | 665 "pand %%mm6, %%mm5 \n\t" |
666 "psubb %%mm6, %%mm7 \n\t" | |
10955
fdddf3d4238f
Use two separate memory arguments since 8+() is invalid gas syntax
conrad
parents:
10953
diff
changeset
|
667 "movq (%3,%4), %%mm3 \n\t" |
fdddf3d4238f
Use two separate memory arguments since 8+() is invalid gas syntax
conrad
parents:
10953
diff
changeset
|
668 H264_DEBLOCK_Q1(%%mm3, %%mm4, "(%3,%4,2)", "(%3,%4)", %%mm5, %%mm6) |
8430 | 669 |
670 /* filter p0, q0 */ | |
10955
fdddf3d4238f
Use two separate memory arguments since 8+() is invalid gas syntax
conrad
parents:
10953
diff
changeset
|
671 H264_DEBLOCK_P0_Q0(%9, unused) |
fdddf3d4238f
Use two separate memory arguments since 8+() is invalid gas syntax
conrad
parents:
10953
diff
changeset
|
672 "movq %%mm1, (%2,%4,2) \n\t" |
fdddf3d4238f
Use two separate memory arguments since 8+() is invalid gas syntax
conrad
parents:
10953
diff
changeset
|
673 "movq %%mm2, (%3) \n\t" |
8430 | 674 |
10955
fdddf3d4238f
Use two separate memory arguments since 8+() is invalid gas syntax
conrad
parents:
10953
diff
changeset
|
675 : "=m"(tmp0[0]), "=m"(tmp0[1]) |
8430 | 676 : "r"(pix-3*stride), "r"(pix), "r"((x86_reg)stride), |
677 "m"(*tmp0/*unused*/), "m"(*(uint32_t*)tc0), "m"(alpha1), "m"(beta1), | |
678 "m"(ff_bone) | |
679 ); | |
680 } | |
681 | |
682 static void h264_v_loop_filter_luma_mmx2(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) | |
683 { | |
684 if((tc0[0] & tc0[1]) >= 0) | |
685 h264_loop_filter_luma_mmx2(pix, stride, alpha-1, beta-1, tc0); | |
686 if((tc0[2] & tc0[3]) >= 0) | |
687 h264_loop_filter_luma_mmx2(pix+8, stride, alpha-1, beta-1, tc0+2); | |
688 } | |
689 static void h264_h_loop_filter_luma_mmx2(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) | |
690 { | |
691 //FIXME: could cut some load/stores by merging transpose with filter | |
692 // also, it only needs to transpose 6x8 | |
10961
34a65026fa06
Move array specifiers outside DECLARE_ALIGNED() invocations
mru
parents:
10955
diff
changeset
|
693 DECLARE_ALIGNED_8(uint8_t, trans)[8*8]; |
8430 | 694 int i; |
695 for(i=0; i<2; i++, pix+=8*stride, tc0+=2) { | |
696 if((tc0[0] & tc0[1]) < 0) | |
697 continue; | |
698 transpose4x4(trans, pix-4, 8, stride); | |
699 transpose4x4(trans +4*8, pix, 8, stride); | |
700 transpose4x4(trans+4, pix-4+4*stride, 8, stride); | |
701 transpose4x4(trans+4+4*8, pix +4*stride, 8, stride); | |
702 h264_loop_filter_luma_mmx2(trans+4*8, 8, alpha-1, beta-1, tc0); | |
703 transpose4x4(pix-2, trans +2*8, stride, 8); | |
704 transpose4x4(pix-2+4*stride, trans+4+2*8, stride, 8); | |
705 } | |
706 } | |
707 | |
708 static inline void h264_loop_filter_chroma_mmx2(uint8_t *pix, int stride, int alpha1, int beta1, int8_t *tc0) | |
709 { | |
710 __asm__ volatile( | |
711 "movq (%0), %%mm0 \n\t" //p1 | |
712 "movq (%0,%2), %%mm1 \n\t" //p0 | |
713 "movq (%1), %%mm2 \n\t" //q0 | |
714 "movq (%1,%2), %%mm3 \n\t" //q1 | |
715 H264_DEBLOCK_MASK(%4, %5) | |
716 "movd %3, %%mm6 \n\t" | |
717 "punpcklbw %%mm6, %%mm6 \n\t" | |
718 "pand %%mm6, %%mm7 \n\t" // mm7 = tc&mask | |
719 H264_DEBLOCK_P0_Q0(%6, %7) | |
720 "movq %%mm1, (%0,%2) \n\t" | |
721 "movq %%mm2, (%1) \n\t" | |
722 | |
723 :: "r"(pix-2*stride), "r"(pix), "r"((x86_reg)stride), | |
724 "r"(*(uint32_t*)tc0), | |
725 "m"(alpha1), "m"(beta1), "m"(ff_bone), "m"(ff_pb_3F) | |
726 ); | |
727 } | |
728 | |
729 static void h264_v_loop_filter_chroma_mmx2(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) | |
730 { | |
731 h264_loop_filter_chroma_mmx2(pix, stride, alpha-1, beta-1, tc0); | |
732 } | |
733 | |
734 static void h264_h_loop_filter_chroma_mmx2(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) | |
735 { | |
736 //FIXME: could cut some load/stores by merging transpose with filter | |
10961
34a65026fa06
Move array specifiers outside DECLARE_ALIGNED() invocations
mru
parents:
10955
diff
changeset
|
737 DECLARE_ALIGNED_8(uint8_t, trans)[8*4]; |
8430 | 738 transpose4x4(trans, pix-2, 8, stride); |
739 transpose4x4(trans+4, pix-2+4*stride, 8, stride); | |
740 h264_loop_filter_chroma_mmx2(trans+2*8, 8, alpha-1, beta-1, tc0); | |
741 transpose4x4(pix-2, trans, stride, 8); | |
742 transpose4x4(pix-2+4*stride, trans+4, stride, 8); | |
743 } | |
744 | |
745 // p0 = (p0 + q1 + 2*p1 + 2) >> 2 | |
746 #define H264_FILTER_CHROMA4(p0, p1, q1, one) \ | |
747 "movq "#p0", %%mm4 \n\t"\ | |
748 "pxor "#q1", %%mm4 \n\t"\ | |
749 "pand "#one", %%mm4 \n\t" /* mm4 = (p0^q1)&1 */\ | |
750 "pavgb "#q1", "#p0" \n\t"\ | |
751 "psubusb %%mm4, "#p0" \n\t"\ | |
752 "pavgb "#p1", "#p0" \n\t" /* dst = avg(p1, avg(p0,q1) - ((p0^q1)&1)) */\ | |
753 | |
754 static inline void h264_loop_filter_chroma_intra_mmx2(uint8_t *pix, int stride, int alpha1, int beta1) | |
755 { | |
756 __asm__ volatile( | |
757 "movq (%0), %%mm0 \n\t" | |
758 "movq (%0,%2), %%mm1 \n\t" | |
759 "movq (%1), %%mm2 \n\t" | |
760 "movq (%1,%2), %%mm3 \n\t" | |
761 H264_DEBLOCK_MASK(%3, %4) | |
762 "movq %%mm1, %%mm5 \n\t" | |
763 "movq %%mm2, %%mm6 \n\t" | |
764 H264_FILTER_CHROMA4(%%mm1, %%mm0, %%mm3, %5) //p0' | |
765 H264_FILTER_CHROMA4(%%mm2, %%mm3, %%mm0, %5) //q0' | |
766 "psubb %%mm5, %%mm1 \n\t" | |
767 "psubb %%mm6, %%mm2 \n\t" | |
768 "pand %%mm7, %%mm1 \n\t" | |
769 "pand %%mm7, %%mm2 \n\t" | |
770 "paddb %%mm5, %%mm1 \n\t" | |
771 "paddb %%mm6, %%mm2 \n\t" | |
772 "movq %%mm1, (%0,%2) \n\t" | |
773 "movq %%mm2, (%1) \n\t" | |
774 :: "r"(pix-2*stride), "r"(pix), "r"((x86_reg)stride), | |
775 "m"(alpha1), "m"(beta1), "m"(ff_bone) | |
776 ); | |
777 } | |
778 | |
779 static void h264_v_loop_filter_chroma_intra_mmx2(uint8_t *pix, int stride, int alpha, int beta) | |
780 { | |
781 h264_loop_filter_chroma_intra_mmx2(pix, stride, alpha-1, beta-1); | |
782 } | |
783 | |
784 static void h264_h_loop_filter_chroma_intra_mmx2(uint8_t *pix, int stride, int alpha, int beta) | |
785 { | |
786 //FIXME: could cut some load/stores by merging transpose with filter | |
10961
34a65026fa06
Move array specifiers outside DECLARE_ALIGNED() invocations
mru
parents:
10955
diff
changeset
|
787 DECLARE_ALIGNED_8(uint8_t, trans)[8*4]; |
8430 | 788 transpose4x4(trans, pix-2, 8, stride); |
789 transpose4x4(trans+4, pix-2+4*stride, 8, stride); | |
790 h264_loop_filter_chroma_intra_mmx2(trans+2*8, 8, alpha-1, beta-1); | |
791 transpose4x4(pix-2, trans, stride, 8); | |
792 transpose4x4(pix-2+4*stride, trans+4, stride, 8); | |
793 } | |
794 | |
795 static void h264_loop_filter_strength_mmx2( int16_t bS[2][4][4], uint8_t nnz[40], int8_t ref[2][40], int16_t mv[2][40][2], | |
796 int bidir, int edges, int step, int mask_mv0, int mask_mv1, int field ) { | |
797 int dir; | |
798 __asm__ volatile( | |
799 "pxor %%mm7, %%mm7 \n\t" | |
800 "movq %0, %%mm6 \n\t" | |
801 "movq %1, %%mm5 \n\t" | |
802 "movq %2, %%mm4 \n\t" | |
803 ::"m"(ff_pb_1), "m"(ff_pb_3), "m"(ff_pb_7) | |
804 ); | |
805 if(field) | |
806 __asm__ volatile( | |
807 "movq %0, %%mm5 \n\t" | |
808 "movq %1, %%mm4 \n\t" | |
809 ::"m"(ff_pb_3_1), "m"(ff_pb_7_3) | |
810 ); | |
811 | |
812 // could do a special case for dir==0 && edges==1, but it only reduces the | |
813 // average filter time by 1.2% | |
814 for( dir=1; dir>=0; dir-- ) { | |
10953 | 815 const x86_reg d_idx = dir ? -8 : -1; |
8430 | 816 const int mask_mv = dir ? mask_mv1 : mask_mv0; |
817 DECLARE_ALIGNED_8(const uint64_t, mask_dir) = dir ? 0 : 0xffffffffffffffffULL; | |
818 int b_idx, edge, l; | |
819 for( b_idx=12, edge=0; edge<edges; edge+=step, b_idx+=8*step ) { | |
820 __asm__ volatile( | |
821 "pand %0, %%mm0 \n\t" | |
822 ::"m"(mask_dir) | |
823 ); | |
824 if(!(mask_mv & edge)) { | |
825 __asm__ volatile("pxor %%mm0, %%mm0 \n\t":); | |
826 for( l = bidir; l >= 0; l-- ) { | |
827 __asm__ volatile( | |
10953 | 828 "movd (%0), %%mm1 \n\t" |
829 "punpckldq (%0,%1), %%mm1 \n\t" | |
8430 | 830 "punpckldq %%mm1, %%mm2 \n\t" |
831 "pcmpeqb %%mm2, %%mm1 \n\t" | |
832 "paddb %%mm6, %%mm1 \n\t" | |
833 "punpckhbw %%mm7, %%mm1 \n\t" // ref[b] != ref[bn] | |
834 "por %%mm1, %%mm0 \n\t" | |
835 | |
10953 | 836 "movq (%2), %%mm1 \n\t" |
837 "movq 8(%2), %%mm2 \n\t" | |
838 "psubw (%2,%1,4), %%mm1 \n\t" | |
839 "psubw 8(%2,%1,4), %%mm2 \n\t" | |
8430 | 840 "packsswb %%mm2, %%mm1 \n\t" |
841 "paddb %%mm5, %%mm1 \n\t" | |
842 "pminub %%mm4, %%mm1 \n\t" | |
843 "pcmpeqb %%mm4, %%mm1 \n\t" // abs(mv[b] - mv[bn]) >= limit | |
844 "por %%mm1, %%mm0 \n\t" | |
10953 | 845 ::"r"(ref[l]+b_idx), |
846 "r"(d_idx), | |
847 "r"(mv[l]+b_idx) | |
8430 | 848 ); |
849 } | |
10938
2a50b786b888
Fix h264_loop_filter_strength_mmx2() so it works with b frames.
michael
parents:
10937
diff
changeset
|
850 if(bidir==1){ |
2a50b786b888
Fix h264_loop_filter_strength_mmx2() so it works with b frames.
michael
parents:
10937
diff
changeset
|
851 __asm__ volatile("pxor %%mm3, %%mm3 \n\t":); |
2a50b786b888
Fix h264_loop_filter_strength_mmx2() so it works with b frames.
michael
parents:
10937
diff
changeset
|
852 for( l = bidir; l >= 0; l-- ) { |
2a50b786b888
Fix h264_loop_filter_strength_mmx2() so it works with b frames.
michael
parents:
10937
diff
changeset
|
853 __asm__ volatile( |
10953 | 854 "movd (%0), %%mm1 \n\t" |
855 "punpckldq (%1), %%mm1 \n\t" | |
10938
2a50b786b888
Fix h264_loop_filter_strength_mmx2() so it works with b frames.
michael
parents:
10937
diff
changeset
|
856 "punpckldq %%mm1, %%mm2 \n\t" |
2a50b786b888
Fix h264_loop_filter_strength_mmx2() so it works with b frames.
michael
parents:
10937
diff
changeset
|
857 "pcmpeqb %%mm2, %%mm1 \n\t" |
2a50b786b888
Fix h264_loop_filter_strength_mmx2() so it works with b frames.
michael
parents:
10937
diff
changeset
|
858 "paddb %%mm6, %%mm1 \n\t" |
2a50b786b888
Fix h264_loop_filter_strength_mmx2() so it works with b frames.
michael
parents:
10937
diff
changeset
|
859 "punpckhbw %%mm7, %%mm1 \n\t" // ref[b] != ref[bn] |
2a50b786b888
Fix h264_loop_filter_strength_mmx2() so it works with b frames.
michael
parents:
10937
diff
changeset
|
860 "por %%mm1, %%mm3 \n\t" |
2a50b786b888
Fix h264_loop_filter_strength_mmx2() so it works with b frames.
michael
parents:
10937
diff
changeset
|
861 |
10953 | 862 "movq (%2), %%mm1 \n\t" |
863 "movq 8(%2), %%mm2 \n\t" | |
864 "psubw (%3), %%mm1 \n\t" | |
865 "psubw 8(%3), %%mm2 \n\t" | |
10938
2a50b786b888
Fix h264_loop_filter_strength_mmx2() so it works with b frames.
michael
parents:
10937
diff
changeset
|
866 "packsswb %%mm2, %%mm1 \n\t" |
2a50b786b888
Fix h264_loop_filter_strength_mmx2() so it works with b frames.
michael
parents:
10937
diff
changeset
|
867 "paddb %%mm5, %%mm1 \n\t" |
2a50b786b888
Fix h264_loop_filter_strength_mmx2() so it works with b frames.
michael
parents:
10937
diff
changeset
|
868 "pminub %%mm4, %%mm1 \n\t" |
2a50b786b888
Fix h264_loop_filter_strength_mmx2() so it works with b frames.
michael
parents:
10937
diff
changeset
|
869 "pcmpeqb %%mm4, %%mm1 \n\t" // abs(mv[b] - mv[bn]) >= limit |
2a50b786b888
Fix h264_loop_filter_strength_mmx2() so it works with b frames.
michael
parents:
10937
diff
changeset
|
870 "por %%mm1, %%mm3 \n\t" |
10953 | 871 ::"r"(ref[l]+b_idx), |
872 "r"(ref[1-l]+b_idx+d_idx), | |
873 "r"(mv[l][b_idx]), | |
874 "r"(mv[1-l][b_idx+d_idx]) | |
10938
2a50b786b888
Fix h264_loop_filter_strength_mmx2() so it works with b frames.
michael
parents:
10937
diff
changeset
|
875 ); |
2a50b786b888
Fix h264_loop_filter_strength_mmx2() so it works with b frames.
michael
parents:
10937
diff
changeset
|
876 } |
2a50b786b888
Fix h264_loop_filter_strength_mmx2() so it works with b frames.
michael
parents:
10937
diff
changeset
|
877 __asm__ volatile( |
2a50b786b888
Fix h264_loop_filter_strength_mmx2() so it works with b frames.
michael
parents:
10937
diff
changeset
|
878 "pcmpeqw %%mm7, %%mm3 \n\t" |
2a50b786b888
Fix h264_loop_filter_strength_mmx2() so it works with b frames.
michael
parents:
10937
diff
changeset
|
879 "psubusw %%mm3, %%mm0 \n\t" |
2a50b786b888
Fix h264_loop_filter_strength_mmx2() so it works with b frames.
michael
parents:
10937
diff
changeset
|
880 :); |
2a50b786b888
Fix h264_loop_filter_strength_mmx2() so it works with b frames.
michael
parents:
10937
diff
changeset
|
881 } |
8430 | 882 } |
883 __asm__ volatile( | |
884 "movd %0, %%mm1 \n\t" | |
885 "por %1, %%mm1 \n\t" | |
886 "punpcklbw %%mm7, %%mm1 \n\t" | |
887 "pcmpgtw %%mm7, %%mm1 \n\t" // nnz[b] || nnz[bn] | |
888 ::"m"(nnz[b_idx]), | |
889 "m"(nnz[b_idx+d_idx]) | |
890 ); | |
891 __asm__ volatile( | |
892 "pcmpeqw %%mm7, %%mm0 \n\t" | |
893 "pcmpeqw %%mm7, %%mm0 \n\t" | |
894 "psrlw $15, %%mm0 \n\t" // nonzero -> 1 | |
895 "psrlw $14, %%mm1 \n\t" | |
896 "movq %%mm0, %%mm2 \n\t" | |
897 "por %%mm1, %%mm2 \n\t" | |
898 "psrlw $1, %%mm1 \n\t" | |
899 "pandn %%mm2, %%mm1 \n\t" | |
900 "movq %%mm1, %0 \n\t" | |
901 :"=m"(*bS[dir][edge]) | |
902 ::"memory" | |
903 ); | |
904 } | |
905 edges = 4; | |
906 step = 1; | |
907 } | |
908 __asm__ volatile( | |
909 "movq (%0), %%mm0 \n\t" | |
910 "movq 8(%0), %%mm1 \n\t" | |
911 "movq 16(%0), %%mm2 \n\t" | |
912 "movq 24(%0), %%mm3 \n\t" | |
913 TRANSPOSE4(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4) | |
914 "movq %%mm0, (%0) \n\t" | |
915 "movq %%mm3, 8(%0) \n\t" | |
916 "movq %%mm4, 16(%0) \n\t" | |
917 "movq %%mm2, 24(%0) \n\t" | |
918 ::"r"(bS[0]) | |
919 :"memory" | |
920 ); | |
921 } | |
922 | |
923 /***********************************/ | |
924 /* motion compensation */ | |
925 | |
926 #define QPEL_H264V_MM(A,B,C,D,E,F,OP,T,Z,d,q)\ | |
927 "mov"#q" "#C", "#T" \n\t"\ | |
928 "mov"#d" (%0), "#F" \n\t"\ | |
929 "paddw "#D", "#T" \n\t"\ | |
930 "psllw $2, "#T" \n\t"\ | |
931 "psubw "#B", "#T" \n\t"\ | |
932 "psubw "#E", "#T" \n\t"\ | |
933 "punpcklbw "#Z", "#F" \n\t"\ | |
934 "pmullw %4, "#T" \n\t"\ | |
935 "paddw %5, "#A" \n\t"\ | |
936 "add %2, %0 \n\t"\ | |
937 "paddw "#F", "#A" \n\t"\ | |
938 "paddw "#A", "#T" \n\t"\ | |
939 "psraw $5, "#T" \n\t"\ | |
940 "packuswb "#T", "#T" \n\t"\ | |
941 OP(T, (%1), A, d)\ | |
942 "add %3, %1 \n\t" | |
943 | |
944 #define QPEL_H264HV_MM(A,B,C,D,E,F,OF,T,Z,d,q)\ | |
945 "mov"#q" "#C", "#T" \n\t"\ | |
946 "mov"#d" (%0), "#F" \n\t"\ | |
947 "paddw "#D", "#T" \n\t"\ | |
948 "psllw $2, "#T" \n\t"\ | |
949 "paddw %4, "#A" \n\t"\ | |
950 "psubw "#B", "#T" \n\t"\ | |
951 "psubw "#E", "#T" \n\t"\ | |
952 "punpcklbw "#Z", "#F" \n\t"\ | |
953 "pmullw %3, "#T" \n\t"\ | |
954 "paddw "#F", "#A" \n\t"\ | |
955 "add %2, %0 \n\t"\ | |
956 "paddw "#A", "#T" \n\t"\ | |
957 "mov"#q" "#T", "#OF"(%1) \n\t" | |
958 | |
959 #define QPEL_H264V(A,B,C,D,E,F,OP) QPEL_H264V_MM(A,B,C,D,E,F,OP,%%mm6,%%mm7,d,q) | |
960 #define QPEL_H264HV(A,B,C,D,E,F,OF) QPEL_H264HV_MM(A,B,C,D,E,F,OF,%%mm6,%%mm7,d,q) | |
961 #define QPEL_H264V_XMM(A,B,C,D,E,F,OP) QPEL_H264V_MM(A,B,C,D,E,F,OP,%%xmm6,%%xmm7,q,dqa) | |
962 #define QPEL_H264HV_XMM(A,B,C,D,E,F,OF) QPEL_H264HV_MM(A,B,C,D,E,F,OF,%%xmm6,%%xmm7,q,dqa) | |
963 | |
964 | |
965 #define QPEL_H264(OPNAME, OP, MMX)\ | |
966 static av_noinline void OPNAME ## h264_qpel4_h_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | |
967 int h=4;\ | |
968 \ | |
969 __asm__ volatile(\ | |
970 "pxor %%mm7, %%mm7 \n\t"\ | |
971 "movq %5, %%mm4 \n\t"\ | |
972 "movq %6, %%mm5 \n\t"\ | |
973 "1: \n\t"\ | |
974 "movd -1(%0), %%mm1 \n\t"\ | |
975 "movd (%0), %%mm2 \n\t"\ | |
976 "movd 1(%0), %%mm3 \n\t"\ | |
977 "movd 2(%0), %%mm0 \n\t"\ | |
978 "punpcklbw %%mm7, %%mm1 \n\t"\ | |
979 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
980 "punpcklbw %%mm7, %%mm3 \n\t"\ | |
981 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
982 "paddw %%mm0, %%mm1 \n\t"\ | |
983 "paddw %%mm3, %%mm2 \n\t"\ | |
984 "movd -2(%0), %%mm0 \n\t"\ | |
985 "movd 3(%0), %%mm3 \n\t"\ | |
986 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
987 "punpcklbw %%mm7, %%mm3 \n\t"\ | |
988 "paddw %%mm3, %%mm0 \n\t"\ | |
989 "psllw $2, %%mm2 \n\t"\ | |
990 "psubw %%mm1, %%mm2 \n\t"\ | |
991 "pmullw %%mm4, %%mm2 \n\t"\ | |
992 "paddw %%mm5, %%mm0 \n\t"\ | |
993 "paddw %%mm2, %%mm0 \n\t"\ | |
994 "psraw $5, %%mm0 \n\t"\ | |
995 "packuswb %%mm0, %%mm0 \n\t"\ | |
996 OP(%%mm0, (%1),%%mm6, d)\ | |
997 "add %3, %0 \n\t"\ | |
998 "add %4, %1 \n\t"\ | |
999 "decl %2 \n\t"\ | |
1000 " jnz 1b \n\t"\ | |
1001 : "+a"(src), "+c"(dst), "+g"(h)\ | |
1002 : "d"((x86_reg)srcStride), "S"((x86_reg)dstStride), "m"(ff_pw_5), "m"(ff_pw_16)\ | |
1003 : "memory"\ | |
1004 );\ | |
1005 }\ | |
1006 static av_noinline void OPNAME ## h264_qpel4_h_lowpass_l2_ ## MMX(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride){\ | |
1007 int h=4;\ | |
1008 __asm__ volatile(\ | |
1009 "pxor %%mm7, %%mm7 \n\t"\ | |
1010 "movq %0, %%mm4 \n\t"\ | |
1011 "movq %1, %%mm5 \n\t"\ | |
1012 :: "m"(ff_pw_5), "m"(ff_pw_16)\ | |
1013 );\ | |
1014 do{\ | |
1015 __asm__ volatile(\ | |
1016 "movd -1(%0), %%mm1 \n\t"\ | |
1017 "movd (%0), %%mm2 \n\t"\ | |
1018 "movd 1(%0), %%mm3 \n\t"\ | |
1019 "movd 2(%0), %%mm0 \n\t"\ | |
1020 "punpcklbw %%mm7, %%mm1 \n\t"\ | |
1021 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
1022 "punpcklbw %%mm7, %%mm3 \n\t"\ | |
1023 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
1024 "paddw %%mm0, %%mm1 \n\t"\ | |
1025 "paddw %%mm3, %%mm2 \n\t"\ | |
1026 "movd -2(%0), %%mm0 \n\t"\ | |
1027 "movd 3(%0), %%mm3 \n\t"\ | |
1028 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
1029 "punpcklbw %%mm7, %%mm3 \n\t"\ | |
1030 "paddw %%mm3, %%mm0 \n\t"\ | |
1031 "psllw $2, %%mm2 \n\t"\ | |
1032 "psubw %%mm1, %%mm2 \n\t"\ | |
1033 "pmullw %%mm4, %%mm2 \n\t"\ | |
1034 "paddw %%mm5, %%mm0 \n\t"\ | |
1035 "paddw %%mm2, %%mm0 \n\t"\ | |
1036 "movd (%2), %%mm3 \n\t"\ | |
1037 "psraw $5, %%mm0 \n\t"\ | |
1038 "packuswb %%mm0, %%mm0 \n\t"\ | |
1039 PAVGB" %%mm3, %%mm0 \n\t"\ | |
1040 OP(%%mm0, (%1),%%mm6, d)\ | |
1041 "add %4, %0 \n\t"\ | |
1042 "add %4, %1 \n\t"\ | |
1043 "add %3, %2 \n\t"\ | |
1044 : "+a"(src), "+c"(dst), "+d"(src2)\ | |
1045 : "D"((x86_reg)src2Stride), "S"((x86_reg)dstStride)\ | |
1046 : "memory"\ | |
1047 );\ | |
1048 }while(--h);\ | |
1049 }\ | |
1050 static av_noinline void OPNAME ## h264_qpel4_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | |
1051 src -= 2*srcStride;\ | |
1052 __asm__ volatile(\ | |
1053 "pxor %%mm7, %%mm7 \n\t"\ | |
1054 "movd (%0), %%mm0 \n\t"\ | |
1055 "add %2, %0 \n\t"\ | |
1056 "movd (%0), %%mm1 \n\t"\ | |
1057 "add %2, %0 \n\t"\ | |
1058 "movd (%0), %%mm2 \n\t"\ | |
1059 "add %2, %0 \n\t"\ | |
1060 "movd (%0), %%mm3 \n\t"\ | |
1061 "add %2, %0 \n\t"\ | |
1062 "movd (%0), %%mm4 \n\t"\ | |
1063 "add %2, %0 \n\t"\ | |
1064 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
1065 "punpcklbw %%mm7, %%mm1 \n\t"\ | |
1066 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
1067 "punpcklbw %%mm7, %%mm3 \n\t"\ | |
1068 "punpcklbw %%mm7, %%mm4 \n\t"\ | |
1069 QPEL_H264V(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP)\ | |
1070 QPEL_H264V(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP)\ | |
1071 QPEL_H264V(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP)\ | |
1072 QPEL_H264V(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP)\ | |
1073 \ | |
1074 : "+a"(src), "+c"(dst)\ | |
1075 : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "m"(ff_pw_5), "m"(ff_pw_16)\ | |
1076 : "memory"\ | |
1077 );\ | |
1078 }\ | |
1079 static av_noinline void OPNAME ## h264_qpel4_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\ | |
1080 int h=4;\ | |
1081 int w=3;\ | |
1082 src -= 2*srcStride+2;\ | |
1083 while(w--){\ | |
1084 __asm__ volatile(\ | |
1085 "pxor %%mm7, %%mm7 \n\t"\ | |
1086 "movd (%0), %%mm0 \n\t"\ | |
1087 "add %2, %0 \n\t"\ | |
1088 "movd (%0), %%mm1 \n\t"\ | |
1089 "add %2, %0 \n\t"\ | |
1090 "movd (%0), %%mm2 \n\t"\ | |
1091 "add %2, %0 \n\t"\ | |
1092 "movd (%0), %%mm3 \n\t"\ | |
1093 "add %2, %0 \n\t"\ | |
1094 "movd (%0), %%mm4 \n\t"\ | |
1095 "add %2, %0 \n\t"\ | |
1096 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
1097 "punpcklbw %%mm7, %%mm1 \n\t"\ | |
1098 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
1099 "punpcklbw %%mm7, %%mm3 \n\t"\ | |
1100 "punpcklbw %%mm7, %%mm4 \n\t"\ | |
1101 QPEL_H264HV(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, 0*8*3)\ | |
1102 QPEL_H264HV(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, 1*8*3)\ | |
1103 QPEL_H264HV(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, 2*8*3)\ | |
1104 QPEL_H264HV(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, 3*8*3)\ | |
1105 \ | |
1106 : "+a"(src)\ | |
1107 : "c"(tmp), "S"((x86_reg)srcStride), "m"(ff_pw_5), "m"(ff_pw_16)\ | |
1108 : "memory"\ | |
1109 );\ | |
1110 tmp += 4;\ | |
1111 src += 4 - 9*srcStride;\ | |
1112 }\ | |
1113 tmp -= 3*4;\ | |
1114 __asm__ volatile(\ | |
1115 "1: \n\t"\ | |
1116 "movq (%0), %%mm0 \n\t"\ | |
1117 "paddw 10(%0), %%mm0 \n\t"\ | |
1118 "movq 2(%0), %%mm1 \n\t"\ | |
1119 "paddw 8(%0), %%mm1 \n\t"\ | |
1120 "movq 4(%0), %%mm2 \n\t"\ | |
1121 "paddw 6(%0), %%mm2 \n\t"\ | |
1122 "psubw %%mm1, %%mm0 \n\t"/*a-b (abccba)*/\ | |
1123 "psraw $2, %%mm0 \n\t"/*(a-b)/4 */\ | |
1124 "psubw %%mm1, %%mm0 \n\t"/*(a-b)/4-b */\ | |
1125 "paddsw %%mm2, %%mm0 \n\t"\ | |
1126 "psraw $2, %%mm0 \n\t"/*((a-b)/4-b+c)/4 */\ | |
1127 "paddw %%mm2, %%mm0 \n\t"/*(a-5*b+20*c)/16 */\ | |
1128 "psraw $6, %%mm0 \n\t"\ | |
1129 "packuswb %%mm0, %%mm0 \n\t"\ | |
1130 OP(%%mm0, (%1),%%mm7, d)\ | |
1131 "add $24, %0 \n\t"\ | |
1132 "add %3, %1 \n\t"\ | |
1133 "decl %2 \n\t"\ | |
1134 " jnz 1b \n\t"\ | |
1135 : "+a"(tmp), "+c"(dst), "+g"(h)\ | |
1136 : "S"((x86_reg)dstStride)\ | |
1137 : "memory"\ | |
1138 );\ | |
1139 }\ | |
1140 \ | |
1141 static av_noinline void OPNAME ## h264_qpel8_h_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | |
1142 int h=8;\ | |
1143 __asm__ volatile(\ | |
1144 "pxor %%mm7, %%mm7 \n\t"\ | |
1145 "movq %5, %%mm6 \n\t"\ | |
1146 "1: \n\t"\ | |
1147 "movq (%0), %%mm0 \n\t"\ | |
1148 "movq 1(%0), %%mm2 \n\t"\ | |
1149 "movq %%mm0, %%mm1 \n\t"\ | |
1150 "movq %%mm2, %%mm3 \n\t"\ | |
1151 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
1152 "punpckhbw %%mm7, %%mm1 \n\t"\ | |
1153 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
1154 "punpckhbw %%mm7, %%mm3 \n\t"\ | |
1155 "paddw %%mm2, %%mm0 \n\t"\ | |
1156 "paddw %%mm3, %%mm1 \n\t"\ | |
1157 "psllw $2, %%mm0 \n\t"\ | |
1158 "psllw $2, %%mm1 \n\t"\ | |
1159 "movq -1(%0), %%mm2 \n\t"\ | |
1160 "movq 2(%0), %%mm4 \n\t"\ | |
1161 "movq %%mm2, %%mm3 \n\t"\ | |
1162 "movq %%mm4, %%mm5 \n\t"\ | |
1163 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
1164 "punpckhbw %%mm7, %%mm3 \n\t"\ | |
1165 "punpcklbw %%mm7, %%mm4 \n\t"\ | |
1166 "punpckhbw %%mm7, %%mm5 \n\t"\ | |
1167 "paddw %%mm4, %%mm2 \n\t"\ | |
1168 "paddw %%mm3, %%mm5 \n\t"\ | |
1169 "psubw %%mm2, %%mm0 \n\t"\ | |
1170 "psubw %%mm5, %%mm1 \n\t"\ | |
1171 "pmullw %%mm6, %%mm0 \n\t"\ | |
1172 "pmullw %%mm6, %%mm1 \n\t"\ | |
1173 "movd -2(%0), %%mm2 \n\t"\ | |
1174 "movd 7(%0), %%mm5 \n\t"\ | |
1175 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
1176 "punpcklbw %%mm7, %%mm5 \n\t"\ | |
1177 "paddw %%mm3, %%mm2 \n\t"\ | |
1178 "paddw %%mm5, %%mm4 \n\t"\ | |
1179 "movq %6, %%mm5 \n\t"\ | |
1180 "paddw %%mm5, %%mm2 \n\t"\ | |
1181 "paddw %%mm5, %%mm4 \n\t"\ | |
1182 "paddw %%mm2, %%mm0 \n\t"\ | |
1183 "paddw %%mm4, %%mm1 \n\t"\ | |
1184 "psraw $5, %%mm0 \n\t"\ | |
1185 "psraw $5, %%mm1 \n\t"\ | |
1186 "packuswb %%mm1, %%mm0 \n\t"\ | |
1187 OP(%%mm0, (%1),%%mm5, q)\ | |
1188 "add %3, %0 \n\t"\ | |
1189 "add %4, %1 \n\t"\ | |
1190 "decl %2 \n\t"\ | |
1191 " jnz 1b \n\t"\ | |
1192 : "+a"(src), "+c"(dst), "+g"(h)\ | |
1193 : "d"((x86_reg)srcStride), "S"((x86_reg)dstStride), "m"(ff_pw_5), "m"(ff_pw_16)\ | |
1194 : "memory"\ | |
1195 );\ | |
1196 }\ | |
1197 \ | |
1198 static av_noinline void OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride){\ | |
1199 int h=8;\ | |
1200 __asm__ volatile(\ | |
1201 "pxor %%mm7, %%mm7 \n\t"\ | |
1202 "movq %0, %%mm6 \n\t"\ | |
1203 :: "m"(ff_pw_5)\ | |
1204 );\ | |
1205 do{\ | |
1206 __asm__ volatile(\ | |
1207 "movq (%0), %%mm0 \n\t"\ | |
1208 "movq 1(%0), %%mm2 \n\t"\ | |
1209 "movq %%mm0, %%mm1 \n\t"\ | |
1210 "movq %%mm2, %%mm3 \n\t"\ | |
1211 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
1212 "punpckhbw %%mm7, %%mm1 \n\t"\ | |
1213 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
1214 "punpckhbw %%mm7, %%mm3 \n\t"\ | |
1215 "paddw %%mm2, %%mm0 \n\t"\ | |
1216 "paddw %%mm3, %%mm1 \n\t"\ | |
1217 "psllw $2, %%mm0 \n\t"\ | |
1218 "psllw $2, %%mm1 \n\t"\ | |
1219 "movq -1(%0), %%mm2 \n\t"\ | |
1220 "movq 2(%0), %%mm4 \n\t"\ | |
1221 "movq %%mm2, %%mm3 \n\t"\ | |
1222 "movq %%mm4, %%mm5 \n\t"\ | |
1223 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
1224 "punpckhbw %%mm7, %%mm3 \n\t"\ | |
1225 "punpcklbw %%mm7, %%mm4 \n\t"\ | |
1226 "punpckhbw %%mm7, %%mm5 \n\t"\ | |
1227 "paddw %%mm4, %%mm2 \n\t"\ | |
1228 "paddw %%mm3, %%mm5 \n\t"\ | |
1229 "psubw %%mm2, %%mm0 \n\t"\ | |
1230 "psubw %%mm5, %%mm1 \n\t"\ | |
1231 "pmullw %%mm6, %%mm0 \n\t"\ | |
1232 "pmullw %%mm6, %%mm1 \n\t"\ | |
1233 "movd -2(%0), %%mm2 \n\t"\ | |
1234 "movd 7(%0), %%mm5 \n\t"\ | |
1235 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
1236 "punpcklbw %%mm7, %%mm5 \n\t"\ | |
1237 "paddw %%mm3, %%mm2 \n\t"\ | |
1238 "paddw %%mm5, %%mm4 \n\t"\ | |
1239 "movq %5, %%mm5 \n\t"\ | |
1240 "paddw %%mm5, %%mm2 \n\t"\ | |
1241 "paddw %%mm5, %%mm4 \n\t"\ | |
1242 "paddw %%mm2, %%mm0 \n\t"\ | |
1243 "paddw %%mm4, %%mm1 \n\t"\ | |
1244 "psraw $5, %%mm0 \n\t"\ | |
1245 "psraw $5, %%mm1 \n\t"\ | |
1246 "movq (%2), %%mm4 \n\t"\ | |
1247 "packuswb %%mm1, %%mm0 \n\t"\ | |
1248 PAVGB" %%mm4, %%mm0 \n\t"\ | |
1249 OP(%%mm0, (%1),%%mm5, q)\ | |
1250 "add %4, %0 \n\t"\ | |
1251 "add %4, %1 \n\t"\ | |
1252 "add %3, %2 \n\t"\ | |
1253 : "+a"(src), "+c"(dst), "+d"(src2)\ | |
1254 : "D"((x86_reg)src2Stride), "S"((x86_reg)dstStride),\ | |
1255 "m"(ff_pw_16)\ | |
1256 : "memory"\ | |
1257 );\ | |
1258 }while(--h);\ | |
1259 }\ | |
1260 \ | |
1261 static av_noinline void OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\ | |
1262 int w= 2;\ | |
1263 src -= 2*srcStride;\ | |
1264 \ | |
1265 while(w--){\ | |
1266 __asm__ volatile(\ | |
1267 "pxor %%mm7, %%mm7 \n\t"\ | |
1268 "movd (%0), %%mm0 \n\t"\ | |
1269 "add %2, %0 \n\t"\ | |
1270 "movd (%0), %%mm1 \n\t"\ | |
1271 "add %2, %0 \n\t"\ | |
1272 "movd (%0), %%mm2 \n\t"\ | |
1273 "add %2, %0 \n\t"\ | |
1274 "movd (%0), %%mm3 \n\t"\ | |
1275 "add %2, %0 \n\t"\ | |
1276 "movd (%0), %%mm4 \n\t"\ | |
1277 "add %2, %0 \n\t"\ | |
1278 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
1279 "punpcklbw %%mm7, %%mm1 \n\t"\ | |
1280 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
1281 "punpcklbw %%mm7, %%mm3 \n\t"\ | |
1282 "punpcklbw %%mm7, %%mm4 \n\t"\ | |
1283 QPEL_H264V(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP)\ | |
1284 QPEL_H264V(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP)\ | |
1285 QPEL_H264V(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP)\ | |
1286 QPEL_H264V(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP)\ | |
1287 QPEL_H264V(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, OP)\ | |
1288 QPEL_H264V(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, OP)\ | |
1289 QPEL_H264V(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP)\ | |
1290 QPEL_H264V(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP)\ | |
1291 \ | |
1292 : "+a"(src), "+c"(dst)\ | |
1293 : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "m"(ff_pw_5), "m"(ff_pw_16)\ | |
1294 : "memory"\ | |
1295 );\ | |
1296 if(h==16){\ | |
1297 __asm__ volatile(\ | |
1298 QPEL_H264V(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP)\ | |
1299 QPEL_H264V(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP)\ | |
1300 QPEL_H264V(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, OP)\ | |
1301 QPEL_H264V(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, OP)\ | |
1302 QPEL_H264V(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP)\ | |
1303 QPEL_H264V(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP)\ | |
1304 QPEL_H264V(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP)\ | |
1305 QPEL_H264V(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP)\ | |
1306 \ | |
1307 : "+a"(src), "+c"(dst)\ | |
1308 : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "m"(ff_pw_5), "m"(ff_pw_16)\ | |
1309 : "memory"\ | |
1310 );\ | |
1311 }\ | |
1312 src += 4-(h+5)*srcStride;\ | |
1313 dst += 4-h*dstStride;\ | |
1314 }\ | |
1315 }\ | |
1316 static av_always_inline void OPNAME ## h264_qpel8or16_hv1_lowpass_ ## MMX(int16_t *tmp, uint8_t *src, int tmpStride, int srcStride, int size){\ | |
1317 int w = (size+8)>>2;\ | |
1318 src -= 2*srcStride+2;\ | |
1319 while(w--){\ | |
1320 __asm__ volatile(\ | |
1321 "pxor %%mm7, %%mm7 \n\t"\ | |
1322 "movd (%0), %%mm0 \n\t"\ | |
1323 "add %2, %0 \n\t"\ | |
1324 "movd (%0), %%mm1 \n\t"\ | |
1325 "add %2, %0 \n\t"\ | |
1326 "movd (%0), %%mm2 \n\t"\ | |
1327 "add %2, %0 \n\t"\ | |
1328 "movd (%0), %%mm3 \n\t"\ | |
1329 "add %2, %0 \n\t"\ | |
1330 "movd (%0), %%mm4 \n\t"\ | |
1331 "add %2, %0 \n\t"\ | |
1332 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
1333 "punpcklbw %%mm7, %%mm1 \n\t"\ | |
1334 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
1335 "punpcklbw %%mm7, %%mm3 \n\t"\ | |
1336 "punpcklbw %%mm7, %%mm4 \n\t"\ | |
1337 QPEL_H264HV(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, 0*48)\ | |
1338 QPEL_H264HV(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, 1*48)\ | |
1339 QPEL_H264HV(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, 2*48)\ | |
1340 QPEL_H264HV(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, 3*48)\ | |
1341 QPEL_H264HV(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, 4*48)\ | |
1342 QPEL_H264HV(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, 5*48)\ | |
1343 QPEL_H264HV(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, 6*48)\ | |
1344 QPEL_H264HV(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, 7*48)\ | |
1345 : "+a"(src)\ | |
1346 : "c"(tmp), "S"((x86_reg)srcStride), "m"(ff_pw_5), "m"(ff_pw_16)\ | |
1347 : "memory"\ | |
1348 );\ | |
1349 if(size==16){\ | |
1350 __asm__ volatile(\ | |
1351 QPEL_H264HV(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, 8*48)\ | |
1352 QPEL_H264HV(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, 9*48)\ | |
1353 QPEL_H264HV(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, 10*48)\ | |
1354 QPEL_H264HV(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, 11*48)\ | |
1355 QPEL_H264HV(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, 12*48)\ | |
1356 QPEL_H264HV(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, 13*48)\ | |
1357 QPEL_H264HV(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, 14*48)\ | |
1358 QPEL_H264HV(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, 15*48)\ | |
1359 : "+a"(src)\ | |
1360 : "c"(tmp), "S"((x86_reg)srcStride), "m"(ff_pw_5), "m"(ff_pw_16)\ | |
1361 : "memory"\ | |
1362 );\ | |
1363 }\ | |
1364 tmp += 4;\ | |
1365 src += 4 - (size+5)*srcStride;\ | |
1366 }\ | |
1367 }\ | |
1368 static av_always_inline void OPNAME ## h264_qpel8or16_hv2_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, int dstStride, int tmpStride, int size){\ | |
1369 int w = size>>4;\ | |
1370 do{\ | |
1371 int h = size;\ | |
1372 __asm__ volatile(\ | |
1373 "1: \n\t"\ | |
1374 "movq (%0), %%mm0 \n\t"\ | |
1375 "movq 8(%0), %%mm3 \n\t"\ | |
1376 "movq 2(%0), %%mm1 \n\t"\ | |
1377 "movq 10(%0), %%mm4 \n\t"\ | |
1378 "paddw %%mm4, %%mm0 \n\t"\ | |
1379 "paddw %%mm3, %%mm1 \n\t"\ | |
1380 "paddw 18(%0), %%mm3 \n\t"\ | |
1381 "paddw 16(%0), %%mm4 \n\t"\ | |
1382 "movq 4(%0), %%mm2 \n\t"\ | |
1383 "movq 12(%0), %%mm5 \n\t"\ | |
1384 "paddw 6(%0), %%mm2 \n\t"\ | |
1385 "paddw 14(%0), %%mm5 \n\t"\ | |
1386 "psubw %%mm1, %%mm0 \n\t"\ | |
1387 "psubw %%mm4, %%mm3 \n\t"\ | |
1388 "psraw $2, %%mm0 \n\t"\ | |
1389 "psraw $2, %%mm3 \n\t"\ | |
1390 "psubw %%mm1, %%mm0 \n\t"\ | |
1391 "psubw %%mm4, %%mm3 \n\t"\ | |
1392 "paddsw %%mm2, %%mm0 \n\t"\ | |
1393 "paddsw %%mm5, %%mm3 \n\t"\ | |
1394 "psraw $2, %%mm0 \n\t"\ | |
1395 "psraw $2, %%mm3 \n\t"\ | |
1396 "paddw %%mm2, %%mm0 \n\t"\ | |
1397 "paddw %%mm5, %%mm3 \n\t"\ | |
1398 "psraw $6, %%mm0 \n\t"\ | |
1399 "psraw $6, %%mm3 \n\t"\ | |
1400 "packuswb %%mm3, %%mm0 \n\t"\ | |
1401 OP(%%mm0, (%1),%%mm7, q)\ | |
1402 "add $48, %0 \n\t"\ | |
1403 "add %3, %1 \n\t"\ | |
1404 "decl %2 \n\t"\ | |
1405 " jnz 1b \n\t"\ | |
1406 : "+a"(tmp), "+c"(dst), "+g"(h)\ | |
1407 : "S"((x86_reg)dstStride)\ | |
1408 : "memory"\ | |
1409 );\ | |
1410 tmp += 8 - size*24;\ | |
1411 dst += 8 - size*dstStride;\ | |
1412 }while(w--);\ | |
1413 }\ | |
1414 \ | |
1415 static void OPNAME ## h264_qpel8_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | |
1416 OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst , src , dstStride, srcStride, 8);\ | |
1417 }\ | |
1418 static av_noinline void OPNAME ## h264_qpel16_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | |
1419 OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst , src , dstStride, srcStride, 16);\ | |
1420 OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride, 16);\ | |
1421 }\ | |
1422 \ | |
1423 static void OPNAME ## h264_qpel16_h_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | |
1424 OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst , src , dstStride, srcStride);\ | |
1425 OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\ | |
1426 src += 8*srcStride;\ | |
1427 dst += 8*dstStride;\ | |
1428 OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst , src , dstStride, srcStride);\ | |
1429 OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\ | |
1430 }\ | |
1431 \ | |
1432 static av_noinline void OPNAME ## h264_qpel16_h_lowpass_l2_ ## MMX(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride){\ | |
1433 OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst , src , src2 , dstStride, src2Stride);\ | |
1434 OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst+8, src+8, src2+8, dstStride, src2Stride);\ | |
1435 src += 8*dstStride;\ | |
1436 dst += 8*dstStride;\ | |
1437 src2 += 8*src2Stride;\ | |
1438 OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst , src , src2 , dstStride, src2Stride);\ | |
1439 OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst+8, src+8, src2+8, dstStride, src2Stride);\ | |
1440 }\ | |
1441 \ | |
1442 static av_noinline void OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride, int size){\ | |
1443 put_h264_qpel8or16_hv1_lowpass_ ## MMX(tmp, src, tmpStride, srcStride, size);\ | |
1444 OPNAME ## h264_qpel8or16_hv2_lowpass_ ## MMX(dst, tmp, dstStride, tmpStride, size);\ | |
1445 }\ | |
1446 static void OPNAME ## h264_qpel8_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\ | |
1447 OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(dst , tmp , src , dstStride, tmpStride, srcStride, 8);\ | |
1448 }\ | |
1449 \ | |
1450 static void OPNAME ## h264_qpel16_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\ | |
1451 OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(dst , tmp , src , dstStride, tmpStride, srcStride, 16);\ | |
1452 }\ | |
1453 \ | |
1454 static av_noinline void OPNAME ## pixels4_l2_shift5_ ## MMX(uint8_t *dst, int16_t *src16, uint8_t *src8, int dstStride, int src8Stride, int h)\ | |
1455 {\ | |
1456 __asm__ volatile(\ | |
1457 "movq (%1), %%mm0 \n\t"\ | |
1458 "movq 24(%1), %%mm1 \n\t"\ | |
1459 "psraw $5, %%mm0 \n\t"\ | |
1460 "psraw $5, %%mm1 \n\t"\ | |
1461 "packuswb %%mm0, %%mm0 \n\t"\ | |
1462 "packuswb %%mm1, %%mm1 \n\t"\ | |
1463 PAVGB" (%0), %%mm0 \n\t"\ | |
1464 PAVGB" (%0,%3), %%mm1 \n\t"\ | |
1465 OP(%%mm0, (%2), %%mm4, d)\ | |
1466 OP(%%mm1, (%2,%4), %%mm5, d)\ | |
1467 "lea (%0,%3,2), %0 \n\t"\ | |
1468 "lea (%2,%4,2), %2 \n\t"\ | |
1469 "movq 48(%1), %%mm0 \n\t"\ | |
1470 "movq 72(%1), %%mm1 \n\t"\ | |
1471 "psraw $5, %%mm0 \n\t"\ | |
1472 "psraw $5, %%mm1 \n\t"\ | |
1473 "packuswb %%mm0, %%mm0 \n\t"\ | |
1474 "packuswb %%mm1, %%mm1 \n\t"\ | |
1475 PAVGB" (%0), %%mm0 \n\t"\ | |
1476 PAVGB" (%0,%3), %%mm1 \n\t"\ | |
1477 OP(%%mm0, (%2), %%mm4, d)\ | |
1478 OP(%%mm1, (%2,%4), %%mm5, d)\ | |
1479 :"+a"(src8), "+c"(src16), "+d"(dst)\ | |
1480 :"S"((x86_reg)src8Stride), "D"((x86_reg)dstStride)\ | |
1481 :"memory");\ | |
1482 }\ | |
1483 static av_noinline void OPNAME ## pixels8_l2_shift5_ ## MMX(uint8_t *dst, int16_t *src16, uint8_t *src8, int dstStride, int src8Stride, int h)\ | |
1484 {\ | |
1485 do{\ | |
1486 __asm__ volatile(\ | |
1487 "movq (%1), %%mm0 \n\t"\ | |
1488 "movq 8(%1), %%mm1 \n\t"\ | |
1489 "movq 48(%1), %%mm2 \n\t"\ | |
1490 "movq 8+48(%1), %%mm3 \n\t"\ | |
1491 "psraw $5, %%mm0 \n\t"\ | |
1492 "psraw $5, %%mm1 \n\t"\ | |
1493 "psraw $5, %%mm2 \n\t"\ | |
1494 "psraw $5, %%mm3 \n\t"\ | |
1495 "packuswb %%mm1, %%mm0 \n\t"\ | |
1496 "packuswb %%mm3, %%mm2 \n\t"\ | |
1497 PAVGB" (%0), %%mm0 \n\t"\ | |
1498 PAVGB" (%0,%3), %%mm2 \n\t"\ | |
1499 OP(%%mm0, (%2), %%mm5, q)\ | |
1500 OP(%%mm2, (%2,%4), %%mm5, q)\ | |
1501 ::"a"(src8), "c"(src16), "d"(dst),\ | |
1502 "r"((x86_reg)src8Stride), "r"((x86_reg)dstStride)\ | |
1503 :"memory");\ | |
1504 src8 += 2L*src8Stride;\ | |
1505 src16 += 48;\ | |
1506 dst += 2L*dstStride;\ | |
1507 }while(h-=2);\ | |
1508 }\ | |
1509 static void OPNAME ## pixels16_l2_shift5_ ## MMX(uint8_t *dst, int16_t *src16, uint8_t *src8, int dstStride, int src8Stride, int h)\ | |
1510 {\ | |
1511 OPNAME ## pixels8_l2_shift5_ ## MMX(dst , src16 , src8 , dstStride, src8Stride, h);\ | |
1512 OPNAME ## pixels8_l2_shift5_ ## MMX(dst+8, src16+8, src8+8, dstStride, src8Stride, h);\ | |
1513 }\ | |
1514 | |
1515 | |
8590 | 1516 #if ARCH_X86_64 |
8430 | 1517 #define QPEL_H264_H16_XMM(OPNAME, OP, MMX)\ |
1518 static av_noinline void OPNAME ## h264_qpel16_h_lowpass_l2_ ## MMX(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride){\ | |
1519 int h=16;\ | |
1520 __asm__ volatile(\ | |
1521 "pxor %%xmm15, %%xmm15 \n\t"\ | |
1522 "movdqa %6, %%xmm14 \n\t"\ | |
1523 "movdqa %7, %%xmm13 \n\t"\ | |
1524 "1: \n\t"\ | |
9739 | 1525 "lddqu 6(%0), %%xmm1 \n\t"\ |
1526 "lddqu -2(%0), %%xmm7 \n\t"\ | |
8430 | 1527 "movdqa %%xmm1, %%xmm0 \n\t"\ |
1528 "punpckhbw %%xmm15, %%xmm1 \n\t"\ | |
1529 "punpcklbw %%xmm15, %%xmm0 \n\t"\ | |
1530 "punpcklbw %%xmm15, %%xmm7 \n\t"\ | |
1531 "movdqa %%xmm1, %%xmm2 \n\t"\ | |
1532 "movdqa %%xmm0, %%xmm6 \n\t"\ | |
1533 "movdqa %%xmm1, %%xmm3 \n\t"\ | |
1534 "movdqa %%xmm0, %%xmm8 \n\t"\ | |
1535 "movdqa %%xmm1, %%xmm4 \n\t"\ | |
1536 "movdqa %%xmm0, %%xmm9 \n\t"\ | |
9739 | 1537 "movdqa %%xmm0, %%xmm12 \n\t"\ |
1538 "movdqa %%xmm1, %%xmm11 \n\t"\ | |
1539 "palignr $10,%%xmm0, %%xmm11\n\t"\ | |
1540 "palignr $10,%%xmm7, %%xmm12\n\t"\ | |
1541 "palignr $2, %%xmm0, %%xmm4 \n\t"\ | |
1542 "palignr $2, %%xmm7, %%xmm9 \n\t"\ | |
1543 "palignr $4, %%xmm0, %%xmm3 \n\t"\ | |
1544 "palignr $4, %%xmm7, %%xmm8 \n\t"\ | |
1545 "palignr $6, %%xmm0, %%xmm2 \n\t"\ | |
1546 "palignr $6, %%xmm7, %%xmm6 \n\t"\ | |
1547 "paddw %%xmm0 ,%%xmm11 \n\t"\ | |
1548 "palignr $8, %%xmm0, %%xmm1 \n\t"\ | |
1549 "palignr $8, %%xmm7, %%xmm0 \n\t"\ | |
1550 "paddw %%xmm12,%%xmm7 \n\t"\ | |
8430 | 1551 "paddw %%xmm3, %%xmm2 \n\t"\ |
1552 "paddw %%xmm8, %%xmm6 \n\t"\ | |
1553 "paddw %%xmm4, %%xmm1 \n\t"\ | |
1554 "paddw %%xmm9, %%xmm0 \n\t"\ | |
1555 "psllw $2, %%xmm2 \n\t"\ | |
1556 "psllw $2, %%xmm6 \n\t"\ | |
1557 "psubw %%xmm1, %%xmm2 \n\t"\ | |
1558 "psubw %%xmm0, %%xmm6 \n\t"\ | |
9739 | 1559 "paddw %%xmm13,%%xmm11 \n\t"\ |
1560 "paddw %%xmm13,%%xmm7 \n\t"\ | |
8430 | 1561 "pmullw %%xmm14,%%xmm2 \n\t"\ |
1562 "pmullw %%xmm14,%%xmm6 \n\t"\ | |
1563 "lddqu (%2), %%xmm3 \n\t"\ | |
9739 | 1564 "paddw %%xmm11,%%xmm2 \n\t"\ |
1565 "paddw %%xmm7, %%xmm6 \n\t"\ | |
8430 | 1566 "psraw $5, %%xmm2 \n\t"\ |
1567 "psraw $5, %%xmm6 \n\t"\ | |
1568 "packuswb %%xmm2,%%xmm6 \n\t"\ | |
1569 "pavgb %%xmm3, %%xmm6 \n\t"\ | |
1570 OP(%%xmm6, (%1), %%xmm4, dqa)\ | |
1571 "add %5, %0 \n\t"\ | |
1572 "add %5, %1 \n\t"\ | |
1573 "add %4, %2 \n\t"\ | |
1574 "decl %3 \n\t"\ | |
1575 "jg 1b \n\t"\ | |
1576 : "+a"(src), "+c"(dst), "+d"(src2), "+g"(h)\ | |
1577 : "D"((x86_reg)src2Stride), "S"((x86_reg)dstStride),\ | |
1578 "m"(ff_pw_5), "m"(ff_pw_16)\ | |
1579 : "memory"\ | |
1580 );\ | |
1581 } | |
1582 #else // ARCH_X86_64 | |
1583 #define QPEL_H264_H16_XMM(OPNAME, OP, MMX)\ | |
1584 static av_noinline void OPNAME ## h264_qpel16_h_lowpass_l2_ ## MMX(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride){\ | |
1585 OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst , src , src2 , dstStride, src2Stride);\ | |
1586 OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst+8, src+8, src2+8, dstStride, src2Stride);\ | |
1587 src += 8*dstStride;\ | |
1588 dst += 8*dstStride;\ | |
1589 src2 += 8*src2Stride;\ | |
1590 OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst , src , src2 , dstStride, src2Stride);\ | |
1591 OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst+8, src+8, src2+8, dstStride, src2Stride);\ | |
1592 } | |
1593 #endif // ARCH_X86_64 | |
1594 | |
1595 #define QPEL_H264_H_XMM(OPNAME, OP, MMX)\ | |
1596 static av_noinline void OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride){\ | |
1597 int h=8;\ | |
1598 __asm__ volatile(\ | |
1599 "pxor %%xmm7, %%xmm7 \n\t"\ | |
1600 "movdqa %0, %%xmm6 \n\t"\ | |
1601 :: "m"(ff_pw_5)\ | |
1602 );\ | |
1603 do{\ | |
1604 __asm__ volatile(\ | |
9739 | 1605 "lddqu -2(%0), %%xmm1 \n\t"\ |
8430 | 1606 "movdqa %%xmm1, %%xmm0 \n\t"\ |
1607 "punpckhbw %%xmm7, %%xmm1 \n\t"\ | |
1608 "punpcklbw %%xmm7, %%xmm0 \n\t"\ | |
1609 "movdqa %%xmm1, %%xmm2 \n\t"\ | |
1610 "movdqa %%xmm1, %%xmm3 \n\t"\ | |
1611 "movdqa %%xmm1, %%xmm4 \n\t"\ | |
1612 "movdqa %%xmm1, %%xmm5 \n\t"\ | |
9739 | 1613 "palignr $2, %%xmm0, %%xmm4 \n\t"\ |
1614 "palignr $4, %%xmm0, %%xmm3 \n\t"\ | |
1615 "palignr $6, %%xmm0, %%xmm2 \n\t"\ | |
1616 "palignr $8, %%xmm0, %%xmm1 \n\t"\ | |
1617 "palignr $10,%%xmm0, %%xmm5 \n\t"\ | |
1618 "paddw %%xmm5, %%xmm0 \n\t"\ | |
8430 | 1619 "paddw %%xmm3, %%xmm2 \n\t"\ |
1620 "paddw %%xmm4, %%xmm1 \n\t"\ | |
1621 "psllw $2, %%xmm2 \n\t"\ | |
1622 "movq (%2), %%xmm3 \n\t"\ | |
1623 "psubw %%xmm1, %%xmm2 \n\t"\ | |
9739 | 1624 "paddw %5, %%xmm0 \n\t"\ |
8430 | 1625 "pmullw %%xmm6, %%xmm2 \n\t"\ |
9739 | 1626 "paddw %%xmm0, %%xmm2 \n\t"\ |
8430 | 1627 "psraw $5, %%xmm2 \n\t"\ |
1628 "packuswb %%xmm2, %%xmm2 \n\t"\ | |
1629 "pavgb %%xmm3, %%xmm2 \n\t"\ | |
1630 OP(%%xmm2, (%1), %%xmm4, q)\ | |
1631 "add %4, %0 \n\t"\ | |
1632 "add %4, %1 \n\t"\ | |
1633 "add %3, %2 \n\t"\ | |
1634 : "+a"(src), "+c"(dst), "+d"(src2)\ | |
1635 : "D"((x86_reg)src2Stride), "S"((x86_reg)dstStride),\ | |
1636 "m"(ff_pw_16)\ | |
1637 : "memory"\ | |
1638 );\ | |
1639 }while(--h);\ | |
1640 }\ | |
1641 QPEL_H264_H16_XMM(OPNAME, OP, MMX)\ | |
1642 \ | |
1643 static av_noinline void OPNAME ## h264_qpel8_h_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | |
1644 int h=8;\ | |
1645 __asm__ volatile(\ | |
1646 "pxor %%xmm7, %%xmm7 \n\t"\ | |
1647 "movdqa %5, %%xmm6 \n\t"\ | |
1648 "1: \n\t"\ | |
9739 | 1649 "lddqu -2(%0), %%xmm1 \n\t"\ |
8430 | 1650 "movdqa %%xmm1, %%xmm0 \n\t"\ |
1651 "punpckhbw %%xmm7, %%xmm1 \n\t"\ | |
1652 "punpcklbw %%xmm7, %%xmm0 \n\t"\ | |
1653 "movdqa %%xmm1, %%xmm2 \n\t"\ | |
1654 "movdqa %%xmm1, %%xmm3 \n\t"\ | |
1655 "movdqa %%xmm1, %%xmm4 \n\t"\ | |
1656 "movdqa %%xmm1, %%xmm5 \n\t"\ | |
9739 | 1657 "palignr $2, %%xmm0, %%xmm4 \n\t"\ |
1658 "palignr $4, %%xmm0, %%xmm3 \n\t"\ | |
1659 "palignr $6, %%xmm0, %%xmm2 \n\t"\ | |
1660 "palignr $8, %%xmm0, %%xmm1 \n\t"\ | |
1661 "palignr $10,%%xmm0, %%xmm5 \n\t"\ | |
1662 "paddw %%xmm5, %%xmm0 \n\t"\ | |
8430 | 1663 "paddw %%xmm3, %%xmm2 \n\t"\ |
1664 "paddw %%xmm4, %%xmm1 \n\t"\ | |
1665 "psllw $2, %%xmm2 \n\t"\ | |
1666 "psubw %%xmm1, %%xmm2 \n\t"\ | |
9739 | 1667 "paddw %6, %%xmm0 \n\t"\ |
8430 | 1668 "pmullw %%xmm6, %%xmm2 \n\t"\ |
9739 | 1669 "paddw %%xmm0, %%xmm2 \n\t"\ |
8430 | 1670 "psraw $5, %%xmm2 \n\t"\ |
1671 "packuswb %%xmm2, %%xmm2 \n\t"\ | |
1672 OP(%%xmm2, (%1), %%xmm4, q)\ | |
1673 "add %3, %0 \n\t"\ | |
1674 "add %4, %1 \n\t"\ | |
1675 "decl %2 \n\t"\ | |
1676 " jnz 1b \n\t"\ | |
1677 : "+a"(src), "+c"(dst), "+g"(h)\ | |
1678 : "D"((x86_reg)srcStride), "S"((x86_reg)dstStride),\ | |
1679 "m"(ff_pw_5), "m"(ff_pw_16)\ | |
1680 : "memory"\ | |
1681 );\ | |
1682 }\ | |
1683 static void OPNAME ## h264_qpel16_h_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | |
1684 OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst , src , dstStride, srcStride);\ | |
1685 OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\ | |
1686 src += 8*srcStride;\ | |
1687 dst += 8*dstStride;\ | |
1688 OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst , src , dstStride, srcStride);\ | |
1689 OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\ | |
1690 }\ | |
1691 | |
1692 #define QPEL_H264_V_XMM(OPNAME, OP, MMX)\ | |
1693 static av_noinline void OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\ | |
1694 src -= 2*srcStride;\ | |
1695 \ | |
1696 __asm__ volatile(\ | |
1697 "pxor %%xmm7, %%xmm7 \n\t"\ | |
1698 "movq (%0), %%xmm0 \n\t"\ | |
1699 "add %2, %0 \n\t"\ | |
1700 "movq (%0), %%xmm1 \n\t"\ | |
1701 "add %2, %0 \n\t"\ | |
1702 "movq (%0), %%xmm2 \n\t"\ | |
1703 "add %2, %0 \n\t"\ | |
1704 "movq (%0), %%xmm3 \n\t"\ | |
1705 "add %2, %0 \n\t"\ | |
1706 "movq (%0), %%xmm4 \n\t"\ | |
1707 "add %2, %0 \n\t"\ | |
1708 "punpcklbw %%xmm7, %%xmm0 \n\t"\ | |
1709 "punpcklbw %%xmm7, %%xmm1 \n\t"\ | |
1710 "punpcklbw %%xmm7, %%xmm2 \n\t"\ | |
1711 "punpcklbw %%xmm7, %%xmm3 \n\t"\ | |
1712 "punpcklbw %%xmm7, %%xmm4 \n\t"\ | |
1713 QPEL_H264V_XMM(%%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, OP)\ | |
1714 QPEL_H264V_XMM(%%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, OP)\ | |
1715 QPEL_H264V_XMM(%%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, OP)\ | |
1716 QPEL_H264V_XMM(%%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, OP)\ | |
1717 QPEL_H264V_XMM(%%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, %%xmm3, OP)\ | |
1718 QPEL_H264V_XMM(%%xmm5, %%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, OP)\ | |
1719 QPEL_H264V_XMM(%%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, OP)\ | |
1720 QPEL_H264V_XMM(%%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, OP)\ | |
1721 \ | |
1722 : "+a"(src), "+c"(dst)\ | |
1723 : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "m"(ff_pw_5), "m"(ff_pw_16)\ | |
1724 : "memory"\ | |
1725 );\ | |
1726 if(h==16){\ | |
1727 __asm__ volatile(\ | |
1728 QPEL_H264V_XMM(%%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, OP)\ | |
1729 QPEL_H264V_XMM(%%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, OP)\ | |
1730 QPEL_H264V_XMM(%%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, %%xmm3, OP)\ | |
1731 QPEL_H264V_XMM(%%xmm5, %%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, OP)\ | |
1732 QPEL_H264V_XMM(%%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, OP)\ | |
1733 QPEL_H264V_XMM(%%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, OP)\ | |
1734 QPEL_H264V_XMM(%%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, OP)\ | |
1735 QPEL_H264V_XMM(%%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, OP)\ | |
1736 \ | |
1737 : "+a"(src), "+c"(dst)\ | |
1738 : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "m"(ff_pw_5), "m"(ff_pw_16)\ | |
1739 : "memory"\ | |
1740 );\ | |
1741 }\ | |
1742 }\ | |
1743 static void OPNAME ## h264_qpel8_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | |
1744 OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst , src , dstStride, srcStride, 8);\ | |
1745 }\ | |
1746 static av_noinline void OPNAME ## h264_qpel16_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | |
1747 OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst , src , dstStride, srcStride, 16);\ | |
1748 OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride, 16);\ | |
1749 } | |
1750 | |
1751 static av_always_inline void put_h264_qpel8or16_hv1_lowpass_sse2(int16_t *tmp, uint8_t *src, int tmpStride, int srcStride, int size){ | |
1752 int w = (size+8)>>3; | |
1753 src -= 2*srcStride+2; | |
1754 while(w--){ | |
1755 __asm__ volatile( | |
1756 "pxor %%xmm7, %%xmm7 \n\t" | |
1757 "movq (%0), %%xmm0 \n\t" | |
1758 "add %2, %0 \n\t" | |
1759 "movq (%0), %%xmm1 \n\t" | |
1760 "add %2, %0 \n\t" | |
1761 "movq (%0), %%xmm2 \n\t" | |
1762 "add %2, %0 \n\t" | |
1763 "movq (%0), %%xmm3 \n\t" | |
1764 "add %2, %0 \n\t" | |
1765 "movq (%0), %%xmm4 \n\t" | |
1766 "add %2, %0 \n\t" | |
1767 "punpcklbw %%xmm7, %%xmm0 \n\t" | |
1768 "punpcklbw %%xmm7, %%xmm1 \n\t" | |
1769 "punpcklbw %%xmm7, %%xmm2 \n\t" | |
1770 "punpcklbw %%xmm7, %%xmm3 \n\t" | |
1771 "punpcklbw %%xmm7, %%xmm4 \n\t" | |
1772 QPEL_H264HV_XMM(%%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, 0*48) | |
1773 QPEL_H264HV_XMM(%%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, 1*48) | |
1774 QPEL_H264HV_XMM(%%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, 2*48) | |
1775 QPEL_H264HV_XMM(%%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, 3*48) | |
1776 QPEL_H264HV_XMM(%%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, %%xmm3, 4*48) | |
1777 QPEL_H264HV_XMM(%%xmm5, %%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, 5*48) | |
1778 QPEL_H264HV_XMM(%%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, 6*48) | |
1779 QPEL_H264HV_XMM(%%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, 7*48) | |
1780 : "+a"(src) | |
1781 : "c"(tmp), "S"((x86_reg)srcStride), "m"(ff_pw_5), "m"(ff_pw_16) | |
1782 : "memory" | |
1783 ); | |
1784 if(size==16){ | |
1785 __asm__ volatile( | |
1786 QPEL_H264HV_XMM(%%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, 8*48) | |
1787 QPEL_H264HV_XMM(%%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, 9*48) | |
1788 QPEL_H264HV_XMM(%%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, %%xmm3, 10*48) | |
1789 QPEL_H264HV_XMM(%%xmm5, %%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, 11*48) | |
1790 QPEL_H264HV_XMM(%%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, 12*48) | |
1791 QPEL_H264HV_XMM(%%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, 13*48) | |
1792 QPEL_H264HV_XMM(%%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, 14*48) | |
1793 QPEL_H264HV_XMM(%%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, 15*48) | |
1794 : "+a"(src) | |
1795 : "c"(tmp), "S"((x86_reg)srcStride), "m"(ff_pw_5), "m"(ff_pw_16) | |
1796 : "memory" | |
1797 ); | |
1798 } | |
1799 tmp += 8; | |
1800 src += 8 - (size+5)*srcStride; | |
1801 } | |
1802 } | |
1803 | |
1804 #define QPEL_H264_HV2_XMM(OPNAME, OP, MMX)\ | |
1805 static av_always_inline void OPNAME ## h264_qpel8or16_hv2_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, int dstStride, int tmpStride, int size){\ | |
1806 int h = size;\ | |
1807 if(size == 16){\ | |
1808 __asm__ volatile(\ | |
1809 "1: \n\t"\ | |
1810 "movdqa 32(%0), %%xmm4 \n\t"\ | |
1811 "movdqa 16(%0), %%xmm5 \n\t"\ | |
1812 "movdqa (%0), %%xmm7 \n\t"\ | |
1813 "movdqa %%xmm4, %%xmm3 \n\t"\ | |
1814 "movdqa %%xmm4, %%xmm2 \n\t"\ | |
1815 "movdqa %%xmm4, %%xmm1 \n\t"\ | |
1816 "movdqa %%xmm4, %%xmm0 \n\t"\ | |
1817 "palignr $10, %%xmm5, %%xmm0 \n\t"\ | |
1818 "palignr $8, %%xmm5, %%xmm1 \n\t"\ | |
1819 "palignr $6, %%xmm5, %%xmm2 \n\t"\ | |
1820 "palignr $4, %%xmm5, %%xmm3 \n\t"\ | |
1821 "palignr $2, %%xmm5, %%xmm4 \n\t"\ | |
1822 "paddw %%xmm5, %%xmm0 \n\t"\ | |
1823 "paddw %%xmm4, %%xmm1 \n\t"\ | |
1824 "paddw %%xmm3, %%xmm2 \n\t"\ | |
1825 "movdqa %%xmm5, %%xmm6 \n\t"\ | |
1826 "movdqa %%xmm5, %%xmm4 \n\t"\ | |
1827 "movdqa %%xmm5, %%xmm3 \n\t"\ | |
1828 "palignr $8, %%xmm7, %%xmm4 \n\t"\ | |
1829 "palignr $2, %%xmm7, %%xmm6 \n\t"\ | |
1830 "palignr $10, %%xmm7, %%xmm3 \n\t"\ | |
1831 "paddw %%xmm6, %%xmm4 \n\t"\ | |
1832 "movdqa %%xmm5, %%xmm6 \n\t"\ | |
1833 "palignr $6, %%xmm7, %%xmm5 \n\t"\ | |
1834 "palignr $4, %%xmm7, %%xmm6 \n\t"\ | |
1835 "paddw %%xmm7, %%xmm3 \n\t"\ | |
1836 "paddw %%xmm6, %%xmm5 \n\t"\ | |
1837 \ | |
1838 "psubw %%xmm1, %%xmm0 \n\t"\ | |
1839 "psubw %%xmm4, %%xmm3 \n\t"\ | |
1840 "psraw $2, %%xmm0 \n\t"\ | |
1841 "psraw $2, %%xmm3 \n\t"\ | |
1842 "psubw %%xmm1, %%xmm0 \n\t"\ | |
1843 "psubw %%xmm4, %%xmm3 \n\t"\ | |
1844 "paddw %%xmm2, %%xmm0 \n\t"\ | |
1845 "paddw %%xmm5, %%xmm3 \n\t"\ | |
1846 "psraw $2, %%xmm0 \n\t"\ | |
1847 "psraw $2, %%xmm3 \n\t"\ | |
1848 "paddw %%xmm2, %%xmm0 \n\t"\ | |
1849 "paddw %%xmm5, %%xmm3 \n\t"\ | |
1850 "psraw $6, %%xmm0 \n\t"\ | |
1851 "psraw $6, %%xmm3 \n\t"\ | |
1852 "packuswb %%xmm0, %%xmm3 \n\t"\ | |
1853 OP(%%xmm3, (%1), %%xmm7, dqa)\ | |
1854 "add $48, %0 \n\t"\ | |
1855 "add %3, %1 \n\t"\ | |
1856 "decl %2 \n\t"\ | |
1857 " jnz 1b \n\t"\ | |
1858 : "+a"(tmp), "+c"(dst), "+g"(h)\ | |
1859 : "S"((x86_reg)dstStride)\ | |
1860 : "memory"\ | |
1861 );\ | |
1862 }else{\ | |
1863 __asm__ volatile(\ | |
1864 "1: \n\t"\ | |
1865 "movdqa 16(%0), %%xmm1 \n\t"\ | |
1866 "movdqa (%0), %%xmm0 \n\t"\ | |
1867 "movdqa %%xmm1, %%xmm2 \n\t"\ | |
1868 "movdqa %%xmm1, %%xmm3 \n\t"\ | |
1869 "movdqa %%xmm1, %%xmm4 \n\t"\ | |
1870 "movdqa %%xmm1, %%xmm5 \n\t"\ | |
1871 "palignr $10, %%xmm0, %%xmm5 \n\t"\ | |
1872 "palignr $8, %%xmm0, %%xmm4 \n\t"\ | |
1873 "palignr $6, %%xmm0, %%xmm3 \n\t"\ | |
1874 "palignr $4, %%xmm0, %%xmm2 \n\t"\ | |
1875 "palignr $2, %%xmm0, %%xmm1 \n\t"\ | |
1876 "paddw %%xmm5, %%xmm0 \n\t"\ | |
1877 "paddw %%xmm4, %%xmm1 \n\t"\ | |
1878 "paddw %%xmm3, %%xmm2 \n\t"\ | |
1879 "psubw %%xmm1, %%xmm0 \n\t"\ | |
1880 "psraw $2, %%xmm0 \n\t"\ | |
1881 "psubw %%xmm1, %%xmm0 \n\t"\ | |
1882 "paddw %%xmm2, %%xmm0 \n\t"\ | |
1883 "psraw $2, %%xmm0 \n\t"\ | |
1884 "paddw %%xmm2, %%xmm0 \n\t"\ | |
1885 "psraw $6, %%xmm0 \n\t"\ | |
1886 "packuswb %%xmm0, %%xmm0 \n\t"\ | |
1887 OP(%%xmm0, (%1), %%xmm7, q)\ | |
1888 "add $48, %0 \n\t"\ | |
1889 "add %3, %1 \n\t"\ | |
1890 "decl %2 \n\t"\ | |
1891 " jnz 1b \n\t"\ | |
1892 : "+a"(tmp), "+c"(dst), "+g"(h)\ | |
1893 : "S"((x86_reg)dstStride)\ | |
1894 : "memory"\ | |
1895 );\ | |
1896 }\ | |
1897 } | |
1898 | |
1899 #define QPEL_H264_HV_XMM(OPNAME, OP, MMX)\ | |
1900 static av_noinline void OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride, int size){\ | |
1901 put_h264_qpel8or16_hv1_lowpass_sse2(tmp, src, tmpStride, srcStride, size);\ | |
1902 OPNAME ## h264_qpel8or16_hv2_lowpass_ ## MMX(dst, tmp, dstStride, tmpStride, size);\ | |
1903 }\ | |
1904 static void OPNAME ## h264_qpel8_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\ | |
1905 OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(dst, tmp, src, dstStride, tmpStride, srcStride, 8);\ | |
1906 }\ | |
1907 static void OPNAME ## h264_qpel16_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\ | |
1908 OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(dst, tmp, src, dstStride, tmpStride, srcStride, 16);\ | |
1909 }\ | |
1910 | |
1911 #define put_pixels8_l2_sse2 put_pixels8_l2_mmx2 | |
1912 #define avg_pixels8_l2_sse2 avg_pixels8_l2_mmx2 | |
1913 #define put_pixels16_l2_sse2 put_pixels16_l2_mmx2 | |
1914 #define avg_pixels16_l2_sse2 avg_pixels16_l2_mmx2 | |
1915 #define put_pixels8_l2_ssse3 put_pixels8_l2_mmx2 | |
1916 #define avg_pixels8_l2_ssse3 avg_pixels8_l2_mmx2 | |
1917 #define put_pixels16_l2_ssse3 put_pixels16_l2_mmx2 | |
1918 #define avg_pixels16_l2_ssse3 avg_pixels16_l2_mmx2 | |
1919 | |
1920 #define put_pixels8_l2_shift5_sse2 put_pixels8_l2_shift5_mmx2 | |
1921 #define avg_pixels8_l2_shift5_sse2 avg_pixels8_l2_shift5_mmx2 | |
1922 #define put_pixels16_l2_shift5_sse2 put_pixels16_l2_shift5_mmx2 | |
1923 #define avg_pixels16_l2_shift5_sse2 avg_pixels16_l2_shift5_mmx2 | |
1924 #define put_pixels8_l2_shift5_ssse3 put_pixels8_l2_shift5_mmx2 | |
1925 #define avg_pixels8_l2_shift5_ssse3 avg_pixels8_l2_shift5_mmx2 | |
1926 #define put_pixels16_l2_shift5_ssse3 put_pixels16_l2_shift5_mmx2 | |
1927 #define avg_pixels16_l2_shift5_ssse3 avg_pixels16_l2_shift5_mmx2 | |
1928 | |
1929 #define put_h264_qpel8_h_lowpass_l2_sse2 put_h264_qpel8_h_lowpass_l2_mmx2 | |
1930 #define avg_h264_qpel8_h_lowpass_l2_sse2 avg_h264_qpel8_h_lowpass_l2_mmx2 | |
1931 #define put_h264_qpel16_h_lowpass_l2_sse2 put_h264_qpel16_h_lowpass_l2_mmx2 | |
1932 #define avg_h264_qpel16_h_lowpass_l2_sse2 avg_h264_qpel16_h_lowpass_l2_mmx2 | |
1933 | |
1934 #define put_h264_qpel8_v_lowpass_ssse3 put_h264_qpel8_v_lowpass_sse2 | |
1935 #define avg_h264_qpel8_v_lowpass_ssse3 avg_h264_qpel8_v_lowpass_sse2 | |
1936 #define put_h264_qpel16_v_lowpass_ssse3 put_h264_qpel16_v_lowpass_sse2 | |
1937 #define avg_h264_qpel16_v_lowpass_ssse3 avg_h264_qpel16_v_lowpass_sse2 | |
1938 | |
1939 #define put_h264_qpel8or16_hv2_lowpass_sse2 put_h264_qpel8or16_hv2_lowpass_mmx2 | |
1940 #define avg_h264_qpel8or16_hv2_lowpass_sse2 avg_h264_qpel8or16_hv2_lowpass_mmx2 | |
1941 | |
1942 #define H264_MC(OPNAME, SIZE, MMX, ALIGN) \ | |
1943 H264_MC_C(OPNAME, SIZE, MMX, ALIGN)\ | |
1944 H264_MC_V(OPNAME, SIZE, MMX, ALIGN)\ | |
1945 H264_MC_H(OPNAME, SIZE, MMX, ALIGN)\ | |
1946 H264_MC_HV(OPNAME, SIZE, MMX, ALIGN)\ | |
1947 | |
1948 static void put_h264_qpel16_mc00_sse2 (uint8_t *dst, uint8_t *src, int stride){ | |
1949 put_pixels16_sse2(dst, src, stride, 16); | |
1950 } | |
1951 static void avg_h264_qpel16_mc00_sse2 (uint8_t *dst, uint8_t *src, int stride){ | |
1952 avg_pixels16_sse2(dst, src, stride, 16); | |
1953 } | |
1954 #define put_h264_qpel8_mc00_sse2 put_h264_qpel8_mc00_mmx2 | |
1955 #define avg_h264_qpel8_mc00_sse2 avg_h264_qpel8_mc00_mmx2 | |
1956 | |
1957 #define H264_MC_C(OPNAME, SIZE, MMX, ALIGN) \ | |
1958 static void OPNAME ## h264_qpel ## SIZE ## _mc00_ ## MMX (uint8_t *dst, uint8_t *src, int stride){\ | |
1959 OPNAME ## pixels ## SIZE ## _ ## MMX(dst, src, stride, SIZE);\ | |
1960 }\ | |
1961 | |
1962 #define H264_MC_H(OPNAME, SIZE, MMX, ALIGN) \ | |
1963 static void OPNAME ## h264_qpel ## SIZE ## _mc10_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1964 OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, src, stride, stride);\ | |
1965 }\ | |
1966 \ | |
1967 static void OPNAME ## h264_qpel ## SIZE ## _mc20_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1968 OPNAME ## h264_qpel ## SIZE ## _h_lowpass_ ## MMX(dst, src, stride, stride);\ | |
1969 }\ | |
1970 \ | |
1971 static void OPNAME ## h264_qpel ## SIZE ## _mc30_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1972 OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, src+1, stride, stride);\ | |
1973 }\ | |
1974 | |
1975 #define H264_MC_V(OPNAME, SIZE, MMX, ALIGN) \ | |
1976 static void OPNAME ## h264_qpel ## SIZE ## _mc01_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
10961
34a65026fa06
Move array specifiers outside DECLARE_ALIGNED() invocations
mru
parents:
10955
diff
changeset
|
1977 DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*SIZE];\ |
8430 | 1978 put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(temp, src, SIZE, stride);\ |
1979 OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, src, temp, stride, stride, SIZE);\ | |
1980 }\ | |
1981 \ | |
1982 static void OPNAME ## h264_qpel ## SIZE ## _mc02_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1983 OPNAME ## h264_qpel ## SIZE ## _v_lowpass_ ## MMX(dst, src, stride, stride);\ | |
1984 }\ | |
1985 \ | |
1986 static void OPNAME ## h264_qpel ## SIZE ## _mc03_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
10961
34a65026fa06
Move array specifiers outside DECLARE_ALIGNED() invocations
mru
parents:
10955
diff
changeset
|
1987 DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*SIZE];\ |
8430 | 1988 put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(temp, src, SIZE, stride);\ |
1989 OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, src+stride, temp, stride, stride, SIZE);\ | |
1990 }\ | |
1991 | |
1992 #define H264_MC_HV(OPNAME, SIZE, MMX, ALIGN) \ | |
1993 static void OPNAME ## h264_qpel ## SIZE ## _mc11_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
10961
34a65026fa06
Move array specifiers outside DECLARE_ALIGNED() invocations
mru
parents:
10955
diff
changeset
|
1994 DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*SIZE];\ |
8430 | 1995 put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(temp, src, SIZE, stride);\ |
1996 OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, temp, stride, SIZE);\ | |
1997 }\ | |
1998 \ | |
1999 static void OPNAME ## h264_qpel ## SIZE ## _mc31_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
10961
34a65026fa06
Move array specifiers outside DECLARE_ALIGNED() invocations
mru
parents:
10955
diff
changeset
|
2000 DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*SIZE];\ |
8430 | 2001 put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(temp, src+1, SIZE, stride);\ |
2002 OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, temp, stride, SIZE);\ | |
2003 }\ | |
2004 \ | |
2005 static void OPNAME ## h264_qpel ## SIZE ## _mc13_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
10961
34a65026fa06
Move array specifiers outside DECLARE_ALIGNED() invocations
mru
parents:
10955
diff
changeset
|
2006 DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*SIZE];\ |
8430 | 2007 put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(temp, src, SIZE, stride);\ |
2008 OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src+stride, temp, stride, SIZE);\ | |
2009 }\ | |
2010 \ | |
2011 static void OPNAME ## h264_qpel ## SIZE ## _mc33_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
10961
34a65026fa06
Move array specifiers outside DECLARE_ALIGNED() invocations
mru
parents:
10955
diff
changeset
|
2012 DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*SIZE];\ |
8430 | 2013 put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(temp, src+1, SIZE, stride);\ |
2014 OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src+stride, temp, stride, SIZE);\ | |
2015 }\ | |
2016 \ | |
2017 static void OPNAME ## h264_qpel ## SIZE ## _mc22_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
10961
34a65026fa06
Move array specifiers outside DECLARE_ALIGNED() invocations
mru
parents:
10955
diff
changeset
|
2018 DECLARE_ALIGNED(ALIGN, uint16_t, temp)[SIZE*(SIZE<8?12:24)];\ |
8430 | 2019 OPNAME ## h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(dst, temp, src, stride, SIZE, stride);\ |
2020 }\ | |
2021 \ | |
2022 static void OPNAME ## h264_qpel ## SIZE ## _mc21_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
10961
34a65026fa06
Move array specifiers outside DECLARE_ALIGNED() invocations
mru
parents:
10955
diff
changeset
|
2023 DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*(SIZE<8?12:24)*2 + SIZE*SIZE];\ |
8430 | 2024 uint8_t * const halfHV= temp;\ |
2025 int16_t * const halfV= (int16_t*)(temp + SIZE*SIZE);\ | |
2026 assert(((int)temp & 7) == 0);\ | |
2027 put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, halfV, src, SIZE, SIZE, stride);\ | |
2028 OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, halfHV, stride, SIZE);\ | |
2029 }\ | |
2030 \ | |
2031 static void OPNAME ## h264_qpel ## SIZE ## _mc23_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
10961
34a65026fa06
Move array specifiers outside DECLARE_ALIGNED() invocations
mru
parents:
10955
diff
changeset
|
2032 DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*(SIZE<8?12:24)*2 + SIZE*SIZE];\ |
8430 | 2033 uint8_t * const halfHV= temp;\ |
2034 int16_t * const halfV= (int16_t*)(temp + SIZE*SIZE);\ | |
2035 assert(((int)temp & 7) == 0);\ | |
2036 put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, halfV, src, SIZE, SIZE, stride);\ | |
2037 OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src+stride, halfHV, stride, SIZE);\ | |
2038 }\ | |
2039 \ | |
2040 static void OPNAME ## h264_qpel ## SIZE ## _mc12_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
10961
34a65026fa06
Move array specifiers outside DECLARE_ALIGNED() invocations
mru
parents:
10955
diff
changeset
|
2041 DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*(SIZE<8?12:24)*2 + SIZE*SIZE];\ |
8430 | 2042 uint8_t * const halfHV= temp;\ |
2043 int16_t * const halfV= (int16_t*)(temp + SIZE*SIZE);\ | |
2044 assert(((int)temp & 7) == 0);\ | |
2045 put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, halfV, src, SIZE, SIZE, stride);\ | |
2046 OPNAME ## pixels ## SIZE ## _l2_shift5_ ## MMX(dst, halfV+2, halfHV, stride, SIZE, SIZE);\ | |
2047 }\ | |
2048 \ | |
2049 static void OPNAME ## h264_qpel ## SIZE ## _mc32_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
10961
34a65026fa06
Move array specifiers outside DECLARE_ALIGNED() invocations
mru
parents:
10955
diff
changeset
|
2050 DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*(SIZE<8?12:24)*2 + SIZE*SIZE];\ |
8430 | 2051 uint8_t * const halfHV= temp;\ |
2052 int16_t * const halfV= (int16_t*)(temp + SIZE*SIZE);\ | |
2053 assert(((int)temp & 7) == 0);\ | |
2054 put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, halfV, src, SIZE, SIZE, stride);\ | |
2055 OPNAME ## pixels ## SIZE ## _l2_shift5_ ## MMX(dst, halfV+3, halfHV, stride, SIZE, SIZE);\ | |
2056 }\ | |
2057 | |
2058 #define H264_MC_4816(MMX)\ | |
2059 H264_MC(put_, 4, MMX, 8)\ | |
2060 H264_MC(put_, 8, MMX, 8)\ | |
2061 H264_MC(put_, 16,MMX, 8)\ | |
2062 H264_MC(avg_, 4, MMX, 8)\ | |
2063 H264_MC(avg_, 8, MMX, 8)\ | |
2064 H264_MC(avg_, 16,MMX, 8)\ | |
2065 | |
2066 #define H264_MC_816(QPEL, XMM)\ | |
2067 QPEL(put_, 8, XMM, 16)\ | |
2068 QPEL(put_, 16,XMM, 16)\ | |
2069 QPEL(avg_, 8, XMM, 16)\ | |
2070 QPEL(avg_, 16,XMM, 16)\ | |
2071 | |
2072 | |
2073 #define AVG_3DNOW_OP(a,b,temp, size) \ | |
2074 "mov" #size " " #b ", " #temp " \n\t"\ | |
2075 "pavgusb " #temp ", " #a " \n\t"\ | |
2076 "mov" #size " " #a ", " #b " \n\t" | |
2077 #define AVG_MMX2_OP(a,b,temp, size) \ | |
2078 "mov" #size " " #b ", " #temp " \n\t"\ | |
2079 "pavgb " #temp ", " #a " \n\t"\ | |
2080 "mov" #size " " #a ", " #b " \n\t" | |
2081 | |
2082 #define PAVGB "pavgusb" | |
2083 QPEL_H264(put_, PUT_OP, 3dnow) | |
2084 QPEL_H264(avg_, AVG_3DNOW_OP, 3dnow) | |
2085 #undef PAVGB | |
2086 #define PAVGB "pavgb" | |
2087 QPEL_H264(put_, PUT_OP, mmx2) | |
2088 QPEL_H264(avg_, AVG_MMX2_OP, mmx2) | |
2089 QPEL_H264_V_XMM(put_, PUT_OP, sse2) | |
2090 QPEL_H264_V_XMM(avg_, AVG_MMX2_OP, sse2) | |
2091 QPEL_H264_HV_XMM(put_, PUT_OP, sse2) | |
2092 QPEL_H264_HV_XMM(avg_, AVG_MMX2_OP, sse2) | |
8590 | 2093 #if HAVE_SSSE3 |
8430 | 2094 QPEL_H264_H_XMM(put_, PUT_OP, ssse3) |
2095 QPEL_H264_H_XMM(avg_, AVG_MMX2_OP, ssse3) | |
2096 QPEL_H264_HV2_XMM(put_, PUT_OP, ssse3) | |
2097 QPEL_H264_HV2_XMM(avg_, AVG_MMX2_OP, ssse3) | |
2098 QPEL_H264_HV_XMM(put_, PUT_OP, ssse3) | |
2099 QPEL_H264_HV_XMM(avg_, AVG_MMX2_OP, ssse3) | |
2100 #endif | |
2101 #undef PAVGB | |
2102 | |
2103 H264_MC_4816(3dnow) | |
2104 H264_MC_4816(mmx2) | |
2105 H264_MC_816(H264_MC_V, sse2) | |
2106 H264_MC_816(H264_MC_HV, sse2) | |
8590 | 2107 #if HAVE_SSSE3 |
8430 | 2108 H264_MC_816(H264_MC_H, ssse3) |
2109 H264_MC_816(H264_MC_HV, ssse3) | |
2110 #endif | |
2111 | |
8519
cc64e1343397
Use H264 MMX chroma functions to accelerate RV40 decoding.
cehoyos
parents:
8510
diff
changeset
|
2112 /* rnd interleaved with rnd div 8, use p+1 to access rnd div 8 */ |
10961
34a65026fa06
Move array specifiers outside DECLARE_ALIGNED() invocations
mru
parents:
10955
diff
changeset
|
2113 DECLARE_ALIGNED_8(static const uint64_t, h264_rnd_reg)[4] = { |
8519
cc64e1343397
Use H264 MMX chroma functions to accelerate RV40 decoding.
cehoyos
parents:
8510
diff
changeset
|
2114 0x0020002000200020ULL, 0x0004000400040004ULL, 0x001C001C001C001CULL, 0x0003000300030003ULL |
cc64e1343397
Use H264 MMX chroma functions to accelerate RV40 decoding.
cehoyos
parents:
8510
diff
changeset
|
2115 }; |
8430 | 2116 |
2117 #define H264_CHROMA_OP(S,D) | |
2118 #define H264_CHROMA_OP4(S,D,T) | |
8519
cc64e1343397
Use H264 MMX chroma functions to accelerate RV40 decoding.
cehoyos
parents:
8510
diff
changeset
|
2119 #define H264_CHROMA_MC8_TMPL put_h264_chroma_generic_mc8_mmx |
cc64e1343397
Use H264 MMX chroma functions to accelerate RV40 decoding.
cehoyos
parents:
8510
diff
changeset
|
2120 #define H264_CHROMA_MC4_TMPL put_h264_chroma_generic_mc4_mmx |
8430 | 2121 #define H264_CHROMA_MC2_TMPL put_h264_chroma_mc2_mmx2 |
2122 #define H264_CHROMA_MC8_MV0 put_pixels8_mmx | |
2123 #include "dsputil_h264_template_mmx.c" | |
2124 | |
2125 static void put_h264_chroma_mc8_mmx_rnd(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y) | |
2126 { | |
8519
cc64e1343397
Use H264 MMX chroma functions to accelerate RV40 decoding.
cehoyos
parents:
8510
diff
changeset
|
2127 put_h264_chroma_generic_mc8_mmx(dst, src, stride, h, x, y, h264_rnd_reg); |
8430 | 2128 } |
9439
ef3a7b711cc0
Rename put_no_rnd_h264_chroma* to reflect its usage in VC1 only
conrad
parents:
8758
diff
changeset
|
2129 static void put_vc1_chroma_mc8_mmx_nornd(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y) |
8430 | 2130 { |
8519
cc64e1343397
Use H264 MMX chroma functions to accelerate RV40 decoding.
cehoyos
parents:
8510
diff
changeset
|
2131 put_h264_chroma_generic_mc8_mmx(dst, src, stride, h, x, y, h264_rnd_reg+2); |
cc64e1343397
Use H264 MMX chroma functions to accelerate RV40 decoding.
cehoyos
parents:
8510
diff
changeset
|
2132 } |
cc64e1343397
Use H264 MMX chroma functions to accelerate RV40 decoding.
cehoyos
parents:
8510
diff
changeset
|
2133 static void put_h264_chroma_mc4_mmx(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y) |
cc64e1343397
Use H264 MMX chroma functions to accelerate RV40 decoding.
cehoyos
parents:
8510
diff
changeset
|
2134 { |
cc64e1343397
Use H264 MMX chroma functions to accelerate RV40 decoding.
cehoyos
parents:
8510
diff
changeset
|
2135 put_h264_chroma_generic_mc4_mmx(dst, src, stride, h, x, y, h264_rnd_reg); |
8430 | 2136 } |
2137 | |
2138 #undef H264_CHROMA_OP | |
2139 #undef H264_CHROMA_OP4 | |
2140 #undef H264_CHROMA_MC8_TMPL | |
2141 #undef H264_CHROMA_MC4_TMPL | |
2142 #undef H264_CHROMA_MC2_TMPL | |
2143 #undef H264_CHROMA_MC8_MV0 | |
2144 | |
2145 #define H264_CHROMA_OP(S,D) "pavgb " #S ", " #D " \n\t" | |
2146 #define H264_CHROMA_OP4(S,D,T) "movd " #S ", " #T " \n\t"\ | |
2147 "pavgb " #T ", " #D " \n\t" | |
8519
cc64e1343397
Use H264 MMX chroma functions to accelerate RV40 decoding.
cehoyos
parents:
8510
diff
changeset
|
2148 #define H264_CHROMA_MC8_TMPL avg_h264_chroma_generic_mc8_mmx2 |
cc64e1343397
Use H264 MMX chroma functions to accelerate RV40 decoding.
cehoyos
parents:
8510
diff
changeset
|
2149 #define H264_CHROMA_MC4_TMPL avg_h264_chroma_generic_mc4_mmx2 |
8430 | 2150 #define H264_CHROMA_MC2_TMPL avg_h264_chroma_mc2_mmx2 |
2151 #define H264_CHROMA_MC8_MV0 avg_pixels8_mmx2 | |
2152 #include "dsputil_h264_template_mmx.c" | |
2153 static void avg_h264_chroma_mc8_mmx2_rnd(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y) | |
2154 { | |
8519
cc64e1343397
Use H264 MMX chroma functions to accelerate RV40 decoding.
cehoyos
parents:
8510
diff
changeset
|
2155 avg_h264_chroma_generic_mc8_mmx2(dst, src, stride, h, x, y, h264_rnd_reg); |
cc64e1343397
Use H264 MMX chroma functions to accelerate RV40 decoding.
cehoyos
parents:
8510
diff
changeset
|
2156 } |
9440 | 2157 static void avg_vc1_chroma_mc8_mmx2_nornd(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y) |
2158 { | |
2159 avg_h264_chroma_generic_mc8_mmx2(dst, src, stride, h, x, y, h264_rnd_reg+2); | |
2160 } | |
8519
cc64e1343397
Use H264 MMX chroma functions to accelerate RV40 decoding.
cehoyos
parents:
8510
diff
changeset
|
2161 static void avg_h264_chroma_mc4_mmx2(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y) |
cc64e1343397
Use H264 MMX chroma functions to accelerate RV40 decoding.
cehoyos
parents:
8510
diff
changeset
|
2162 { |
cc64e1343397
Use H264 MMX chroma functions to accelerate RV40 decoding.
cehoyos
parents:
8510
diff
changeset
|
2163 avg_h264_chroma_generic_mc4_mmx2(dst, src, stride, h, x, y, h264_rnd_reg); |
8430 | 2164 } |
2165 #undef H264_CHROMA_OP | |
2166 #undef H264_CHROMA_OP4 | |
2167 #undef H264_CHROMA_MC8_TMPL | |
2168 #undef H264_CHROMA_MC4_TMPL | |
2169 #undef H264_CHROMA_MC2_TMPL | |
2170 #undef H264_CHROMA_MC8_MV0 | |
2171 | |
2172 #define H264_CHROMA_OP(S,D) "pavgusb " #S ", " #D " \n\t" | |
2173 #define H264_CHROMA_OP4(S,D,T) "movd " #S ", " #T " \n\t"\ | |
2174 "pavgusb " #T ", " #D " \n\t" | |
8519
cc64e1343397
Use H264 MMX chroma functions to accelerate RV40 decoding.
cehoyos
parents:
8510
diff
changeset
|
2175 #define H264_CHROMA_MC8_TMPL avg_h264_chroma_generic_mc8_3dnow |
cc64e1343397
Use H264 MMX chroma functions to accelerate RV40 decoding.
cehoyos
parents:
8510
diff
changeset
|
2176 #define H264_CHROMA_MC4_TMPL avg_h264_chroma_generic_mc4_3dnow |
8430 | 2177 #define H264_CHROMA_MC8_MV0 avg_pixels8_3dnow |
2178 #include "dsputil_h264_template_mmx.c" | |
2179 static void avg_h264_chroma_mc8_3dnow_rnd(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y) | |
2180 { | |
8519
cc64e1343397
Use H264 MMX chroma functions to accelerate RV40 decoding.
cehoyos
parents:
8510
diff
changeset
|
2181 avg_h264_chroma_generic_mc8_3dnow(dst, src, stride, h, x, y, h264_rnd_reg); |
cc64e1343397
Use H264 MMX chroma functions to accelerate RV40 decoding.
cehoyos
parents:
8510
diff
changeset
|
2182 } |
cc64e1343397
Use H264 MMX chroma functions to accelerate RV40 decoding.
cehoyos
parents:
8510
diff
changeset
|
2183 static void avg_h264_chroma_mc4_3dnow(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y) |
cc64e1343397
Use H264 MMX chroma functions to accelerate RV40 decoding.
cehoyos
parents:
8510
diff
changeset
|
2184 { |
cc64e1343397
Use H264 MMX chroma functions to accelerate RV40 decoding.
cehoyos
parents:
8510
diff
changeset
|
2185 avg_h264_chroma_generic_mc4_3dnow(dst, src, stride, h, x, y, h264_rnd_reg); |
8430 | 2186 } |
2187 #undef H264_CHROMA_OP | |
2188 #undef H264_CHROMA_OP4 | |
2189 #undef H264_CHROMA_MC8_TMPL | |
2190 #undef H264_CHROMA_MC4_TMPL | |
2191 #undef H264_CHROMA_MC8_MV0 | |
2192 | |
8590 | 2193 #if HAVE_SSSE3 |
8430 | 2194 #define AVG_OP(X) |
2195 #undef H264_CHROMA_MC8_TMPL | |
2196 #undef H264_CHROMA_MC4_TMPL | |
2197 #define H264_CHROMA_MC8_TMPL put_h264_chroma_mc8_ssse3 | |
2198 #define H264_CHROMA_MC4_TMPL put_h264_chroma_mc4_ssse3 | |
2199 #define H264_CHROMA_MC8_MV0 put_pixels8_mmx | |
2200 #include "dsputil_h264_template_ssse3.c" | |
2201 static void put_h264_chroma_mc8_ssse3_rnd(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y) | |
2202 { | |
2203 put_h264_chroma_mc8_ssse3(dst, src, stride, h, x, y, 1); | |
2204 } | |
9439
ef3a7b711cc0
Rename put_no_rnd_h264_chroma* to reflect its usage in VC1 only
conrad
parents:
8758
diff
changeset
|
2205 static void put_vc1_chroma_mc8_ssse3_nornd(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y) |
8430 | 2206 { |
2207 put_h264_chroma_mc8_ssse3(dst, src, stride, h, x, y, 0); | |
2208 } | |
2209 | |
2210 #undef AVG_OP | |
2211 #undef H264_CHROMA_MC8_TMPL | |
2212 #undef H264_CHROMA_MC4_TMPL | |
2213 #undef H264_CHROMA_MC8_MV0 | |
2214 #define AVG_OP(X) X | |
2215 #define H264_CHROMA_MC8_TMPL avg_h264_chroma_mc8_ssse3 | |
2216 #define H264_CHROMA_MC4_TMPL avg_h264_chroma_mc4_ssse3 | |
2217 #define H264_CHROMA_MC8_MV0 avg_pixels8_mmx2 | |
2218 #include "dsputil_h264_template_ssse3.c" | |
2219 static void avg_h264_chroma_mc8_ssse3_rnd(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y) | |
2220 { | |
2221 avg_h264_chroma_mc8_ssse3(dst, src, stride, h, x, y, 1); | |
2222 } | |
9440 | 2223 static void avg_vc1_chroma_mc8_ssse3_nornd(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y) |
2224 { | |
2225 avg_h264_chroma_mc8_ssse3(dst, src, stride, h, x, y, 0); | |
2226 } | |
8430 | 2227 #undef AVG_OP |
2228 #undef H264_CHROMA_MC8_TMPL | |
2229 #undef H264_CHROMA_MC4_TMPL | |
2230 #undef H264_CHROMA_MC8_MV0 | |
2231 #endif | |
2232 | |
2233 /***********************************/ | |
2234 /* weighted prediction */ | |
2235 | |
2236 static inline void ff_h264_weight_WxH_mmx2(uint8_t *dst, int stride, int log2_denom, int weight, int offset, int w, int h) | |
2237 { | |
2238 int x, y; | |
2239 offset <<= log2_denom; | |
2240 offset += (1 << log2_denom) >> 1; | |
2241 __asm__ volatile( | |
2242 "movd %0, %%mm4 \n\t" | |
2243 "movd %1, %%mm5 \n\t" | |
2244 "movd %2, %%mm6 \n\t" | |
2245 "pshufw $0, %%mm4, %%mm4 \n\t" | |
2246 "pshufw $0, %%mm5, %%mm5 \n\t" | |
2247 "pxor %%mm7, %%mm7 \n\t" | |
2248 :: "g"(weight), "g"(offset), "g"(log2_denom) | |
2249 ); | |
2250 for(y=0; y<h; y+=2){ | |
2251 for(x=0; x<w; x+=4){ | |
2252 __asm__ volatile( | |
2253 "movd %0, %%mm0 \n\t" | |
2254 "movd %1, %%mm1 \n\t" | |
2255 "punpcklbw %%mm7, %%mm0 \n\t" | |
2256 "punpcklbw %%mm7, %%mm1 \n\t" | |
2257 "pmullw %%mm4, %%mm0 \n\t" | |
2258 "pmullw %%mm4, %%mm1 \n\t" | |
2259 "paddsw %%mm5, %%mm0 \n\t" | |
2260 "paddsw %%mm5, %%mm1 \n\t" | |
2261 "psraw %%mm6, %%mm0 \n\t" | |
2262 "psraw %%mm6, %%mm1 \n\t" | |
2263 "packuswb %%mm7, %%mm0 \n\t" | |
2264 "packuswb %%mm7, %%mm1 \n\t" | |
2265 "movd %%mm0, %0 \n\t" | |
2266 "movd %%mm1, %1 \n\t" | |
2267 : "+m"(*(uint32_t*)(dst+x)), | |
2268 "+m"(*(uint32_t*)(dst+x+stride)) | |
2269 ); | |
2270 } | |
2271 dst += 2*stride; | |
2272 } | |
2273 } | |
2274 | |
2275 static inline void ff_h264_biweight_WxH_mmx2(uint8_t *dst, uint8_t *src, int stride, int log2_denom, int weightd, int weights, int offset, int w, int h) | |
2276 { | |
2277 int x, y; | |
2278 offset = ((offset + 1) | 1) << log2_denom; | |
2279 __asm__ volatile( | |
2280 "movd %0, %%mm3 \n\t" | |
2281 "movd %1, %%mm4 \n\t" | |
2282 "movd %2, %%mm5 \n\t" | |
2283 "movd %3, %%mm6 \n\t" | |
2284 "pshufw $0, %%mm3, %%mm3 \n\t" | |
2285 "pshufw $0, %%mm4, %%mm4 \n\t" | |
2286 "pshufw $0, %%mm5, %%mm5 \n\t" | |
2287 "pxor %%mm7, %%mm7 \n\t" | |
2288 :: "g"(weightd), "g"(weights), "g"(offset), "g"(log2_denom+1) | |
2289 ); | |
2290 for(y=0; y<h; y++){ | |
2291 for(x=0; x<w; x+=4){ | |
2292 __asm__ volatile( | |
2293 "movd %0, %%mm0 \n\t" | |
2294 "movd %1, %%mm1 \n\t" | |
2295 "punpcklbw %%mm7, %%mm0 \n\t" | |
2296 "punpcklbw %%mm7, %%mm1 \n\t" | |
2297 "pmullw %%mm3, %%mm0 \n\t" | |
2298 "pmullw %%mm4, %%mm1 \n\t" | |
2299 "paddsw %%mm1, %%mm0 \n\t" | |
2300 "paddsw %%mm5, %%mm0 \n\t" | |
2301 "psraw %%mm6, %%mm0 \n\t" | |
2302 "packuswb %%mm0, %%mm0 \n\t" | |
2303 "movd %%mm0, %0 \n\t" | |
2304 : "+m"(*(uint32_t*)(dst+x)) | |
2305 : "m"(*(uint32_t*)(src+x)) | |
2306 ); | |
2307 } | |
2308 src += stride; | |
2309 dst += stride; | |
2310 } | |
2311 } | |
2312 | |
2313 #define H264_WEIGHT(W,H) \ | |
2314 static void ff_h264_biweight_ ## W ## x ## H ## _mmx2(uint8_t *dst, uint8_t *src, int stride, int log2_denom, int weightd, int weights, int offset){ \ | |
2315 ff_h264_biweight_WxH_mmx2(dst, src, stride, log2_denom, weightd, weights, offset, W, H); \ | |
2316 } \ | |
2317 static void ff_h264_weight_ ## W ## x ## H ## _mmx2(uint8_t *dst, int stride, int log2_denom, int weight, int offset){ \ | |
2318 ff_h264_weight_WxH_mmx2(dst, stride, log2_denom, weight, offset, W, H); \ | |
2319 } | |
2320 | |
2321 H264_WEIGHT(16,16) | |
2322 H264_WEIGHT(16, 8) | |
2323 H264_WEIGHT( 8,16) | |
2324 H264_WEIGHT( 8, 8) | |
2325 H264_WEIGHT( 8, 4) | |
2326 H264_WEIGHT( 4, 8) | |
2327 H264_WEIGHT( 4, 4) | |
2328 H264_WEIGHT( 4, 2) | |
2329 |