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 #include <stdint.h>
00027
00028 #include "config.h"
00029 #include "libavutil/attributes.h"
00030 #include "libavutil/x86/asm.h"
00031 #include "libavutil/x86/cpu.h"
00032 #include "libavutil/cpu.h"
00033 #include "libavutil/bswap.h"
00034 #include "libswscale/rgb2rgb.h"
00035 #include "libswscale/swscale.h"
00036 #include "libswscale/swscale_internal.h"
00037
00038 #if HAVE_INLINE_ASM
00039
00040 DECLARE_ASM_CONST(8, uint64_t, mmx_ff) = 0x00000000000000FFULL;
00041 DECLARE_ASM_CONST(8, uint64_t, mmx_null) = 0x0000000000000000ULL;
00042 DECLARE_ASM_CONST(8, uint64_t, mmx_one) = 0xFFFFFFFFFFFFFFFFULL;
00043 DECLARE_ASM_CONST(8, uint64_t, mask32b) = 0x000000FF000000FFULL;
00044 DECLARE_ASM_CONST(8, uint64_t, mask32g) = 0x0000FF000000FF00ULL;
00045 DECLARE_ASM_CONST(8, uint64_t, mask32r) = 0x00FF000000FF0000ULL;
00046 DECLARE_ASM_CONST(8, uint64_t, mask32a) = 0xFF000000FF000000ULL;
00047 DECLARE_ASM_CONST(8, uint64_t, mask32) = 0x00FFFFFF00FFFFFFULL;
00048 DECLARE_ASM_CONST(8, uint64_t, mask3216br) = 0x00F800F800F800F8ULL;
00049 DECLARE_ASM_CONST(8, uint64_t, mask3216g) = 0x0000FC000000FC00ULL;
00050 DECLARE_ASM_CONST(8, uint64_t, mask3215g) = 0x0000F8000000F800ULL;
00051 DECLARE_ASM_CONST(8, uint64_t, mul3216) = 0x2000000420000004ULL;
00052 DECLARE_ASM_CONST(8, uint64_t, mul3215) = 0x2000000820000008ULL;
00053 DECLARE_ASM_CONST(8, uint64_t, mask24b) = 0x00FF0000FF0000FFULL;
00054 DECLARE_ASM_CONST(8, uint64_t, mask24g) = 0xFF0000FF0000FF00ULL;
00055 DECLARE_ASM_CONST(8, uint64_t, mask24r) = 0x0000FF0000FF0000ULL;
00056 DECLARE_ASM_CONST(8, uint64_t, mask24l) = 0x0000000000FFFFFFULL;
00057 DECLARE_ASM_CONST(8, uint64_t, mask24h) = 0x0000FFFFFF000000ULL;
00058 DECLARE_ASM_CONST(8, uint64_t, mask24hh) = 0xffff000000000000ULL;
00059 DECLARE_ASM_CONST(8, uint64_t, mask24hhh) = 0xffffffff00000000ULL;
00060 DECLARE_ASM_CONST(8, uint64_t, mask24hhhh) = 0xffffffffffff0000ULL;
00061 DECLARE_ASM_CONST(8, uint64_t, mask15b) = 0x001F001F001F001FULL;
00062 DECLARE_ASM_CONST(8, uint64_t, mask15rg) = 0x7FE07FE07FE07FE0ULL;
00063 DECLARE_ASM_CONST(8, uint64_t, mask15s) = 0xFFE0FFE0FFE0FFE0ULL;
00064 DECLARE_ASM_CONST(8, uint64_t, mask15g) = 0x03E003E003E003E0ULL;
00065 DECLARE_ASM_CONST(8, uint64_t, mask15r) = 0x7C007C007C007C00ULL;
00066 #define mask16b mask15b
00067 DECLARE_ASM_CONST(8, uint64_t, mask16g) = 0x07E007E007E007E0ULL;
00068 DECLARE_ASM_CONST(8, uint64_t, mask16r) = 0xF800F800F800F800ULL;
00069 DECLARE_ASM_CONST(8, uint64_t, red_16mask) = 0x0000f8000000f800ULL;
00070 DECLARE_ASM_CONST(8, uint64_t, green_16mask) = 0x000007e0000007e0ULL;
00071 DECLARE_ASM_CONST(8, uint64_t, blue_16mask) = 0x0000001f0000001fULL;
00072 DECLARE_ASM_CONST(8, uint64_t, red_15mask) = 0x00007c0000007c00ULL;
00073 DECLARE_ASM_CONST(8, uint64_t, green_15mask) = 0x000003e0000003e0ULL;
00074 DECLARE_ASM_CONST(8, uint64_t, blue_15mask) = 0x0000001f0000001fULL;
00075 DECLARE_ASM_CONST(8, uint64_t, mul15_mid) = 0x4200420042004200ULL;
00076 DECLARE_ASM_CONST(8, uint64_t, mul15_hi) = 0x0210021002100210ULL;
00077 DECLARE_ASM_CONST(8, uint64_t, mul16_mid) = 0x2080208020802080ULL;
00078
00079 #define RGB2YUV_SHIFT 8
00080 #define BY ((int)( 0.098*(1<<RGB2YUV_SHIFT)+0.5))
00081 #define BV ((int)(-0.071*(1<<RGB2YUV_SHIFT)+0.5))
00082 #define BU ((int)( 0.439*(1<<RGB2YUV_SHIFT)+0.5))
00083 #define GY ((int)( 0.504*(1<<RGB2YUV_SHIFT)+0.5))
00084 #define GV ((int)(-0.368*(1<<RGB2YUV_SHIFT)+0.5))
00085 #define GU ((int)(-0.291*(1<<RGB2YUV_SHIFT)+0.5))
00086 #define RY ((int)( 0.257*(1<<RGB2YUV_SHIFT)+0.5))
00087 #define RV ((int)( 0.439*(1<<RGB2YUV_SHIFT)+0.5))
00088 #define RU ((int)(-0.148*(1<<RGB2YUV_SHIFT)+0.5))
00089
00090
00091
00092 #define COMPILE_TEMPLATE_MMXEXT 0
00093 #define COMPILE_TEMPLATE_AMD3DNOW 0
00094 #define COMPILE_TEMPLATE_SSE2 0
00095
00096
00097 #undef RENAME
00098 #define RENAME(a) a ## _MMX
00099 #include "rgb2rgb_template.c"
00100
00101
00102 #undef RENAME
00103 #undef COMPILE_TEMPLATE_MMXEXT
00104 #define COMPILE_TEMPLATE_MMXEXT 1
00105 #define RENAME(a) a ## _MMX2
00106 #include "rgb2rgb_template.c"
00107
00108
00109 #undef RENAME
00110 #undef COMPILE_TEMPLATE_SSE2
00111 #define COMPILE_TEMPLATE_SSE2 1
00112 #define RENAME(a) a ## _SSE2
00113 #include "rgb2rgb_template.c"
00114
00115
00116 #undef RENAME
00117 #undef COMPILE_TEMPLATE_MMXEXT
00118 #undef COMPILE_TEMPLATE_SSE2
00119 #undef COMPILE_TEMPLATE_AMD3DNOW
00120 #define COMPILE_TEMPLATE_MMXEXT 0
00121 #define COMPILE_TEMPLATE_SSE2 0
00122 #define COMPILE_TEMPLATE_AMD3DNOW 1
00123 #define RENAME(a) a ## _3DNOW
00124 #include "rgb2rgb_template.c"
00125
00126
00127
00128
00129
00130
00131
00132
00133 #endif
00134
00135 av_cold void rgb2rgb_init_x86(void)
00136 {
00137 #if HAVE_INLINE_ASM
00138 int cpu_flags = av_get_cpu_flags();
00139
00140 if (INLINE_MMX(cpu_flags))
00141 rgb2rgb_init_MMX();
00142 if (INLINE_AMD3DNOW(cpu_flags))
00143 rgb2rgb_init_3DNOW();
00144 if (INLINE_MMXEXT(cpu_flags))
00145 rgb2rgb_init_MMX2();
00146 if (INLINE_SSE2(cpu_flags))
00147 rgb2rgb_init_SSE2();
00148 #endif
00149 }