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
00026
00027 #include <stdio.h>
00028 #include <stdlib.h>
00029 #include <inttypes.h>
00030 #include <assert.h>
00031
00032 #include "config.h"
00033 #include "libswscale/rgb2rgb.h"
00034 #include "libswscale/swscale.h"
00035 #include "libswscale/swscale_internal.h"
00036 #include "libavutil/attributes.h"
00037 #include "libavutil/x86/asm.h"
00038 #include "libavutil/cpu.h"
00039
00040 #if HAVE_INLINE_ASM
00041
00042 #define DITHER1XBPP // only for MMX
00043
00044
00045 DECLARE_ASM_CONST(8, uint64_t, mmx_00ffw) = 0x00ff00ff00ff00ffULL;
00046 DECLARE_ASM_CONST(8, uint64_t, mmx_redmask) = 0xf8f8f8f8f8f8f8f8ULL;
00047 DECLARE_ASM_CONST(8, uint64_t, mmx_grnmask) = 0xfcfcfcfcfcfcfcfcULL;
00048 DECLARE_ASM_CONST(8, uint64_t, pb_e0) = 0xe0e0e0e0e0e0e0e0ULL;
00049 DECLARE_ASM_CONST(8, uint64_t, pb_03) = 0x0303030303030303ULL;
00050 DECLARE_ASM_CONST(8, uint64_t, pb_07) = 0x0707070707070707ULL;
00051
00052
00053 #if HAVE_MMX_INLINE
00054 #undef RENAME
00055 #undef COMPILE_TEMPLATE_MMXEXT
00056 #define COMPILE_TEMPLATE_MMXEXT 0
00057 #define RENAME(a) a ## _MMX
00058 #include "yuv2rgb_template.c"
00059 #endif
00060
00061
00062 #if HAVE_MMXEXT_INLINE
00063 #undef RENAME
00064 #undef COMPILE_TEMPLATE_MMXEXT
00065 #define COMPILE_TEMPLATE_MMXEXT 1
00066 #define RENAME(a) a ## _MMX2
00067 #include "yuv2rgb_template.c"
00068 #endif
00069
00070 #endif
00071
00072 av_cold SwsFunc ff_yuv2rgb_init_mmx(SwsContext *c)
00073 {
00074 #if HAVE_INLINE_ASM
00075 int cpu_flags = av_get_cpu_flags();
00076
00077 #if HAVE_MMXEXT_INLINE
00078 if (cpu_flags & AV_CPU_FLAG_MMXEXT) {
00079 switch (c->dstFormat) {
00080 case PIX_FMT_RGB24: return yuv420_rgb24_MMX2;
00081 case PIX_FMT_BGR24: return yuv420_bgr24_MMX2;
00082 }
00083 }
00084 #endif
00085
00086 if (cpu_flags & AV_CPU_FLAG_MMX) {
00087 switch (c->dstFormat) {
00088 case PIX_FMT_RGB32:
00089 if (c->srcFormat == PIX_FMT_YUVA420P) {
00090 #if HAVE_7REGS && CONFIG_SWSCALE_ALPHA
00091 return yuva420_rgb32_MMX;
00092 #endif
00093 break;
00094 } else return yuv420_rgb32_MMX;
00095 case PIX_FMT_BGR32:
00096 if (c->srcFormat == PIX_FMT_YUVA420P) {
00097 #if HAVE_7REGS && CONFIG_SWSCALE_ALPHA
00098 return yuva420_bgr32_MMX;
00099 #endif
00100 break;
00101 } else return yuv420_bgr32_MMX;
00102 case PIX_FMT_RGB24: return yuv420_rgb24_MMX;
00103 case PIX_FMT_BGR24: return yuv420_bgr24_MMX;
00104 case PIX_FMT_RGB565: return yuv420_rgb16_MMX;
00105 case PIX_FMT_RGB555: return yuv420_rgb15_MMX;
00106 }
00107 }
00108 #endif
00109
00110 return NULL;
00111 }