19 |
* along with this program; if not, write to the Free Software |
* along with this program; if not, write to the Free Software |
20 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 |
* |
* |
22 |
* $Id: xvid_bench.c,v 1.32 2006-10-30 10:52:00 Skal Exp $ |
* $Id: xvid_bench.c,v 1.35 2006-12-21 23:27:35 Isibaar Exp $ |
23 |
* |
* |
24 |
****************************************************************************/ |
****************************************************************************/ |
25 |
|
|
58 |
#include "utils/timer.h" |
#include "utils/timer.h" |
59 |
#include "quant/quant_matrix.c" |
#include "quant/quant_matrix.c" |
60 |
#include "bitstream/cbp.h" |
#include "bitstream/cbp.h" |
61 |
|
#include "bitstream/bitstream.h" |
62 |
|
|
63 |
#include <math.h> |
#include <math.h> |
64 |
|
|
2010 |
printf( "ERROR! please post your platform/compiler specs to xvid-devel@xvid.org !\n" ); |
printf( "ERROR! please post your platform/compiler specs to xvid-devel@xvid.org !\n" ); |
2011 |
} |
} |
2012 |
} |
} |
2013 |
|
|
2014 |
/********************************************************************* |
/********************************************************************* |
2015 |
* test SSIM functions |
* test SSIM functions |
2016 |
*********************************************************************/ |
*********************************************************************/ |
2021 |
extern int lum_8x8_c(uint8_t* ptr, int stride); |
extern int lum_8x8_c(uint8_t* ptr, int stride); |
2022 |
extern int lum_8x8_mmx(uint8_t* ptr, int stride); |
extern int lum_8x8_mmx(uint8_t* ptr, int stride); |
2023 |
extern int lum_2x8_c(uint8_t* ptr, int stride); |
extern int lum_2x8_c(uint8_t* ptr, int stride); |
2024 |
extern void iconsim_c(uint8_t* ptro, uint8_t* ptrc, int stride, int lumo, int lumc, int* pdevo, int* pdevc, int* pcorr); |
extern void consim_c(uint8_t* ptro, uint8_t* ptrc, int stride, int lumo, int lumc, int* pdevo, int* pdevc, int* pcorr); |
2025 |
extern void consim_mmx(uint8_t* ptro, uint8_t* ptrc, int stride, int lumo, int lumc, int* pdevo, int* pdevc, int* pcorr); |
extern void consim_mmx(uint8_t* ptro, uint8_t* ptrc, int stride, int lumo, int lumc, int* pdevo, int* pdevc, int* pcorr); |
2026 |
extern void consim_sse2(uint8_t* ptro, uint8_t* ptrc, int stride, int lumo, int lumc, int* pdevo, int* pdevc, int* pcorr); |
extern void consim_sse2(uint8_t* ptro, uint8_t* ptrc, int stride, int lumo, int lumc, int* pdevo, int* pdevc, int* pcorr); |
2027 |
|
|
2059 |
continue; |
continue; |
2060 |
lum8x8 = lum_8x8_c; |
lum8x8 = lum_8x8_c; |
2061 |
lum2x8 = lum_2x8_c; |
lum2x8 = lum_2x8_c; |
2062 |
csim = iconsim_c; |
csim = consim_c; |
2063 |
|
#ifdef ARCH_IS_IA32 |
2064 |
if (cpu->cpu & XVID_CPU_MMX){ |
if (cpu->cpu & XVID_CPU_MMX){ |
2065 |
lum8x8 = lum_8x8_mmx; |
lum8x8 = lum_8x8_mmx; |
2066 |
csim = consim_mmx; |
csim = consim_mmx; |
2068 |
if (cpu->cpu & XVID_CPU_MMX){ |
if (cpu->cpu & XVID_CPU_MMX){ |
2069 |
csim = consim_sse2; |
csim = consim_sse2; |
2070 |
} |
} |
2071 |
|
#endif |
2072 |
t = gettime_usec(); |
t = gettime_usec(); |
2073 |
emms(); |
emms(); |
2074 |
for(tst=0; tst<nb_tests; ++tst) m = lum8x8(Ref1, 16); |
for(tst=0; tst<nb_tests; ++tst) m = lum8x8(Ref1, 16); |
2094 |
t = (gettime_usec() - t) / nb_tests; |
t = (gettime_usec() - t) / nb_tests; |
2095 |
printf("%s - ssim-consim %.3f usec devs=[0x%x 0x%x 0x%x] %s\n", |
printf("%s - ssim-consim %.3f usec devs=[0x%x 0x%x 0x%x] %s\n", |
2096 |
cpu->name, t, devs[0], devs[1], devs[2], |
cpu->name, t, devs[0], devs[1], devs[2], |
2097 |
(devs[0]!=0xeba80 || devs[1]!=0x1053e7 || devs[2]!=0x51215)?"| ERROR": "" ); |
(devs[0]!=0x1bdf0f || devs[1]!=0x137258 || devs[2]!=0xcdb13)?"| ERROR": "" ); |
|
|
|
2098 |
printf( " --- \n" ); |
printf( " --- \n" ); |
2099 |
} |
} |
2100 |
} |
} |
2101 |
|
|
2102 |
/********************************************************************* |
/********************************************************************* |
2103 |
|
* test bitstream functions |
2104 |
|
*********************************************************************/ |
2105 |
|
|
2106 |
|
#define BIT_BUF_SIZE 2000 |
2107 |
|
|
2108 |
|
static void test_bits() |
2109 |
|
{ |
2110 |
|
const int nb_tests = 50*speed_ref; |
2111 |
|
int tst; |
2112 |
|
uint32_t Crc; |
2113 |
|
uint8_t Buf[BIT_BUF_SIZE]; |
2114 |
|
uint32_t Extracted[BIT_BUF_SIZE*8]; /* worst case: bits read 1 by 1 */ |
2115 |
|
int Lens[BIT_BUF_SIZE*8]; |
2116 |
|
double t1; |
2117 |
|
|
2118 |
|
|
2119 |
|
printf( "\n === test bitstream ===\n" ); |
2120 |
|
ieee_reseed(1); |
2121 |
|
Crc = 0; |
2122 |
|
|
2123 |
|
t1 = gettime_usec(); |
2124 |
|
for(tst=0; tst<nb_tests; ++tst) { |
2125 |
|
Bitstream bs; |
2126 |
|
int m, m2, l, l2; |
2127 |
|
|
2128 |
|
for(l=0; l<BIT_BUF_SIZE; ++l) |
2129 |
|
Buf[l] = (uint8_t)ieee_rand(0,255); |
2130 |
|
|
2131 |
|
l = BIT_BUF_SIZE - ieee_rand(1,BIT_BUF_SIZE/10); |
2132 |
|
BitstreamInit(&bs, (void*)(Buf+BIT_BUF_SIZE-l), l); |
2133 |
|
|
2134 |
|
|
2135 |
|
BitstreamReset(&bs); |
2136 |
|
for(l2=l*8, m=0; l2>0; m++) { |
2137 |
|
const int b = ieee_rand(1,32); |
2138 |
|
Lens[m] = b; |
2139 |
|
l2 -= b; |
2140 |
|
if (l2<0) break; |
2141 |
|
Extracted[m] = BitstreamShowBits(&bs, b); |
2142 |
|
BitstreamSkip(&bs, b); |
2143 |
|
// printf( "<= %d: %d 0x%x\n", m, b, Extracted[m]); |
2144 |
|
} |
2145 |
|
|
2146 |
|
BitstreamReset(&bs); |
2147 |
|
for(m2=0; m2<m; ++m2) { |
2148 |
|
const int b = Lens[m2]; |
2149 |
|
const uint32_t v = BitstreamGetBits(&bs, b); |
2150 |
|
Crc |= (v!=Extracted[m2]); |
2151 |
|
// printf( "=> %d: %d 0x%x %c\n", m2, b, v, " *"[Crc]); |
2152 |
|
} |
2153 |
|
} |
2154 |
|
t1 = (gettime_usec() - t1) / nb_tests; |
2155 |
|
printf(" test_bits %.3f usec %s\n", t1, (Crc!=0)?"| ERROR": "" ); |
2156 |
|
} |
2157 |
|
|
2158 |
|
/********************************************************************* |
2159 |
* main |
* main |
2160 |
*********************************************************************/ |
*********************************************************************/ |
2161 |
|
|
2227 |
if (what==0 || what==14) test_yuv(); |
if (what==0 || what==14) test_yuv(); |
2228 |
if (what==0 || what==15) test_SSIM(); |
if (what==0 || what==15) test_SSIM(); |
2229 |
if (what==0 || what==16) test_yuv2(); |
if (what==0 || what==16) test_yuv2(); |
2230 |
|
if (what==0 || what==17) test_bits(); |
2231 |
|
|
2232 |
if (what==7) { |
if (what==7) { |
2233 |
test_IEEE1180_compliance(-256, 255, 1); |
test_IEEE1180_compliance(-256, 255, 1); |