26 |
/***************************************************************************** |
/***************************************************************************** |
27 |
* |
* |
28 |
* 'Reference' output is at the end of file. |
* 'Reference' output is at the end of file. |
|
* Don't take the checksums and crc too seriouly, they aren't |
|
|
* bullet-proof (should plug some .md5 here)... |
|
29 |
* |
* |
30 |
* compiles with something like: |
* compiles with something like: |
31 |
* gcc -o xvid_bench xvid_bench.c -I../src/ -lxvidcore -lm |
* gcc -o xvid_bench xvid_bench.c -I../src/ -lxvidcore -lm |
119 |
, { "3DNOW ", XVID_CPU_3DNOW } |
, { "3DNOW ", XVID_CPU_3DNOW } |
120 |
, { "3DNOWE", XVID_CPU_3DNOW | XVID_CPU_3DNOWEXT } |
, { "3DNOWE", XVID_CPU_3DNOW | XVID_CPU_3DNOWEXT } |
121 |
#endif |
#endif |
122 |
|
#ifdef ARCH_IS_PPC |
123 |
|
, { "ALTIVEC", XVID_CPU_ALTIVEC } |
124 |
|
#endif |
125 |
|
#ifdef ARCH_IS_X86_64 |
126 |
|
, { "X86_64", XVID_CPU_ASM} |
127 |
|
#endif |
128 |
//, { "IA64 ", XVID_CPU_IA64 } |
//, { "IA64 ", XVID_CPU_IA64 } |
129 |
//, { "TSC ", XVID_CPU_TSC } |
//, { "TSC ", XVID_CPU_TSC } |
130 |
, { 0, 0 } }; |
, { 0, 0 } }; |
661 |
} \ |
} \ |
662 |
t = (gettime_usec()-t-overhead)/nb_tests/qm |
t = (gettime_usec()-t-overhead)/nb_tests/qm |
663 |
|
|
664 |
|
#define TEST_INTRA(REFFUNC, NEWFUNC, RANGE) \ |
665 |
|
{ int i,q,s;\ |
666 |
|
DECLARE_ALIGNED_MATRIX(Src, 8, 8, int16_t, 16); \ |
667 |
|
DECLARE_ALIGNED_MATRIX(Dst, 8, 8, int16_t, 16); \ |
668 |
|
DECLARE_ALIGNED_MATRIX(Dst2,8, 8, int16_t, 16); \ |
669 |
|
for(q=1;q<=max_Q;q++) \ |
670 |
|
for(s=-RANGE;s<RANGE;s++) { \ |
671 |
|
for(i=0;i<64;i++) Src[i]=s; \ |
672 |
|
(REFFUNC)((Dst),(Src),q,q,mpeg_quant_matrices); \ |
673 |
|
(NEWFUNC)((Dst2),(Src),q,q,mpeg_quant_matrices); \ |
674 |
|
for(i=0;i<64;i++) \ |
675 |
|
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]); \ |
676 |
|
} \ |
677 |
|
} |
678 |
|
|
679 |
|
#define TEST_INTER(REFFUNC, NEWFUNC, RANGE) \ |
680 |
|
{ int i,q,s; \ |
681 |
|
DECLARE_ALIGNED_MATRIX(Src, 8, 8, int16_t, 16); \ |
682 |
|
DECLARE_ALIGNED_MATRIX(Dst, 8, 8, int16_t, 16); \ |
683 |
|
DECLARE_ALIGNED_MATRIX(Dst2,8, 8, int16_t, 16); \ |
684 |
|
for(q=1;q<=max_Q;q++) \ |
685 |
|
for(s=-RANGE;s<RANGE;s++) { \ |
686 |
|
for(i=0;i<64;i++) Src[i]=s; \ |
687 |
|
(REFFUNC)((Dst),(Src),q,mpeg_quant_matrices); \ |
688 |
|
(NEWFUNC)((Dst2),(Src),q,mpeg_quant_matrices); \ |
689 |
|
emms(); \ |
690 |
|
for(i=0;i<64;i++) \ |
691 |
|
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]); \ |
692 |
|
} \ |
693 |
|
} |
694 |
|
|
695 |
void test_quant() |
void test_quant() |
696 |
{ |
{ |
697 |
const int nb_tests = 1*speed_ref; |
const int nb_tests = 1*speed_ref; |
702 |
CPU *cpu; |
CPU *cpu; |
703 |
DECLARE_ALIGNED_MATRIX(Src, 8, 8, int16_t, 16); |
DECLARE_ALIGNED_MATRIX(Src, 8, 8, int16_t, 16); |
704 |
DECLARE_ALIGNED_MATRIX(Dst, 8, 8, int16_t, 16); |
DECLARE_ALIGNED_MATRIX(Dst, 8, 8, int16_t, 16); |
705 |
|
DECLARE_ALIGNED_MATRIX(Dst2,8, 8, int16_t, 16); |
706 |
uint8_t Quant[8*8]; |
uint8_t Quant[8*8]; |
707 |
|
|
708 |
printf( "\n ===== test quant =====\n" ); |
printf( "\n ===== test quant =====\n" ); |
723 |
if (!init_cpu(cpu)) |
if (!init_cpu(cpu)) |
724 |
continue; |
continue; |
725 |
|
|
726 |
|
// exhaustive tests to compare against the (ref) C-version |
727 |
|
TEST_INTRA(quant_h263_intra_c, quant_h263_intra, 2048); |
728 |
|
TEST_INTRA(dequant_h263_intra_c, dequant_h263_intra , 512 ); |
729 |
|
TEST_INTER(quant_h263_inter_c, quant_h263_inter , 2048); |
730 |
|
TEST_INTER(dequant_h263_inter_c, dequant_h263_inter , 512 ); |
731 |
|
|
732 |
overhead = -gettime_usec(); |
overhead = -gettime_usec(); |
733 |
for(s=0,qm=1; qm<=255; ++qm) { |
for(s=0,qm=1; qm<=255; ++qm) { |
734 |
for(i=0; i<8*8; ++i) Quant[i] = qm; |
for(i=0; i<8*8; ++i) Quant[i] = qm; |
783 |
} |
} |
784 |
|
|
785 |
/********************************************************************* |
/********************************************************************* |
786 |
|
* test distortion operators |
787 |
|
*********************************************************************/ |
788 |
|
|
789 |
|
static void ieee_reseed(long s); |
790 |
|
static long ieee_rand(int Min, int Max); |
791 |
|
|
792 |
|
#define TEST_SSE(FUNCTION, SRC1, SRC2, STRIDE) \ |
793 |
|
do { \ |
794 |
|
t = gettime_usec(); \ |
795 |
|
tst = nb_tests; \ |
796 |
|
while((tst--)>0) sse = (FUNCTION)((SRC1), (SRC2), (STRIDE)); \ |
797 |
|
emms(); \ |
798 |
|
t = (gettime_usec() - t)/(double)nb_tests; \ |
799 |
|
} while(0) |
800 |
|
|
801 |
|
|
802 |
|
void test_sse() |
803 |
|
{ |
804 |
|
const int nb_tests = 100000*speed_ref; |
805 |
|
int i; |
806 |
|
CPU *cpu; |
807 |
|
DECLARE_ALIGNED_MATRIX(Src1, 8, 8, int16_t, 16); |
808 |
|
DECLARE_ALIGNED_MATRIX(Src2, 8, 8, int16_t, 16); |
809 |
|
DECLARE_ALIGNED_MATRIX(Src3, 8, 8, int16_t, 16); |
810 |
|
DECLARE_ALIGNED_MATRIX(Src4, 8, 8, int16_t, 16); |
811 |
|
|
812 |
|
printf( "\n ===== test sse =====\n" ); |
813 |
|
|
814 |
|
ieee_reseed(1); |
815 |
|
for(i=0; i<64; ++i) { |
816 |
|
Src1[i] = ieee_rand(-2048, 2047); |
817 |
|
Src2[i] = ieee_rand(-2048, 2047); |
818 |
|
Src3[i] = ieee_rand(-2048, 2047); |
819 |
|
Src4[i] = ieee_rand(-2048, 2047); |
820 |
|
} |
821 |
|
|
822 |
|
for(cpu = cpu_list; cpu->name!=0; ++cpu) |
823 |
|
{ |
824 |
|
double t; |
825 |
|
int tst, sse; |
826 |
|
|
827 |
|
if (!init_cpu(cpu)) |
828 |
|
continue; |
829 |
|
|
830 |
|
/* 16 bit element blocks */ |
831 |
|
TEST_SSE(sse8_16bit, Src1, Src2, 16); |
832 |
|
printf("%s - sse8_16bit#1 %.3f usec sse=%d %s\n", |
833 |
|
cpu->name, t, sse, (sse!=182013834)?"| ERROR": ""); |
834 |
|
TEST_SSE(sse8_16bit, Src1, Src3, 16); |
835 |
|
printf("%s - sse8_16bit#2 %.3f usec sse=%d %s\n", |
836 |
|
cpu->name, t, sse, (sse!=142545203)?"| ERROR": ""); |
837 |
|
TEST_SSE(sse8_16bit, Src1, Src4, 16); |
838 |
|
printf("%s - sse8_16bit#3 %.3f usec sse=%d %s\n", |
839 |
|
cpu->name, t, sse, (sse!=146340935)?"| ERROR": ""); |
840 |
|
TEST_SSE(sse8_16bit, Src2, Src3, 16); |
841 |
|
printf("%s - sse8_16bit#4 %.3f usec sse=%d %s\n", |
842 |
|
cpu->name, t, sse, (sse!=130136661)?"| ERROR": ""); |
843 |
|
TEST_SSE(sse8_16bit, Src2, Src4, 16); |
844 |
|
printf("%s - sse8_16bit#5 %.3f usec sse=%d %s\n", |
845 |
|
cpu->name, t, sse, (sse!=136870353)?"| ERROR": ""); |
846 |
|
TEST_SSE(sse8_16bit, Src3, Src4, 16); |
847 |
|
printf("%s - sse8_16bit#6 %.3f usec sse=%d %s\n", |
848 |
|
cpu->name, t, sse, (sse!=164107772)?"| ERROR": ""); |
849 |
|
|
850 |
|
/* 8 bit element blocks */ |
851 |
|
TEST_SSE(sse8_8bit, (int8_t*)Src1, (int8_t*)Src2, 8); |
852 |
|
printf("%s - sse8_8bit#1 %.3f usec sse=%d %s\n", |
853 |
|
cpu->name, t, sse, (sse!=1356423)?"| ERROR": ""); |
854 |
|
TEST_SSE(sse8_8bit, (int8_t*)Src1, (int8_t*)Src3, 8); |
855 |
|
printf("%s - sse8_8bit#2 %.3f usec sse=%d %s\n", |
856 |
|
cpu->name, t, sse, (sse!=1173074)?"| ERROR": ""); |
857 |
|
TEST_SSE(sse8_8bit, (int8_t*)Src1, (int8_t*)Src4, 8); |
858 |
|
printf("%s - sse8_8bit#3 %.3f usec sse=%d %s\n", |
859 |
|
cpu->name, t, sse, (sse!=1092357)?"| ERROR": ""); |
860 |
|
TEST_SSE(sse8_8bit, (int8_t*)Src2, (int8_t*)Src3, 8); |
861 |
|
printf("%s - sse8_8bit#4 %.3f usec sse=%d %s\n", |
862 |
|
cpu->name, t, sse, (sse!=1360239)?"| ERROR": ""); |
863 |
|
TEST_SSE(sse8_8bit, (int8_t*)Src2, (int8_t*)Src4, 8); |
864 |
|
printf("%s - sse8_8bit#5 %.3f usec sse=%d %s\n", |
865 |
|
cpu->name, t, sse, (sse!=1208414)?"| ERROR": ""); |
866 |
|
TEST_SSE(sse8_8bit, (int8_t*)Src3, (int8_t*)Src4, 8); |
867 |
|
printf("%s - sse8_8bit#6 %.3f usec sse=%d %s\n", |
868 |
|
cpu->name, t, sse, (sse!=1099285)?"| ERROR": ""); |
869 |
|
|
870 |
|
printf(" ---\n"); |
871 |
|
} |
872 |
|
} |
873 |
|
|
874 |
|
/********************************************************************* |
875 |
* test non-zero AC counting |
* test non-zero AC counting |
876 |
*********************************************************************/ |
*********************************************************************/ |
877 |
|
|
912 |
continue; |
continue; |
913 |
|
|
914 |
TEST_CBP(calc_cbp, Src1); |
TEST_CBP(calc_cbp, Src1); |
915 |
printf("%s - calc_cbp#1 %.3f usec cbp=0x%02x\n", |
printf("%s - calc_cbp#1 %.3f usec cbp=0x%02x %s\n", |
916 |
cpu->name, t, cbp, (cbp!=0x15)?"| ERROR": ""); |
cpu->name, t, cbp, (cbp!=0x15)?"| ERROR": ""); |
917 |
TEST_CBP(calc_cbp, Src2); |
TEST_CBP(calc_cbp, Src2); |
918 |
printf("%s - calc_cbp#2 %.3f usec cbp=0x%02x\n", |
printf("%s - calc_cbp#2 %.3f usec cbp=0x%02x %s\n", |
919 |
cpu->name, t, cbp, (cbp!=0x38)?"| ERROR": ""); |
cpu->name, t, cbp, (cbp!=0x38)?"| ERROR": ""); |
920 |
TEST_CBP(calc_cbp, Src3); |
TEST_CBP(calc_cbp, Src3); |
921 |
printf("%s - calc_cbp#3 %.3f usec cbp=0x%02x\n", |
printf("%s - calc_cbp#3 %.3f usec cbp=0x%02x %s\n", |
922 |
cpu->name, t, cbp, (cbp!=0x0f)?"| ERROR": "" ); |
cpu->name, t, cbp, (cbp!=0x0f)?"| ERROR": "" ); |
923 |
TEST_CBP(calc_cbp, Src4); |
TEST_CBP(calc_cbp, Src4); |
924 |
printf("%s - calc_cbp#4 %.3f usec cbp=0x%02x\n", |
printf("%s - calc_cbp#4 %.3f usec cbp=0x%02x %s\n", |
925 |
cpu->name, t, cbp, (cbp!=0x05)?"| ERROR": "" ); |
cpu->name, t, cbp, (cbp!=0x05)?"| ERROR": "" ); |
926 |
printf( " --- \n" ); |
printf( " --- \n" ); |
927 |
} |
} |
1591 |
if (what==0 || what==4) test_transfer(); |
if (what==0 || what==4) test_transfer(); |
1592 |
if (what==0 || what==5) test_quant(); |
if (what==0 || what==5) test_quant(); |
1593 |
if (what==0 || what==6) test_cbp(); |
if (what==0 || what==6) test_cbp(); |
1594 |
|
if (what==0 || what==10) test_sse(); |
1595 |
|
|
1596 |
if (what==7) { |
if (what==7) { |
1597 |
test_IEEE1180_compliance(-256, 255, 1); |
test_IEEE1180_compliance(-256, 255, 1); |
1621 |
if (what==-2) |
if (what==-2) |
1622 |
test_quant_bug(); |
test_quant_bug(); |
1623 |
|
|
1624 |
if (what >= 0 && what <= 6) { |
if ((what >= 0 && what <= 6) || what == 10) { |
1625 |
printf("\n\n" |
printf("\n\n" |
1626 |
"NB: If a function isn't optimised for a specific set of intructions,\n" |
"NB: If a function isn't optimised for a specific set of intructions,\n" |
1627 |
" a C function is used instead. So don't panic if some functions\n" |
" a C function is used instead. So don't panic if some functions\n" |