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