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
00072 #define RGB2YUV_SHIFT 8
00073 #define BY ((int)( 0.098*(1<<RGB2YUV_SHIFT)+0.5))
00074 #define BV ((int)(-0.071*(1<<RGB2YUV_SHIFT)+0.5))
00075 #define BU ((int)( 0.439*(1<<RGB2YUV_SHIFT)+0.5))
00076 #define GY ((int)( 0.504*(1<<RGB2YUV_SHIFT)+0.5))
00077 #define GV ((int)(-0.368*(1<<RGB2YUV_SHIFT)+0.5))
00078 #define GU ((int)(-0.291*(1<<RGB2YUV_SHIFT)+0.5))
00079 #define RY ((int)( 0.257*(1<<RGB2YUV_SHIFT)+0.5))
00080 #define RV ((int)( 0.439*(1<<RGB2YUV_SHIFT)+0.5))
00081 #define RU ((int)(-0.148*(1<<RGB2YUV_SHIFT)+0.5))
00082
00083
00084
00085 #define COMPILE_TEMPLATE_MMX2 0
00086 #define COMPILE_TEMPLATE_AMD3DNOW 0
00087 #define COMPILE_TEMPLATE_SSE2 0
00088
00089
00090 #undef RENAME
00091 #define RENAME(a) a ## _MMX
00092 #include "rgb2rgb_template.c"
00093
00094
00095 #undef RENAME
00096 #undef COMPILE_TEMPLATE_MMX2
00097 #define COMPILE_TEMPLATE_MMX2 1
00098 #define RENAME(a) a ## _MMX2
00099 #include "rgb2rgb_template.c"
00100
00101
00102 #undef RENAME
00103 #undef COMPILE_TEMPLATE_SSE2
00104 #define COMPILE_TEMPLATE_SSE2 1
00105 #define RENAME(a) a ## _SSE2
00106 #include "rgb2rgb_template.c"
00107
00108
00109 #undef RENAME
00110 #undef COMPILE_TEMPLATE_MMX2
00111 #undef COMPILE_TEMPLATE_SSE2
00112 #undef COMPILE_TEMPLATE_AMD3DNOW
00113 #define COMPILE_TEMPLATE_MMX2 0
00114 #define COMPILE_TEMPLATE_SSE2 0
00115 #define COMPILE_TEMPLATE_AMD3DNOW 1
00116 #define RENAME(a) a ## _3DNOW
00117 #include "rgb2rgb_template.c"
00118
00119
00120
00121
00122
00123
00124
00125
00126 void rgb2rgb_init_x86(void)
00127 {
00128 int cpu_flags = av_get_cpu_flags();
00129
00130 if (cpu_flags & AV_CPU_FLAG_MMX)
00131 rgb2rgb_init_MMX();
00132 if (HAVE_AMD3DNOW && cpu_flags & AV_CPU_FLAG_3DNOW)
00133 rgb2rgb_init_3DNOW();
00134 if (HAVE_MMX2 && cpu_flags & AV_CPU_FLAG_MMX2)
00135 rgb2rgb_init_MMX2();
00136 if (HAVE_SSE && cpu_flags & AV_CPU_FLAG_SSE2)
00137 rgb2rgb_init_SSE2();
00138 }