Mercurial > mplayer.hg
annotate libswscale/cs_test.c @ 20658:ed20cbab07a4
Corrigendum 1
change chapter_id from v to s to allow negative chapter_id as required by the spec text
change was unanimously accepted (rich, oded, myself)
this change should not break any existing muxers or demuxers, with the exception of
assumtations about (non)overlapping chapters
author | michael |
---|---|
date | Sat, 04 Nov 2006 22:01:51 +0000 |
parents | aca9e9783f67 |
children | 2fbe2debf5e6 |
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: | |
57 fprintf(stderr, "Unknown option %c\n", o); | |
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 | |
72 printf("memory corruption test ...\n"); | |
19470 | 73 args_parse(argc, argv); |
74 fprintf(stderr, "CPU capabilities forced to %x\n", cpu_caps); | |
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 | |
83 printf("."); fflush(stdout); | |
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"; | |
152 rgb32to15(src, dst, width*srcBpp); | |
153 break; | |
154 case 9: | |
155 srcBpp=4; | |
156 dstBpp=2; | |
157 name="rgb32to16"; | |
158 rgb32to16(src, dst, width*srcBpp); | |
159 break; | |
160 case 10: | |
161 srcBpp=4; | |
162 dstBpp=3; | |
163 name="rgb32to24"; | |
164 rgb32to24(src, dst, width*srcBpp); | |
165 break; | |
166 case 11: | |
167 srcBpp=2; | |
168 dstBpp=2; | |
169 name="rgb16to15"; | |
170 rgb16to15(src, dst, width*srcBpp); | |
171 break; | |
172 | |
173 case 14: | |
174 srcBpp=2; | |
175 dstBpp=2; | |
176 name="rgb15tobgr15"; | |
177 rgb15tobgr15(src, dst, width*srcBpp); | |
178 break; | |
179 case 15: | |
180 srcBpp=2; | |
181 dstBpp=2; | |
182 name="rgb15tobgr16"; | |
183 rgb15tobgr16(src, dst, width*srcBpp); | |
184 break; | |
185 case 16: | |
186 srcBpp=2; | |
187 dstBpp=3; | |
188 name="rgb15tobgr24"; | |
189 rgb15tobgr24(src, dst, width*srcBpp); | |
190 break; | |
191 case 17: | |
192 srcBpp=2; | |
193 dstBpp=4; | |
194 name="rgb15tobgr32"; | |
195 rgb15tobgr32(src, dst, width*srcBpp); | |
196 break; | |
197 case 18: | |
198 srcBpp=2; | |
199 dstBpp=2; | |
200 name="rgb16tobgr15"; | |
201 rgb16tobgr15(src, dst, width*srcBpp); | |
202 break; | |
203 case 19: | |
204 srcBpp=2; | |
205 dstBpp=2; | |
206 name="rgb16tobgr16"; | |
207 rgb16tobgr16(src, dst, width*srcBpp); | |
208 break; | |
209 case 20: | |
210 srcBpp=2; | |
211 dstBpp=3; | |
212 name="rgb16tobgr24"; | |
213 rgb16tobgr24(src, dst, width*srcBpp); | |
214 break; | |
215 case 21: | |
216 srcBpp=2; | |
217 dstBpp=4; | |
218 name="rgb16tobgr32"; | |
219 rgb16tobgr32(src, dst, width*srcBpp); | |
220 break; | |
221 case 22: | |
222 srcBpp=3; | |
223 dstBpp=2; | |
224 name="rgb24tobgr15"; | |
225 rgb24tobgr15(src, dst, width*srcBpp); | |
226 break; | |
227 case 23: | |
228 srcBpp=3; | |
229 dstBpp=2; | |
230 name="rgb24tobgr16"; | |
231 rgb24tobgr16(src, dst, width*srcBpp); | |
232 break; | |
233 case 24: | |
234 srcBpp=3; | |
235 dstBpp=3; | |
236 name="rgb24tobgr24"; | |
237 rgb24tobgr24(src, dst, width*srcBpp); | |
238 break; | |
239 case 25: | |
240 srcBpp=3; | |
241 dstBpp=4; | |
242 name="rgb24tobgr32"; | |
243 rgb24tobgr32(src, dst, width*srcBpp); | |
244 break; | |
245 case 26: | |
246 srcBpp=4; | |
247 dstBpp=2; | |
248 name="rgb32tobgr15"; | |
249 rgb32tobgr15(src, dst, width*srcBpp); | |
250 break; | |
251 case 27: | |
252 srcBpp=4; | |
253 dstBpp=2; | |
254 name="rgb32tobgr16"; | |
255 rgb32tobgr16(src, dst, width*srcBpp); | |
256 break; | |
257 case 28: | |
258 srcBpp=4; | |
259 dstBpp=3; | |
260 name="rgb32tobgr24"; | |
261 rgb32tobgr24(src, dst, width*srcBpp); | |
262 break; | |
263 case 29: | |
264 srcBpp=4; | |
265 dstBpp=4; | |
266 name="rgb32tobgr32"; | |
267 rgb32tobgr32(src, dst, width*srcBpp); | |
268 break; | |
269 | |
270 } | |
271 if(!srcBpp) break; | |
272 | |
273 for(i=0; i<SIZE; i++){ | |
274 if(srcBuffer[i]!=srcByte){ | |
275 printf("src damaged at %d w:%d src:%d dst:%d %s\n", | |
276 i, width, srcOffset, dstOffset, name); | |
277 failed=1; | |
278 break; | |
279 } | |
280 } | |
281 for(i=0; i<dstOffset; i++){ | |
282 if(dstBuffer[i]!=dstByte){ | |
283 printf("dst damaged at %d w:%d src:%d dst:%d %s\n", | |
284 i, width, srcOffset, dstOffset, name); | |
285 failed=1; | |
286 break; | |
287 } | |
288 } | |
289 for(i=dstOffset + width*dstBpp; i<SIZE; i++){ | |
290 if(dstBuffer[i]!=dstByte){ | |
291 printf("dst damaged at %d w:%d src:%d dst:%d %s\n", | |
292 i, width, srcOffset, dstOffset, name); | |
293 failed=1; | |
294 break; | |
295 } | |
296 } | |
297 } | |
298 } | |
299 } | |
300 if(failed) failedNum++; | |
301 else if(srcBpp) passedNum++; | |
302 } | |
303 | |
304 printf("%d converters passed, %d converters randomly overwrote memory\n", passedNum, failedNum); | |
305 return failedNum; | |
306 } |