2 * Chinese AVS video (AVS1-P2, JiZhun profile) decoder.
3 * Copyright (c) 2006 Stefan Gehrer <stefan.gehrer@gmx.de>
5 * MMX-optimized DSP functions, based on H.264 optimizations by
6 * Michael Niedermayer and Loren Merritt
8 * This file is part of FFmpeg.
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.
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.
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
25 #include "libavutil/common.h"
26 #include "libavutil/cpu.h"
27 #include "libavutil/x86_cpu.h"
28 #include "libavcodec/dsputil.h"
29 #include "libavcodec/cavsdsp.h"
30 #include "dsputil_mmx.h"
34 /* in/out: mma=mma+mmb, mmb=mmb-mma */
35 #define SUMSUB_BA( a, b ) \
36 "paddw "#b", "#a" \n\t"\
37 "paddw "#b", "#b" \n\t"\
38 "psubw "#a", "#b" \n\t"
40 /*****************************************************************************
44 ****************************************************************************/
46 static inline void cavs_idct8_1d(int16_t *block, uint64_t bias)
49 "movq 112(%0), %%mm4 \n\t" /* mm4 = src7 */
50 "movq 16(%0), %%mm5 \n\t" /* mm5 = src1 */
51 "movq 80(%0), %%mm2 \n\t" /* mm2 = src5 */
52 "movq 48(%0), %%mm7 \n\t" /* mm7 = src3 */
53 "movq %%mm4, %%mm0 \n\t"
54 "movq %%mm5, %%mm3 \n\t"
55 "movq %%mm2, %%mm6 \n\t"
56 "movq %%mm7, %%mm1 \n\t"
58 "paddw %%mm4, %%mm4 \n\t" /* mm4 = 2*src7 */
59 "paddw %%mm3, %%mm3 \n\t" /* mm3 = 2*src1 */
60 "paddw %%mm6, %%mm6 \n\t" /* mm6 = 2*src5 */
61 "paddw %%mm1, %%mm1 \n\t" /* mm1 = 2*src3 */
62 "paddw %%mm4, %%mm0 \n\t" /* mm0 = 3*src7 */
63 "paddw %%mm3, %%mm5 \n\t" /* mm5 = 3*src1 */
64 "paddw %%mm6, %%mm2 \n\t" /* mm2 = 3*src5 */
65 "paddw %%mm1, %%mm7 \n\t" /* mm7 = 3*src3 */
66 "psubw %%mm4, %%mm5 \n\t" /* mm5 = 3*src1 - 2*src7 = a0 */
67 "paddw %%mm6, %%mm7 \n\t" /* mm7 = 3*src3 + 2*src5 = a1 */
68 "psubw %%mm2, %%mm1 \n\t" /* mm1 = 2*src3 - 3*src5 = a2 */
69 "paddw %%mm0, %%mm3 \n\t" /* mm3 = 2*src1 + 3*src7 = a3 */
71 "movq %%mm5, %%mm4 \n\t"
72 "movq %%mm7, %%mm6 \n\t"
73 "movq %%mm3, %%mm0 \n\t"
74 "movq %%mm1, %%mm2 \n\t"
75 SUMSUB_BA( %%mm7, %%mm5 ) /* mm7 = a0 + a1 mm5 = a0 - a1 */
76 "paddw %%mm3, %%mm7 \n\t" /* mm7 = a0 + a1 + a3 */
77 "paddw %%mm1, %%mm5 \n\t" /* mm5 = a0 - a1 + a2 */
78 "paddw %%mm7, %%mm7 \n\t"
79 "paddw %%mm5, %%mm5 \n\t"
80 "paddw %%mm6, %%mm7 \n\t" /* mm7 = b4 */
81 "paddw %%mm4, %%mm5 \n\t" /* mm5 = b5 */
83 SUMSUB_BA( %%mm1, %%mm3 ) /* mm1 = a3 + a2 mm3 = a3 - a2 */
84 "psubw %%mm1, %%mm4 \n\t" /* mm4 = a0 - a2 - a3 */
85 "movq %%mm4, %%mm1 \n\t" /* mm1 = a0 - a2 - a3 */
86 "psubw %%mm6, %%mm3 \n\t" /* mm3 = a3 - a2 - a1 */
87 "paddw %%mm1, %%mm1 \n\t"
88 "paddw %%mm3, %%mm3 \n\t"
89 "psubw %%mm2, %%mm1 \n\t" /* mm1 = b7 */
90 "paddw %%mm0, %%mm3 \n\t" /* mm3 = b6 */
92 "movq 32(%0), %%mm2 \n\t" /* mm2 = src2 */
93 "movq 96(%0), %%mm6 \n\t" /* mm6 = src6 */
94 "movq %%mm2, %%mm4 \n\t"
95 "movq %%mm6, %%mm0 \n\t"
96 "psllw $2, %%mm4 \n\t" /* mm4 = 4*src2 */
97 "psllw $2, %%mm6 \n\t" /* mm6 = 4*src6 */
98 "paddw %%mm4, %%mm2 \n\t" /* mm2 = 5*src2 */
99 "paddw %%mm6, %%mm0 \n\t" /* mm0 = 5*src6 */
100 "paddw %%mm2, %%mm2 \n\t"
101 "paddw %%mm0, %%mm0 \n\t"
102 "psubw %%mm0, %%mm4 \n\t" /* mm4 = 4*src2 - 10*src6 = a7 */
103 "paddw %%mm2, %%mm6 \n\t" /* mm6 = 4*src6 + 10*src2 = a6 */
105 "movq (%0), %%mm2 \n\t" /* mm2 = src0 */
106 "movq 64(%0), %%mm0 \n\t" /* mm0 = src4 */
107 SUMSUB_BA( %%mm0, %%mm2 ) /* mm0 = src0+src4 mm2 = src0-src4 */
108 "psllw $3, %%mm0 \n\t"
109 "psllw $3, %%mm2 \n\t"
110 "paddw %1, %%mm0 \n\t" /* add rounding bias */
111 "paddw %1, %%mm2 \n\t" /* add rounding bias */
113 SUMSUB_BA( %%mm6, %%mm0 ) /* mm6 = a4 + a6 mm0 = a4 - a6 */
114 SUMSUB_BA( %%mm4, %%mm2 ) /* mm4 = a5 + a7 mm2 = a5 - a7 */
115 SUMSUB_BA( %%mm7, %%mm6 ) /* mm7 = dst0 mm6 = dst7 */
116 SUMSUB_BA( %%mm5, %%mm4 ) /* mm5 = dst1 mm4 = dst6 */
117 SUMSUB_BA( %%mm3, %%mm2 ) /* mm3 = dst2 mm2 = dst5 */
118 SUMSUB_BA( %%mm1, %%mm0 ) /* mm1 = dst3 mm0 = dst4 */
119 :: "r"(block), "m"(bias)
123 static void cavs_idct8_add_mmx(uint8_t *dst, int16_t *block, int stride)
126 DECLARE_ALIGNED(8, int16_t, b2)[64];
129 DECLARE_ALIGNED(8, uint64_t, tmp);
131 cavs_idct8_1d(block+4*i, ff_pw_4.a);
134 "psraw $3, %%mm7 \n\t"
135 "psraw $3, %%mm6 \n\t"
136 "psraw $3, %%mm5 \n\t"
137 "psraw $3, %%mm4 \n\t"
138 "psraw $3, %%mm3 \n\t"
139 "psraw $3, %%mm2 \n\t"
140 "psraw $3, %%mm1 \n\t"
141 "psraw $3, %%mm0 \n\t"
142 "movq %%mm7, %0 \n\t"
143 TRANSPOSE4( %%mm0, %%mm2, %%mm4, %%mm6, %%mm7 )
144 "movq %%mm0, 8(%1) \n\t"
145 "movq %%mm6, 24(%1) \n\t"
146 "movq %%mm7, 40(%1) \n\t"
147 "movq %%mm4, 56(%1) \n\t"
148 "movq %0, %%mm7 \n\t"
149 TRANSPOSE4( %%mm7, %%mm5, %%mm3, %%mm1, %%mm0 )
150 "movq %%mm7, (%1) \n\t"
151 "movq %%mm1, 16(%1) \n\t"
152 "movq %%mm0, 32(%1) \n\t"
153 "movq %%mm3, 48(%1) \n\t"
161 cavs_idct8_1d(b2+4*i, ff_pw_64.a);
164 "psraw $7, %%mm7 \n\t"
165 "psraw $7, %%mm6 \n\t"
166 "psraw $7, %%mm5 \n\t"
167 "psraw $7, %%mm4 \n\t"
168 "psraw $7, %%mm3 \n\t"
169 "psraw $7, %%mm2 \n\t"
170 "psraw $7, %%mm1 \n\t"
171 "psraw $7, %%mm0 \n\t"
172 "movq %%mm7, (%0) \n\t"
173 "movq %%mm5, 16(%0) \n\t"
174 "movq %%mm3, 32(%0) \n\t"
175 "movq %%mm1, 48(%0) \n\t"
176 "movq %%mm0, 64(%0) \n\t"
177 "movq %%mm2, 80(%0) \n\t"
178 "movq %%mm4, 96(%0) \n\t"
179 "movq %%mm6, 112(%0) \n\t"
185 ff_add_pixels_clamped_mmx(b2, dst, stride);
188 /*****************************************************************************
190 * motion compensation
192 ****************************************************************************/
194 /* vertical filter [-1 -2 96 42 -7 0] */
195 #define QPEL_CAVSV1(A,B,C,D,E,F,OP,MUL2) \
196 "movd (%0), "#F" \n\t"\
197 "movq "#C", %%mm6 \n\t"\
198 "pmullw %5, %%mm6 \n\t"\
199 "movq "#D", %%mm7 \n\t"\
200 "pmullw "MANGLE(MUL2)", %%mm7\n\t"\
201 "psllw $3, "#E" \n\t"\
202 "psubw "#E", %%mm6 \n\t"\
203 "psraw $3, "#E" \n\t"\
204 "paddw %%mm7, %%mm6 \n\t"\
205 "paddw "#E", %%mm6 \n\t"\
206 "paddw "#B", "#B" \n\t"\
207 "pxor %%mm7, %%mm7 \n\t"\
209 "punpcklbw %%mm7, "#F" \n\t"\
210 "psubw "#B", %%mm6 \n\t"\
211 "psraw $1, "#B" \n\t"\
212 "psubw "#A", %%mm6 \n\t"\
213 "paddw %4, %%mm6 \n\t"\
214 "psraw $7, %%mm6 \n\t"\
215 "packuswb %%mm6, %%mm6 \n\t"\
216 OP(%%mm6, (%1), A, d) \
219 /* vertical filter [ 0 -1 5 5 -1 0] */
220 #define QPEL_CAVSV2(A,B,C,D,E,F,OP,MUL2) \
221 "movd (%0), "#F" \n\t"\
222 "movq "#C", %%mm6 \n\t"\
223 "paddw "#D", %%mm6 \n\t"\
224 "pmullw %5, %%mm6 \n\t"\
226 "punpcklbw %%mm7, "#F" \n\t"\
227 "psubw "#B", %%mm6 \n\t"\
228 "psubw "#E", %%mm6 \n\t"\
229 "paddw %4, %%mm6 \n\t"\
230 "psraw $3, %%mm6 \n\t"\
231 "packuswb %%mm6, %%mm6 \n\t"\
232 OP(%%mm6, (%1), A, d) \
235 /* vertical filter [ 0 -7 42 96 -2 -1] */
236 #define QPEL_CAVSV3(A,B,C,D,E,F,OP,MUL2) \
237 "movd (%0), "#F" \n\t"\
238 "movq "#C", %%mm6 \n\t"\
239 "pmullw "MANGLE(MUL2)", %%mm6\n\t"\
240 "movq "#D", %%mm7 \n\t"\
241 "pmullw %5, %%mm7 \n\t"\
242 "psllw $3, "#B" \n\t"\
243 "psubw "#B", %%mm6 \n\t"\
244 "psraw $3, "#B" \n\t"\
245 "paddw %%mm7, %%mm6 \n\t"\
246 "paddw "#B", %%mm6 \n\t"\
247 "paddw "#E", "#E" \n\t"\
248 "pxor %%mm7, %%mm7 \n\t"\
250 "punpcklbw %%mm7, "#F" \n\t"\
251 "psubw "#E", %%mm6 \n\t"\
252 "psraw $1, "#E" \n\t"\
253 "psubw "#F", %%mm6 \n\t"\
254 "paddw %4, %%mm6 \n\t"\
255 "psraw $7, %%mm6 \n\t"\
256 "packuswb %%mm6, %%mm6 \n\t"\
257 OP(%%mm6, (%1), A, d) \
261 #define QPEL_CAVSVNUM(VOP,OP,ADD,MUL1,MUL2)\
267 "pxor %%mm7, %%mm7 \n\t"\
268 "movd (%0), %%mm0 \n\t"\
270 "movd (%0), %%mm1 \n\t"\
272 "movd (%0), %%mm2 \n\t"\
274 "movd (%0), %%mm3 \n\t"\
276 "movd (%0), %%mm4 \n\t"\
278 "punpcklbw %%mm7, %%mm0 \n\t"\
279 "punpcklbw %%mm7, %%mm1 \n\t"\
280 "punpcklbw %%mm7, %%mm2 \n\t"\
281 "punpcklbw %%mm7, %%mm3 \n\t"\
282 "punpcklbw %%mm7, %%mm4 \n\t"\
283 VOP(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP, MUL2)\
284 VOP(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP, MUL2)\
285 VOP(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP, MUL2)\
286 VOP(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP, MUL2)\
287 VOP(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, OP, MUL2)\
288 VOP(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, OP, MUL2)\
289 VOP(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP, MUL2)\
290 VOP(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP, MUL2)\
292 : "+a"(src), "+c"(dst)\
293 : "S"((x86_reg)srcStride), "r"((x86_reg)dstStride), "m"(ADD), "m"(MUL1)\
298 VOP(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP, MUL2)\
299 VOP(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP, MUL2)\
300 VOP(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, OP, MUL2)\
301 VOP(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, OP, MUL2)\
302 VOP(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP, MUL2)\
303 VOP(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP, MUL2)\
304 VOP(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP, MUL2)\
305 VOP(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP, MUL2)\
307 : "+a"(src), "+c"(dst)\
308 : "S"((x86_reg)srcStride), "r"((x86_reg)dstStride), "m"(ADD), "m"(MUL1)\
312 src += 4-(h+5)*srcStride;\
313 dst += 4-h*dstStride;\
316 #define QPEL_CAVS(OPNAME, OP, MMX)\
317 static void OPNAME ## cavs_qpel8_h_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
320 "pxor %%mm7, %%mm7 \n\t"\
321 "movq %5, %%mm6 \n\t"\
323 "movq (%0), %%mm0 \n\t"\
324 "movq 1(%0), %%mm2 \n\t"\
325 "movq %%mm0, %%mm1 \n\t"\
326 "movq %%mm2, %%mm3 \n\t"\
327 "punpcklbw %%mm7, %%mm0 \n\t"\
328 "punpckhbw %%mm7, %%mm1 \n\t"\
329 "punpcklbw %%mm7, %%mm2 \n\t"\
330 "punpckhbw %%mm7, %%mm3 \n\t"\
331 "paddw %%mm2, %%mm0 \n\t"\
332 "paddw %%mm3, %%mm1 \n\t"\
333 "pmullw %%mm6, %%mm0 \n\t"\
334 "pmullw %%mm6, %%mm1 \n\t"\
335 "movq -1(%0), %%mm2 \n\t"\
336 "movq 2(%0), %%mm4 \n\t"\
337 "movq %%mm2, %%mm3 \n\t"\
338 "movq %%mm4, %%mm5 \n\t"\
339 "punpcklbw %%mm7, %%mm2 \n\t"\
340 "punpckhbw %%mm7, %%mm3 \n\t"\
341 "punpcklbw %%mm7, %%mm4 \n\t"\
342 "punpckhbw %%mm7, %%mm5 \n\t"\
343 "paddw %%mm4, %%mm2 \n\t"\
344 "paddw %%mm3, %%mm5 \n\t"\
345 "psubw %%mm2, %%mm0 \n\t"\
346 "psubw %%mm5, %%mm1 \n\t"\
347 "movq %6, %%mm5 \n\t"\
348 "paddw %%mm5, %%mm0 \n\t"\
349 "paddw %%mm5, %%mm1 \n\t"\
350 "psraw $3, %%mm0 \n\t"\
351 "psraw $3, %%mm1 \n\t"\
352 "packuswb %%mm1, %%mm0 \n\t"\
353 OP(%%mm0, (%1),%%mm5, q) \
358 : "+a"(src), "+c"(dst), "+m"(h)\
359 : "d"((x86_reg)srcStride), "S"((x86_reg)dstStride), "m"(ff_pw_5), "m"(ff_pw_4)\
364 static inline void OPNAME ## cavs_qpel8or16_v1_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
365 QPEL_CAVSVNUM(QPEL_CAVSV1,OP,ff_pw_64,ff_pw_96,ff_pw_42) \
368 static inline void OPNAME ## cavs_qpel8or16_v2_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
369 QPEL_CAVSVNUM(QPEL_CAVSV2,OP,ff_pw_4,ff_pw_5,ff_pw_5) \
372 static inline void OPNAME ## cavs_qpel8or16_v3_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
373 QPEL_CAVSVNUM(QPEL_CAVSV3,OP,ff_pw_64,ff_pw_96,ff_pw_42) \
376 static void OPNAME ## cavs_qpel8_v1_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
377 OPNAME ## cavs_qpel8or16_v1_ ## MMX(dst , src , dstStride, srcStride, 8);\
379 static void OPNAME ## cavs_qpel16_v1_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
380 OPNAME ## cavs_qpel8or16_v1_ ## MMX(dst , src , dstStride, srcStride, 16);\
381 OPNAME ## cavs_qpel8or16_v1_ ## MMX(dst+8, src+8, dstStride, srcStride, 16);\
384 static void OPNAME ## cavs_qpel8_v2_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
385 OPNAME ## cavs_qpel8or16_v2_ ## MMX(dst , src , dstStride, srcStride, 8);\
387 static void OPNAME ## cavs_qpel16_v2_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
388 OPNAME ## cavs_qpel8or16_v2_ ## MMX(dst , src , dstStride, srcStride, 16);\
389 OPNAME ## cavs_qpel8or16_v2_ ## MMX(dst+8, src+8, dstStride, srcStride, 16);\
392 static void OPNAME ## cavs_qpel8_v3_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
393 OPNAME ## cavs_qpel8or16_v3_ ## MMX(dst , src , dstStride, srcStride, 8);\
395 static void OPNAME ## cavs_qpel16_v3_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
396 OPNAME ## cavs_qpel8or16_v3_ ## MMX(dst , src , dstStride, srcStride, 16);\
397 OPNAME ## cavs_qpel8or16_v3_ ## MMX(dst+8, src+8, dstStride, srcStride, 16);\
400 static void OPNAME ## cavs_qpel16_h_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
401 OPNAME ## cavs_qpel8_h_ ## MMX(dst , src , dstStride, srcStride);\
402 OPNAME ## cavs_qpel8_h_ ## MMX(dst+8, src+8, dstStride, srcStride);\
405 OPNAME ## cavs_qpel8_h_ ## MMX(dst , src , dstStride, srcStride);\
406 OPNAME ## cavs_qpel8_h_ ## MMX(dst+8, src+8, dstStride, srcStride);\
409 #define CAVS_MC(OPNAME, SIZE, MMX) \
410 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc20_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
411 OPNAME ## cavs_qpel ## SIZE ## _h_ ## MMX(dst, src, stride, stride);\
414 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc01_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
415 OPNAME ## cavs_qpel ## SIZE ## _v1_ ## MMX(dst, src, stride, stride);\
418 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc02_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
419 OPNAME ## cavs_qpel ## SIZE ## _v2_ ## MMX(dst, src, stride, stride);\
422 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc03_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
423 OPNAME ## cavs_qpel ## SIZE ## _v3_ ## MMX(dst, src, stride, stride);\
426 #define PUT_OP(a,b,temp, size) "mov" #size " " #a ", " #b " \n\t"
427 #define AVG_3DNOW_OP(a,b,temp, size) \
428 "mov" #size " " #b ", " #temp " \n\t"\
429 "pavgusb " #temp ", " #a " \n\t"\
430 "mov" #size " " #a ", " #b " \n\t"
431 #define AVG_MMX2_OP(a,b,temp, size) \
432 "mov" #size " " #b ", " #temp " \n\t"\
433 "pavgb " #temp ", " #a " \n\t"\
434 "mov" #size " " #a ", " #b " \n\t"
436 QPEL_CAVS(put_, PUT_OP, 3dnow)
437 QPEL_CAVS(avg_, AVG_3DNOW_OP, 3dnow)
438 QPEL_CAVS(put_, PUT_OP, mmx2)
439 QPEL_CAVS(avg_, AVG_MMX2_OP, mmx2)
441 CAVS_MC(put_, 8, 3dnow)
442 CAVS_MC(put_, 16,3dnow)
443 CAVS_MC(avg_, 8, 3dnow)
444 CAVS_MC(avg_, 16,3dnow)
445 CAVS_MC(put_, 8, mmx2)
446 CAVS_MC(put_, 16,mmx2)
447 CAVS_MC(avg_, 8, mmx2)
448 CAVS_MC(avg_, 16,mmx2)
450 static void ff_cavsdsp_init_mmx2(CAVSDSPContext* c, AVCodecContext *avctx) {
451 #define dspfunc(PFX, IDX, NUM) \
452 c->PFX ## _pixels_tab[IDX][ 0] = ff_ ## PFX ## NUM ## _mc00_mmx2; \
453 c->PFX ## _pixels_tab[IDX][ 2] = ff_ ## PFX ## NUM ## _mc20_mmx2; \
454 c->PFX ## _pixels_tab[IDX][ 4] = ff_ ## PFX ## NUM ## _mc01_mmx2; \
455 c->PFX ## _pixels_tab[IDX][ 8] = ff_ ## PFX ## NUM ## _mc02_mmx2; \
456 c->PFX ## _pixels_tab[IDX][12] = ff_ ## PFX ## NUM ## _mc03_mmx2; \
458 dspfunc(put_cavs_qpel, 0, 16);
459 dspfunc(put_cavs_qpel, 1, 8);
460 dspfunc(avg_cavs_qpel, 0, 16);
461 dspfunc(avg_cavs_qpel, 1, 8);
463 c->cavs_idct8_add = cavs_idct8_add_mmx;
466 static void ff_cavsdsp_init_3dnow(CAVSDSPContext* c, AVCodecContext *avctx) {
467 #define dspfunc(PFX, IDX, NUM) \
468 c->PFX ## _pixels_tab[IDX][ 0] = ff_ ## PFX ## NUM ## _mc00_mmx2; \
469 c->PFX ## _pixels_tab[IDX][ 2] = ff_ ## PFX ## NUM ## _mc20_3dnow; \
470 c->PFX ## _pixels_tab[IDX][ 4] = ff_ ## PFX ## NUM ## _mc01_3dnow; \
471 c->PFX ## _pixels_tab[IDX][ 8] = ff_ ## PFX ## NUM ## _mc02_3dnow; \
472 c->PFX ## _pixels_tab[IDX][12] = ff_ ## PFX ## NUM ## _mc03_3dnow; \
474 dspfunc(put_cavs_qpel, 0, 16);
475 dspfunc(put_cavs_qpel, 1, 8);
476 dspfunc(avg_cavs_qpel, 0, 16);
477 dspfunc(avg_cavs_qpel, 1, 8);
479 c->cavs_idct8_add = cavs_idct8_add_mmx;
482 #endif /* HAVE_INLINE_ASM */
484 void ff_cavsdsp_init_mmx(CAVSDSPContext *c, AVCodecContext *avctx)
486 int mm_flags = av_get_cpu_flags();
489 if (mm_flags & AV_CPU_FLAG_MMXEXT) ff_cavsdsp_init_mmx2(c, avctx);
490 if (mm_flags & AV_CPU_FLAG_3DNOW) ff_cavsdsp_init_3dnow(c, avctx);
491 #endif /* HAVE_INLINE_ASM */