--- trunk/xvidcore/examples/xvid_bench.c 2006/10/11 14:55:28 1731 +++ trunk/xvidcore/examples/xvid_bench.c 2008/12/02 13:44:55 1839 @@ -19,7 +19,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: xvid_bench.c,v 1.29 2006-10-11 14:55:28 Skal Exp $ + * $Id: xvid_bench.c,v 1.39 2008-12-02 13:44:55 Isibaar Exp $ * ****************************************************************************/ @@ -47,6 +47,7 @@ #include "xvid.h" // inner guts +#include "portab.h" #include "dct/idct.h" #include "dct/fdct.h" #include "image/colorspace.h" @@ -58,6 +59,7 @@ #include "utils/timer.h" #include "quant/quant_matrix.c" #include "bitstream/cbp.h" +#include "bitstream/bitstream.h" #include @@ -114,19 +116,18 @@ CPU cpu_list[] = { { "PLAINC ", 0 }, -#ifdef ARCH_IS_IA32 +#if defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64) { "MMX ", XVID_CPU_MMX }, { "MMXEXT ", XVID_CPU_MMXEXT | XVID_CPU_MMX }, { "SSE2 ", XVID_CPU_SSE2 | XVID_CPU_MMX }, + { "SSE3 ", XVID_CPU_SSE3 | XVID_CPU_SSE2 | XVID_CPU_MMX }, + { "SSE41 ", XVID_CPU_SSE41| XVID_CPU_SSE3 | XVID_CPU_SSE2 | XVID_CPU_MMX }, { "3DNOW ", XVID_CPU_3DNOW }, { "3DNOWE ", XVID_CPU_3DNOW | XVID_CPU_3DNOWEXT }, #endif #ifdef ARCH_IS_PPC { "ALTIVEC", XVID_CPU_ALTIVEC }, #endif -#ifdef ARCH_IS_X86_64 - { "X86_64 ", XVID_CPU_ASM}, -#endif #ifdef ARCH_IS_IA64 // { "IA64 ", XVID_CPU_IA64 }, #endif @@ -411,6 +412,15 @@ cpu->name, t, s, (s!=26274)?"| ERROR": "" ); + t = gettime_usec(); + emms(); + for(tst=0; tstname, t, s, + (s!=4002)?"| ERROR": "" ); + t = gettime_usec(); emms(); for(tst=0; tstname!=0; ++cpu) { double t, overhead; - int tst, q; + int32_t tst, q; uint32_t s; if (!init_cpu(cpu)) @@ -819,7 +830,7 @@ TEST_QUANT2(quant_mpeg_intra, Dst, Src); printf("%s - quant_mpeg_intra %.3f usec crc32=0x%08x %s\n", cpu->name, t, s, - (s!=0xfd6a21a4)? "| ERROR": ""); + (s!=0x3b999af6)? "| ERROR": ""); TEST_QUANT(quant_mpeg_inter, Dst, Src); printf("%s - quant_mpeg_inter %.3f usec crc32=0x%08x %s\n", @@ -1720,60 +1731,150 @@ t = (gettime_usec() - t) / nb_tests; \ iCrc = calc_crc((uint8_t*)Dst0, sizeof(Dst0), CRC32_INITIAL) -#define TEST_YUYV(FUNC, S) \ +#define TEST_YUYV(FUNC, S, FLIP) \ ENTER \ -for(tst=0; tstcpu & XVID_CPU_MMX){ lum8x8 = lum_8x8_mmx; csim = consim_mmx; @@ -2000,7 +2103,7 @@ if (cpu->cpu & XVID_CPU_MMX){ csim = consim_sse2; } - +#endif t = gettime_usec(); emms(); for(tst=0; tstname, t, m, - (m!=-841)?"| ERROR": "" ); + (m!=681)?"| ERROR": "" ); t = gettime_usec(); emms(); for(tst=0; tstname, t, devs[0], devs[1], devs[2], - (devs[0]!=0xeba80 || devs[1]!=0x1053e7 || devs[2]!=0x51215)?"| ERROR": "" ); - + (devs[0]!=0x1bdf0f || devs[1]!=0x137258 || devs[2]!=0xcdb13)?"| ERROR": "" ); printf( " --- \n" ); } } /********************************************************************* + * test bitstream functions + *********************************************************************/ + +#define BIT_BUF_SIZE 2000 + +static void test_bits() +{ + const int nb_tests = 50*speed_ref; + int tst; + uint32_t Crc; + uint8_t Buf[BIT_BUF_SIZE]; + uint32_t Extracted[BIT_BUF_SIZE*8]; /* worst case: bits read 1 by 1 */ + int Lens[BIT_BUF_SIZE*8]; + double t1; + + + printf( "\n === test bitstream ===\n" ); + ieee_reseed(1); + Crc = 0; + + t1 = gettime_usec(); + for(tst=0; tst0; m++) { + const int b = ieee_rand(1,32); + Lens[m] = b; + l2 -= b; + if (l2<0) break; + Extracted[m] = BitstreamShowBits(&bs, b); + BitstreamSkip(&bs, b); +// printf( "<= %d: %d 0x%x\n", m, b, Extracted[m]); + } + + BitstreamReset(&bs); + for(m2=0; m2 %d: %d 0x%x %c\n", m2, b, v, " *"[Crc]); + } + } + t1 = (gettime_usec() - t1) / nb_tests; + printf(" test_bits %.3f usec %s\n", t1, (Crc!=0)?"| ERROR": "" ); +} + +/********************************************************************* * main *********************************************************************/ @@ -2047,7 +2205,14 @@ int c, what = 0; int width, height; uint32_t chksum = 0; - const char * test_bitstream = 0; + const char * test_bitstream = 0; +#if defined(WIN32) && defined(ARCH_IS_X86_64) + DECLARE_ALIGNED_MATRIX(xmm_save, 2, 4, uint64_t, 16); + // assumes xmm6 and xmm7 won't be falsely preserved by C code + for(c=0;c<4;c++) + xmm_save[c] = read_counter(); + prime_xmm(xmm_save); +#endif cpu_mask = 0; // default => will use autodectect for(c=1; c= 0 && what <= 6) || what == 10) { printf("\n\n" "NB: If a function isn't optimised for a specific set of intructions,\n" @@ -2131,7 +2313,7 @@ " may appear to be slow.\n"); } -#ifdef ARCH_IS_IA32 +#if defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64) if (what == 0 || what == 5) { printf("\n" "NB: MMX mpeg4 quantization is known to have very small errors (+/-1 magnitude)\n"