Mercurial > mplayer.hg
annotate libswscale/cs_test.c @ 22654:e69efc71da7b
Merge CFLAGS and INCLUDES where appropriate.
author | diego |
---|---|
date | Sat, 17 Mar 2007 01:18:03 +0000 |
parents | a9b8e965de13 |
children | 9ade9f0ebfc0 |
rev | line source |
---|---|
18861 | 1 /* |
20094
aca9e9783f67
Change license headers to say 'FFmpeg' instead of 'this program'.
diego
parents:
20030
diff
changeset
|
2 * Copyright (C) 2002 Michael Niedermayer <michaelni@gmx.at> |
aca9e9783f67
Change license headers to say 'FFmpeg' instead of 'this program'.
diego
parents:
20030
diff
changeset
|
3 * |
aca9e9783f67
Change license headers to say 'FFmpeg' instead of 'this program'.
diego
parents:
20030
diff
changeset
|
4 * This file is part of FFmpeg. |
aca9e9783f67
Change license headers to say 'FFmpeg' instead of 'this program'.
diego
parents:
20030
diff
changeset
|
5 * |
aca9e9783f67
Change license headers to say 'FFmpeg' instead of 'this program'.
diego
parents:
20030
diff
changeset
|
6 * FFmpeg is free software; you can redistribute it and/or modify |
aca9e9783f67
Change license headers to say 'FFmpeg' instead of 'this program'.
diego
parents:
20030
diff
changeset
|
7 * it under the terms of the GNU General Public License as published by |
aca9e9783f67
Change license headers to say 'FFmpeg' instead of 'this program'.
diego
parents:
20030
diff
changeset
|
8 * the Free Software Foundation; either version 2 of the License, or |
aca9e9783f67
Change license headers to say 'FFmpeg' instead of 'this program'.
diego
parents:
20030
diff
changeset
|
9 * (at your option) any later version. |
aca9e9783f67
Change license headers to say 'FFmpeg' instead of 'this program'.
diego
parents:
20030
diff
changeset
|
10 * |
aca9e9783f67
Change license headers to say 'FFmpeg' instead of 'this program'.
diego
parents:
20030
diff
changeset
|
11 * FFmpeg is distributed in the hope that it will be useful, |
aca9e9783f67
Change license headers to say 'FFmpeg' instead of 'this program'.
diego
parents:
20030
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
aca9e9783f67
Change license headers to say 'FFmpeg' instead of 'this program'.
diego
parents:
20030
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
aca9e9783f67
Change license headers to say 'FFmpeg' instead of 'this program'.
diego
parents:
20030
diff
changeset
|
14 * GNU General Public License for more details. |
aca9e9783f67
Change license headers to say 'FFmpeg' instead of 'this program'.
diego
parents:
20030
diff
changeset
|
15 * |
aca9e9783f67
Change license headers to say 'FFmpeg' instead of 'this program'.
diego
parents:
20030
diff
changeset
|
16 * You should have received a copy of the GNU General Public License |
aca9e9783f67
Change license headers to say 'FFmpeg' instead of 'this program'.
diego
parents:
20030
diff
changeset
|
17 * along with FFmpeg; if not, write to the Free Software |
aca9e9783f67
Change license headers to say 'FFmpeg' instead of 'this program'.
diego
parents:
20030
diff
changeset
|
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
aca9e9783f67
Change license headers to say 'FFmpeg' instead of 'this program'.
diego
parents:
20030
diff
changeset
|
19 */ |
18861 | 20 |
21 #include <stdio.h> | |
19470 | 22 #include <string.h> /* for memset() */ |
23 #include <unistd.h> | |
18861 | 24 #include <stdlib.h> |
25 #include <inttypes.h> | |
20030 | 26 #include <malloc.h> |
18861 | 27 |
28 #include "swscale.h" | |
29 #include "rgb2rgb.h" | |
30 | |
31 #define SIZE 1000 | |
32 #define srcByte 0x55 | |
33 #define dstByte 0xBB | |
34 | |
35 #ifdef __APPLE_CC__ | |
36 #define memalign(x,y) malloc(y) | |
37 #endif | |
38 | |
19470 | 39 static int cpu_caps; |
40 | |
41 static char *args_parse(int argc, char *argv[]) | |
18861 | 42 { |
19470 | 43 int o; |
44 | |
45 while ((o = getopt(argc, argv, "m23")) != -1) { | |
46 switch (o) { | |
47 case 'm': | |
48 cpu_caps |= SWS_CPU_CAPS_MMX; | |
49 break; | |
50 case '2': | |
51 cpu_caps |= SWS_CPU_CAPS_MMX2; | |
52 break; | |
53 case '3': | |
54 cpu_caps |= SWS_CPU_CAPS_3DNOW; | |
55 break; | |
56 default: | |
22029 | 57 av_log(NULL, AV_LOG_ERROR, "Unknown option %c\n", o); |
19470 | 58 } |
59 } | |
60 | |
61 return argv[optind]; | |
18861 | 62 } |
63 | |
20030 | 64 int main(int argc, char **argv) |
18861 | 65 { |
66 int i, funcNum; | |
67 uint8_t *srcBuffer= (uint8_t*)memalign(128, SIZE); | |
68 uint8_t *dstBuffer= (uint8_t*)memalign(128, SIZE); | |
69 int failedNum=0; | |
70 int passedNum=0; | |
71 | |
22029 | 72 av_log(NULL, AV_LOG_INFO, "memory corruption test ...\n"); |
19470 | 73 args_parse(argc, argv); |
22029 | 74 av_log(NULL, AV_LOG_INFO, "CPU capabilities forced to %x\n", cpu_caps); |
19470 | 75 sws_rgb2rgb_init(cpu_caps); |
18861 | 76 |
77 for(funcNum=0; funcNum<100; funcNum++){ | |
78 int width; | |
79 int failed=0; | |
80 int srcBpp=0; | |
81 int dstBpp=0; | |
82 | |
22033 | 83 av_log(NULL, AV_LOG_INFO,"."); |
18861 | 84 memset(srcBuffer, srcByte, SIZE); |
85 | |
86 for(width=32; width<64; width++){ | |
87 int dstOffset; | |
88 for(dstOffset=128; dstOffset<196; dstOffset++){ | |
89 int srcOffset; | |
90 memset(dstBuffer, dstByte, SIZE); | |
91 | |
92 for(srcOffset=128; srcOffset<196; srcOffset++){ | |
93 uint8_t *src= srcBuffer+srcOffset; | |
94 uint8_t *dst= dstBuffer+dstOffset; | |
95 char *name=NULL; | |
96 | |
97 if(failed) break; //don't fill the screen with shit ... | |
98 | |
99 switch(funcNum){ | |
100 case 0: | |
101 srcBpp=2; | |
102 dstBpp=2; | |
103 name="rgb15to16"; | |
104 rgb15to16(src, dst, width*srcBpp); | |
105 break; | |
106 case 1: | |
107 srcBpp=2; | |
108 dstBpp=3; | |
109 name="rgb15to24"; | |
110 rgb15to24(src, dst, width*srcBpp); | |
111 break; | |
112 case 2: | |
113 srcBpp=2; | |
114 dstBpp=4; | |
115 name="rgb15to32"; | |
116 rgb15to32(src, dst, width*srcBpp); | |
117 break; | |
118 case 3: | |
119 srcBpp=2; | |
120 dstBpp=3; | |
121 name="rgb16to24"; | |
122 rgb16to24(src, dst, width*srcBpp); | |
123 break; | |
124 case 4: | |
125 srcBpp=2; | |
126 dstBpp=4; | |
127 name="rgb16to32"; | |
128 rgb16to32(src, dst, width*srcBpp); | |
129 break; | |
130 case 5: | |
131 srcBpp=3; | |
132 dstBpp=2; | |
133 name="rgb24to15"; | |
134 rgb24to15(src, dst, width*srcBpp); | |
135 break; | |
136 case 6: | |
137 srcBpp=3; | |
138 dstBpp=2; | |
139 name="rgb24to16"; | |
140 rgb24to16(src, dst, width*srcBpp); | |
141 break; | |
142 case 7: | |
143 srcBpp=3; | |
144 dstBpp=4; | |
145 name="rgb24to32"; | |
146 rgb24to32(src, dst, width*srcBpp); | |
147 break; | |
148 case 8: | |
149 srcBpp=4; | |
150 dstBpp=2; | |
151 name="rgb32to15"; | |
22029 | 152 //((*s++) << TGA_SHIFT32) | TGA_ALPHA32; |
18861 | 153 rgb32to15(src, dst, width*srcBpp); |
154 break; | |
155 case 9: | |
156 srcBpp=4; | |
157 dstBpp=2; | |
158 name="rgb32to16"; | |
159 rgb32to16(src, dst, width*srcBpp); | |
160 break; | |
161 case 10: | |
162 srcBpp=4; | |
163 dstBpp=3; | |
164 name="rgb32to24"; | |
165 rgb32to24(src, dst, width*srcBpp); | |
166 break; | |
167 case 11: | |
168 srcBpp=2; | |
169 dstBpp=2; | |
170 name="rgb16to15"; | |
171 rgb16to15(src, dst, width*srcBpp); | |
172 break; | |
173 | |
174 case 14: | |
175 srcBpp=2; | |
176 dstBpp=2; | |
177 name="rgb15tobgr15"; | |
178 rgb15tobgr15(src, dst, width*srcBpp); | |
179 break; | |
180 case 15: | |
181 srcBpp=2; | |
182 dstBpp=2; | |
183 name="rgb15tobgr16"; | |
184 rgb15tobgr16(src, dst, width*srcBpp); | |
185 break; | |
186 case 16: | |
187 srcBpp=2; | |
188 dstBpp=3; | |
189 name="rgb15tobgr24"; | |
190 rgb15tobgr24(src, dst, width*srcBpp); | |
191 break; | |
192 case 17: | |
193 srcBpp=2; | |
194 dstBpp=4; | |
195 name="rgb15tobgr32"; | |
196 rgb15tobgr32(src, dst, width*srcBpp); | |
197 break; | |
198 case 18: | |
199 srcBpp=2; | |
200 dstBpp=2; | |
201 name="rgb16tobgr15"; | |
202 rgb16tobgr15(src, dst, width*srcBpp); | |
203 break; | |
204 case 19: | |
205 srcBpp=2; | |
206 dstBpp=2; | |
207 name="rgb16tobgr16"; | |
208 rgb16tobgr16(src, dst, width*srcBpp); | |
209 break; | |
210 case 20: | |
211 srcBpp=2; | |
212 dstBpp=3; | |
213 name="rgb16tobgr24"; | |
214 rgb16tobgr24(src, dst, width*srcBpp); | |
215 break; | |
216 case 21: | |
217 srcBpp=2; | |
218 dstBpp=4; | |
219 name="rgb16tobgr32"; | |
220 rgb16tobgr32(src, dst, width*srcBpp); | |
221 break; | |
222 case 22: | |
223 srcBpp=3; | |
224 dstBpp=2; | |
225 name="rgb24tobgr15"; | |
226 rgb24tobgr15(src, dst, width*srcBpp); | |
227 break; | |
228 case 23: | |
229 srcBpp=3; | |
230 dstBpp=2; | |
231 name="rgb24tobgr16"; | |
232 rgb24tobgr16(src, dst, width*srcBpp); | |
233 break; | |
234 case 24: | |
235 srcBpp=3; | |
236 dstBpp=3; | |
237 name="rgb24tobgr24"; | |
238 rgb24tobgr24(src, dst, width*srcBpp); | |
239 break; | |
240 case 25: | |
241 srcBpp=3; | |
242 dstBpp=4; | |
243 name="rgb24tobgr32"; | |
244 rgb24tobgr32(src, dst, width*srcBpp); | |
245 break; | |
246 case 26: | |
247 srcBpp=4; | |
248 dstBpp=2; | |
249 name="rgb32tobgr15"; | |
250 rgb32tobgr15(src, dst, width*srcBpp); | |
251 break; | |
252 case 27: | |
253 srcBpp=4; | |
254 dstBpp=2; | |
255 name="rgb32tobgr16"; | |
256 rgb32tobgr16(src, dst, width*srcBpp); | |
257 break; | |
258 case 28: | |
259 srcBpp=4; | |
260 dstBpp=3; | |
261 name="rgb32tobgr24"; | |
262 rgb32tobgr24(src, dst, width*srcBpp); | |
263 break; | |
264 case 29: | |
265 srcBpp=4; | |
266 dstBpp=4; | |
267 name="rgb32tobgr32"; | |
268 rgb32tobgr32(src, dst, width*srcBpp); | |
269 break; | |
270 | |
271 } | |
272 if(!srcBpp) break; | |
273 | |
274 for(i=0; i<SIZE; i++){ | |
275 if(srcBuffer[i]!=srcByte){ | |
22029 | 276 av_log(NULL, AV_LOG_INFO, "src damaged at %d w:%d src:%d dst:%d %s\n", |
18861 | 277 i, width, srcOffset, dstOffset, name); |
278 failed=1; | |
279 break; | |
280 } | |
281 } | |
282 for(i=0; i<dstOffset; i++){ | |
283 if(dstBuffer[i]!=dstByte){ | |
22029 | 284 av_log(NULL, AV_LOG_INFO, "dst damaged at %d w:%d src:%d dst:%d %s\n", |
18861 | 285 i, width, srcOffset, dstOffset, name); |
286 failed=1; | |
287 break; | |
288 } | |
289 } | |
290 for(i=dstOffset + width*dstBpp; i<SIZE; i++){ | |
291 if(dstBuffer[i]!=dstByte){ | |
22029 | 292 av_log(NULL, AV_LOG_INFO, "dst damaged at %d w:%d src:%d dst:%d %s\n", |
18861 | 293 i, width, srcOffset, dstOffset, name); |
294 failed=1; | |
295 break; | |
296 } | |
297 } | |
298 } | |
299 } | |
300 } | |
301 if(failed) failedNum++; | |
302 else if(srcBpp) passedNum++; | |
303 } | |
304 | |
22029 | 305 av_log(NULL, AV_LOG_INFO, "%d converters passed, %d converters randomly overwrote memory\n", passedNum, failedNum); |
18861 | 306 return failedNum; |
307 } |