40 #define SUMSUB_BA( a, b ) \
41 "paddw "#b", "#a" \n\t"\
42 "paddw "#b", "#b" \n\t"\
43 "psubw "#a", "#b" \n\t"
51 static inline void cavs_idct8_1d(int16_t *
block, uint64_t bias)
54 "movq 112(%0), %%mm4 \n\t"
55 "movq 16(%0), %%mm5 \n\t"
56 "movq 80(%0), %%mm2 \n\t"
57 "movq 48(%0), %%mm7 \n\t"
58 "movq %%mm4, %%mm0 \n\t"
59 "movq %%mm5, %%mm3 \n\t"
60 "movq %%mm2, %%mm6 \n\t"
61 "movq %%mm7, %%mm1 \n\t"
63 "paddw %%mm4, %%mm4 \n\t"
64 "paddw %%mm3, %%mm3 \n\t"
65 "paddw %%mm6, %%mm6 \n\t"
66 "paddw %%mm1, %%mm1 \n\t"
67 "paddw %%mm4, %%mm0 \n\t"
68 "paddw %%mm3, %%mm5 \n\t"
69 "paddw %%mm6, %%mm2 \n\t"
70 "paddw %%mm1, %%mm7 \n\t"
71 "psubw %%mm4, %%mm5 \n\t"
72 "paddw %%mm6, %%mm7 \n\t"
73 "psubw %%mm2, %%mm1 \n\t"
74 "paddw %%mm0, %%mm3 \n\t"
76 "movq %%mm5, %%mm4 \n\t"
77 "movq %%mm7, %%mm6 \n\t"
78 "movq %%mm3, %%mm0 \n\t"
79 "movq %%mm1, %%mm2 \n\t"
80 SUMSUB_BA( %%mm7, %%mm5 )
81 "paddw %%mm3, %%mm7 \n\t"
82 "paddw %%mm1, %%mm5 \n\t"
83 "paddw %%mm7, %%mm7 \n\t"
84 "paddw %%mm5, %%mm5 \n\t"
85 "paddw %%mm6, %%mm7 \n\t"
86 "paddw %%mm4, %%mm5 \n\t"
88 SUMSUB_BA( %%mm1, %%mm3 )
89 "psubw %%mm1, %%mm4 \n\t"
90 "movq %%mm4, %%mm1 \n\t"
91 "psubw %%mm6, %%mm3 \n\t"
92 "paddw %%mm1, %%mm1 \n\t"
93 "paddw %%mm3, %%mm3 \n\t"
94 "psubw %%mm2, %%mm1 \n\t"
95 "paddw %%mm0, %%mm3 \n\t"
97 "movq 32(%0), %%mm2 \n\t"
98 "movq 96(%0), %%mm6 \n\t"
99 "movq %%mm2, %%mm4 \n\t"
100 "movq %%mm6, %%mm0 \n\t"
101 "psllw $2, %%mm4 \n\t"
102 "psllw $2, %%mm6 \n\t"
103 "paddw %%mm4, %%mm2 \n\t"
104 "paddw %%mm6, %%mm0 \n\t"
105 "paddw %%mm2, %%mm2 \n\t"
106 "paddw %%mm0, %%mm0 \n\t"
107 "psubw %%mm0, %%mm4 \n\t"
108 "paddw %%mm2, %%mm6 \n\t"
110 "movq (%0), %%mm2 \n\t"
111 "movq 64(%0), %%mm0 \n\t"
112 SUMSUB_BA( %%mm0, %%mm2 )
113 "psllw $3, %%mm0 \n\t"
114 "psllw $3, %%mm2 \n\t"
115 "paddw %1, %%mm0 \n\t"
116 "paddw %1, %%mm2 \n\t"
118 SUMSUB_BA( %%mm6, %%mm0 )
119 SUMSUB_BA( %%mm4, %%mm2 )
120 SUMSUB_BA( %%mm7, %%mm6 )
121 SUMSUB_BA( %%mm5, %%mm4 )
122 SUMSUB_BA( %%mm3, %%mm2 )
123 SUMSUB_BA( %%mm1, %%mm0 )
124 :: "
r"(block), "
m"(bias)
128 #define SBUTTERFLY(a,b,t,n,m)\
129 "mov" #m " " #a ", " #t " \n\t" \
130 "punpckl" #n " " #b ", " #a " \n\t" \
131 "punpckh" #n " " #b ", " #t " \n\t" \
133 #define TRANSPOSE4(a,b,c,d,t)\
134 SBUTTERFLY(a,b,t,wd,q) \
135 SBUTTERFLY(c,d,b,wd,q) \
136 SBUTTERFLY(a,c,d,dq,q) \
137 SBUTTERFLY(t,b,c,dq,q)
139 static void cavs_idct8_add_mmx(
uint8_t *dst, int16_t *block,
int stride)
147 cavs_idct8_1d(block+4*i,
ff_pw_4.
a);
150 "psraw $3, %%mm7 \n\t"
151 "psraw $3, %%mm6 \n\t"
152 "psraw $3, %%mm5 \n\t"
153 "psraw $3, %%mm4 \n\t"
154 "psraw $3, %%mm3 \n\t"
155 "psraw $3, %%mm2 \n\t"
156 "psraw $3, %%mm1 \n\t"
157 "psraw $3, %%mm0 \n\t"
158 "movq %%mm7, %0 \n\t"
159 TRANSPOSE4( %%mm0, %%mm2, %%mm4, %%mm6, %%mm7 )
160 "movq %%mm0, 8(%1) \n\t"
161 "movq %%mm6, 24(%1) \n\t"
162 "movq %%mm7, 40(%1) \n\t"
163 "movq %%mm4, 56(%1) \n\t"
164 "movq %0, %%mm7 \n\t"
165 TRANSPOSE4( %%mm7, %%mm5, %%mm3, %%mm1, %%mm0 )
166 "movq %%mm7, (%1) \n\t"
167 "movq %%mm1, 16(%1) \n\t"
168 "movq %%mm0, 32(%1) \n\t"
169 "movq %%mm3, 48(%1) \n\t"
180 "psraw $7, %%mm7 \n\t"
181 "psraw $7, %%mm6 \n\t"
182 "psraw $7, %%mm5 \n\t"
183 "psraw $7, %%mm4 \n\t"
184 "psraw $7, %%mm3 \n\t"
185 "psraw $7, %%mm2 \n\t"
186 "psraw $7, %%mm1 \n\t"
187 "psraw $7, %%mm0 \n\t"
188 "movq %%mm7, (%0) \n\t"
189 "movq %%mm5, 16(%0) \n\t"
190 "movq %%mm3, 32(%0) \n\t"
191 "movq %%mm1, 48(%0) \n\t"
192 "movq %%mm0, 64(%0) \n\t"
193 "movq %%mm2, 80(%0) \n\t"
194 "movq %%mm4, 96(%0) \n\t"
195 "movq %%mm6, 112(%0) \n\t"
206 #if (HAVE_MMXEXT_INLINE || HAVE_AMD3DNOW_INLINE)
215 #define QPEL_CAVSV1(A,B,C,D,E,F,OP,ADD, MUL1, MUL2) \
216 "movd (%0), "#F" \n\t"\
217 "movq "#C", %%mm6 \n\t"\
218 "pmullw "MANGLE(MUL1)", %%mm6\n\t"\
219 "movq "#D", %%mm7 \n\t"\
220 "pmullw "MANGLE(MUL2)", %%mm7\n\t"\
221 "psllw $3, "#E" \n\t"\
222 "psubw "#E", %%mm6 \n\t"\
223 "psraw $3, "#E" \n\t"\
224 "paddw %%mm7, %%mm6 \n\t"\
225 "paddw "#E", %%mm6 \n\t"\
226 "paddw "#B", "#B" \n\t"\
227 "pxor %%mm7, %%mm7 \n\t"\
229 "punpcklbw %%mm7, "#F" \n\t"\
230 "psubw "#B", %%mm6 \n\t"\
231 "psraw $1, "#B" \n\t"\
232 "psubw "#A", %%mm6 \n\t"\
233 "paddw "MANGLE(ADD)", %%mm6 \n\t"\
234 "psraw $7, %%mm6 \n\t"\
235 "packuswb %%mm6, %%mm6 \n\t"\
236 OP(%%mm6, (%1), A, d) \
240 #define QPEL_CAVSV2(A,B,C,D,E,F,OP,ADD, MUL1, MUL2) \
241 "movd (%0), "#F" \n\t"\
242 "movq "#C", %%mm6 \n\t"\
243 "paddw "#D", %%mm6 \n\t"\
244 "pmullw "MANGLE(MUL1)", %%mm6\n\t"\
246 "punpcklbw %%mm7, "#F" \n\t"\
247 "psubw "#B", %%mm6 \n\t"\
248 "psubw "#E", %%mm6 \n\t"\
249 "paddw "MANGLE(ADD)", %%mm6 \n\t"\
250 "psraw $3, %%mm6 \n\t"\
251 "packuswb %%mm6, %%mm6 \n\t"\
252 OP(%%mm6, (%1), A, d) \
256 #define QPEL_CAVSV3(A,B,C,D,E,F,OP,ADD, MUL1, MUL2) \
257 "movd (%0), "#F" \n\t"\
258 "movq "#C", %%mm6 \n\t"\
259 "pmullw "MANGLE(MUL2)", %%mm6\n\t"\
260 "movq "#D", %%mm7 \n\t"\
261 "pmullw "MANGLE(MUL1)", %%mm7\n\t"\
262 "psllw $3, "#B" \n\t"\
263 "psubw "#B", %%mm6 \n\t"\
264 "psraw $3, "#B" \n\t"\
265 "paddw %%mm7, %%mm6 \n\t"\
266 "paddw "#B", %%mm6 \n\t"\
267 "paddw "#E", "#E" \n\t"\
268 "pxor %%mm7, %%mm7 \n\t"\
270 "punpcklbw %%mm7, "#F" \n\t"\
271 "psubw "#E", %%mm6 \n\t"\
272 "psraw $1, "#E" \n\t"\
273 "psubw "#F", %%mm6 \n\t"\
274 "paddw "MANGLE(ADD)", %%mm6 \n\t"\
275 "psraw $7, %%mm6 \n\t"\
276 "packuswb %%mm6, %%mm6 \n\t"\
277 OP(%%mm6, (%1), A, d) \
281 #define QPEL_CAVSVNUM(VOP,OP,ADD,MUL1,MUL2)\
287 "pxor %%mm7, %%mm7 \n\t"\
288 "movd (%0), %%mm0 \n\t"\
290 "movd (%0), %%mm1 \n\t"\
292 "movd (%0), %%mm2 \n\t"\
294 "movd (%0), %%mm3 \n\t"\
296 "movd (%0), %%mm4 \n\t"\
298 "punpcklbw %%mm7, %%mm0 \n\t"\
299 "punpcklbw %%mm7, %%mm1 \n\t"\
300 "punpcklbw %%mm7, %%mm2 \n\t"\
301 "punpcklbw %%mm7, %%mm3 \n\t"\
302 "punpcklbw %%mm7, %%mm4 \n\t"\
303 VOP(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP, ADD, MUL1, MUL2)\
304 VOP(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP, ADD, MUL1, MUL2)\
305 VOP(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP, ADD, MUL1, MUL2)\
306 VOP(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP, ADD, MUL1, MUL2)\
307 VOP(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, OP, ADD, MUL1, MUL2)\
308 VOP(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, OP, ADD, MUL1, MUL2)\
309 VOP(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP, ADD, MUL1, MUL2)\
310 VOP(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP, ADD, MUL1, MUL2)\
312 : "+a"(src), "+c"(dst)\
313 : "S"((x86_reg)srcStride), "r"((x86_reg)dstStride)\
314 NAMED_CONSTRAINTS_ADD(ADD,MUL1,MUL2)\
319 VOP(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP, ADD, MUL1, MUL2)\
320 VOP(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP, ADD, MUL1, MUL2)\
321 VOP(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, OP, ADD, MUL1, MUL2)\
322 VOP(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, OP, ADD, MUL1, MUL2)\
323 VOP(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP, ADD, MUL1, MUL2)\
324 VOP(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP, ADD, MUL1, MUL2)\
325 VOP(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP, ADD, MUL1, MUL2)\
326 VOP(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP, ADD, MUL1, MUL2)\
328 : "+a"(src), "+c"(dst)\
329 : "S"((x86_reg)srcStride), "r"((x86_reg)dstStride)\
330 NAMED_CONSTRAINTS_ADD(ADD,MUL1,MUL2)\
334 src += 4-(h+5)*srcStride;\
335 dst += 4-h*dstStride;\
338 #define QPEL_CAVS(OPNAME, OP, MMX)\
339 static void OPNAME ## cavs_qpel8_h_ ## MMX(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride){\
342 "pxor %%mm7, %%mm7 \n\t"\
343 "movq "MANGLE(ff_pw_5)", %%mm6\n\t"\
345 "movq (%0), %%mm0 \n\t"\
346 "movq 1(%0), %%mm2 \n\t"\
347 "movq %%mm0, %%mm1 \n\t"\
348 "movq %%mm2, %%mm3 \n\t"\
349 "punpcklbw %%mm7, %%mm0 \n\t"\
350 "punpckhbw %%mm7, %%mm1 \n\t"\
351 "punpcklbw %%mm7, %%mm2 \n\t"\
352 "punpckhbw %%mm7, %%mm3 \n\t"\
353 "paddw %%mm2, %%mm0 \n\t"\
354 "paddw %%mm3, %%mm1 \n\t"\
355 "pmullw %%mm6, %%mm0 \n\t"\
356 "pmullw %%mm6, %%mm1 \n\t"\
357 "movq -1(%0), %%mm2 \n\t"\
358 "movq 2(%0), %%mm4 \n\t"\
359 "movq %%mm2, %%mm3 \n\t"\
360 "movq %%mm4, %%mm5 \n\t"\
361 "punpcklbw %%mm7, %%mm2 \n\t"\
362 "punpckhbw %%mm7, %%mm3 \n\t"\
363 "punpcklbw %%mm7, %%mm4 \n\t"\
364 "punpckhbw %%mm7, %%mm5 \n\t"\
365 "paddw %%mm4, %%mm2 \n\t"\
366 "paddw %%mm3, %%mm5 \n\t"\
367 "psubw %%mm2, %%mm0 \n\t"\
368 "psubw %%mm5, %%mm1 \n\t"\
369 "movq "MANGLE(ff_pw_4)", %%mm5\n\t"\
370 "paddw %%mm5, %%mm0 \n\t"\
371 "paddw %%mm5, %%mm1 \n\t"\
372 "psraw $3, %%mm0 \n\t"\
373 "psraw $3, %%mm1 \n\t"\
374 "packuswb %%mm1, %%mm0 \n\t"\
375 OP(%%mm0, (%1),%%mm5, q) \
380 : "+a"(src), "+c"(dst), "+m"(h)\
381 : "d"((x86_reg)srcStride), "S"((x86_reg)dstStride)\
382 NAMED_CONSTRAINTS_ADD(ff_pw_4,ff_pw_5)\
387 static inline void OPNAME ## cavs_qpel8or16_v1_ ## MMX(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h){\
388 QPEL_CAVSVNUM(QPEL_CAVSV1,OP,ff_pw_64,ff_pw_96,ff_pw_42) \
391 static inline void OPNAME ## cavs_qpel8or16_v2_ ## MMX(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h){\
392 QPEL_CAVSVNUM(QPEL_CAVSV2,OP,ff_pw_4,ff_pw_5,ff_pw_42) \
395 static inline void OPNAME ## cavs_qpel8or16_v3_ ## MMX(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h){\
396 QPEL_CAVSVNUM(QPEL_CAVSV3,OP,ff_pw_64,ff_pw_96,ff_pw_42) \
399 static void OPNAME ## cavs_qpel8_v1_ ## MMX(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride){\
400 OPNAME ## cavs_qpel8or16_v1_ ## MMX(dst , src , dstStride, srcStride, 8);\
402 static void OPNAME ## cavs_qpel16_v1_ ## MMX(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride){\
403 OPNAME ## cavs_qpel8or16_v1_ ## MMX(dst , src , dstStride, srcStride, 16);\
404 OPNAME ## cavs_qpel8or16_v1_ ## MMX(dst+8, src+8, dstStride, srcStride, 16);\
407 static void OPNAME ## cavs_qpel8_v2_ ## MMX(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride){\
408 OPNAME ## cavs_qpel8or16_v2_ ## MMX(dst , src , dstStride, srcStride, 8);\
410 static void OPNAME ## cavs_qpel16_v2_ ## MMX(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride){\
411 OPNAME ## cavs_qpel8or16_v2_ ## MMX(dst , src , dstStride, srcStride, 16);\
412 OPNAME ## cavs_qpel8or16_v2_ ## MMX(dst+8, src+8, dstStride, srcStride, 16);\
415 static void OPNAME ## cavs_qpel8_v3_ ## MMX(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride){\
416 OPNAME ## cavs_qpel8or16_v3_ ## MMX(dst , src , dstStride, srcStride, 8);\
418 static void OPNAME ## cavs_qpel16_v3_ ## MMX(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride){\
419 OPNAME ## cavs_qpel8or16_v3_ ## MMX(dst , src , dstStride, srcStride, 16);\
420 OPNAME ## cavs_qpel8or16_v3_ ## MMX(dst+8, src+8, dstStride, srcStride, 16);\
423 static void OPNAME ## cavs_qpel16_h_ ## MMX(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride){\
424 OPNAME ## cavs_qpel8_h_ ## MMX(dst , src , dstStride, srcStride);\
425 OPNAME ## cavs_qpel8_h_ ## MMX(dst+8, src+8, dstStride, srcStride);\
428 OPNAME ## cavs_qpel8_h_ ## MMX(dst , src , dstStride, srcStride);\
429 OPNAME ## cavs_qpel8_h_ ## MMX(dst+8, src+8, dstStride, srcStride);\
432 #define CAVS_MC(OPNAME, SIZE, MMX) \
433 static void OPNAME ## cavs_qpel ## SIZE ## _mc20_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
435 OPNAME ## cavs_qpel ## SIZE ## _h_ ## MMX(dst, src, stride, stride);\
438 static void OPNAME ## cavs_qpel ## SIZE ## _mc01_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
440 OPNAME ## cavs_qpel ## SIZE ## _v1_ ## MMX(dst, src, stride, stride);\
443 static void OPNAME ## cavs_qpel ## SIZE ## _mc02_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
445 OPNAME ## cavs_qpel ## SIZE ## _v2_ ## MMX(dst, src, stride, stride);\
448 static void OPNAME ## cavs_qpel ## SIZE ## _mc03_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
450 OPNAME ## cavs_qpel ## SIZE ## _v3_ ## MMX(dst, src, stride, stride);\
453 #define PUT_OP(a,b,temp, size) "mov" #size " " #a ", " #b " \n\t"
454 #define AVG_3DNOW_OP(a,b,temp, size) \
455 "mov" #size " " #b ", " #temp " \n\t"\
456 "pavgusb " #temp ", " #a " \n\t"\
457 "mov" #size " " #a ", " #b " \n\t"
458 #define AVG_MMXEXT_OP(a, b, temp, size) \
459 "mov" #size " " #b ", " #temp " \n\t"\
460 "pavgb " #temp ", " #a " \n\t"\
461 "mov" #size " " #a ", " #b " \n\t"
465 #if HAVE_MMX_EXTERNAL
518 #if HAVE_MMX_EXTERNAL
531 #define DSPFUNC(PFX, IDX, NUM, EXT) \
532 c->PFX ## _cavs_qpel_pixels_tab[IDX][ 2] = PFX ## _cavs_qpel ## NUM ## _mc20_ ## EXT; \
533 c->PFX ## _cavs_qpel_pixels_tab[IDX][ 4] = PFX ## _cavs_qpel ## NUM ## _mc01_ ## EXT; \
534 c->PFX ## _cavs_qpel_pixels_tab[IDX][ 8] = PFX ## _cavs_qpel ## NUM ## _mc02_ ## EXT; \
535 c->PFX ## _cavs_qpel_pixels_tab[IDX][12] = PFX ## _cavs_qpel ## NUM ## _mc03_ ## EXT; \
537 #if HAVE_MMXEXT_INLINE
538 QPEL_CAVS(put_, PUT_OP, mmxext)
539 QPEL_CAVS(avg_, AVG_MMXEXT_OP, mmxext)
547 #if HAVE_AMD3DNOW_INLINE
548 QPEL_CAVS(put_, PUT_OP, 3dnow)
549 QPEL_CAVS(avg_, AVG_3DNOW_OP, 3dnow)
571 #if HAVE_AMD3DNOW_INLINE
573 cavsdsp_init_3dnow(c, avctx);
575 #if HAVE_MMXEXT_INLINE
583 #if HAVE_MMX_EXTERNAL
589 #if HAVE_SSE2_EXTERNAL