Mercurial > mplayer.hg
annotate libswscale/cs_test.c @ 22963:84add524a0f4
r22975: cosmetics: remove trailing white space
author | voroshil |
---|---|
date | Thu, 12 Apr 2007 16:33:48 +0000 |
parents | 9ade9f0ebfc0 |
children | 5922ce1dfefc |
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> | |
26 | |
27 #include "swscale.h" | |
28 #include "rgb2rgb.h" | |
29 | |
30 #define SIZE 1000 | |
31 #define srcByte 0x55 | |
32 #define dstByte 0xBB | |
33 | |
34 | |
19470 | 35 static int cpu_caps; |
36 | |
37 static char *args_parse(int argc, char *argv[]) | |
18861 | 38 { |
19470 | 39 int o; |
40 | |
41 while ((o = getopt(argc, argv, "m23")) != -1) { | |
42 switch (o) { | |
43 case 'm': | |
44 cpu_caps |= SWS_CPU_CAPS_MMX; | |
45 break; | |
46 case '2': | |
47 cpu_caps |= SWS_CPU_CAPS_MMX2; | |
48 break; | |
49 case '3': | |
50 cpu_caps |= SWS_CPU_CAPS_3DNOW; | |
51 break; | |
52 default: | |
22029 | 53 av_log(NULL, AV_LOG_ERROR, "Unknown option %c\n", o); |
19470 | 54 } |
55 } | |
56 | |
57 return argv[optind]; | |
18861 | 58 } |
59 | |
20030 | 60 int main(int argc, char **argv) |
18861 | 61 { |
62 int i, funcNum; | |
22829 | 63 uint8_t *srcBuffer= (uint8_t*)av_malloc(SIZE); |
64 uint8_t *dstBuffer= (uint8_t*)av_malloc(SIZE); | |
18861 | 65 int failedNum=0; |
66 int passedNum=0; | |
67 | |
22029 | 68 av_log(NULL, AV_LOG_INFO, "memory corruption test ...\n"); |
19470 | 69 args_parse(argc, argv); |
22029 | 70 av_log(NULL, AV_LOG_INFO, "CPU capabilities forced to %x\n", cpu_caps); |
19470 | 71 sws_rgb2rgb_init(cpu_caps); |
18861 | 72 |
73 for(funcNum=0; funcNum<100; funcNum++){ | |
74 int width; | |
75 int failed=0; | |
76 int srcBpp=0; | |
77 int dstBpp=0; | |
78 | |
22033 | 79 av_log(NULL, AV_LOG_INFO,"."); |
18861 | 80 memset(srcBuffer, srcByte, SIZE); |
81 | |
82 for(width=32; width<64; width++){ | |
83 int dstOffset; | |
22829 | 84 for(dstOffset=128; dstOffset<196; dstOffset+=4){ |
18861 | 85 int srcOffset; |
86 memset(dstBuffer, dstByte, SIZE); | |
87 | |
22829 | 88 for(srcOffset=128; srcOffset<196; srcOffset+=4){ |
18861 | 89 uint8_t *src= srcBuffer+srcOffset; |
90 uint8_t *dst= dstBuffer+dstOffset; | |
91 char *name=NULL; | |
92 | |
93 if(failed) break; //don't fill the screen with shit ... | |
94 | |
95 switch(funcNum){ | |
96 case 0: | |
97 srcBpp=2; | |
98 dstBpp=2; | |
99 name="rgb15to16"; | |
100 rgb15to16(src, dst, width*srcBpp); | |
101 break; | |
102 case 1: | |
103 srcBpp=2; | |
104 dstBpp=3; | |
105 name="rgb15to24"; | |
106 rgb15to24(src, dst, width*srcBpp); | |
107 break; | |
108 case 2: | |
109 srcBpp=2; | |
110 dstBpp=4; | |
111 name="rgb15to32"; | |
112 rgb15to32(src, dst, width*srcBpp); | |
113 break; | |
114 case 3: | |
115 srcBpp=2; | |
116 dstBpp=3; | |
117 name="rgb16to24"; | |
118 rgb16to24(src, dst, width*srcBpp); | |
119 break; | |
120 case 4: | |
121 srcBpp=2; | |
122 dstBpp=4; | |
123 name="rgb16to32"; | |
124 rgb16to32(src, dst, width*srcBpp); | |
125 break; | |
126 case 5: | |
127 srcBpp=3; | |
128 dstBpp=2; | |
129 name="rgb24to15"; | |
130 rgb24to15(src, dst, width*srcBpp); | |
131 break; | |
132 case 6: | |
133 srcBpp=3; | |
134 dstBpp=2; | |
135 name="rgb24to16"; | |
136 rgb24to16(src, dst, width*srcBpp); | |
137 break; | |
138 case 7: | |
139 srcBpp=3; | |
140 dstBpp=4; | |
141 name="rgb24to32"; | |
142 rgb24to32(src, dst, width*srcBpp); | |
143 break; | |
144 case 8: | |
145 srcBpp=4; | |
146 dstBpp=2; | |
147 name="rgb32to15"; | |
22029 | 148 //((*s++) << TGA_SHIFT32) | TGA_ALPHA32; |
18861 | 149 rgb32to15(src, dst, width*srcBpp); |
150 break; | |
151 case 9: | |
152 srcBpp=4; | |
153 dstBpp=2; | |
154 name="rgb32to16"; | |
155 rgb32to16(src, dst, width*srcBpp); | |
156 break; | |
157 case 10: | |
158 srcBpp=4; | |
159 dstBpp=3; | |
160 name="rgb32to24"; | |
161 rgb32to24(src, dst, width*srcBpp); | |
162 break; | |
163 case 11: | |
164 srcBpp=2; | |
165 dstBpp=2; | |
166 name="rgb16to15"; | |
167 rgb16to15(src, dst, width*srcBpp); | |
168 break; | |
169 | |
170 case 14: | |
171 srcBpp=2; | |
172 dstBpp=2; | |
173 name="rgb15tobgr15"; | |
174 rgb15tobgr15(src, dst, width*srcBpp); | |
175 break; | |
176 case 15: | |
177 srcBpp=2; | |
178 dstBpp=2; | |
179 name="rgb15tobgr16"; | |
180 rgb15tobgr16(src, dst, width*srcBpp); | |
181 break; | |
182 case 16: | |
183 srcBpp=2; | |
184 dstBpp=3; | |
185 name="rgb15tobgr24"; | |
186 rgb15tobgr24(src, dst, width*srcBpp); | |
187 break; | |
188 case 17: | |
189 srcBpp=2; | |
190 dstBpp=4; | |
191 name="rgb15tobgr32"; | |
192 rgb15tobgr32(src, dst, width*srcBpp); | |
193 break; | |
194 case 18: | |
195 srcBpp=2; | |
196 dstBpp=2; | |
197 name="rgb16tobgr15"; | |
198 rgb16tobgr15(src, dst, width*srcBpp); | |
199 break; | |
200 case 19: | |
201 srcBpp=2; | |
202 dstBpp=2; | |
203 name="rgb16tobgr16"; | |
204 rgb16tobgr16(src, dst, width*srcBpp); | |
205 break; | |
206 case 20: | |
207 srcBpp=2; | |
208 dstBpp=3; | |
209 name="rgb16tobgr24"; | |
210 rgb16tobgr24(src, dst, width*srcBpp); | |
211 break; | |
212 case 21: | |
213 srcBpp=2; | |
214 dstBpp=4; | |
215 name="rgb16tobgr32"; | |
216 rgb16tobgr32(src, dst, width*srcBpp); | |
217 break; | |
218 case 22: | |
219 srcBpp=3; | |
220 dstBpp=2; | |
221 name="rgb24tobgr15"; | |
222 rgb24tobgr15(src, dst, width*srcBpp); | |
223 break; | |
224 case 23: | |
225 srcBpp=3; | |
226 dstBpp=2; | |
227 name="rgb24tobgr16"; | |
228 rgb24tobgr16(src, dst, width*srcBpp); | |
229 break; | |
230 case 24: | |
231 srcBpp=3; | |
232 dstBpp=3; | |
233 name="rgb24tobgr24"; | |
234 rgb24tobgr24(src, dst, width*srcBpp); | |
235 break; | |
236 case 25: | |
237 srcBpp=3; | |
238 dstBpp=4; | |
239 name="rgb24tobgr32"; | |
240 rgb24tobgr32(src, dst, width*srcBpp); | |
241 break; | |
242 case 26: | |
243 srcBpp=4; | |
244 dstBpp=2; | |
245 name="rgb32tobgr15"; | |
246 rgb32tobgr15(src, dst, width*srcBpp); | |
247 break; | |
248 case 27: | |
249 srcBpp=4; | |
250 dstBpp=2; | |
251 name="rgb32tobgr16"; | |
252 rgb32tobgr16(src, dst, width*srcBpp); | |
253 break; | |
254 case 28: | |
255 srcBpp=4; | |
256 dstBpp=3; | |
257 name="rgb32tobgr24"; | |
258 rgb32tobgr24(src, dst, width*srcBpp); | |
259 break; | |
260 case 29: | |
261 srcBpp=4; | |
262 dstBpp=4; | |
263 name="rgb32tobgr32"; | |
264 rgb32tobgr32(src, dst, width*srcBpp); | |
265 break; | |
266 | |
267 } | |
268 if(!srcBpp) break; | |
269 | |
270 for(i=0; i<SIZE; i++){ | |
271 if(srcBuffer[i]!=srcByte){ | |
22029 | 272 av_log(NULL, AV_LOG_INFO, "src damaged at %d w:%d src:%d dst:%d %s\n", |
18861 | 273 i, width, srcOffset, dstOffset, name); |
274 failed=1; | |
275 break; | |
276 } | |
277 } | |
278 for(i=0; i<dstOffset; i++){ | |
279 if(dstBuffer[i]!=dstByte){ | |
22029 | 280 av_log(NULL, AV_LOG_INFO, "dst damaged at %d w:%d src:%d dst:%d %s\n", |
18861 | 281 i, width, srcOffset, dstOffset, name); |
282 failed=1; | |
283 break; | |
284 } | |
285 } | |
286 for(i=dstOffset + width*dstBpp; i<SIZE; i++){ | |
287 if(dstBuffer[i]!=dstByte){ | |
22029 | 288 av_log(NULL, AV_LOG_INFO, "dst damaged at %d w:%d src:%d dst:%d %s\n", |
18861 | 289 i, width, srcOffset, dstOffset, name); |
290 failed=1; | |
291 break; | |
292 } | |
293 } | |
294 } | |
295 } | |
296 } | |
297 if(failed) failedNum++; | |
298 else if(srcBpp) passedNum++; | |
299 } | |
300 | |
22029 | 301 av_log(NULL, AV_LOG_INFO, "%d converters passed, %d converters randomly overwrote memory\n", passedNum, failedNum); |
18861 | 302 return failedNum; |
303 } |