x86/cavsdsp.c
Go to the documentation of this file.
1 /*
2  * Chinese AVS video (AVS1-P2, JiZhun profile) decoder.
3  * Copyright (c) 2006 Stefan Gehrer <stefan.gehrer@gmx.de>
4  *
5  * MMX-optimized DSP functions, based on H.264 optimizations by
6  * Michael Niedermayer and Loren Merritt
7  *
8  * This file is part of FFmpeg.
9  *
10  * FFmpeg is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) any later version.
14  *
15  * FFmpeg is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with FFmpeg; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23  */
24 
25 #include "libavutil/attributes.h"
26 #include "libavutil/common.h"
27 #include "libavutil/cpu.h"
28 #include "libavutil/x86/asm.h"
29 #include "libavutil/x86/cpu.h"
30 #include "libavcodec/cavsdsp.h"
31 #include "dsputil_mmx.h"
32 #include "config.h"
33 
34 #if (HAVE_MMXEXT_INLINE || HAVE_AMD3DNOW_INLINE)
35 
36 /* in/out: mma=mma+mmb, mmb=mmb-mma */
37 #define SUMSUB_BA( a, b ) \
38  "paddw "#b", "#a" \n\t"\
39  "paddw "#b", "#b" \n\t"\
40  "psubw "#a", "#b" \n\t"
41 
42 /*****************************************************************************
43  *
44  * inverse transform
45  *
46  ****************************************************************************/
47 
48 static inline void cavs_idct8_1d(int16_t *block, uint64_t bias)
49 {
50  __asm__ volatile(
51  "movq 112(%0), %%mm4 \n\t" /* mm4 = src7 */
52  "movq 16(%0), %%mm5 \n\t" /* mm5 = src1 */
53  "movq 80(%0), %%mm2 \n\t" /* mm2 = src5 */
54  "movq 48(%0), %%mm7 \n\t" /* mm7 = src3 */
55  "movq %%mm4, %%mm0 \n\t"
56  "movq %%mm5, %%mm3 \n\t"
57  "movq %%mm2, %%mm6 \n\t"
58  "movq %%mm7, %%mm1 \n\t"
59 
60  "paddw %%mm4, %%mm4 \n\t" /* mm4 = 2*src7 */
61  "paddw %%mm3, %%mm3 \n\t" /* mm3 = 2*src1 */
62  "paddw %%mm6, %%mm6 \n\t" /* mm6 = 2*src5 */
63  "paddw %%mm1, %%mm1 \n\t" /* mm1 = 2*src3 */
64  "paddw %%mm4, %%mm0 \n\t" /* mm0 = 3*src7 */
65  "paddw %%mm3, %%mm5 \n\t" /* mm5 = 3*src1 */
66  "paddw %%mm6, %%mm2 \n\t" /* mm2 = 3*src5 */
67  "paddw %%mm1, %%mm7 \n\t" /* mm7 = 3*src3 */
68  "psubw %%mm4, %%mm5 \n\t" /* mm5 = 3*src1 - 2*src7 = a0 */
69  "paddw %%mm6, %%mm7 \n\t" /* mm7 = 3*src3 + 2*src5 = a1 */
70  "psubw %%mm2, %%mm1 \n\t" /* mm1 = 2*src3 - 3*src5 = a2 */
71  "paddw %%mm0, %%mm3 \n\t" /* mm3 = 2*src1 + 3*src7 = a3 */
72 
73  "movq %%mm5, %%mm4 \n\t"
74  "movq %%mm7, %%mm6 \n\t"
75  "movq %%mm3, %%mm0 \n\t"
76  "movq %%mm1, %%mm2 \n\t"
77  SUMSUB_BA( %%mm7, %%mm5 ) /* mm7 = a0 + a1 mm5 = a0 - a1 */
78  "paddw %%mm3, %%mm7 \n\t" /* mm7 = a0 + a1 + a3 */
79  "paddw %%mm1, %%mm5 \n\t" /* mm5 = a0 - a1 + a2 */
80  "paddw %%mm7, %%mm7 \n\t"
81  "paddw %%mm5, %%mm5 \n\t"
82  "paddw %%mm6, %%mm7 \n\t" /* mm7 = b4 */
83  "paddw %%mm4, %%mm5 \n\t" /* mm5 = b5 */
84 
85  SUMSUB_BA( %%mm1, %%mm3 ) /* mm1 = a3 + a2 mm3 = a3 - a2 */
86  "psubw %%mm1, %%mm4 \n\t" /* mm4 = a0 - a2 - a3 */
87  "movq %%mm4, %%mm1 \n\t" /* mm1 = a0 - a2 - a3 */
88  "psubw %%mm6, %%mm3 \n\t" /* mm3 = a3 - a2 - a1 */
89  "paddw %%mm1, %%mm1 \n\t"
90  "paddw %%mm3, %%mm3 \n\t"
91  "psubw %%mm2, %%mm1 \n\t" /* mm1 = b7 */
92  "paddw %%mm0, %%mm3 \n\t" /* mm3 = b6 */
93 
94  "movq 32(%0), %%mm2 \n\t" /* mm2 = src2 */
95  "movq 96(%0), %%mm6 \n\t" /* mm6 = src6 */
96  "movq %%mm2, %%mm4 \n\t"
97  "movq %%mm6, %%mm0 \n\t"
98  "psllw $2, %%mm4 \n\t" /* mm4 = 4*src2 */
99  "psllw $2, %%mm6 \n\t" /* mm6 = 4*src6 */
100  "paddw %%mm4, %%mm2 \n\t" /* mm2 = 5*src2 */
101  "paddw %%mm6, %%mm0 \n\t" /* mm0 = 5*src6 */
102  "paddw %%mm2, %%mm2 \n\t"
103  "paddw %%mm0, %%mm0 \n\t"
104  "psubw %%mm0, %%mm4 \n\t" /* mm4 = 4*src2 - 10*src6 = a7 */
105  "paddw %%mm2, %%mm6 \n\t" /* mm6 = 4*src6 + 10*src2 = a6 */
106 
107  "movq (%0), %%mm2 \n\t" /* mm2 = src0 */
108  "movq 64(%0), %%mm0 \n\t" /* mm0 = src4 */
109  SUMSUB_BA( %%mm0, %%mm2 ) /* mm0 = src0+src4 mm2 = src0-src4 */
110  "psllw $3, %%mm0 \n\t"
111  "psllw $3, %%mm2 \n\t"
112  "paddw %1, %%mm0 \n\t" /* add rounding bias */
113  "paddw %1, %%mm2 \n\t" /* add rounding bias */
114 
115  SUMSUB_BA( %%mm6, %%mm0 ) /* mm6 = a4 + a6 mm0 = a4 - a6 */
116  SUMSUB_BA( %%mm4, %%mm2 ) /* mm4 = a5 + a7 mm2 = a5 - a7 */
117  SUMSUB_BA( %%mm7, %%mm6 ) /* mm7 = dst0 mm6 = dst7 */
118  SUMSUB_BA( %%mm5, %%mm4 ) /* mm5 = dst1 mm4 = dst6 */
119  SUMSUB_BA( %%mm3, %%mm2 ) /* mm3 = dst2 mm2 = dst5 */
120  SUMSUB_BA( %%mm1, %%mm0 ) /* mm1 = dst3 mm0 = dst4 */
121  :: "r"(block), "m"(bias)
122  );
123 }
124 
125 static void cavs_idct8_add_mmx(uint8_t *dst, int16_t *block, int stride)
126 {
127  int i;
128  DECLARE_ALIGNED(8, int16_t, b2)[64];
129 
130  for(i=0; i<2; i++){
131  DECLARE_ALIGNED(8, uint64_t, tmp);
132 
133  cavs_idct8_1d(block+4*i, ff_pw_4.a);
134 
135  __asm__ volatile(
136  "psraw $3, %%mm7 \n\t"
137  "psraw $3, %%mm6 \n\t"
138  "psraw $3, %%mm5 \n\t"
139  "psraw $3, %%mm4 \n\t"
140  "psraw $3, %%mm3 \n\t"
141  "psraw $3, %%mm2 \n\t"
142  "psraw $3, %%mm1 \n\t"
143  "psraw $3, %%mm0 \n\t"
144  "movq %%mm7, %0 \n\t"
145  TRANSPOSE4( %%mm0, %%mm2, %%mm4, %%mm6, %%mm7 )
146  "movq %%mm0, 8(%1) \n\t"
147  "movq %%mm6, 24(%1) \n\t"
148  "movq %%mm7, 40(%1) \n\t"
149  "movq %%mm4, 56(%1) \n\t"
150  "movq %0, %%mm7 \n\t"
151  TRANSPOSE4( %%mm7, %%mm5, %%mm3, %%mm1, %%mm0 )
152  "movq %%mm7, (%1) \n\t"
153  "movq %%mm1, 16(%1) \n\t"
154  "movq %%mm0, 32(%1) \n\t"
155  "movq %%mm3, 48(%1) \n\t"
156  : "=m"(tmp)
157  : "r"(b2+32*i)
158  : "memory"
159  );
160  }
161 
162  for(i=0; i<2; i++){
163  cavs_idct8_1d(b2+4*i, ff_pw_64.a);
164 
165  __asm__ volatile(
166  "psraw $7, %%mm7 \n\t"
167  "psraw $7, %%mm6 \n\t"
168  "psraw $7, %%mm5 \n\t"
169  "psraw $7, %%mm4 \n\t"
170  "psraw $7, %%mm3 \n\t"
171  "psraw $7, %%mm2 \n\t"
172  "psraw $7, %%mm1 \n\t"
173  "psraw $7, %%mm0 \n\t"
174  "movq %%mm7, (%0) \n\t"
175  "movq %%mm5, 16(%0) \n\t"
176  "movq %%mm3, 32(%0) \n\t"
177  "movq %%mm1, 48(%0) \n\t"
178  "movq %%mm0, 64(%0) \n\t"
179  "movq %%mm2, 80(%0) \n\t"
180  "movq %%mm4, 96(%0) \n\t"
181  "movq %%mm6, 112(%0) \n\t"
182  :: "r"(b2+4*i)
183  : "memory"
184  );
185  }
186 
187  ff_add_pixels_clamped_mmx(b2, dst, stride);
188 }
189 
190 /*****************************************************************************
191  *
192  * motion compensation
193  *
194  ****************************************************************************/
195 
196 /* vertical filter [-1 -2 96 42 -7 0] */
197 #define QPEL_CAVSV1(A,B,C,D,E,F,OP,MUL2) \
198  "movd (%0), "#F" \n\t"\
199  "movq "#C", %%mm6 \n\t"\
200  "pmullw %5, %%mm6 \n\t"\
201  "movq "#D", %%mm7 \n\t"\
202  "pmullw "MANGLE(MUL2)", %%mm7\n\t"\
203  "psllw $3, "#E" \n\t"\
204  "psubw "#E", %%mm6 \n\t"\
205  "psraw $3, "#E" \n\t"\
206  "paddw %%mm7, %%mm6 \n\t"\
207  "paddw "#E", %%mm6 \n\t"\
208  "paddw "#B", "#B" \n\t"\
209  "pxor %%mm7, %%mm7 \n\t"\
210  "add %2, %0 \n\t"\
211  "punpcklbw %%mm7, "#F" \n\t"\
212  "psubw "#B", %%mm6 \n\t"\
213  "psraw $1, "#B" \n\t"\
214  "psubw "#A", %%mm6 \n\t"\
215  "paddw %4, %%mm6 \n\t"\
216  "psraw $7, %%mm6 \n\t"\
217  "packuswb %%mm6, %%mm6 \n\t"\
218  OP(%%mm6, (%1), A, d) \
219  "add %3, %1 \n\t"
220 
221 /* vertical filter [ 0 -1 5 5 -1 0] */
222 #define QPEL_CAVSV2(A,B,C,D,E,F,OP,MUL2) \
223  "movd (%0), "#F" \n\t"\
224  "movq "#C", %%mm6 \n\t"\
225  "paddw "#D", %%mm6 \n\t"\
226  "pmullw %5, %%mm6 \n\t"\
227  "add %2, %0 \n\t"\
228  "punpcklbw %%mm7, "#F" \n\t"\
229  "psubw "#B", %%mm6 \n\t"\
230  "psubw "#E", %%mm6 \n\t"\
231  "paddw %4, %%mm6 \n\t"\
232  "psraw $3, %%mm6 \n\t"\
233  "packuswb %%mm6, %%mm6 \n\t"\
234  OP(%%mm6, (%1), A, d) \
235  "add %3, %1 \n\t"
236 
237 /* vertical filter [ 0 -7 42 96 -2 -1] */
238 #define QPEL_CAVSV3(A,B,C,D,E,F,OP,MUL2) \
239  "movd (%0), "#F" \n\t"\
240  "movq "#C", %%mm6 \n\t"\
241  "pmullw "MANGLE(MUL2)", %%mm6\n\t"\
242  "movq "#D", %%mm7 \n\t"\
243  "pmullw %5, %%mm7 \n\t"\
244  "psllw $3, "#B" \n\t"\
245  "psubw "#B", %%mm6 \n\t"\
246  "psraw $3, "#B" \n\t"\
247  "paddw %%mm7, %%mm6 \n\t"\
248  "paddw "#B", %%mm6 \n\t"\
249  "paddw "#E", "#E" \n\t"\
250  "pxor %%mm7, %%mm7 \n\t"\
251  "add %2, %0 \n\t"\
252  "punpcklbw %%mm7, "#F" \n\t"\
253  "psubw "#E", %%mm6 \n\t"\
254  "psraw $1, "#E" \n\t"\
255  "psubw "#F", %%mm6 \n\t"\
256  "paddw %4, %%mm6 \n\t"\
257  "psraw $7, %%mm6 \n\t"\
258  "packuswb %%mm6, %%mm6 \n\t"\
259  OP(%%mm6, (%1), A, d) \
260  "add %3, %1 \n\t"
261 
262 
263 #define QPEL_CAVSVNUM(VOP,OP,ADD,MUL1,MUL2)\
264  int w= 2;\
265  src -= 2*srcStride;\
266  \
267  while(w--){\
268  __asm__ volatile(\
269  "pxor %%mm7, %%mm7 \n\t"\
270  "movd (%0), %%mm0 \n\t"\
271  "add %2, %0 \n\t"\
272  "movd (%0), %%mm1 \n\t"\
273  "add %2, %0 \n\t"\
274  "movd (%0), %%mm2 \n\t"\
275  "add %2, %0 \n\t"\
276  "movd (%0), %%mm3 \n\t"\
277  "add %2, %0 \n\t"\
278  "movd (%0), %%mm4 \n\t"\
279  "add %2, %0 \n\t"\
280  "punpcklbw %%mm7, %%mm0 \n\t"\
281  "punpcklbw %%mm7, %%mm1 \n\t"\
282  "punpcklbw %%mm7, %%mm2 \n\t"\
283  "punpcklbw %%mm7, %%mm3 \n\t"\
284  "punpcklbw %%mm7, %%mm4 \n\t"\
285  VOP(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP, MUL2)\
286  VOP(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP, MUL2)\
287  VOP(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP, MUL2)\
288  VOP(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP, MUL2)\
289  VOP(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, OP, MUL2)\
290  VOP(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, OP, MUL2)\
291  VOP(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP, MUL2)\
292  VOP(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP, MUL2)\
293  \
294  : "+a"(src), "+c"(dst)\
295  : "S"((x86_reg)srcStride), "r"((x86_reg)dstStride), "m"(ADD), "m"(MUL1)\
296  : "memory"\
297  );\
298  if(h==16){\
299  __asm__ volatile(\
300  VOP(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP, MUL2)\
301  VOP(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP, MUL2)\
302  VOP(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, OP, MUL2)\
303  VOP(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, OP, MUL2)\
304  VOP(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP, MUL2)\
305  VOP(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP, MUL2)\
306  VOP(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP, MUL2)\
307  VOP(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP, MUL2)\
308  \
309  : "+a"(src), "+c"(dst)\
310  : "S"((x86_reg)srcStride), "r"((x86_reg)dstStride), "m"(ADD), "m"(MUL1)\
311  : "memory"\
312  );\
313  }\
314  src += 4-(h+5)*srcStride;\
315  dst += 4-h*dstStride;\
316  }
317 
318 #define QPEL_CAVS(OPNAME, OP, MMX)\
319 static void OPNAME ## cavs_qpel8_h_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
320  int h=8;\
321  __asm__ volatile(\
322  "pxor %%mm7, %%mm7 \n\t"\
323  "movq %5, %%mm6 \n\t"\
324  "1: \n\t"\
325  "movq (%0), %%mm0 \n\t"\
326  "movq 1(%0), %%mm2 \n\t"\
327  "movq %%mm0, %%mm1 \n\t"\
328  "movq %%mm2, %%mm3 \n\t"\
329  "punpcklbw %%mm7, %%mm0 \n\t"\
330  "punpckhbw %%mm7, %%mm1 \n\t"\
331  "punpcklbw %%mm7, %%mm2 \n\t"\
332  "punpckhbw %%mm7, %%mm3 \n\t"\
333  "paddw %%mm2, %%mm0 \n\t"\
334  "paddw %%mm3, %%mm1 \n\t"\
335  "pmullw %%mm6, %%mm0 \n\t"\
336  "pmullw %%mm6, %%mm1 \n\t"\
337  "movq -1(%0), %%mm2 \n\t"\
338  "movq 2(%0), %%mm4 \n\t"\
339  "movq %%mm2, %%mm3 \n\t"\
340  "movq %%mm4, %%mm5 \n\t"\
341  "punpcklbw %%mm7, %%mm2 \n\t"\
342  "punpckhbw %%mm7, %%mm3 \n\t"\
343  "punpcklbw %%mm7, %%mm4 \n\t"\
344  "punpckhbw %%mm7, %%mm5 \n\t"\
345  "paddw %%mm4, %%mm2 \n\t"\
346  "paddw %%mm3, %%mm5 \n\t"\
347  "psubw %%mm2, %%mm0 \n\t"\
348  "psubw %%mm5, %%mm1 \n\t"\
349  "movq %6, %%mm5 \n\t"\
350  "paddw %%mm5, %%mm0 \n\t"\
351  "paddw %%mm5, %%mm1 \n\t"\
352  "psraw $3, %%mm0 \n\t"\
353  "psraw $3, %%mm1 \n\t"\
354  "packuswb %%mm1, %%mm0 \n\t"\
355  OP(%%mm0, (%1),%%mm5, q) \
356  "add %3, %0 \n\t"\
357  "add %4, %1 \n\t"\
358  "decl %2 \n\t"\
359  " jnz 1b \n\t"\
360  : "+a"(src), "+c"(dst), "+m"(h)\
361  : "d"((x86_reg)srcStride), "S"((x86_reg)dstStride), "m"(ff_pw_5), "m"(ff_pw_4)\
362  : "memory"\
363  );\
364 }\
365 \
366 static inline void OPNAME ## cavs_qpel8or16_v1_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
367  QPEL_CAVSVNUM(QPEL_CAVSV1,OP,ff_pw_64,ff_pw_96,ff_pw_42) \
368 }\
369 \
370 static inline void OPNAME ## cavs_qpel8or16_v2_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
371  QPEL_CAVSVNUM(QPEL_CAVSV2,OP,ff_pw_4,ff_pw_5,ff_pw_5) \
372 }\
373 \
374 static inline void OPNAME ## cavs_qpel8or16_v3_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
375  QPEL_CAVSVNUM(QPEL_CAVSV3,OP,ff_pw_64,ff_pw_96,ff_pw_42) \
376 }\
377 \
378 static void OPNAME ## cavs_qpel8_v1_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
379  OPNAME ## cavs_qpel8or16_v1_ ## MMX(dst , src , dstStride, srcStride, 8);\
380 }\
381 static void OPNAME ## cavs_qpel16_v1_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
382  OPNAME ## cavs_qpel8or16_v1_ ## MMX(dst , src , dstStride, srcStride, 16);\
383  OPNAME ## cavs_qpel8or16_v1_ ## MMX(dst+8, src+8, dstStride, srcStride, 16);\
384 }\
385 \
386 static void OPNAME ## cavs_qpel8_v2_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
387  OPNAME ## cavs_qpel8or16_v2_ ## MMX(dst , src , dstStride, srcStride, 8);\
388 }\
389 static void OPNAME ## cavs_qpel16_v2_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
390  OPNAME ## cavs_qpel8or16_v2_ ## MMX(dst , src , dstStride, srcStride, 16);\
391  OPNAME ## cavs_qpel8or16_v2_ ## MMX(dst+8, src+8, dstStride, srcStride, 16);\
392 }\
393 \
394 static void OPNAME ## cavs_qpel8_v3_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
395  OPNAME ## cavs_qpel8or16_v3_ ## MMX(dst , src , dstStride, srcStride, 8);\
396 }\
397 static void OPNAME ## cavs_qpel16_v3_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
398  OPNAME ## cavs_qpel8or16_v3_ ## MMX(dst , src , dstStride, srcStride, 16);\
399  OPNAME ## cavs_qpel8or16_v3_ ## MMX(dst+8, src+8, dstStride, srcStride, 16);\
400 }\
401 \
402 static void OPNAME ## cavs_qpel16_h_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
403  OPNAME ## cavs_qpel8_h_ ## MMX(dst , src , dstStride, srcStride);\
404  OPNAME ## cavs_qpel8_h_ ## MMX(dst+8, src+8, dstStride, srcStride);\
405  src += 8*srcStride;\
406  dst += 8*dstStride;\
407  OPNAME ## cavs_qpel8_h_ ## MMX(dst , src , dstStride, srcStride);\
408  OPNAME ## cavs_qpel8_h_ ## MMX(dst+8, src+8, dstStride, srcStride);\
409 }\
410 
411 #define CAVS_MC(OPNAME, SIZE, MMX) \
412 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc20_ ## MMX(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
413 {\
414  OPNAME ## cavs_qpel ## SIZE ## _h_ ## MMX(dst, src, stride, stride);\
415 }\
416 \
417 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc01_ ## MMX(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
418 {\
419  OPNAME ## cavs_qpel ## SIZE ## _v1_ ## MMX(dst, src, stride, stride);\
420 }\
421 \
422 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc02_ ## MMX(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
423 {\
424  OPNAME ## cavs_qpel ## SIZE ## _v2_ ## MMX(dst, src, stride, stride);\
425 }\
426 \
427 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc03_ ## MMX(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
428 {\
429  OPNAME ## cavs_qpel ## SIZE ## _v3_ ## MMX(dst, src, stride, stride);\
430 }\
431 
432 #define PUT_OP(a,b,temp, size) "mov" #size " " #a ", " #b " \n\t"
433 #define AVG_3DNOW_OP(a,b,temp, size) \
434 "mov" #size " " #b ", " #temp " \n\t"\
435 "pavgusb " #temp ", " #a " \n\t"\
436 "mov" #size " " #a ", " #b " \n\t"
437 #define AVG_MMXEXT_OP(a, b, temp, size) \
438 "mov" #size " " #b ", " #temp " \n\t"\
439 "pavgb " #temp ", " #a " \n\t"\
440 "mov" #size " " #a ", " #b " \n\t"
441 
442 #endif /* (HAVE_MMXEXT_INLINE || HAVE_AMD3DNOW_INLINE) */
443 
444 #if HAVE_MMXEXT_INLINE
445 QPEL_CAVS(put_, PUT_OP, mmxext)
446 QPEL_CAVS(avg_, AVG_MMXEXT_OP, mmxext)
447 
448 CAVS_MC(put_, 8, mmxext)
449 CAVS_MC(put_, 16, mmxext)
450 CAVS_MC(avg_, 8, mmxext)
451 CAVS_MC(avg_, 16, mmxext)
452 
453 static av_cold void ff_cavsdsp_init_mmxext(CAVSDSPContext *c,
454  AVCodecContext *avctx)
455 {
456 #define dspfunc(PFX, IDX, NUM) \
457  c->PFX ## _pixels_tab[IDX][ 0] = ff_ ## PFX ## NUM ## _mc00_mmxext; \
458  c->PFX ## _pixels_tab[IDX][ 2] = ff_ ## PFX ## NUM ## _mc20_mmxext; \
459  c->PFX ## _pixels_tab[IDX][ 4] = ff_ ## PFX ## NUM ## _mc01_mmxext; \
460  c->PFX ## _pixels_tab[IDX][ 8] = ff_ ## PFX ## NUM ## _mc02_mmxext; \
461  c->PFX ## _pixels_tab[IDX][12] = ff_ ## PFX ## NUM ## _mc03_mmxext; \
462 
463  dspfunc(put_cavs_qpel, 0, 16);
464  dspfunc(put_cavs_qpel, 1, 8);
465  dspfunc(avg_cavs_qpel, 0, 16);
466  dspfunc(avg_cavs_qpel, 1, 8);
467 #undef dspfunc
468  c->cavs_idct8_add = cavs_idct8_add_mmx;
469  c->idct_perm = FF_TRANSPOSE_IDCT_PERM;
470 }
471 #endif /* HAVE_MMXEXT_INLINE */
472 
473 #if HAVE_AMD3DNOW_INLINE
474 QPEL_CAVS(put_, PUT_OP, 3dnow)
475 QPEL_CAVS(avg_, AVG_3DNOW_OP, 3dnow)
476 
477 CAVS_MC(put_, 8, 3dnow)
478 CAVS_MC(put_, 16,3dnow)
479 CAVS_MC(avg_, 8, 3dnow)
480 CAVS_MC(avg_, 16,3dnow)
481 
482 static av_cold void ff_cavsdsp_init_3dnow(CAVSDSPContext *c,
483  AVCodecContext *avctx)
484 {
485 #define dspfunc(PFX, IDX, NUM) \
486  c->PFX ## _pixels_tab[IDX][ 0] = ff_ ## PFX ## NUM ## _mc00_mmxext; \
487  c->PFX ## _pixels_tab[IDX][ 2] = ff_ ## PFX ## NUM ## _mc20_3dnow; \
488  c->PFX ## _pixels_tab[IDX][ 4] = ff_ ## PFX ## NUM ## _mc01_3dnow; \
489  c->PFX ## _pixels_tab[IDX][ 8] = ff_ ## PFX ## NUM ## _mc02_3dnow; \
490  c->PFX ## _pixels_tab[IDX][12] = ff_ ## PFX ## NUM ## _mc03_3dnow; \
491 
492  dspfunc(put_cavs_qpel, 0, 16);
493  dspfunc(put_cavs_qpel, 1, 8);
494  dspfunc(avg_cavs_qpel, 0, 16);
495  dspfunc(avg_cavs_qpel, 1, 8);
496 #undef dspfunc
497  c->cavs_idct8_add = cavs_idct8_add_mmx;
498  c->idct_perm = FF_TRANSPOSE_IDCT_PERM;
499 }
500 #endif /* HAVE_AMD3DNOW_INLINE */
501 
503 {
504  int mm_flags = av_get_cpu_flags();
505 
506 #if HAVE_MMXEXT_INLINE
507  if (mm_flags & AV_CPU_FLAG_MMXEXT) ff_cavsdsp_init_mmxext(c, avctx);
508 #endif /* HAVE_MMXEXT_INLINE */
509 #if HAVE_AMD3DNOW_INLINE
510  if (mm_flags & AV_CPU_FLAG_3DNOW) ff_cavsdsp_init_3dnow(c, avctx);
511 #endif /* HAVE_AMD3DNOW_INLINE */
512 }
#define TRANSPOSE4(a, b, c, d, t)
Definition: dsputil_mmx.h:64
#define DECLARE_ALIGNED(n, t, v)
Definition: mem.h:59
int stride
Definition: mace.c:144
Macro definitions for various function/variable attributes.
const xmm_reg ff_pw_64
uint8_t
#define av_cold
Definition: attributes.h:78
window constants for m
#define AV_CPU_FLAG_MMXEXT
SSE integer functions or AMD MMX ext.
Definition: cpu.h:30
uint64_t a
const xmm_reg ff_pw_4
const char * r
Definition: vf_curves.c:94
#define CAVS_MC(OPNAME, SIZE)
Definition: cavsdsp.c:423
void ff_add_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels, int line_size)
#define AV_CPU_FLAG_3DNOW
AMD 3DNOW.
Definition: cpu.h:32
#define dspfunc(PFX, IDX, NUM)
main external API structure.
synthesis window for stochastic i
av_cold void ff_cavsdsp_init_x86(CAVSDSPContext *c, AVCodecContext *avctx)
Definition: x86/cavsdsp.c:502
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition: cpu.c:30
common internal and external API header
static double c[64]
else dst[i][x+y *dst_stride[i]]
Definition: vf_mcdeint.c:160
#define FF_TRANSPOSE_IDCT_PERM
Definition: dsputil.h:254