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