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