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