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