2 Copyright (C) 2002 Michael Niedermayer <michaelni@gmx.at>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "cpudetect.h"
32 #define memalign(x,y) malloc(y)
35 static int get_sws_cpuflags()
37 return (gCpuCaps
.hasMMX
? SWS_CPU_CAPS_MMX
: 0) |
38 (gCpuCaps
.hasMMX2
? SWS_CPU_CAPS_MMX2
: 0) |
39 (gCpuCaps
.has3DNow
? SWS_CPU_CAPS_3DNOW
: 0);
42 main(int argc
, char **argv
)
45 uint8_t *srcBuffer
= (uint8_t*)memalign(128, SIZE
);
46 uint8_t *dstBuffer
= (uint8_t*)memalign(128, SIZE
);
50 printf("memory corruption test ...\n");
53 GetCpuCaps(&gCpuCaps
);
54 printf("testing mmx\n");
57 sws_rgb2rgb_init(get_sws_cpuflags());
59 for(funcNum
=0; funcNum
<100; funcNum
++){
65 printf("."); fflush(stdout
);
66 memset(srcBuffer
, srcByte
, SIZE
);
68 for(width
=32; width
<64; width
++){
70 for(dstOffset
=128; dstOffset
<196; dstOffset
++){
72 memset(dstBuffer
, dstByte
, SIZE
);
74 for(srcOffset
=128; srcOffset
<196; srcOffset
++){
75 uint8_t *src
= srcBuffer
+srcOffset
;
76 uint8_t *dst
= dstBuffer
+dstOffset
;
79 if(failed
) break; //don't fill the screen with shit ...
86 rgb15to16(src
, dst
, width
*srcBpp
);
92 rgb15to24(src
, dst
, width
*srcBpp
);
98 rgb15to32(src
, dst
, width
*srcBpp
);
104 rgb16to24(src
, dst
, width
*srcBpp
);
110 rgb16to32(src
, dst
, width
*srcBpp
);
116 rgb24to15(src
, dst
, width
*srcBpp
);
122 rgb24to16(src
, dst
, width
*srcBpp
);
128 rgb24to32(src
, dst
, width
*srcBpp
);
134 rgb32to15(src
, dst
, width
*srcBpp
);
140 rgb32to16(src
, dst
, width
*srcBpp
);
146 rgb32to24(src
, dst
, width
*srcBpp
);
152 rgb16to15(src
, dst
, width
*srcBpp
);
159 rgb15tobgr15(src
, dst
, width
*srcBpp
);
165 rgb15tobgr16(src
, dst
, width
*srcBpp
);
171 rgb15tobgr24(src
, dst
, width
*srcBpp
);
177 rgb15tobgr32(src
, dst
, width
*srcBpp
);
183 rgb16tobgr15(src
, dst
, width
*srcBpp
);
189 rgb16tobgr16(src
, dst
, width
*srcBpp
);
195 rgb16tobgr24(src
, dst
, width
*srcBpp
);
201 rgb16tobgr32(src
, dst
, width
*srcBpp
);
207 rgb24tobgr15(src
, dst
, width
*srcBpp
);
213 rgb24tobgr16(src
, dst
, width
*srcBpp
);
219 rgb24tobgr24(src
, dst
, width
*srcBpp
);
225 rgb24tobgr32(src
, dst
, width
*srcBpp
);
231 rgb32tobgr15(src
, dst
, width
*srcBpp
);
237 rgb32tobgr16(src
, dst
, width
*srcBpp
);
243 rgb32tobgr24(src
, dst
, width
*srcBpp
);
249 rgb32tobgr32(src
, dst
, width
*srcBpp
);
255 for(i
=0; i
<SIZE
; i
++){
256 if(srcBuffer
[i
]!=srcByte
){
257 printf("src damaged at %d w:%d src:%d dst:%d %s\n",
258 i
, width
, srcOffset
, dstOffset
, name
);
263 for(i
=0; i
<dstOffset
; i
++){
264 if(dstBuffer
[i
]!=dstByte
){
265 printf("dst damaged at %d w:%d src:%d dst:%d %s\n",
266 i
, width
, srcOffset
, dstOffset
, name
);
271 for(i
=dstOffset
+ width
*dstBpp
; i
<SIZE
; i
++){
272 if(dstBuffer
[i
]!=dstByte
){
273 printf("dst damaged at %d w:%d src:%d dst:%d %s\n",
274 i
, width
, srcOffset
, dstOffset
, name
);
282 if(failed
) failedNum
++;
283 else if(srcBpp
) passedNum
++;
286 printf("%d converters passed, %d converters randomly overwrote memory\n", passedNum
, failedNum
);