Mercurial > mplayer.hg
annotate postproc/swscale.c @ 3152:54710806be56
runtime cpu detection optional (compiles faster)
author | michael |
---|---|
date | Tue, 27 Nov 2001 01:19:56 +0000 |
parents | b196b915fdc4 |
children | 0b172eb639f1 |
rev | line source |
---|---|
2216 | 1 |
2 // Software scaling and colorspace conversion routines for MPlayer | |
3 | |
2269 | 4 // Orginal C implementation by A'rpi/ESP-team <arpi@thot.banki.hu> |
2264
7851375ea156
increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents:
2237
diff
changeset
|
5 // current version mostly by Michael Niedermayer (michaelni@gmx.at) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
6 // the parts written by michael are under GNU GPL |
2264
7851375ea156
increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents:
2237
diff
changeset
|
7 |
2232
65996b3467d7
MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents:
2230
diff
changeset
|
8 #include <inttypes.h> |
2476 | 9 #include <string.h> |
2232
65996b3467d7
MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents:
2230
diff
changeset
|
10 #include "../config.h" |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
11 #include "swscale.h" |
3126 | 12 #include "../cpudetect.h" |
2540 | 13 #undef MOVNTQ |
2680 | 14 #undef PAVGB |
2232
65996b3467d7
MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents:
2230
diff
changeset
|
15 |
2264
7851375ea156
increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents:
2237
diff
changeset
|
16 //#undef HAVE_MMX2 |
2232
65996b3467d7
MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents:
2230
diff
changeset
|
17 //#undef HAVE_MMX |
2264
7851375ea156
increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents:
2237
diff
changeset
|
18 //#undef ARCH_X86 |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
19 #define DITHER1XBPP |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
20 int fullUVIpol=0; |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
21 //disables the unscaled height version |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
22 int allwaysIpol=0; |
2232
65996b3467d7
MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents:
2230
diff
changeset
|
23 |
65996b3467d7
MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents:
2230
diff
changeset
|
24 #define RET 0xC3 //near return opcode |
2264
7851375ea156
increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents:
2237
diff
changeset
|
25 /* |
7851375ea156
increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents:
2237
diff
changeset
|
26 NOTES |
2216 | 27 |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
28 known BUGS with known cause (no bugreports please!, but patches are welcome :) ) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
29 horizontal MMX2 scaler reads 1-7 samples too much (might cause a sig11) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
30 |
2326 | 31 Supported output formats BGR15 BGR16 BGR24 BGR32 |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
32 BGR15 & BGR16 MMX verions support dithering |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
33 Special versions: fast Y 1:1 scaling (no interpolation in y direction) |
2216 | 34 |
2264
7851375ea156
increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents:
2237
diff
changeset
|
35 TODO |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
36 more intelligent missalignment avoidance for the horizontal scaler |
2566 | 37 bicubic scaler |
2585 | 38 dither in C |
39 change the distance of the u & v buffer | |
3126 | 40 how to differenciate between x86 an C at runtime ?! (using C for now) |
2264
7851375ea156
increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents:
2237
diff
changeset
|
41 */ |
2216 | 42 |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
43 #define ABS(a) ((a) > 0 ? (a) : (-(a))) |
2469 | 44 #define MIN(a,b) ((a) > (b) ? (b) : (a)) |
45 #define MAX(a,b) ((a) < (b) ? (b) : (a)) | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
46 |
3126 | 47 #ifdef ARCH_X86 |
48 #define CAN_COMPILE_X86_ASM | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
49 #endif |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
50 |
3126 | 51 #ifdef CAN_COMPILE_X86_ASM |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
52 static uint64_t __attribute__((aligned(8))) yCoeff= 0x2568256825682568LL; |
2503 | 53 static uint64_t __attribute__((aligned(8))) vrCoeff= 0x3343334333433343LL; |
54 static uint64_t __attribute__((aligned(8))) ubCoeff= 0x40cf40cf40cf40cfLL; | |
55 static uint64_t __attribute__((aligned(8))) vgCoeff= 0xE5E2E5E2E5E2E5E2LL; | |
56 static uint64_t __attribute__((aligned(8))) ugCoeff= 0xF36EF36EF36EF36ELL; | |
2669 | 57 static uint64_t __attribute__((aligned(8))) bF8= 0xF8F8F8F8F8F8F8F8LL; |
58 static uint64_t __attribute__((aligned(8))) bFC= 0xFCFCFCFCFCFCFCFCLL; | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
59 static uint64_t __attribute__((aligned(8))) w400= 0x0400040004000400LL; |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
60 static uint64_t __attribute__((aligned(8))) w80= 0x0080008000800080LL; |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
61 static uint64_t __attribute__((aligned(8))) w10= 0x0010001000100010LL; |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
62 static uint64_t __attribute__((aligned(8))) bm00001111=0x00000000FFFFFFFFLL; |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
63 static uint64_t __attribute__((aligned(8))) bm00000111=0x0000000000FFFFFFLL; |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
64 static uint64_t __attribute__((aligned(8))) bm11111000=0xFFFFFFFFFF000000LL; |
2232
65996b3467d7
MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents:
2230
diff
changeset
|
65 |
2750
9ef09e232505
gcc does optimize writes to non volatile variables away if it didnt know that they were read in between
michael
parents:
2748
diff
changeset
|
66 static volatile uint64_t __attribute__((aligned(8))) b5Dither; |
9ef09e232505
gcc does optimize writes to non volatile variables away if it didnt know that they were read in between
michael
parents:
2748
diff
changeset
|
67 static volatile uint64_t __attribute__((aligned(8))) g5Dither; |
9ef09e232505
gcc does optimize writes to non volatile variables away if it didnt know that they were read in between
michael
parents:
2748
diff
changeset
|
68 static volatile uint64_t __attribute__((aligned(8))) g6Dither; |
9ef09e232505
gcc does optimize writes to non volatile variables away if it didnt know that they were read in between
michael
parents:
2748
diff
changeset
|
69 static volatile uint64_t __attribute__((aligned(8))) r5Dither; |
2748 | 70 |
71 static uint64_t __attribute__((aligned(8))) dither4[2]={ | |
72 0x0103010301030103LL, | |
73 0x0200020002000200LL,}; | |
74 | |
75 static uint64_t __attribute__((aligned(8))) dither8[2]={ | |
76 0x0602060206020602LL, | |
77 0x0004000400040004LL,}; | |
2232
65996b3467d7
MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents:
2230
diff
changeset
|
78 |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
79 static uint64_t __attribute__((aligned(8))) b16Mask= 0x001F001F001F001FLL; |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
80 static uint64_t __attribute__((aligned(8))) g16Mask= 0x07E007E007E007E0LL; |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
81 static uint64_t __attribute__((aligned(8))) r16Mask= 0xF800F800F800F800LL; |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
82 static uint64_t __attribute__((aligned(8))) b15Mask= 0x001F001F001F001FLL; |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
83 static uint64_t __attribute__((aligned(8))) g15Mask= 0x03E003E003E003E0LL; |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
84 static uint64_t __attribute__((aligned(8))) r15Mask= 0x7C007C007C007C00LL; |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
85 |
2730 | 86 static uint64_t __attribute__((aligned(8))) M24A= 0x00FF0000FF0000FFLL; |
87 static uint64_t __attribute__((aligned(8))) M24B= 0xFF0000FF0000FF00LL; | |
88 static uint64_t __attribute__((aligned(8))) M24C= 0x0000FF0000FF0000LL; | |
89 | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
90 static uint64_t __attribute__((aligned(8))) temp0; |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
91 static uint64_t __attribute__((aligned(8))) asm_yalpha1; |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
92 static uint64_t __attribute__((aligned(8))) asm_uvalpha1; |
2264
7851375ea156
increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents:
2237
diff
changeset
|
93 |
7851375ea156
increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents:
2237
diff
changeset
|
94 // temporary storage for 4 yuv lines: |
7851375ea156
increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents:
2237
diff
changeset
|
95 // 16bit for now (mmx likes it more compact) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
96 static uint16_t __attribute__((aligned(8))) pix_buf_y[4][2048]; |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
97 static uint16_t __attribute__((aligned(8))) pix_buf_uv[2][2048*2]; |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
98 #else |
2264
7851375ea156
increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents:
2237
diff
changeset
|
99 static uint16_t pix_buf_y[4][2048]; |
7851375ea156
increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents:
2237
diff
changeset
|
100 static uint16_t pix_buf_uv[2][2048*2]; |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
101 #endif |
2264
7851375ea156
increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents:
2237
diff
changeset
|
102 |
7851375ea156
increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents:
2237
diff
changeset
|
103 // clipping helper table for C implementations: |
7851375ea156
increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents:
2237
diff
changeset
|
104 static unsigned char clip_table[768]; |
7851375ea156
increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents:
2237
diff
changeset
|
105 |
2584 | 106 static unsigned short clip_table16b[768]; |
107 static unsigned short clip_table16g[768]; | |
108 static unsigned short clip_table16r[768]; | |
109 static unsigned short clip_table15b[768]; | |
110 static unsigned short clip_table15g[768]; | |
111 static unsigned short clip_table15r[768]; | |
112 | |
2264
7851375ea156
increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents:
2237
diff
changeset
|
113 // yuv->rgb conversion tables: |
7851375ea156
increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents:
2237
diff
changeset
|
114 static int yuvtab_2568[256]; |
7851375ea156
increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents:
2237
diff
changeset
|
115 static int yuvtab_3343[256]; |
7851375ea156
increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents:
2237
diff
changeset
|
116 static int yuvtab_0c92[256]; |
7851375ea156
increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents:
2237
diff
changeset
|
117 static int yuvtab_1a1e[256]; |
7851375ea156
increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents:
2237
diff
changeset
|
118 static int yuvtab_40cf[256]; |
7851375ea156
increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents:
2237
diff
changeset
|
119 |
3126 | 120 #ifdef CAN_COMPILE_X86_ASM |
2232
65996b3467d7
MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents:
2230
diff
changeset
|
121 static uint8_t funnyYCode[10000]; |
65996b3467d7
MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents:
2230
diff
changeset
|
122 static uint8_t funnyUVCode[10000]; |
2671 | 123 #endif |
2232
65996b3467d7
MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents:
2230
diff
changeset
|
124 |
2469 | 125 static int canMMX2BeUsed=0; |
126 | |
3126 | 127 #ifdef CAN_COMPILE_X86_ASM |
2671 | 128 void in_asm_used_var_warning_killer() |
129 { | |
130 int i= yCoeff+vrCoeff+ubCoeff+vgCoeff+ugCoeff+bF8+bFC+w400+w80+w10+ | |
2748 | 131 bm00001111+bm00000111+bm11111000+b16Mask+g16Mask+r16Mask+b15Mask+g15Mask+r15Mask+temp0+asm_yalpha1+ asm_uvalpha1+ |
2730 | 132 M24A+M24B+M24C; |
2671 | 133 if(i) i=0; |
134 } | |
135 #endif | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
136 |
3126 | 137 //Note: we have C, X86, MMX, MMX2, 3DNOW version therse no 3DNOW+MMX2 one |
138 //Plain C versions | |
3152 | 139 #if !defined (HAVE_MMX) || defined (RUNTIME_CPUDETECT) |
140 #define COMPILE_C | |
141 #endif | |
142 | |
143 #ifdef CAN_COMPILE_X86_ASM | |
144 | |
145 #if (defined (HAVE_MMX) && !defined (HAVE_3DNOW) && !defined (HAVE_MMX2)) || defined (RUNTIME_CPUDETECT) | |
146 #define COMPILE_MMX | |
147 #endif | |
148 | |
149 #if defined (HAVE_MMX2) || defined (RUNTIME_CPUDETECT) | |
150 #define COMPILE_MMX2 | |
151 #endif | |
152 | |
153 #if (defined (HAVE_3DNOW) && !defined (HAVE_MMX2)) || defined (RUNTIME_CPUDETECT) | |
154 #define COMPILE_3DNOW | |
155 #endif | |
156 #endif //CAN_COMPILE_X86_ASM | |
157 | |
158 #undef HAVE_MMX | |
159 #undef HAVE_MMX2 | |
160 #undef HAVE_3DNOW | |
161 #undef ARCH_X86 | |
162 | |
163 #ifdef COMPILE_C | |
3126 | 164 #undef HAVE_MMX |
165 #undef HAVE_MMX2 | |
166 #undef HAVE_3DNOW | |
167 #undef ARCH_X86 | |
168 #define RENAME(a) a ## _C | |
169 #include "swscale_template.c" | |
3152 | 170 #endif |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
171 |
3126 | 172 #ifdef CAN_COMPILE_X86_ASM |
2576 | 173 |
3126 | 174 //X86 versions |
175 /* | |
176 #undef RENAME | |
177 #undef HAVE_MMX | |
178 #undef HAVE_MMX2 | |
179 #undef HAVE_3DNOW | |
180 #define ARCH_X86 | |
181 #define RENAME(a) a ## _X86 | |
182 #include "swscale_template.c" | |
183 */ | |
184 //MMX versions | |
3152 | 185 #ifdef COMPILE_MMX |
3126 | 186 #undef RENAME |
187 #define HAVE_MMX | |
188 #undef HAVE_MMX2 | |
189 #undef HAVE_3DNOW | |
190 #define ARCH_X86 | |
191 #define RENAME(a) a ## _MMX | |
192 #include "swscale_template.c" | |
3152 | 193 #endif |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
194 |
3126 | 195 //MMX2 versions |
3152 | 196 #ifdef COMPILE_MMX2 |
3126 | 197 #undef RENAME |
198 #define HAVE_MMX | |
199 #define HAVE_MMX2 | |
200 #undef HAVE_3DNOW | |
201 #define ARCH_X86 | |
202 #define RENAME(a) a ## _MMX2 | |
203 #include "swscale_template.c" | |
3152 | 204 #endif |
2469 | 205 |
3126 | 206 //3DNOW versions |
3152 | 207 #ifdef COMPILE_3DNOW |
3126 | 208 #undef RENAME |
209 #define HAVE_MMX | |
210 #undef HAVE_MMX2 | |
211 #define HAVE_3DNOW | |
212 #define ARCH_X86 | |
213 #define RENAME(a) a ## _3DNow | |
214 #include "swscale_template.c" | |
3152 | 215 #endif |
2469 | 216 |
3126 | 217 #endif //CAN_COMPILE_X86_ASM |
2469 | 218 |
3126 | 219 // minor note: the HAVE_xyz is messed up after that line so dont use it |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
220 |
2232
65996b3467d7
MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents:
2230
diff
changeset
|
221 |
2519 | 222 // *** bilinear scaling and yuv->rgb or yuv->yuv conversion of yv12 slices: |
2216 | 223 // *** Note: it's called multiple times while decoding a frame, first time y==0 |
224 // *** Designed to upscale, but may work for downscale too. | |
2274 | 225 // s_xinc = (src_width << 16) / dst_width |
2216 | 226 // s_yinc = (src_height << 16) / dst_height |
3126 | 227 // switching the cpu type during a sliced drawing can have bad effects, like sig11 |
2519 | 228 void SwScale_YV12slice(unsigned char* srcptr[],int stride[], int y, int h, |
229 uint8_t* dstptr[], int dststride, int dstw, int dstbpp, | |
2216 | 230 unsigned int s_xinc,unsigned int s_yinc){ |
231 | |
232 // scaling factors: | |
233 //static int s_yinc=(vo_dga_src_height<<16)/vo_dga_vp_height; | |
234 //static int s_xinc=(vo_dga_src_width<<8)/vo_dga_vp_width; | |
3152 | 235 #ifdef RUNTIME_CPUDETECT |
3126 | 236 #ifdef CAN_COMPILE_X86_ASM |
237 // ordered per speed fasterst first | |
238 if(gCpuCaps.hasMMX2) | |
239 SwScale_YV12slice_MMX2(srcptr, stride, y, h, dstptr, dststride, dstw, dstbpp, s_xinc, s_yinc); | |
240 else if(gCpuCaps.has3DNow) | |
241 SwScale_YV12slice_3DNow(srcptr, stride, y, h, dstptr, dststride, dstw, dstbpp, s_xinc, s_yinc); | |
242 else if(gCpuCaps.hasMMX) | |
243 SwScale_YV12slice_MMX(srcptr, stride, y, h, dstptr, dststride, dstw, dstbpp, s_xinc, s_yinc); | |
244 else | |
245 SwScale_YV12slice_C(srcptr, stride, y, h, dstptr, dststride, dstw, dstbpp, s_xinc, s_yinc); | |
246 #else | |
247 SwScale_YV12slice_C(srcptr, stride, y, h, dstptr, dststride, dstw, dstbpp, s_xinc, s_yinc); | |
2270 | 248 #endif |
3152 | 249 #else //RUNTIME_CPUDETECT |
250 #ifdef HAVE_MMX2 | |
251 SwScale_YV12slice_MMX2(srcptr, stride, y, h, dstptr, dststride, dstw, dstbpp, s_xinc, s_yinc); | |
252 #elif defined (HAVE_3DNOW) | |
253 SwScale_YV12slice_3DNow(srcptr, stride, y, h, dstptr, dststride, dstw, dstbpp, s_xinc, s_yinc); | |
254 #elif defined (HAVE_MMX) | |
255 SwScale_YV12slice_MMX(srcptr, stride, y, h, dstptr, dststride, dstw, dstbpp, s_xinc, s_yinc); | |
256 #else | |
257 SwScale_YV12slice_C(srcptr, stride, y, h, dstptr, dststride, dstw, dstbpp, s_xinc, s_yinc); | |
258 #endif | |
259 #endif //!RUNTIME_CPUDETECT | |
2270 | 260 |
2216 | 261 } |
262 | |
263 void SwScale_Init(){ | |
264 // generating tables: | |
265 int i; | |
266 for(i=0;i<256;i++){ | |
267 clip_table[i]=0; | |
268 clip_table[i+256]=i; | |
269 clip_table[i+512]=255; | |
270 yuvtab_2568[i]=(0x2568*(i-16))+(256<<13); | |
271 yuvtab_3343[i]=0x3343*(i-128); | |
272 yuvtab_0c92[i]=-0x0c92*(i-128); | |
273 yuvtab_1a1e[i]=-0x1a1e*(i-128); | |
274 yuvtab_40cf[i]=0x40cf*(i-128); | |
275 } | |
276 | |
2584 | 277 for(i=0; i<768; i++) |
278 { | |
279 int v= clip_table[i]; | |
280 clip_table16b[i]= v>>3; | |
281 clip_table16g[i]= (v<<3)&0x07E0; | |
282 clip_table16r[i]= (v<<8)&0xF800; | |
283 clip_table15b[i]= v>>3; | |
284 clip_table15g[i]= (v<<2)&0x03E0; | |
285 clip_table15r[i]= (v<<7)&0x7C00; | |
286 } | |
3126 | 287 } |
2584 | 288 |