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