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.33 2006-10-30 11:21:42 Skal Exp $ |
* $Id: xvid_bench.c,v 1.34 2006-11-01 07:12:26 Skal 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 |
*********************************************************************/ |
*********************************************************************/ |
2099 |
} |
} |
2100 |
|
|
2101 |
/********************************************************************* |
/********************************************************************* |
2102 |
|
* test bitstream functions |
2103 |
|
*********************************************************************/ |
2104 |
|
|
2105 |
|
#define BIT_BUF_SIZE 2000 |
2106 |
|
|
2107 |
|
static void test_bits() |
2108 |
|
{ |
2109 |
|
const int nb_tests = 50*speed_ref; |
2110 |
|
int tst; |
2111 |
|
uint32_t Crc; |
2112 |
|
uint8_t Buf[BIT_BUF_SIZE]; |
2113 |
|
uint32_t Extracted[BIT_BUF_SIZE*8]; /* worst case: bits read 1 by 1 */ |
2114 |
|
int Lens[BIT_BUF_SIZE*8]; |
2115 |
|
double t1; |
2116 |
|
|
2117 |
|
|
2118 |
|
printf( "\n === test bitstream ===\n" ); |
2119 |
|
ieee_reseed(1); |
2120 |
|
Crc = 0; |
2121 |
|
|
2122 |
|
t1 = gettime_usec(); |
2123 |
|
for(tst=0; tst<nb_tests; ++tst) { |
2124 |
|
Bitstream bs; |
2125 |
|
int m, m2, l, l2; |
2126 |
|
|
2127 |
|
for(l=0; l<BIT_BUF_SIZE; ++l) |
2128 |
|
Buf[l] = (uint8_t)ieee_rand(0,255); |
2129 |
|
|
2130 |
|
l = BIT_BUF_SIZE - ieee_rand(1,BIT_BUF_SIZE/10); |
2131 |
|
BitstreamInit(&bs, (void*)(Buf+BIT_BUF_SIZE-l), l); |
2132 |
|
|
2133 |
|
|
2134 |
|
BitstreamReset(&bs); |
2135 |
|
for(l2=l*8, m=0; l2>0; m++) { |
2136 |
|
const int b = ieee_rand(1,32); |
2137 |
|
Lens[m] = b; |
2138 |
|
l2 -= b; |
2139 |
|
if (l2<0) break; |
2140 |
|
Extracted[m] = BitstreamShowBits(&bs, b); |
2141 |
|
BitstreamSkip(&bs, b); |
2142 |
|
// printf( "<= %d: %d 0x%x\n", m, b, Extracted[m]); |
2143 |
|
} |
2144 |
|
|
2145 |
|
BitstreamReset(&bs); |
2146 |
|
for(m2=0; m2<m; ++m2) { |
2147 |
|
const int b = Lens[m2]; |
2148 |
|
const uint32_t v = BitstreamGetBits(&bs, b); |
2149 |
|
Crc |= (v!=Extracted[m2]); |
2150 |
|
// printf( "=> %d: %d 0x%x %c\n", m2, b, v, " *"[Crc]); |
2151 |
|
} |
2152 |
|
} |
2153 |
|
t1 = (gettime_usec() - t1) / nb_tests; |
2154 |
|
printf(" test_bits %.3f usec %s\n", t1, (Crc!=0)?"| ERROR": "" ); |
2155 |
|
} |
2156 |
|
|
2157 |
|
/********************************************************************* |
2158 |
* main |
* main |
2159 |
*********************************************************************/ |
*********************************************************************/ |
2160 |
|
|
2226 |
if (what==0 || what==14) test_yuv(); |
if (what==0 || what==14) test_yuv(); |
2227 |
if (what==0 || what==15) test_SSIM(); |
if (what==0 || what==15) test_SSIM(); |
2228 |
if (what==0 || what==16) test_yuv2(); |
if (what==0 || what==16) test_yuv2(); |
2229 |
|
if (what==0 || what==17) test_bits(); |
2230 |
|
|
2231 |
if (what==7) { |
if (what==7) { |
2232 |
test_IEEE1180_compliance(-256, 255, 1); |
test_IEEE1180_compliance(-256, 255, 1); |