Mercurial > mplayer.hg
annotate libswscale/cs_test.c @ 24690:119acb03c645
Fix typo.
author | cehoyos |
---|---|
date | Fri, 05 Oct 2007 12:37:08 +0000 |
parents | 5159b5f8784e |
children | f250e353a56b |
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 |
23702 | 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
20094
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 | |
22964 | 34 #define FUNC(s,d,n) {s,d,#n,n} |
18861 | 35 |
19470 | 36 static int cpu_caps; |
37 | |
38 static char *args_parse(int argc, char *argv[]) | |
18861 | 39 { |
19470 | 40 int o; |
41 | |
42 while ((o = getopt(argc, argv, "m23")) != -1) { | |
43 switch (o) { | |
44 case 'm': | |
45 cpu_caps |= SWS_CPU_CAPS_MMX; | |
46 break; | |
47 case '2': | |
48 cpu_caps |= SWS_CPU_CAPS_MMX2; | |
49 break; | |
50 case '3': | |
51 cpu_caps |= SWS_CPU_CAPS_3DNOW; | |
52 break; | |
53 default: | |
22029 | 54 av_log(NULL, AV_LOG_ERROR, "Unknown option %c\n", o); |
19470 | 55 } |
56 } | |
57 | |
58 return argv[optind]; | |
18861 | 59 } |
60 | |
20030 | 61 int main(int argc, char **argv) |
18861 | 62 { |
22965 | 63 int i, funcNum; |
64 uint8_t *srcBuffer= (uint8_t*)av_malloc(SIZE); | |
65 uint8_t *dstBuffer= (uint8_t*)av_malloc(SIZE); | |
66 int failedNum=0; | |
67 int passedNum=0; | |
23129 | 68 |
22965 | 69 av_log(NULL, AV_LOG_INFO, "memory corruption test ...\n"); |
70 args_parse(argc, argv); | |
71 av_log(NULL, AV_LOG_INFO, "CPU capabilities forced to %x\n", cpu_caps); | |
72 sws_rgb2rgb_init(cpu_caps); | |
23129 | 73 |
22965 | 74 for(funcNum=0; ; funcNum++){ |
75 struct func_info_s { | |
76 int src_bpp; | |
77 int dst_bpp; | |
78 char *name; | |
79 void (*func)(const uint8_t *src, uint8_t *dst, long src_size); | |
80 } func_info[] = { | |
81 FUNC(2, 2, rgb15to16), | |
82 FUNC(2, 3, rgb15to24), | |
83 FUNC(2, 4, rgb15to32), | |
84 FUNC(2, 3, rgb16to24), | |
85 FUNC(2, 4, rgb16to32), | |
86 FUNC(3, 2, rgb24to15), | |
87 FUNC(3, 2, rgb24to16), | |
88 FUNC(3, 4, rgb24to32), | |
89 FUNC(4, 2, rgb32to15), | |
90 FUNC(4, 2, rgb32to16), | |
91 FUNC(4, 3, rgb32to24), | |
92 FUNC(2, 2, rgb16to15), | |
93 FUNC(2, 2, rgb15tobgr15), | |
94 FUNC(2, 2, rgb15tobgr16), | |
95 FUNC(2, 3, rgb15tobgr24), | |
96 FUNC(2, 4, rgb15tobgr32), | |
97 FUNC(2, 2, rgb16tobgr15), | |
98 FUNC(2, 2, rgb16tobgr16), | |
99 FUNC(2, 3, rgb16tobgr24), | |
100 FUNC(2, 4, rgb16tobgr32), | |
101 FUNC(3, 2, rgb24tobgr15), | |
102 FUNC(3, 2, rgb24tobgr16), | |
103 FUNC(3, 3, rgb24tobgr24), | |
104 FUNC(3, 4, rgb24tobgr32), | |
105 FUNC(4, 2, rgb32tobgr15), | |
106 FUNC(4, 2, rgb32tobgr16), | |
107 FUNC(4, 3, rgb32tobgr24), | |
108 FUNC(4, 4, rgb32tobgr32), | |
109 FUNC(0, 0, NULL) | |
110 }; | |
111 int width; | |
112 int failed=0; | |
113 int srcBpp=0; | |
114 int dstBpp=0; | |
18861 | 115 |
22965 | 116 if (!func_info[funcNum].func) break; |
22964 | 117 |
22965 | 118 av_log(NULL, AV_LOG_INFO,"."); |
119 memset(srcBuffer, srcByte, SIZE); | |
18861 | 120 |
23000
16ae5604c82b
test widths all down to one. this tests whether the scalers correctly switch
ivo
parents:
22965
diff
changeset
|
121 for(width=63; width>0; width--){ |
22965 | 122 int dstOffset; |
123 for(dstOffset=128; dstOffset<196; dstOffset+=4){ | |
124 int srcOffset; | |
125 memset(dstBuffer, dstByte, SIZE); | |
18861 | 126 |
22965 | 127 for(srcOffset=128; srcOffset<196; srcOffset+=4){ |
128 uint8_t *src= srcBuffer+srcOffset; | |
129 uint8_t *dst= dstBuffer+dstOffset; | |
130 char *name=NULL; | |
23129 | 131 |
22965 | 132 if(failed) break; //don't fill the screen with shit ... |
18861 | 133 |
22965 | 134 srcBpp = func_info[funcNum].src_bpp; |
135 dstBpp = func_info[funcNum].dst_bpp; | |
136 name = func_info[funcNum].name; | |
18861 | 137 |
22965 | 138 func_info[funcNum].func(src, dst, width*srcBpp); |
22964 | 139 |
22965 | 140 if(!srcBpp) break; |
18861 | 141 |
22965 | 142 for(i=0; i<SIZE; i++){ |
143 if(srcBuffer[i]!=srcByte){ | |
23129 | 144 av_log(NULL, AV_LOG_INFO, "src damaged at %d w:%d src:%d dst:%d %s\n", |
23140
4d3870361b73
cosmetics attack, part I: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
145 i, width, srcOffset, dstOffset, name); |
22965 | 146 failed=1; |
147 break; | |
148 } | |
149 } | |
150 for(i=0; i<dstOffset; i++){ | |
151 if(dstBuffer[i]!=dstByte){ | |
23129 | 152 av_log(NULL, AV_LOG_INFO, "dst damaged at %d w:%d src:%d dst:%d %s\n", |
23140
4d3870361b73
cosmetics attack, part I: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
153 i, width, srcOffset, dstOffset, name); |
22965 | 154 failed=1; |
155 break; | |
156 } | |
157 } | |
158 for(i=dstOffset + width*dstBpp; i<SIZE; i++){ | |
159 if(dstBuffer[i]!=dstByte){ | |
23129 | 160 av_log(NULL, AV_LOG_INFO, "dst damaged at %d w:%d src:%d dst:%d %s\n", |
23140
4d3870361b73
cosmetics attack, part I: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
161 i, width, srcOffset, dstOffset, name); |
22965 | 162 failed=1; |
163 break; | |
164 } | |
165 } | |
166 } | |
167 } | |
168 } | |
169 if(failed) failedNum++; | |
170 else if(srcBpp) passedNum++; | |
171 } | |
23129 | 172 |
22965 | 173 av_log(NULL, AV_LOG_INFO, "\n%d converters passed, %d converters randomly overwrote memory\n", passedNum, failedNum); |
174 return failedNum; | |
18861 | 175 } |