00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "libavutil/common.h"
00026 #include "libavutil/cpu.h"
00027 #include "libavutil/x86/asm.h"
00028 #include "libavcodec/dsputil.h"
00029 #include "libavcodec/cavsdsp.h"
00030 #include "dsputil_mmx.h"
00031
00032 #if HAVE_INLINE_ASM
00033
00034
00035 #define SUMSUB_BA( a, b ) \
00036 "paddw "#b", "#a" \n\t"\
00037 "paddw "#b", "#b" \n\t"\
00038 "psubw "#a", "#b" \n\t"
00039
00040
00041
00042
00043
00044
00045
00046 static inline void cavs_idct8_1d(int16_t *block, uint64_t bias)
00047 {
00048 __asm__ volatile(
00049 "movq 112(%0), %%mm4 \n\t"
00050 "movq 16(%0), %%mm5 \n\t"
00051 "movq 80(%0), %%mm2 \n\t"
00052 "movq 48(%0), %%mm7 \n\t"
00053 "movq %%mm4, %%mm0 \n\t"
00054 "movq %%mm5, %%mm3 \n\t"
00055 "movq %%mm2, %%mm6 \n\t"
00056 "movq %%mm7, %%mm1 \n\t"
00057
00058 "paddw %%mm4, %%mm4 \n\t"
00059 "paddw %%mm3, %%mm3 \n\t"
00060 "paddw %%mm6, %%mm6 \n\t"
00061 "paddw %%mm1, %%mm1 \n\t"
00062 "paddw %%mm4, %%mm0 \n\t"
00063 "paddw %%mm3, %%mm5 \n\t"
00064 "paddw %%mm6, %%mm2 \n\t"
00065 "paddw %%mm1, %%mm7 \n\t"
00066 "psubw %%mm4, %%mm5 \n\t"
00067 "paddw %%mm6, %%mm7 \n\t"
00068 "psubw %%mm2, %%mm1 \n\t"
00069 "paddw %%mm0, %%mm3 \n\t"
00070
00071 "movq %%mm5, %%mm4 \n\t"
00072 "movq %%mm7, %%mm6 \n\t"
00073 "movq %%mm3, %%mm0 \n\t"
00074 "movq %%mm1, %%mm2 \n\t"
00075 SUMSUB_BA( %%mm7, %%mm5 )
00076 "paddw %%mm3, %%mm7 \n\t"
00077 "paddw %%mm1, %%mm5 \n\t"
00078 "paddw %%mm7, %%mm7 \n\t"
00079 "paddw %%mm5, %%mm5 \n\t"
00080 "paddw %%mm6, %%mm7 \n\t"
00081 "paddw %%mm4, %%mm5 \n\t"
00082
00083 SUMSUB_BA( %%mm1, %%mm3 )
00084 "psubw %%mm1, %%mm4 \n\t"
00085 "movq %%mm4, %%mm1 \n\t"
00086 "psubw %%mm6, %%mm3 \n\t"
00087 "paddw %%mm1, %%mm1 \n\t"
00088 "paddw %%mm3, %%mm3 \n\t"
00089 "psubw %%mm2, %%mm1 \n\t"
00090 "paddw %%mm0, %%mm3 \n\t"
00091
00092 "movq 32(%0), %%mm2 \n\t"
00093 "movq 96(%0), %%mm6 \n\t"
00094 "movq %%mm2, %%mm4 \n\t"
00095 "movq %%mm6, %%mm0 \n\t"
00096 "psllw $2, %%mm4 \n\t"
00097 "psllw $2, %%mm6 \n\t"
00098 "paddw %%mm4, %%mm2 \n\t"
00099 "paddw %%mm6, %%mm0 \n\t"
00100 "paddw %%mm2, %%mm2 \n\t"
00101 "paddw %%mm0, %%mm0 \n\t"
00102 "psubw %%mm0, %%mm4 \n\t"
00103 "paddw %%mm2, %%mm6 \n\t"
00104
00105 "movq (%0), %%mm2 \n\t"
00106 "movq 64(%0), %%mm0 \n\t"
00107 SUMSUB_BA( %%mm0, %%mm2 )
00108 "psllw $3, %%mm0 \n\t"
00109 "psllw $3, %%mm2 \n\t"
00110 "paddw %1, %%mm0 \n\t"
00111 "paddw %1, %%mm2 \n\t"
00112
00113 SUMSUB_BA( %%mm6, %%mm0 )
00114 SUMSUB_BA( %%mm4, %%mm2 )
00115 SUMSUB_BA( %%mm7, %%mm6 )
00116 SUMSUB_BA( %%mm5, %%mm4 )
00117 SUMSUB_BA( %%mm3, %%mm2 )
00118 SUMSUB_BA( %%mm1, %%mm0 )
00119 :: "r"(block), "m"(bias)
00120 );
00121 }
00122
00123 static void cavs_idct8_add_mmx(uint8_t *dst, int16_t *block, int stride)
00124 {
00125 int i;
00126 DECLARE_ALIGNED(8, int16_t, b2)[64];
00127
00128 for(i=0; i<2; i++){
00129 DECLARE_ALIGNED(8, uint64_t, tmp);
00130
00131 cavs_idct8_1d(block+4*i, ff_pw_4.a);
00132
00133 __asm__ volatile(
00134 "psraw $3, %%mm7 \n\t"
00135 "psraw $3, %%mm6 \n\t"
00136 "psraw $3, %%mm5 \n\t"
00137 "psraw $3, %%mm4 \n\t"
00138 "psraw $3, %%mm3 \n\t"
00139 "psraw $3, %%mm2 \n\t"
00140 "psraw $3, %%mm1 \n\t"
00141 "psraw $3, %%mm0 \n\t"
00142 "movq %%mm7, %0 \n\t"
00143 TRANSPOSE4( %%mm0, %%mm2, %%mm4, %%mm6, %%mm7 )
00144 "movq %%mm0, 8(%1) \n\t"
00145 "movq %%mm6, 24(%1) \n\t"
00146 "movq %%mm7, 40(%1) \n\t"
00147 "movq %%mm4, 56(%1) \n\t"
00148 "movq %0, %%mm7 \n\t"
00149 TRANSPOSE4( %%mm7, %%mm5, %%mm3, %%mm1, %%mm0 )
00150 "movq %%mm7, (%1) \n\t"
00151 "movq %%mm1, 16(%1) \n\t"
00152 "movq %%mm0, 32(%1) \n\t"
00153 "movq %%mm3, 48(%1) \n\t"
00154 : "=m"(tmp)
00155 : "r"(b2+32*i)
00156 : "memory"
00157 );
00158 }
00159
00160 for(i=0; i<2; i++){
00161 cavs_idct8_1d(b2+4*i, ff_pw_64.a);
00162
00163 __asm__ volatile(
00164 "psraw $7, %%mm7 \n\t"
00165 "psraw $7, %%mm6 \n\t"
00166 "psraw $7, %%mm5 \n\t"
00167 "psraw $7, %%mm4 \n\t"
00168 "psraw $7, %%mm3 \n\t"
00169 "psraw $7, %%mm2 \n\t"
00170 "psraw $7, %%mm1 \n\t"
00171 "psraw $7, %%mm0 \n\t"
00172 "movq %%mm7, (%0) \n\t"
00173 "movq %%mm5, 16(%0) \n\t"
00174 "movq %%mm3, 32(%0) \n\t"
00175 "movq %%mm1, 48(%0) \n\t"
00176 "movq %%mm0, 64(%0) \n\t"
00177 "movq %%mm2, 80(%0) \n\t"
00178 "movq %%mm4, 96(%0) \n\t"
00179 "movq %%mm6, 112(%0) \n\t"
00180 :: "r"(b2+4*i)
00181 : "memory"
00182 );
00183 }
00184
00185 ff_add_pixels_clamped_mmx(b2, dst, stride);
00186 }
00187
00188
00189
00190
00191
00192
00193
00194
00195 #define QPEL_CAVSV1(A,B,C,D,E,F,OP,MUL2) \
00196 "movd (%0), "#F" \n\t"\
00197 "movq "#C", %%mm6 \n\t"\
00198 "pmullw %5, %%mm6 \n\t"\
00199 "movq "#D", %%mm7 \n\t"\
00200 "pmullw "MANGLE(MUL2)", %%mm7\n\t"\
00201 "psllw $3, "#E" \n\t"\
00202 "psubw "#E", %%mm6 \n\t"\
00203 "psraw $3, "#E" \n\t"\
00204 "paddw %%mm7, %%mm6 \n\t"\
00205 "paddw "#E", %%mm6 \n\t"\
00206 "paddw "#B", "#B" \n\t"\
00207 "pxor %%mm7, %%mm7 \n\t"\
00208 "add %2, %0 \n\t"\
00209 "punpcklbw %%mm7, "#F" \n\t"\
00210 "psubw "#B", %%mm6 \n\t"\
00211 "psraw $1, "#B" \n\t"\
00212 "psubw "#A", %%mm6 \n\t"\
00213 "paddw %4, %%mm6 \n\t"\
00214 "psraw $7, %%mm6 \n\t"\
00215 "packuswb %%mm6, %%mm6 \n\t"\
00216 OP(%%mm6, (%1), A, d) \
00217 "add %3, %1 \n\t"
00218
00219
00220 #define QPEL_CAVSV2(A,B,C,D,E,F,OP,MUL2) \
00221 "movd (%0), "#F" \n\t"\
00222 "movq "#C", %%mm6 \n\t"\
00223 "paddw "#D", %%mm6 \n\t"\
00224 "pmullw %5, %%mm6 \n\t"\
00225 "add %2, %0 \n\t"\
00226 "punpcklbw %%mm7, "#F" \n\t"\
00227 "psubw "#B", %%mm6 \n\t"\
00228 "psubw "#E", %%mm6 \n\t"\
00229 "paddw %4, %%mm6 \n\t"\
00230 "psraw $3, %%mm6 \n\t"\
00231 "packuswb %%mm6, %%mm6 \n\t"\
00232 OP(%%mm6, (%1), A, d) \
00233 "add %3, %1 \n\t"
00234
00235
00236 #define QPEL_CAVSV3(A,B,C,D,E,F,OP,MUL2) \
00237 "movd (%0), "#F" \n\t"\
00238 "movq "#C", %%mm6 \n\t"\
00239 "pmullw "MANGLE(MUL2)", %%mm6\n\t"\
00240 "movq "#D", %%mm7 \n\t"\
00241 "pmullw %5, %%mm7 \n\t"\
00242 "psllw $3, "#B" \n\t"\
00243 "psubw "#B", %%mm6 \n\t"\
00244 "psraw $3, "#B" \n\t"\
00245 "paddw %%mm7, %%mm6 \n\t"\
00246 "paddw "#B", %%mm6 \n\t"\
00247 "paddw "#E", "#E" \n\t"\
00248 "pxor %%mm7, %%mm7 \n\t"\
00249 "add %2, %0 \n\t"\
00250 "punpcklbw %%mm7, "#F" \n\t"\
00251 "psubw "#E", %%mm6 \n\t"\
00252 "psraw $1, "#E" \n\t"\
00253 "psubw "#F", %%mm6 \n\t"\
00254 "paddw %4, %%mm6 \n\t"\
00255 "psraw $7, %%mm6 \n\t"\
00256 "packuswb %%mm6, %%mm6 \n\t"\
00257 OP(%%mm6, (%1), A, d) \
00258 "add %3, %1 \n\t"
00259
00260
00261 #define QPEL_CAVSVNUM(VOP,OP,ADD,MUL1,MUL2)\
00262 int w= 2;\
00263 src -= 2*srcStride;\
00264 \
00265 while(w--){\
00266 __asm__ volatile(\
00267 "pxor %%mm7, %%mm7 \n\t"\
00268 "movd (%0), %%mm0 \n\t"\
00269 "add %2, %0 \n\t"\
00270 "movd (%0), %%mm1 \n\t"\
00271 "add %2, %0 \n\t"\
00272 "movd (%0), %%mm2 \n\t"\
00273 "add %2, %0 \n\t"\
00274 "movd (%0), %%mm3 \n\t"\
00275 "add %2, %0 \n\t"\
00276 "movd (%0), %%mm4 \n\t"\
00277 "add %2, %0 \n\t"\
00278 "punpcklbw %%mm7, %%mm0 \n\t"\
00279 "punpcklbw %%mm7, %%mm1 \n\t"\
00280 "punpcklbw %%mm7, %%mm2 \n\t"\
00281 "punpcklbw %%mm7, %%mm3 \n\t"\
00282 "punpcklbw %%mm7, %%mm4 \n\t"\
00283 VOP(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP, MUL2)\
00284 VOP(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP, MUL2)\
00285 VOP(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP, MUL2)\
00286 VOP(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP, MUL2)\
00287 VOP(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, OP, MUL2)\
00288 VOP(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, OP, MUL2)\
00289 VOP(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP, MUL2)\
00290 VOP(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP, MUL2)\
00291 \
00292 : "+a"(src), "+c"(dst)\
00293 : "S"((x86_reg)srcStride), "r"((x86_reg)dstStride), "m"(ADD), "m"(MUL1)\
00294 : "memory"\
00295 );\
00296 if(h==16){\
00297 __asm__ volatile(\
00298 VOP(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP, MUL2)\
00299 VOP(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP, MUL2)\
00300 VOP(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, OP, MUL2)\
00301 VOP(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, OP, MUL2)\
00302 VOP(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP, MUL2)\
00303 VOP(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP, MUL2)\
00304 VOP(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP, MUL2)\
00305 VOP(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP, MUL2)\
00306 \
00307 : "+a"(src), "+c"(dst)\
00308 : "S"((x86_reg)srcStride), "r"((x86_reg)dstStride), "m"(ADD), "m"(MUL1)\
00309 : "memory"\
00310 );\
00311 }\
00312 src += 4-(h+5)*srcStride;\
00313 dst += 4-h*dstStride;\
00314 }
00315
00316 #define QPEL_CAVS(OPNAME, OP, MMX)\
00317 static void OPNAME ## cavs_qpel8_h_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
00318 int h=8;\
00319 __asm__ volatile(\
00320 "pxor %%mm7, %%mm7 \n\t"\
00321 "movq %5, %%mm6 \n\t"\
00322 "1: \n\t"\
00323 "movq (%0), %%mm0 \n\t"\
00324 "movq 1(%0), %%mm2 \n\t"\
00325 "movq %%mm0, %%mm1 \n\t"\
00326 "movq %%mm2, %%mm3 \n\t"\
00327 "punpcklbw %%mm7, %%mm0 \n\t"\
00328 "punpckhbw %%mm7, %%mm1 \n\t"\
00329 "punpcklbw %%mm7, %%mm2 \n\t"\
00330 "punpckhbw %%mm7, %%mm3 \n\t"\
00331 "paddw %%mm2, %%mm0 \n\t"\
00332 "paddw %%mm3, %%mm1 \n\t"\
00333 "pmullw %%mm6, %%mm0 \n\t"\
00334 "pmullw %%mm6, %%mm1 \n\t"\
00335 "movq -1(%0), %%mm2 \n\t"\
00336 "movq 2(%0), %%mm4 \n\t"\
00337 "movq %%mm2, %%mm3 \n\t"\
00338 "movq %%mm4, %%mm5 \n\t"\
00339 "punpcklbw %%mm7, %%mm2 \n\t"\
00340 "punpckhbw %%mm7, %%mm3 \n\t"\
00341 "punpcklbw %%mm7, %%mm4 \n\t"\
00342 "punpckhbw %%mm7, %%mm5 \n\t"\
00343 "paddw %%mm4, %%mm2 \n\t"\
00344 "paddw %%mm3, %%mm5 \n\t"\
00345 "psubw %%mm2, %%mm0 \n\t"\
00346 "psubw %%mm5, %%mm1 \n\t"\
00347 "movq %6, %%mm5 \n\t"\
00348 "paddw %%mm5, %%mm0 \n\t"\
00349 "paddw %%mm5, %%mm1 \n\t"\
00350 "psraw $3, %%mm0 \n\t"\
00351 "psraw $3, %%mm1 \n\t"\
00352 "packuswb %%mm1, %%mm0 \n\t"\
00353 OP(%%mm0, (%1),%%mm5, q) \
00354 "add %3, %0 \n\t"\
00355 "add %4, %1 \n\t"\
00356 "decl %2 \n\t"\
00357 " jnz 1b \n\t"\
00358 : "+a"(src), "+c"(dst), "+m"(h)\
00359 : "d"((x86_reg)srcStride), "S"((x86_reg)dstStride), "m"(ff_pw_5), "m"(ff_pw_4)\
00360 : "memory"\
00361 );\
00362 }\
00363 \
00364 static inline void OPNAME ## cavs_qpel8or16_v1_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
00365 QPEL_CAVSVNUM(QPEL_CAVSV1,OP,ff_pw_64,ff_pw_96,ff_pw_42) \
00366 }\
00367 \
00368 static inline void OPNAME ## cavs_qpel8or16_v2_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
00369 QPEL_CAVSVNUM(QPEL_CAVSV2,OP,ff_pw_4,ff_pw_5,ff_pw_5) \
00370 }\
00371 \
00372 static inline void OPNAME ## cavs_qpel8or16_v3_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
00373 QPEL_CAVSVNUM(QPEL_CAVSV3,OP,ff_pw_64,ff_pw_96,ff_pw_42) \
00374 }\
00375 \
00376 static void OPNAME ## cavs_qpel8_v1_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
00377 OPNAME ## cavs_qpel8or16_v1_ ## MMX(dst , src , dstStride, srcStride, 8);\
00378 }\
00379 static void OPNAME ## cavs_qpel16_v1_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
00380 OPNAME ## cavs_qpel8or16_v1_ ## MMX(dst , src , dstStride, srcStride, 16);\
00381 OPNAME ## cavs_qpel8or16_v1_ ## MMX(dst+8, src+8, dstStride, srcStride, 16);\
00382 }\
00383 \
00384 static void OPNAME ## cavs_qpel8_v2_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
00385 OPNAME ## cavs_qpel8or16_v2_ ## MMX(dst , src , dstStride, srcStride, 8);\
00386 }\
00387 static void OPNAME ## cavs_qpel16_v2_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
00388 OPNAME ## cavs_qpel8or16_v2_ ## MMX(dst , src , dstStride, srcStride, 16);\
00389 OPNAME ## cavs_qpel8or16_v2_ ## MMX(dst+8, src+8, dstStride, srcStride, 16);\
00390 }\
00391 \
00392 static void OPNAME ## cavs_qpel8_v3_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
00393 OPNAME ## cavs_qpel8or16_v3_ ## MMX(dst , src , dstStride, srcStride, 8);\
00394 }\
00395 static void OPNAME ## cavs_qpel16_v3_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
00396 OPNAME ## cavs_qpel8or16_v3_ ## MMX(dst , src , dstStride, srcStride, 16);\
00397 OPNAME ## cavs_qpel8or16_v3_ ## MMX(dst+8, src+8, dstStride, srcStride, 16);\
00398 }\
00399 \
00400 static void OPNAME ## cavs_qpel16_h_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
00401 OPNAME ## cavs_qpel8_h_ ## MMX(dst , src , dstStride, srcStride);\
00402 OPNAME ## cavs_qpel8_h_ ## MMX(dst+8, src+8, dstStride, srcStride);\
00403 src += 8*srcStride;\
00404 dst += 8*dstStride;\
00405 OPNAME ## cavs_qpel8_h_ ## MMX(dst , src , dstStride, srcStride);\
00406 OPNAME ## cavs_qpel8_h_ ## MMX(dst+8, src+8, dstStride, srcStride);\
00407 }\
00408
00409 #define CAVS_MC(OPNAME, SIZE, MMX) \
00410 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc20_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
00411 OPNAME ## cavs_qpel ## SIZE ## _h_ ## MMX(dst, src, stride, stride);\
00412 }\
00413 \
00414 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc01_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
00415 OPNAME ## cavs_qpel ## SIZE ## _v1_ ## MMX(dst, src, stride, stride);\
00416 }\
00417 \
00418 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc02_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
00419 OPNAME ## cavs_qpel ## SIZE ## _v2_ ## MMX(dst, src, stride, stride);\
00420 }\
00421 \
00422 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc03_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
00423 OPNAME ## cavs_qpel ## SIZE ## _v3_ ## MMX(dst, src, stride, stride);\
00424 }\
00425
00426 #define PUT_OP(a,b,temp, size) "mov" #size " " #a ", " #b " \n\t"
00427 #define AVG_3DNOW_OP(a,b,temp, size) \
00428 "mov" #size " " #b ", " #temp " \n\t"\
00429 "pavgusb " #temp ", " #a " \n\t"\
00430 "mov" #size " " #a ", " #b " \n\t"
00431 #define AVG_MMX2_OP(a,b,temp, size) \
00432 "mov" #size " " #b ", " #temp " \n\t"\
00433 "pavgb " #temp ", " #a " \n\t"\
00434 "mov" #size " " #a ", " #b " \n\t"
00435
00436 QPEL_CAVS(put_, PUT_OP, 3dnow)
00437 QPEL_CAVS(avg_, AVG_3DNOW_OP, 3dnow)
00438 QPEL_CAVS(put_, PUT_OP, mmx2)
00439 QPEL_CAVS(avg_, AVG_MMX2_OP, mmx2)
00440
00441 CAVS_MC(put_, 8, 3dnow)
00442 CAVS_MC(put_, 16,3dnow)
00443 CAVS_MC(avg_, 8, 3dnow)
00444 CAVS_MC(avg_, 16,3dnow)
00445 CAVS_MC(put_, 8, mmx2)
00446 CAVS_MC(put_, 16,mmx2)
00447 CAVS_MC(avg_, 8, mmx2)
00448 CAVS_MC(avg_, 16,mmx2)
00449
00450 static void ff_cavsdsp_init_mmx2(CAVSDSPContext* c, AVCodecContext *avctx) {
00451 #define dspfunc(PFX, IDX, NUM) \
00452 c->PFX ## _pixels_tab[IDX][ 0] = ff_ ## PFX ## NUM ## _mc00_mmx2; \
00453 c->PFX ## _pixels_tab[IDX][ 2] = ff_ ## PFX ## NUM ## _mc20_mmx2; \
00454 c->PFX ## _pixels_tab[IDX][ 4] = ff_ ## PFX ## NUM ## _mc01_mmx2; \
00455 c->PFX ## _pixels_tab[IDX][ 8] = ff_ ## PFX ## NUM ## _mc02_mmx2; \
00456 c->PFX ## _pixels_tab[IDX][12] = ff_ ## PFX ## NUM ## _mc03_mmx2; \
00457
00458 dspfunc(put_cavs_qpel, 0, 16);
00459 dspfunc(put_cavs_qpel, 1, 8);
00460 dspfunc(avg_cavs_qpel, 0, 16);
00461 dspfunc(avg_cavs_qpel, 1, 8);
00462 #undef dspfunc
00463 c->cavs_idct8_add = cavs_idct8_add_mmx;
00464 c->idct_perm = FF_TRANSPOSE_IDCT_PERM;
00465 }
00466
00467 static void ff_cavsdsp_init_3dnow(CAVSDSPContext* c, AVCodecContext *avctx) {
00468 #define dspfunc(PFX, IDX, NUM) \
00469 c->PFX ## _pixels_tab[IDX][ 0] = ff_ ## PFX ## NUM ## _mc00_mmx2; \
00470 c->PFX ## _pixels_tab[IDX][ 2] = ff_ ## PFX ## NUM ## _mc20_3dnow; \
00471 c->PFX ## _pixels_tab[IDX][ 4] = ff_ ## PFX ## NUM ## _mc01_3dnow; \
00472 c->PFX ## _pixels_tab[IDX][ 8] = ff_ ## PFX ## NUM ## _mc02_3dnow; \
00473 c->PFX ## _pixels_tab[IDX][12] = ff_ ## PFX ## NUM ## _mc03_3dnow; \
00474
00475 dspfunc(put_cavs_qpel, 0, 16);
00476 dspfunc(put_cavs_qpel, 1, 8);
00477 dspfunc(avg_cavs_qpel, 0, 16);
00478 dspfunc(avg_cavs_qpel, 1, 8);
00479 #undef dspfunc
00480 c->cavs_idct8_add = cavs_idct8_add_mmx;
00481 c->idct_perm = FF_TRANSPOSE_IDCT_PERM;
00482 }
00483
00484 #endif
00485
00486 void ff_cavsdsp_init_mmx(CAVSDSPContext *c, AVCodecContext *avctx)
00487 {
00488 int mm_flags = av_get_cpu_flags();
00489
00490 #if HAVE_INLINE_ASM
00491 if (mm_flags & AV_CPU_FLAG_MMXEXT) ff_cavsdsp_init_mmx2(c, avctx);
00492 if (mm_flags & AV_CPU_FLAG_3DNOW) ff_cavsdsp_init_3dnow(c, avctx);
00493 #endif
00494 }