📄 xvid_bench.c
字号:
TEST_MB(interpolate8x8_halfpel_v, 1); printf("%s - round1 %.3f usec crc32=0x%08x %s\n", cpu->name, t, iCrc, (iCrc!=0x42202efe)?"| ERROR": "" ); TEST_MB(interpolate8x8_halfpel_hv, 0); printf("%s - interp-hv-round0 %.3f usec crc32=0x%08x %s\n", cpu->name, t, iCrc, (iCrc!=0xd198d387)?"| ERROR": "" ); TEST_MB(interpolate8x8_halfpel_hv, 1); printf("%s - round1 %.3f usec crc32=0x%08x %s\n", cpu->name, t, iCrc, (iCrc!=0x9ecfd921)?"| ERROR": "" ); /* this is a new function, as of 06.06.2002 */#if 0 TEST_MB2(interpolate8x8_avrg); printf("%s - interpolate8x8_c %.3f usec crc32=0x%08x %s\n", cpu->name, t, iCrc, (iCrc!=8107)?"| ERROR": "" );#endif /* New functions for field prediction by CK 1.10.2005 */#pragma NEW8X4 TEST_MB(interpolate8x4_halfpel_h, 0); printf("%s - interpfield-h -round0 %.3f usec crc32=0x%08x %s\n", cpu->name, t, iCrc, (iCrc!=0x9538d6df)?"| ERROR": "" ); TEST_MB(interpolate8x4_halfpel_h, 1); printf("%s - round1 %.3f usec crc32=0x%08x %s\n", cpu->name, t, iCrc, (iCrc!=0xde5f1db4)?"| ERROR": "" ); TEST_MB(interpolate8x4_halfpel_v, 0); printf("%s - interpfield- v-round0 %.3f usec crc32=0x%08x %s\n", cpu->name, t, iCrc, (iCrc!=0xea5a69ef)?"| ERROR": "" ); TEST_MB(interpolate8x4_halfpel_v, 1); printf("%s - round1 %.3f usec crc32=0x%08x %s\n", cpu->name, t, iCrc, (iCrc!=0x4f10ec0f)?"| ERROR": "" ); TEST_MB(interpolate8x4_halfpel_hv, 0); printf("%s - interpfield-hv-round0 %.3f usec crc32=0x%08x %s\n", cpu->name, t, iCrc, (iCrc!=0xf97ee367)?"| ERROR": "" ); TEST_MB(interpolate8x4_halfpel_hv, 1); printf("%s - round1 %.3f usec crc32=0x%08x %s\n", cpu->name, t, iCrc, (iCrc!=0xb6a9f581)?"| ERROR": "" );/* End of 8x4 functions */ printf( " --- \n" ); }}/********************************************************************* * test transfer *********************************************************************/#define INIT_TRANSFER \for(i=0; i<8*32; ++i) { \Src8[i] = i; Src16[i] = i; \Dst8[i] = 0; Dst16[i] = 0; \Ref1[i] = i^0x27; \Ref2[i] = i^0x51; \}#define TEST_TRANSFER_BEGIN(DST) \INIT_TRANSFER \overhead = -gettime_usec(); \for(tst=0; tst<nb_tests; ++tst) { \ for(i=0; i<8*32; ++i) (DST)[i] = i^0x6a;\} \overhead += gettime_usec(); \t = gettime_usec(); \emms(); \for(tst=0; tst<nb_tests; ++tst) { \ for(i=0; i<8*32; ++i) (DST)[i] = i^0x6a;#define TEST_TRANSFER_END(DST) \} \emms(); \t = (gettime_usec()-t -overhead) / nb_tests;\byte_swap((uint8_t*)(DST), 8*32*sizeof((DST)[0]), sizeof((DST)[0])); \s = calc_crc((uint8_t*)(DST), 8*32*sizeof((DST)[0]), CRC32_INITIAL)#define TEST_TRANSFER(FUNC, DST, SRC) \TEST_TRANSFER_BEGIN(DST); \ (FUNC)((DST), (SRC), 32); \TEST_TRANSFER_END(DST)#define TEST_TRANSFER2_BEGIN(DST, SRC) \INIT_TRANSFER \overhead = -gettime_usec(); \for(tst=0; tst<nb_tests; ++tst) { \ for(i=0; i<8*32; ++i) (DST)[i] = i^0x6a;\ for(i=0; i<8*32; ++i) (SRC)[i] = i^0x3e;\} \overhead += gettime_usec(); \t = gettime_usec(); \emms(); \for(tst=0; tst<nb_tests; ++tst) { \ for(i=0; i<8*32; ++i) (DST)[i] = i^0x6a;\ for(i=0; i<8*32; ++i) (SRC)[i] = i^0x3e;#define TEST_TRANSFER2_END(DST) \} \emms(); \t = (gettime_usec()-t -overhead) / nb_tests;\byte_swap((uint8_t*)(DST), 8*32*sizeof((DST)[0]), sizeof((DST)[0])); \s = calc_crc((uint8_t*)(DST), 8*32*sizeof((DST)[0]), CRC32_INITIAL)#define TEST_TRANSFER2(FUNC, DST, SRC, R1) \TEST_TRANSFER2_BEGIN(DST,SRC); \ (FUNC)((DST), (SRC), (R1), 32); \TEST_TRANSFER2_END(DST)#define TEST_TRANSFER3(FUNC, DST, SRC, R1, R2)\TEST_TRANSFER_BEGIN(DST); \ (FUNC)((DST), (SRC), (R1), (R2), 32); \TEST_TRANSFER_END(DST)void test_transfer(){ const int nb_tests = 4000*speed_ref; int i; CPU *cpu;// uint8_t Src8[8*32], Dst8[8*32], Ref1[8*32], Ref2[8*32];// int16_t Src16[8*32], Dst16[8*32]; DECLARE_ALIGNED_MATRIX(Src8, 8, 32, uint8_t, CACHE_LINE); DECLARE_ALIGNED_MATRIX(Dst8, 8, 32, uint8_t, CACHE_LINE); DECLARE_ALIGNED_MATRIX(Ref1, 8, 32, uint8_t, CACHE_LINE); DECLARE_ALIGNED_MATRIX(Ref2, 8, 32, uint8_t, CACHE_LINE); DECLARE_ALIGNED_MATRIX(Src16, 8, 32, uint16_t, CACHE_LINE); DECLARE_ALIGNED_MATRIX(Dst16, 8, 32, uint16_t, CACHE_LINE); printf( "\n === test transfer ===\n" ); for(cpu = cpu_list; cpu->name!=0; ++cpu) { double t, overhead; int tst, s; if (!init_cpu(cpu)) continue; TEST_TRANSFER(transfer_8to16copy, Dst16, Src8); printf("%s - 8to16 %.3f usec crc32=0x%08x %s\n", cpu->name, t, s, (s!=0x115814bb)?"| ERROR": ""); TEST_TRANSFER(transfer_16to8copy, Dst8, Src16); printf( "%s - 16to8 %.3f usec crc32=0x%08x %s\n", cpu->name, t, s, (s!=0xee7ccbb4)?"| ERROR": ""); /* New functions for field prediction by CK 1.10.2005 */#pragma NEW8X4 TEST_TRANSFER(transfer8x4_copy, Dst8, Src8); printf("%s - 8to4 %.3f usec crc32=0x%08x %s\n", cpu->name, t, s, (s!=0xbb9c3db5)?"| ERROR": "");/* End of new functions */ TEST_TRANSFER(transfer8x8_copy, Dst8, Src8); printf("%s - 8to8 %.3f usec crc32=0x%08x %s\n", cpu->name, t, s, (s!=0xd37b3295)?"| ERROR": ""); TEST_TRANSFER(transfer_16to8add, Dst8, Src16); printf("%s - 16to8add %.3f usec crc32=0x%08x %s\n", cpu->name, t, s, (s!=0xdd817bf4)?"| ERROR": "" ); TEST_TRANSFER2(transfer_8to16sub, Dst16, Src8, Ref1); { int s1, s2; s1 = calc_crc((uint8_t*)Dst16, 8*32*sizeof(Dst16[0]), CRC32_INITIAL); s2 = calc_crc((uint8_t*)Src8, 8*32*sizeof(Src8[0]), CRC32_INITIAL); printf("%s - 8to16sub %.3f usec crc32(1)=0x%08x crc32(2)=0x%08x %s %s\n", cpu->name, t, s1, s2, (s1!=0xa1e07163)?"| ERROR1": "", (s2!=0xd86c5d23)?"| ERROR2": "" ); } TEST_TRANSFER3(transfer_8to16sub2, Dst16, Src8, Ref1, Ref2); printf("%s - 8to16sub2 %.3f usec crc32=0x%08x %s\n", cpu->name, t, s, (s!=0x99b6c4c7)?"| ERROR": "" ); printf( " --- \n" ); }}/********************************************************************* * test quantization *********************************************************************/#define TEST_QUANT(FUNC, DST, SRC) \t = gettime_usec(); \for(s=CRC32_INITIAL,qm=1; qm<=255; ++qm) { \ for(i=0; i<8*8; ++i) Quant[i] = qm; \ set_inter_matrix( mpeg_quant_matrices, Quant ); \ emms(); \ for(q=1; q<=max_Q; ++q) { \ for(tst=0; tst<nb_tests; ++tst) \ (FUNC)((DST), (SRC), q, mpeg_quant_matrices); \ byte_swap((uint8_t*)(DST), 64*sizeof((DST)[0]), sizeof((DST)[0])); \ s = calc_crc((uint8_t*)(DST), 64*sizeof((DST)[0]), s); \ } \ emms(); \} \t = (gettime_usec()-t-overhead)/nb_tests/qm#define TEST_QUANT2(FUNC, DST, SRC) \t = gettime_usec(); \for(s=CRC32_INITIAL,qm=1; qm<=255; ++qm) { \ for(i=0; i<8*8; ++i) Quant[i] = qm; \ set_intra_matrix( mpeg_quant_matrices, Quant ); \ emms(); \ for(q=1; q<=max_Q; ++q) { \ for(tst=0; tst<nb_tests; ++tst) \ (FUNC)((DST), (SRC), q, q, mpeg_quant_matrices); \ byte_swap((uint8_t*)(DST), 64*sizeof((DST)[0]), sizeof((DST)[0])); \ s = calc_crc((uint8_t*)(DST), 64*sizeof((DST)[0]), s); \ } \ emms(); \} \t = (gettime_usec()-t-overhead)/nb_tests/qm#define TEST_INTRA(REFFUNC, NEWFUNC, RANGE) \{ int i,q,s;\ DECLARE_ALIGNED_MATRIX(Src, 8, 8, int16_t, 16); \ DECLARE_ALIGNED_MATRIX(Dst, 8, 8, int16_t, 16); \ DECLARE_ALIGNED_MATRIX(Dst2,8, 8, int16_t, 16); \ for(q=1;q<=max_Q;q++) \ for(s=-RANGE;s<RANGE;s++) { \ for(i=0;i<64;i++) Src[i]=s; \ (REFFUNC)((Dst),(Src),q,q,mpeg_quant_matrices); \ (NEWFUNC)((Dst2),(Src),q,q,mpeg_quant_matrices); \ for(i=0;i<64;i++) \ if(Dst[i]!=Dst2[i]) printf("ERROR : " #NEWFUNC " i%d quant:%d input:%d C_result:%d ASM_result:%d\n",i,q,s,Dst[i],Dst2[i]); \ } \}#define TEST_INTER(REFFUNC, NEWFUNC, RANGE) \{ int i,q,s; \ DECLARE_ALIGNED_MATRIX(Src, 8, 8, int16_t, 16); \ DECLARE_ALIGNED_MATRIX(Dst, 8, 8, int16_t, 16); \ DECLARE_ALIGNED_MATRIX(Dst2,8, 8, int16_t, 16); \ for(q=1;q<=max_Q;q++) \ for(s=-RANGE;s<RANGE;s++) { \ for(i=0;i<64;i++) Src[i]=s; \ (REFFUNC)((Dst),(Src),q,mpeg_quant_matrices); \ (NEWFUNC)((Dst2),(Src),q,mpeg_quant_matrices); \ emms(); \ for(i=0;i<64;i++) \ if(Dst[i]!=Dst2[i]) printf("ERROR : " #NEWFUNC " i%d quant:%d input:%d C_result:%d ASM_result:%d\n",i,q,s,Dst[i],Dst2[i]); \ } \}void test_quant(){ const int nb_tests = 1*speed_ref; const int max_Q = 31; DECLARE_ALIGNED_MATRIX(mpeg_quant_matrices, 8, 64, uint16_t, 16); int i, qm; CPU *cpu; DECLARE_ALIGNED_MATRIX(Src, 8, 8, int16_t, 16); DECLARE_ALIGNED_MATRIX(Dst, 8, 8, int16_t, 16); DECLARE_ALIGNED_MATRIX(Dst2,8, 8, int16_t, 16); uint8_t Quant[8*8]; printf( "\n ===== test quant =====\n" );/* we deliberately enfringe the norm's specified range [-127,127], *//* to test the robustness of the iquant module */ for(i=0; i<64; ++i) { Src[i] = 1 + (i-32) * (i&6); Dst[i] = 0; } for(cpu = cpu_list; cpu->name!=0; ++cpu) { double t, overhead; int tst, q; uint32_t s; if (!init_cpu(cpu)) continue; // exhaustive tests to compare against the (ref) C-version TEST_INTRA(quant_h263_intra_c, quant_h263_intra, 2048); TEST_INTRA(dequant_h263_intra_c, dequant_h263_intra , 512 ); TEST_INTER(quant_h263_inter_c, quant_h263_inter , 2048); TEST_INTER(dequant_h263_inter_c, dequant_h263_inter , 512 ); overhead = -gettime_usec(); for(s=0,qm=1; qm<=255; ++qm) { for(i=0; i<8*8; ++i) Quant[i] = qm; set_inter_matrix(mpeg_quant_matrices, Quant ); for(q=1; q<=max_Q; ++q) for(i=0; i<64; ++i) s+=Dst[i]^i^qm; } overhead += gettime_usec(); 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": ""); TEST_QUANT(quant_mpeg_inter, Dst, Src); printf("%s - quant_mpeg_inter %.3f usec crc32=0x%08x %s\n", cpu->name, t, s, (s!=0xf6de7757)?"| ERROR": ""); TEST_QUANT2(dequant_mpeg_intra, Dst, Src); printf("%s - dequant_mpeg_intra %.3f usec crc32=0x%08x %s\n", cpu->name, t, s, (s!=0x2def7bc7)?"| ERROR": ""); TEST_QUANT(dequant_mpeg_inter, Dst, Src); printf("%s - dequant_mpeg_inter %.3f usec crc32=0x%08x %s\n", cpu->name, t, s, (s!=0xd878c722)?"| ERROR": ""); TEST_QUANT2(quant_h263_intra, Dst, Src); printf("%s - quant_h263_intra %.3f usec crc32=0x%08x %s\n", cpu->name, t, s, (s!=0x2eba9d43)?"| ERROR": ""); TEST_QUANT(quant_h263_inter, Dst, Src); printf("%s - quant_h263_inter %.3f usec crc32=0x%08x %s\n", cpu->name, t, s, (s!=0xbd315a7e)?"| ERROR": ""); TEST_QUANT2(dequant_h263_intra, Dst, Src); printf("%s - dequant_h263_intra %.3f usec crc32=0x%08x %s\n", cpu->name, t, s, (s!=0x9841212a)?"| ERROR": ""); TEST_QUANT(dequant_h263_inter, Dst, Src); printf("%s - dequant_h263_inter %.3f usec crc32=0x%08x %s\n", cpu->name, t, s, (s!=0xe7df8fba)?"| ERROR": ""); printf( " --- \n" ); }}/********************************************************************* * test distortion operators *********************************************************************/static void ieee_reseed(long s);static long ieee_rand(int Min, int Max);#define TEST_SSE(FUNCTION, SRC1, SRC2, STRIDE) \ do { \ t = gettime_usec(); \ tst = nb_tests; \ while((tst--)>0) sse = (FUNCTION)((SRC1), (SRC2), (STRIDE)); \ emms(); \ t = (gettime_usec() - t)/(double)nb_tests; \ } while(0)void test_sse(){ const int nb_tests = 100000*speed_ref; int i; CPU *cpu; DECLARE_ALIGNED_MATRIX(Src1, 8, 8, int16_t, 16); DECLARE_ALIGNED_MATRIX(Src2, 8, 8, int16_t, 16); DECLARE_ALIGNED_MATRIX(Src3, 8, 8, int16_t, 16); DECLARE_ALIGNED_MATRIX(Src4, 8, 8, int16_t, 16); printf( "\n ===== test sse =====\n" ); ieee_reseed(1); for(i=0; i<64; ++i) { Src1[i] = ieee_rand(-2048, 2047); Src2[i] = ieee_rand(-2048, 2047); Src3[i] = ieee_rand(-2048, 2047); Src4[i] = ieee_rand(-2048, 2047); } for(cpu = cpu_list; cpu->name!=0; ++cpu) { double t; int tst, sse; if (!init_cpu(cpu)) continue; /* 16 bit element blocks */ TEST_SSE(sse8_16bit, Src1, Src2, 16); printf("%s - sse8_16bit#1 %.3f usec sse=%d %s\n", cpu->name, t, sse, (sse!=182013834)?"| ERROR": ""); TEST_SSE(sse8_16bit, Src1, Src3, 16); printf("%s - sse8_16bit#2 %.3f usec sse=%d %s\n", cpu->name, t, sse, (sse!=142545203)?"| ERROR": ""); TEST_SSE(sse8_16bit, Src1, Src4, 16); printf("%s - sse8_16bit#3 %.3f usec sse=%d %s\n", cpu->name, t, sse, (sse!=146340935)?"| ERROR": ""); TEST_SSE(sse8_16bit, Src2, Src3, 16); printf("%s - sse8_16bit#4 %.3f usec sse=%d %s\n", cpu->name, t, sse, (sse!=130136661)?"| ERROR": ""); TEST_SSE(sse8_16bit, Src2, Src4, 16); printf("%s - sse8_16bit#5 %.3f usec sse=%d %s\n", cpu->name, t, sse, (sse!=136870353)?"| ERROR": ""); TEST_SSE(sse8_16bit, Src3, Src4, 16); printf("%s - sse8_16bit#6 %.3f usec sse=%d %s\n", cpu->name, t, sse, (sse!=164107772)?"| ERROR": ""); /* 8 bit element blocks */ TEST_SSE(sse8_8bit, (int8_t*)Src1, (int8_t*)Src2, 8); printf("%s - sse8_8bit#1 %.3f usec sse=%d %s\n", cpu->name, t, sse, (sse!=1356423)?"| ERROR": ""); TEST_SSE(sse8_8bit, (int8_t*)Src1, (int8_t*)Src3, 8); printf("%s - sse8_8bit#2 %.3f usec sse=%d %s\n", cpu->name, t, sse, (sse!=1173074)?"| ERROR": ""); TEST_SSE(sse8_8bit, (int8_t*)Src1, (int8_t*)Src4, 8); printf("%s - sse8_8bit#3 %.3f usec sse=%d %s\n", cpu->name, t, sse, (sse!=1092357)?"| ERROR": ""); TEST_SSE(sse8_8bit, (int8_t*)Src2, (int8_t*)Src3, 8); printf("%s - sse8_8bit#4 %.3f usec sse=%d %s\n", cpu->name, t, sse, (sse!=1360239)?"| ERROR": ""); TEST_SSE(sse8_8bit, (int8_t*)Src2, (int8_t*)Src4, 8); printf("%s - sse8_8bit#5 %.3f usec sse=%d %s\n", cpu->name, t, sse, (sse!=1208414)?"| ERROR": ""); TEST_SSE(sse8_8bit, (int8_t*)Src3, (int8_t*)Src4, 8); printf("%s - sse8_8bit#6 %.3f usec sse=%d %s\n", cpu->name, t, sse, (sse!=1099285)?"| ERROR": ""); printf(" ---\n"); }}/********************************************************************* * test non-zero AC counting *********************************************************************/#define TEST_CBP(FUNC, SRC, NB) \t = gettime_usec(); \emms(); \for(tst=0; tst<NB; ++tst) { \ cbp = (FUNC)((SRC)); \} \emms(); \t = (gettime_usec()-t ) / nb_tests;void test_cbp(){ const int nb_tests = 10000*speed_ref; int i, n, m; CPU *cpu; DECLARE_ALIGNED_MATRIX(Src1, 6, 64, int16_t, 16); DECLARE_ALIGNED_MATRIX(Src2, 6, 64, int16_t, 16); DECLARE_ALIGNED_MATRIX(Src3, 6, 64, int16_t, 16); DECLARE_ALIGNED_MATRIX(Src4, 6, 64, int16_t, 16); DECLARE_ALIGNED_MATRIX(Src5, 6, 64, int16_t, 16); printf( "\n ===== test cbp =====\n" ); for(i=0; i<6*64; ++i) { Src1[i] = (i*i*3/8192)&(i/64)&1; /* 'random' */ Src2[i] = (i<3*64); /* half-full */ Src3[i] = ((i+32)>3*64); Src4[i] = (i==(3*64+2) || i==(5*64+9)); Src5[i] = ieee_rand(0,1) ? -1 : 1; /* +/- test */ } for(cpu = cpu_list; cpu->name!=0; ++cpu) { double t; int tst, cbp; if (!init_cpu(cpu)) continue; TEST_CBP(calc_cbp, Src1, nb_tests); printf("%s - calc_cbp#1 %.3f usec cbp=0x%02x %s\n",
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -