00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <inttypes.h>
00022 #include "config.h"
00023 #include "libswscale/swscale.h"
00024 #include "libswscale/swscale_internal.h"
00025 #include "libavutil/avassert.h"
00026 #include "libavutil/intreadwrite.h"
00027 #include "libavutil/x86_cpu.h"
00028 #include "libavutil/cpu.h"
00029 #include "libavutil/pixdesc.h"
00030
00031 #if HAVE_INLINE_ASM
00032
00033 #define DITHER1XBPP
00034
00035 DECLARE_ASM_CONST(8, uint64_t, bF8)= 0xF8F8F8F8F8F8F8F8LL;
00036 DECLARE_ASM_CONST(8, uint64_t, bFC)= 0xFCFCFCFCFCFCFCFCLL;
00037 DECLARE_ASM_CONST(8, uint64_t, w10)= 0x0010001000100010LL;
00038 DECLARE_ASM_CONST(8, uint64_t, w02)= 0x0002000200020002LL;
00039
00040 const DECLARE_ALIGNED(8, uint64_t, ff_dither4)[2] = {
00041 0x0103010301030103LL,
00042 0x0200020002000200LL,};
00043
00044 const DECLARE_ALIGNED(8, uint64_t, ff_dither8)[2] = {
00045 0x0602060206020602LL,
00046 0x0004000400040004LL,};
00047
00048 DECLARE_ASM_CONST(8, uint64_t, b16Mask)= 0x001F001F001F001FLL;
00049 DECLARE_ASM_CONST(8, uint64_t, g16Mask)= 0x07E007E007E007E0LL;
00050 DECLARE_ASM_CONST(8, uint64_t, r16Mask)= 0xF800F800F800F800LL;
00051 DECLARE_ASM_CONST(8, uint64_t, b15Mask)= 0x001F001F001F001FLL;
00052 DECLARE_ASM_CONST(8, uint64_t, g15Mask)= 0x03E003E003E003E0LL;
00053 DECLARE_ASM_CONST(8, uint64_t, r15Mask)= 0x7C007C007C007C00LL;
00054
00055 DECLARE_ALIGNED(8, const uint64_t, ff_M24A) = 0x00FF0000FF0000FFLL;
00056 DECLARE_ALIGNED(8, const uint64_t, ff_M24B) = 0xFF0000FF0000FF00LL;
00057 DECLARE_ALIGNED(8, const uint64_t, ff_M24C) = 0x0000FF0000FF0000LL;
00058
00059 #ifdef FAST_BGR2YV12
00060 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2YCoeff) = 0x000000210041000DULL;
00061 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2UCoeff) = 0x0000FFEEFFDC0038ULL;
00062 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2VCoeff) = 0x00000038FFD2FFF8ULL;
00063 #else
00064 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2YCoeff) = 0x000020E540830C8BULL;
00065 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2UCoeff) = 0x0000ED0FDAC23831ULL;
00066 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2VCoeff) = 0x00003831D0E6F6EAULL;
00067 #endif
00068 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2YOffset) = 0x1010101010101010ULL;
00069 DECLARE_ALIGNED(8, const uint64_t, ff_bgr2UVOffset) = 0x8080808080808080ULL;
00070 DECLARE_ALIGNED(8, const uint64_t, ff_w1111) = 0x0001000100010001ULL;
00071
00072
00073
00074 #if HAVE_MMX
00075 #undef RENAME
00076 #define COMPILE_TEMPLATE_MMX2 0
00077 #define RENAME(a) a ## _MMX
00078 #include "swscale_template.c"
00079 #endif
00080
00081
00082 #if HAVE_MMX2
00083 #undef RENAME
00084 #undef COMPILE_TEMPLATE_MMX2
00085 #define COMPILE_TEMPLATE_MMX2 1
00086 #define RENAME(a) a ## _MMX2
00087 #include "swscale_template.c"
00088 #endif
00089
00090 void updateMMXDitherTables(SwsContext *c, int dstY, int lumBufIndex, int chrBufIndex,
00091 int lastInLumBuf, int lastInChrBuf)
00092 {
00093 const int dstH= c->dstH;
00094 const int flags= c->flags;
00095 int16_t **lumPixBuf= c->lumPixBuf;
00096 int16_t **chrUPixBuf= c->chrUPixBuf;
00097 int16_t **alpPixBuf= c->alpPixBuf;
00098 const int vLumBufSize= c->vLumBufSize;
00099 const int vChrBufSize= c->vChrBufSize;
00100 int32_t *vLumFilterPos= c->vLumFilterPos;
00101 int32_t *vChrFilterPos= c->vChrFilterPos;
00102 int16_t *vLumFilter= c->vLumFilter;
00103 int16_t *vChrFilter= c->vChrFilter;
00104 int32_t *lumMmxFilter= c->lumMmxFilter;
00105 int32_t *chrMmxFilter= c->chrMmxFilter;
00106 int32_t av_unused *alpMmxFilter= c->alpMmxFilter;
00107 const int vLumFilterSize= c->vLumFilterSize;
00108 const int vChrFilterSize= c->vChrFilterSize;
00109 const int chrDstY= dstY>>c->chrDstVSubSample;
00110 const int firstLumSrcY= vLumFilterPos[dstY];
00111 const int firstChrSrcY= vChrFilterPos[chrDstY];
00112
00113 c->blueDither= ff_dither8[dstY&1];
00114 if (c->dstFormat == PIX_FMT_RGB555 || c->dstFormat == PIX_FMT_BGR555)
00115 c->greenDither= ff_dither8[dstY&1];
00116 else
00117 c->greenDither= ff_dither4[dstY&1];
00118 c->redDither= ff_dither8[(dstY+1)&1];
00119 if (dstY < dstH - 2) {
00120 const int16_t **lumSrcPtr= (const int16_t **)(void*) lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
00121 const int16_t **chrUSrcPtr= (const int16_t **)(void*) chrUPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
00122 const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **)(void*) alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL;
00123 int i;
00124
00125 if (firstLumSrcY < 0 || firstLumSrcY + vLumFilterSize > c->srcH) {
00126 const int16_t **tmpY = (const int16_t **) lumPixBuf + 2 * vLumBufSize;
00127 int neg = -firstLumSrcY, i, end = FFMIN(c->srcH - firstLumSrcY, vLumFilterSize);
00128 for (i = 0; i < neg; i++)
00129 tmpY[i] = lumSrcPtr[neg];
00130 for ( ; i < end; i++)
00131 tmpY[i] = lumSrcPtr[i];
00132 for ( ; i < vLumFilterSize; i++)
00133 tmpY[i] = tmpY[i-1];
00134 lumSrcPtr = tmpY;
00135
00136 if (alpSrcPtr) {
00137 const int16_t **tmpA = (const int16_t **) alpPixBuf + 2 * vLumBufSize;
00138 for (i = 0; i < neg; i++)
00139 tmpA[i] = alpSrcPtr[neg];
00140 for ( ; i < end; i++)
00141 tmpA[i] = alpSrcPtr[i];
00142 for ( ; i < vLumFilterSize; i++)
00143 tmpA[i] = tmpA[i - 1];
00144 alpSrcPtr = tmpA;
00145 }
00146 }
00147 if (firstChrSrcY < 0 || firstChrSrcY + vChrFilterSize > c->chrSrcH) {
00148 const int16_t **tmpU = (const int16_t **) chrUPixBuf + 2 * vChrBufSize;
00149 int neg = -firstChrSrcY, i, end = FFMIN(c->chrSrcH - firstChrSrcY, vChrFilterSize);
00150 for (i = 0; i < neg; i++) {
00151 tmpU[i] = chrUSrcPtr[neg];
00152 }
00153 for ( ; i < end; i++) {
00154 tmpU[i] = chrUSrcPtr[i];
00155 }
00156 for ( ; i < vChrFilterSize; i++) {
00157 tmpU[i] = tmpU[i - 1];
00158 }
00159 chrUSrcPtr = tmpU;
00160 }
00161
00162 if (flags & SWS_ACCURATE_RND) {
00163 int s= APCK_SIZE / 8;
00164 for (i=0; i<vLumFilterSize; i+=2) {
00165 *(const void**)&lumMmxFilter[s*i ]= lumSrcPtr[i ];
00166 *(const void**)&lumMmxFilter[s*i+APCK_PTR2/4 ]= lumSrcPtr[i+(vLumFilterSize>1)];
00167 lumMmxFilter[s*i+APCK_COEF/4 ]=
00168 lumMmxFilter[s*i+APCK_COEF/4+1]= vLumFilter[dstY*vLumFilterSize + i ]
00169 + (vLumFilterSize>1 ? vLumFilter[dstY*vLumFilterSize + i + 1]<<16 : 0);
00170 if (CONFIG_SWSCALE_ALPHA && alpPixBuf) {
00171 *(const void**)&alpMmxFilter[s*i ]= alpSrcPtr[i ];
00172 *(const void**)&alpMmxFilter[s*i+APCK_PTR2/4 ]= alpSrcPtr[i+(vLumFilterSize>1)];
00173 alpMmxFilter[s*i+APCK_COEF/4 ]=
00174 alpMmxFilter[s*i+APCK_COEF/4+1]= lumMmxFilter[s*i+APCK_COEF/4 ];
00175 }
00176 }
00177 for (i=0; i<vChrFilterSize; i+=2) {
00178 *(const void**)&chrMmxFilter[s*i ]= chrUSrcPtr[i ];
00179 *(const void**)&chrMmxFilter[s*i+APCK_PTR2/4 ]= chrUSrcPtr[i+(vChrFilterSize>1)];
00180 chrMmxFilter[s*i+APCK_COEF/4 ]=
00181 chrMmxFilter[s*i+APCK_COEF/4+1]= vChrFilter[chrDstY*vChrFilterSize + i ]
00182 + (vChrFilterSize>1 ? vChrFilter[chrDstY*vChrFilterSize + i + 1]<<16 : 0);
00183 }
00184 } else {
00185 for (i=0; i<vLumFilterSize; i++) {
00186 *(const void**)&lumMmxFilter[4*i+0]= lumSrcPtr[i];
00187 lumMmxFilter[4*i+2]=
00188 lumMmxFilter[4*i+3]=
00189 ((uint16_t)vLumFilter[dstY*vLumFilterSize + i])*0x10001;
00190 if (CONFIG_SWSCALE_ALPHA && alpPixBuf) {
00191 *(const void**)&alpMmxFilter[4*i+0]= alpSrcPtr[i];
00192 alpMmxFilter[4*i+2]=
00193 alpMmxFilter[4*i+3]= lumMmxFilter[4*i+2];
00194 }
00195 }
00196 for (i=0; i<vChrFilterSize; i++) {
00197 *(const void**)&chrMmxFilter[4*i+0]= chrUSrcPtr[i];
00198 chrMmxFilter[4*i+2]=
00199 chrMmxFilter[4*i+3]=
00200 ((uint16_t)vChrFilter[chrDstY*vChrFilterSize + i])*0x10001;
00201 }
00202 }
00203 }
00204 }
00205
00206 #if HAVE_MMX2
00207 static void yuv2yuvX_sse3(const int16_t *filter, int filterSize,
00208 const int16_t **src, uint8_t *dest, int dstW,
00209 const uint8_t *dither, int offset)
00210 {
00211 if(((int)dest) & 15){
00212 return yuv2yuvX_MMX2(filter, filterSize, src, dest, dstW, dither, offset);
00213 }
00214 if (offset) {
00215 __asm__ volatile("movq (%0), %%xmm3\n\t"
00216 "movdqa %%xmm3, %%xmm4\n\t"
00217 "psrlq $24, %%xmm3\n\t"
00218 "psllq $40, %%xmm4\n\t"
00219 "por %%xmm4, %%xmm3\n\t"
00220 :: "r"(dither)
00221 );
00222 } else {
00223 __asm__ volatile("movq (%0), %%xmm3\n\t"
00224 :: "r"(dither)
00225 );
00226 }
00227 __asm__ volatile(
00228 "pxor %%xmm0, %%xmm0\n\t"
00229 "punpcklbw %%xmm0, %%xmm3\n\t"
00230 "psraw $4, %%xmm3\n\t"
00231 "movdqa %%xmm3, %%xmm4\n\t"
00232 "movdqa %%xmm3, %%xmm7\n\t"
00233 "movl %3, %%ecx\n\t"
00234 "mov %0, %%"REG_d" \n\t"\
00235 "mov (%%"REG_d"), %%"REG_S" \n\t"\
00236 ".p2align 4 \n\t" \
00237 "1: \n\t"\
00238 "movddup 8(%%"REG_d"), %%xmm0 \n\t" \
00239 "movdqa (%%"REG_S", %%"REG_c", 2), %%xmm2 \n\t" \
00240 "movdqa 16(%%"REG_S", %%"REG_c", 2), %%xmm5 \n\t" \
00241 "add $16, %%"REG_d" \n\t"\
00242 "mov (%%"REG_d"), %%"REG_S" \n\t"\
00243 "test %%"REG_S", %%"REG_S" \n\t"\
00244 "pmulhw %%xmm0, %%xmm2 \n\t"\
00245 "pmulhw %%xmm0, %%xmm5 \n\t"\
00246 "paddw %%xmm2, %%xmm3 \n\t"\
00247 "paddw %%xmm5, %%xmm4 \n\t"\
00248 " jnz 1b \n\t"\
00249 "psraw $3, %%xmm3 \n\t"\
00250 "psraw $3, %%xmm4 \n\t"\
00251 "packuswb %%xmm4, %%xmm3 \n\t"
00252 "movntdq %%xmm3, (%1, %%"REG_c")\n\t"
00253 "add $16, %%"REG_c" \n\t"\
00254 "cmp %2, %%"REG_c" \n\t"\
00255 "movdqa %%xmm7, %%xmm3\n\t"
00256 "movdqa %%xmm7, %%xmm4\n\t"
00257 "mov %0, %%"REG_d" \n\t"\
00258 "mov (%%"REG_d"), %%"REG_S" \n\t"\
00259 "jb 1b \n\t"\
00260 :: "g" (filter),
00261 "r" (dest-offset), "g" ((x86_reg)(dstW+offset)), "m" (offset)
00262 : "%"REG_d, "%"REG_S, "%"REG_c
00263 );
00264 }
00265 #endif
00266
00267 #endif
00268
00269 #define SCALE_FUNC(filter_n, from_bpc, to_bpc, opt) \
00270 extern void ff_hscale ## from_bpc ## to ## to_bpc ## _ ## filter_n ## _ ## opt( \
00271 SwsContext *c, int16_t *data, \
00272 int dstW, const uint8_t *src, \
00273 const int16_t *filter, \
00274 const int32_t *filterPos, int filterSize)
00275
00276 #define SCALE_FUNCS(filter_n, opt) \
00277 SCALE_FUNC(filter_n, 8, 15, opt); \
00278 SCALE_FUNC(filter_n, 9, 15, opt); \
00279 SCALE_FUNC(filter_n, 10, 15, opt); \
00280 SCALE_FUNC(filter_n, 12, 15, opt); \
00281 SCALE_FUNC(filter_n, 14, 15, opt); \
00282 SCALE_FUNC(filter_n, 16, 15, opt); \
00283 SCALE_FUNC(filter_n, 8, 19, opt); \
00284 SCALE_FUNC(filter_n, 9, 19, opt); \
00285 SCALE_FUNC(filter_n, 10, 19, opt); \
00286 SCALE_FUNC(filter_n, 12, 19, opt); \
00287 SCALE_FUNC(filter_n, 14, 19, opt); \
00288 SCALE_FUNC(filter_n, 16, 19, opt)
00289
00290 #define SCALE_FUNCS_MMX(opt) \
00291 SCALE_FUNCS(4, opt); \
00292 SCALE_FUNCS(8, opt); \
00293 SCALE_FUNCS(X, opt)
00294
00295 #define SCALE_FUNCS_SSE(opt) \
00296 SCALE_FUNCS(4, opt); \
00297 SCALE_FUNCS(8, opt); \
00298 SCALE_FUNCS(X4, opt); \
00299 SCALE_FUNCS(X8, opt)
00300
00301 #if ARCH_X86_32
00302 SCALE_FUNCS_MMX(mmx);
00303 #endif
00304 SCALE_FUNCS_SSE(sse2);
00305 SCALE_FUNCS_SSE(ssse3);
00306 SCALE_FUNCS_SSE(sse4);
00307
00308 #define VSCALEX_FUNC(size, opt) \
00309 extern void ff_yuv2planeX_ ## size ## _ ## opt(const int16_t *filter, int filterSize, \
00310 const int16_t **src, uint8_t *dest, int dstW, \
00311 const uint8_t *dither, int offset)
00312 #define VSCALEX_FUNCS(opt) \
00313 VSCALEX_FUNC(8, opt); \
00314 VSCALEX_FUNC(9, opt); \
00315 VSCALEX_FUNC(10, opt)
00316
00317 #if ARCH_X86_32
00318 VSCALEX_FUNCS(mmx2);
00319 #endif
00320 VSCALEX_FUNCS(sse2);
00321 VSCALEX_FUNCS(sse4);
00322 VSCALEX_FUNC(16, sse4);
00323 VSCALEX_FUNCS(avx);
00324
00325 #define VSCALE_FUNC(size, opt) \
00326 extern void ff_yuv2plane1_ ## size ## _ ## opt(const int16_t *src, uint8_t *dst, int dstW, \
00327 const uint8_t *dither, int offset)
00328 #define VSCALE_FUNCS(opt1, opt2) \
00329 VSCALE_FUNC(8, opt1); \
00330 VSCALE_FUNC(9, opt2); \
00331 VSCALE_FUNC(10, opt2); \
00332 VSCALE_FUNC(16, opt1)
00333
00334 #if ARCH_X86_32
00335 VSCALE_FUNCS(mmx, mmx2);
00336 #endif
00337 VSCALE_FUNCS(sse2, sse2);
00338 VSCALE_FUNC(16, sse4);
00339 VSCALE_FUNCS(avx, avx);
00340
00341 #define INPUT_Y_FUNC(fmt, opt) \
00342 extern void ff_ ## fmt ## ToY_ ## opt(uint8_t *dst, const uint8_t *src, \
00343 int w, uint32_t *unused)
00344 #define INPUT_UV_FUNC(fmt, opt) \
00345 extern void ff_ ## fmt ## ToUV_ ## opt(uint8_t *dstU, uint8_t *dstV, \
00346 const uint8_t *src, const uint8_t *unused1, \
00347 int w, uint32_t *unused2)
00348 #define INPUT_FUNC(fmt, opt) \
00349 INPUT_Y_FUNC(fmt, opt); \
00350 INPUT_UV_FUNC(fmt, opt)
00351 #define INPUT_FUNCS(opt) \
00352 INPUT_FUNC(uyvy, opt); \
00353 INPUT_FUNC(yuyv, opt); \
00354 INPUT_UV_FUNC(nv12, opt); \
00355 INPUT_UV_FUNC(nv21, opt); \
00356 INPUT_FUNC(rgba, opt); \
00357 INPUT_FUNC(bgra, opt); \
00358 INPUT_FUNC(argb, opt); \
00359 INPUT_FUNC(abgr, opt); \
00360 INPUT_FUNC(rgb24, opt); \
00361 INPUT_FUNC(bgr24, opt)
00362
00363 #if ARCH_X86_32
00364 INPUT_FUNCS(mmx);
00365 #endif
00366 INPUT_FUNCS(sse2);
00367 INPUT_FUNCS(ssse3);
00368 INPUT_FUNCS(avx);
00369
00370 void ff_sws_init_swScale_mmx(SwsContext *c)
00371 {
00372 int cpu_flags = av_get_cpu_flags();
00373
00374 #if HAVE_INLINE_ASM
00375 if (cpu_flags & AV_CPU_FLAG_MMX)
00376 sws_init_swScale_MMX(c);
00377 #if HAVE_MMX2
00378 if (cpu_flags & AV_CPU_FLAG_MMX2)
00379 sws_init_swScale_MMX2(c);
00380 if (cpu_flags & AV_CPU_FLAG_SSE3){
00381 if(c->use_mmx_vfilter && !(c->flags & SWS_ACCURATE_RND))
00382 c->yuv2planeX = yuv2yuvX_sse3;
00383 }
00384 #endif
00385 #endif
00386
00387 #if HAVE_YASM
00388 #define ASSIGN_SCALE_FUNC2(hscalefn, filtersize, opt1, opt2) do { \
00389 if (c->srcBpc == 8) { \
00390 hscalefn = c->dstBpc <= 14 ? ff_hscale8to15_ ## filtersize ## _ ## opt2 : \
00391 ff_hscale8to19_ ## filtersize ## _ ## opt1; \
00392 } else if (c->srcBpc == 9) { \
00393 hscalefn = c->dstBpc <= 14 ? ff_hscale9to15_ ## filtersize ## _ ## opt2 : \
00394 ff_hscale9to19_ ## filtersize ## _ ## opt1; \
00395 } else if (c->srcBpc == 10) { \
00396 hscalefn = c->dstBpc <= 14 ? ff_hscale10to15_ ## filtersize ## _ ## opt2 : \
00397 ff_hscale10to19_ ## filtersize ## _ ## opt1; \
00398 } else if (c->srcBpc == 12) { \
00399 hscalefn = c->dstBpc <= 14 ? ff_hscale12to15_ ## filtersize ## _ ## opt2 : \
00400 ff_hscale12to19_ ## filtersize ## _ ## opt1; \
00401 } else if (c->srcBpc == 14 || ((c->srcFormat==PIX_FMT_PAL8||isAnyRGB(c->srcFormat)) && av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1<15)) { \
00402 hscalefn = c->dstBpc <= 14 ? ff_hscale14to15_ ## filtersize ## _ ## opt2 : \
00403 ff_hscale14to19_ ## filtersize ## _ ## opt1; \
00404 } else { \
00405 av_assert0(c->srcBpc == 16);\
00406 hscalefn = c->dstBpc <= 14 ? ff_hscale16to15_ ## filtersize ## _ ## opt2 : \
00407 ff_hscale16to19_ ## filtersize ## _ ## opt1; \
00408 } \
00409 } while (0)
00410 #define ASSIGN_MMX_SCALE_FUNC(hscalefn, filtersize, opt1, opt2) \
00411 switch (filtersize) { \
00412 case 4: ASSIGN_SCALE_FUNC2(hscalefn, 4, opt1, opt2); break; \
00413 case 8: ASSIGN_SCALE_FUNC2(hscalefn, 8, opt1, opt2); break; \
00414 default: ASSIGN_SCALE_FUNC2(hscalefn, X, opt1, opt2); break; \
00415 }
00416 #define ASSIGN_VSCALEX_FUNC(vscalefn, opt, do_16_case, condition_8bit) \
00417 switch(c->dstBpc){ \
00418 case 16: do_16_case; break; \
00419 case 10: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2planeX_10_ ## opt; break; \
00420 case 9: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2planeX_9_ ## opt; break; \
00421 default: if (condition_8bit) break; \
00422 }
00423 #define ASSIGN_VSCALE_FUNC(vscalefn, opt1, opt2, opt2chk) \
00424 switch(c->dstBpc){ \
00425 case 16: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2plane1_16_ ## opt1; break; \
00426 case 10: if (!isBE(c->dstFormat) && opt2chk) vscalefn = ff_yuv2plane1_10_ ## opt2; break; \
00427 case 9: if (!isBE(c->dstFormat) && opt2chk) vscalefn = ff_yuv2plane1_9_ ## opt2; break; \
00428 case 8: vscalefn = ff_yuv2plane1_8_ ## opt1; break; \
00429 default: av_assert0(c->dstBpc>8); \
00430 }
00431 #define case_rgb(x, X, opt) \
00432 case PIX_FMT_ ## X: \
00433 c->lumToYV12 = ff_ ## x ## ToY_ ## opt; \
00434 if (!c->chrSrcHSubSample) \
00435 c->chrToYV12 = ff_ ## x ## ToUV_ ## opt; \
00436 break
00437 #if ARCH_X86_32
00438 if (cpu_flags & AV_CPU_FLAG_MMX) {
00439 ASSIGN_MMX_SCALE_FUNC(c->hyScale, c->hLumFilterSize, mmx, mmx);
00440 ASSIGN_MMX_SCALE_FUNC(c->hcScale, c->hChrFilterSize, mmx, mmx);
00441 ASSIGN_VSCALE_FUNC(c->yuv2plane1, mmx, mmx2, cpu_flags & AV_CPU_FLAG_MMX2);
00442
00443 switch (c->srcFormat) {
00444 case PIX_FMT_Y400A:
00445 c->lumToYV12 = ff_yuyvToY_mmx;
00446 if (c->alpPixBuf)
00447 c->alpToYV12 = ff_uyvyToY_mmx;
00448 break;
00449 case PIX_FMT_YUYV422:
00450 c->lumToYV12 = ff_yuyvToY_mmx;
00451 c->chrToYV12 = ff_yuyvToUV_mmx;
00452 break;
00453 case PIX_FMT_UYVY422:
00454 c->lumToYV12 = ff_uyvyToY_mmx;
00455 c->chrToYV12 = ff_uyvyToUV_mmx;
00456 break;
00457 case PIX_FMT_NV12:
00458 c->chrToYV12 = ff_nv12ToUV_mmx;
00459 break;
00460 case PIX_FMT_NV21:
00461 c->chrToYV12 = ff_nv21ToUV_mmx;
00462 break;
00463 case_rgb(rgb24, RGB24, mmx);
00464 case_rgb(bgr24, BGR24, mmx);
00465 case_rgb(bgra, BGRA, mmx);
00466 case_rgb(rgba, RGBA, mmx);
00467 case_rgb(abgr, ABGR, mmx);
00468 case_rgb(argb, ARGB, mmx);
00469 default:
00470 break;
00471 }
00472 }
00473 if (cpu_flags & AV_CPU_FLAG_MMX2) {
00474 ASSIGN_VSCALEX_FUNC(c->yuv2planeX, mmx2, , 1);
00475 }
00476 #endif
00477 #define ASSIGN_SSE_SCALE_FUNC(hscalefn, filtersize, opt1, opt2) \
00478 switch (filtersize) { \
00479 case 4: ASSIGN_SCALE_FUNC2(hscalefn, 4, opt1, opt2); break; \
00480 case 8: ASSIGN_SCALE_FUNC2(hscalefn, 8, opt1, opt2); break; \
00481 default: if (filtersize & 4) ASSIGN_SCALE_FUNC2(hscalefn, X4, opt1, opt2); \
00482 else ASSIGN_SCALE_FUNC2(hscalefn, X8, opt1, opt2); \
00483 break; \
00484 }
00485 if (cpu_flags & AV_CPU_FLAG_SSE2) {
00486 ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, sse2, sse2);
00487 ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, sse2, sse2);
00488 ASSIGN_VSCALEX_FUNC(c->yuv2planeX, sse2, ,
00489 HAVE_ALIGNED_STACK || ARCH_X86_64);
00490 ASSIGN_VSCALE_FUNC(c->yuv2plane1, sse2, sse2, 1);
00491
00492 switch (c->srcFormat) {
00493 case PIX_FMT_Y400A:
00494 c->lumToYV12 = ff_yuyvToY_sse2;
00495 if (c->alpPixBuf)
00496 c->alpToYV12 = ff_uyvyToY_sse2;
00497 break;
00498 case PIX_FMT_YUYV422:
00499 c->lumToYV12 = ff_yuyvToY_sse2;
00500 c->chrToYV12 = ff_yuyvToUV_sse2;
00501 break;
00502 case PIX_FMT_UYVY422:
00503 c->lumToYV12 = ff_uyvyToY_sse2;
00504 c->chrToYV12 = ff_uyvyToUV_sse2;
00505 break;
00506 case PIX_FMT_NV12:
00507 c->chrToYV12 = ff_nv12ToUV_sse2;
00508 break;
00509 case PIX_FMT_NV21:
00510 c->chrToYV12 = ff_nv21ToUV_sse2;
00511 break;
00512 case_rgb(rgb24, RGB24, sse2);
00513 case_rgb(bgr24, BGR24, sse2);
00514 case_rgb(bgra, BGRA, sse2);
00515 case_rgb(rgba, RGBA, sse2);
00516 case_rgb(abgr, ABGR, sse2);
00517 case_rgb(argb, ARGB, sse2);
00518 default:
00519 break;
00520 }
00521 }
00522 if (cpu_flags & AV_CPU_FLAG_SSSE3) {
00523 ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, ssse3, ssse3);
00524 ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, ssse3, ssse3);
00525 switch (c->srcFormat) {
00526 case_rgb(rgb24, RGB24, ssse3);
00527 case_rgb(bgr24, BGR24, ssse3);
00528 default:
00529 break;
00530 }
00531 }
00532 if (cpu_flags & AV_CPU_FLAG_SSE4) {
00533
00534 ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, sse4, ssse3);
00535 ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, sse4, ssse3);
00536 ASSIGN_VSCALEX_FUNC(c->yuv2planeX, sse4,
00537 if (!isBE(c->dstFormat)) c->yuv2planeX = ff_yuv2planeX_16_sse4,
00538 HAVE_ALIGNED_STACK || ARCH_X86_64);
00539 if (c->dstBpc == 16 && !isBE(c->dstFormat))
00540 c->yuv2plane1 = ff_yuv2plane1_16_sse4;
00541 }
00542
00543 if (HAVE_AVX && cpu_flags & AV_CPU_FLAG_AVX) {
00544 ASSIGN_VSCALEX_FUNC(c->yuv2planeX, avx, ,
00545 HAVE_ALIGNED_STACK || ARCH_X86_64);
00546 ASSIGN_VSCALE_FUNC(c->yuv2plane1, avx, avx, 1);
00547
00548 switch (c->srcFormat) {
00549 case PIX_FMT_YUYV422:
00550 c->chrToYV12 = ff_yuyvToUV_avx;
00551 break;
00552 case PIX_FMT_UYVY422:
00553 c->chrToYV12 = ff_uyvyToUV_avx;
00554 break;
00555 case PIX_FMT_NV12:
00556 c->chrToYV12 = ff_nv12ToUV_avx;
00557 break;
00558 case PIX_FMT_NV21:
00559 c->chrToYV12 = ff_nv21ToUV_avx;
00560 break;
00561 case_rgb(rgb24, RGB24, avx);
00562 case_rgb(bgr24, BGR24, avx);
00563 case_rgb(bgra, BGRA, avx);
00564 case_rgb(rgba, RGBA, avx);
00565 case_rgb(abgr, ABGR, avx);
00566 case_rgb(argb, ARGB, avx);
00567 default:
00568 break;
00569 }
00570 }
00571 #endif
00572 }