⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xvid_bench.c

📁 TMS320C6713Xvid视频压缩算法源代码.rar
💻 C
📖 第 1 页 / 共 4 页
字号:
		3, 1, 2, 3, 1, 2, 2, 6, 2             ,0,0,0, 0,0,0,0,		1, 0, 1, 3, 0, 3, 1, 6, 1             ,0,0,0, 0,0,0,0,		4, 3, 2, 1, 2, 3, 4, 0, 3             ,0,0,0, 0,0,0,0	};	uint8_t Dst[16*8] = {0};	printf( "\n ===  test block motion ===\n" );	for(cpu = cpu_list; cpu->name!=0; ++cpu)	{		double t;		int tst, i, iCrc;		if (!init_cpu(cpu))			continue;		TEST_MB(interpolate8x8_halfpel_h, 0);		printf("%s - interp- h-round0 %.3f usec       crc32=0x%08x %s\n",			   cpu->name, t, iCrc,			   (iCrc!=0x115381ba)?"| ERROR": "" );		TEST_MB(interpolate8x8_halfpel_h, 1);		printf("%s -           round1 %.3f usec       crc32=0x%08x %s\n",			   cpu->name, t, iCrc,			   (iCrc!=0x2b1f528f)?"| ERROR": "" );		TEST_MB(interpolate8x8_halfpel_v, 0);		printf("%s - interp- v-round0 %.3f usec       crc32=0x%08x %s\n",			   cpu->name, t, iCrc,			   (iCrc!=0x423cdcc7)?"| ERROR": "" );		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		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;\s = calc_crc((uint8_t*)(DST), sizeof((DST)), 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;\s = calc_crc((uint8_t*)(DST), sizeof((DST)), 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];	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": "");		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, sizeof(Dst16), CRC32_INITIAL);			s2 = calc_crc((uint8_t*)Src8, sizeof(Src8), 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);              \	s = calc_crc((uint8_t*)(DST), 64*sizeof(int16_t), 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);           \	s = calc_crc((uint8_t*)(DST), 64*sizeof(int16_t), 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 non-zero AC counting *********************************************************************/#define TEST_CBP(FUNC, SRC)               \t = gettime_usec();                       \emms();                                   \for(tst=0; tst<nb_tests; ++tst) {         \  cbp = (FUNC)((SRC));                    \}                                         \emms();                                   \t = (gettime_usec()-t ) / nb_tests;void test_cbp(){	const int nb_tests = 10000*speed_ref;	int i;	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);	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));	}	for(cpu = cpu_list; cpu->name!=0; ++cpu)	{		double t;		int tst, cbp;		if (!init_cpu(cpu))			continue;		TEST_CBP(calc_cbp, Src1);		printf("%s -   calc_cbp#1 %.3f usec       cbp=0x%02x\n",			   cpu->name, t, cbp, (cbp!=0x15)?"| ERROR": "");		TEST_CBP(calc_cbp, Src2);		printf("%s -   calc_cbp#2 %.3f usec       cbp=0x%02x\n",			   cpu->name, t, cbp, (cbp!=0x38)?"| ERROR": "");		TEST_CBP(calc_cbp, Src3);		printf("%s -   calc_cbp#3 %.3f usec       cbp=0x%02x\n",			   cpu->name, t, cbp, (cbp!=0x0f)?"| ERROR": "" );		TEST_CBP(calc_cbp, Src4);		printf("%s -   calc_cbp#4 %.3f usec       cbp=0x%02x\n",			   cpu->name, t, cbp, (cbp!=0x05)?"| ERROR": "" );		printf( " --- \n" );	}}/********************************************************************* * fdct/idct IEEE1180 compliance *********************************************************************/typedef struct {	long Errors[64];	long Sqr_Errors[64];	long Max_Errors[64];	long Nb;} STATS_8x8;void init_stats(STATS_8x8 *S){	int i;	for(i=0; i<64; ++i) {		S->Errors[i]     = 0;		S->Sqr_Errors[i] = 0;		S->Max_Errors[i] = 0;	}	S->Nb = 0;}void store_stats(STATS_8x8 *S, short Blk[64], short Ref[64]){	int i;	for(i=0; i<64; ++i)	{		short Err = Blk[i] - Ref[i];		S->Errors[i] += Err;		S->Sqr_Errors[i] += Err * Err;		if (Err<0) Err = -Err;		if (S->Max_Errors[i]<Err)			S->Max_Errors[i] = Err;	}	S->Nb++;}void print_stats(STATS_8x8 *S){	int i;	double Norm;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -