📄 checkasm.c.svn-base
字号:
ok = 1; used_asm = 0; for( dy = 0; dy < 9; dy++ ) for( dx = 0; dx < 9; dx++ ) { MC_TEST_CHROMA( 8, 8 ); MC_TEST_CHROMA( 8, 4 ); MC_TEST_CHROMA( 4, 8 ); MC_TEST_CHROMA( 4, 4 ); MC_TEST_CHROMA( 4, 2 ); MC_TEST_CHROMA( 2, 4 ); MC_TEST_CHROMA( 2, 2 ); } report( "mc chroma :" );#undef MC_TEST_LUMA#undef MC_TEST_CHROMA#define MC_TEST_AVG( name, ... ) \ for( i = 0, ok = 1, used_asm = 0; i < 10; i++ ) \ { \ memcpy( buf3, buf1, 1024 ); \ memcpy( buf4, buf1, 1024 ); \ if( mc_a.name[i] != mc_ref.name[i] ) \ { \ used_asm = 1; \ mc_c.name[i]( buf3, 32, buf2, 24, ##__VA_ARGS__ ); \ mc_a.name[i]( buf4, 32, buf2, 24, ##__VA_ARGS__ ); \ if( memcmp( buf3, buf4, 1024 ) ) \ { \ ok = 0; \ fprintf( stderr, #name "[%d]: [FAILED]\n", i ); \ } \ } \ } MC_TEST_AVG( avg ); report( "mc avg :" ); for( w = -64; w <= 128 && ok; w++ ) MC_TEST_AVG( avg_weight, w ); report( "mc wpredb :" ); return ret;}static int check_deblock( int cpu_ref, int cpu_new ){ x264_deblock_function_t db_c; x264_deblock_function_t db_ref; x264_deblock_function_t db_a; int ret = 0, ok = 1, used_asm = 0; int alphas[36], betas[36]; int8_t tcs[36][4]; int a, c, i, j; x264_deblock_init( 0, &db_c ); x264_deblock_init( cpu_ref, &db_ref ); x264_deblock_init( cpu_new, &db_a ); /* not exactly the real values of a,b,tc but close enough */ a = 255; c = 250; for( i = 35; i >= 0; i-- ) { alphas[i] = a; betas[i] = (i+1)/2; tcs[i][0] = tcs[i][2] = (c+6)/10; tcs[i][1] = tcs[i][3] = (c+9)/20; a = a*9/10; c = c*9/10; }#define TEST_DEBLOCK( name, ... ) \ for( i = 0; i < 36; i++ ) \ { \ for( j = 0; j < 1024; j++ ) \ /* two distributions of random to excersize different failure modes */\ buf1[j] = rand() & (i&1 ? 0xf : 0xff ); \ memcpy( buf3, buf1, 1024 ); \ memcpy( buf4, buf1, 1024 ); \ if( db_a.name != db_ref.name ) \ { \ used_asm = 1; \ db_c.name( &buf3[8*32], 32, alphas[i], betas[i], ##__VA_ARGS__ ); \ db_a.name( &buf4[8*32], 32, alphas[i], betas[i], ##__VA_ARGS__ ); \ if( memcmp( buf3, buf4, 1024 ) ) \ { \ ok = 0; \ fprintf( stderr, #name "(a=%d, b=%d): [FAILED]\n", alphas[i], betas[i] ); \ break; \ } \ } \ } TEST_DEBLOCK( deblock_h_luma, tcs[i] ); TEST_DEBLOCK( deblock_v_luma, tcs[i] ); TEST_DEBLOCK( deblock_h_chroma, tcs[i] ); TEST_DEBLOCK( deblock_v_chroma, tcs[i] ); TEST_DEBLOCK( deblock_h_luma_intra ); TEST_DEBLOCK( deblock_v_luma_intra ); TEST_DEBLOCK( deblock_h_chroma_intra ); TEST_DEBLOCK( deblock_v_chroma_intra ); report( "deblock :" ); return ret;}static int check_quant( int cpu_ref, int cpu_new ){ x264_quant_function_t qf_c; x264_quant_function_t qf_ref; x264_quant_function_t qf_a; int16_t dct1[64], dct2[64]; uint8_t cqm_buf[64]; int ret = 0, ok, used_asm; int oks[2] = {1,1}, used_asms[2] = {0,0}; int i, i_cqm; x264_t h_buf; x264_t *h = &h_buf; h->pps = h->pps_array; x264_param_default( &h->param ); for( i_cqm = 0; i_cqm < 4; i_cqm++ ) { if( i_cqm == 0 ) for( i = 0; i < 6; i++ ) h->pps->scaling_list[i] = x264_cqm_flat16; else if( i_cqm == 1 ) for( i = 0; i < 6; i++ ) h->pps->scaling_list[i] = x264_cqm_jvt[i]; else { if( i_cqm == 2 ) for( i = 0; i < 64; i++ ) cqm_buf[i] = 10 + rand() % 246; else for( i = 0; i < 64; i++ ) cqm_buf[i] = 1; for( i = 0; i < 6; i++ ) h->pps->scaling_list[i] = cqm_buf; } x264_cqm_init( h ); x264_quant_init( h, 0, &qf_c ); x264_quant_init( h, cpu_ref, &qf_ref ); x264_quant_init( h, cpu_new, &qf_a );#define TEST_QUANT( name, cqm ) \ if( qf_a.name != qf_ref.name ) \ { \ used_asms[0] = 1; \ for( i = 0; i < 64; i++ ) \ dct1[i] = dct2[i] = (rand() & 0x1fff) - 0xfff; \ qf_c.name( (void*)dct1, cqm, 20, (1<<20)/6 ); \ qf_a.name( (void*)dct2, cqm, 20, (1<<20)/6 ); \ if( memcmp( dct1, dct2, 64*2 ) ) \ { \ oks[0] = 0; \ fprintf( stderr, #name "(cqm=%d): [FAILED]\n", i_cqm ); \ } \ } TEST_QUANT( quant_8x8_core, *h->quant8_mf[CQM_8IY] ); TEST_QUANT( quant_8x8_core, *h->quant8_mf[CQM_8PY] ); TEST_QUANT( quant_4x4_core, *h->quant4_mf[CQM_4IY] ); TEST_QUANT( quant_4x4_core, *h->quant4_mf[CQM_4PY] ); TEST_QUANT( quant_4x4_dc_core, ***h->quant4_mf[CQM_4IY] ); TEST_QUANT( quant_2x2_dc_core, ***h->quant4_mf[CQM_4IC] );#define TEST_DEQUANT( name, quant, dqm, cqm, shift ) \ if( qf_a.name != qf_ref.name ) \ { \ int qp; \ used_asms[1] = 1; \ for( qp = 51; qp > 0; qp-- ) \ { \ for( i = 0; i < 64; i++ ) \ dct1[i] = dct2[i] = (rand() & 0x1fff) - 0xfff; \ qf_c.quant( (void*)dct1, cqm[qp%6], shift+qp/6, 0 ); \ memcpy( dct2, dct1, sizeof(dct2) ); \ qf_c.name( (void*)dct1, dqm, qp ); \ qf_a.name( (void*)dct2, dqm, qp ); \ if( memcmp( dct1, dct2, 64*2 ) ) \ { \ oks[1] = 0; \ fprintf( stderr, #name "(qp=%d, cqm=%d): [FAILED]\n", qp, i_cqm ); \ break; \ } \ } \ } TEST_DEQUANT( dequant_8x8, quant_8x8_core, h->dequant8_mf[CQM_8PY], h->quant8_mf[CQM_8PY], 16 ); TEST_DEQUANT( dequant_4x4, quant_4x4_core, h->dequant4_mf[CQM_4PY], h->quant4_mf[CQM_4PY], 15 ); } ok = oks[0]; used_asm = used_asms[0]; report( "quant :" ); ok = oks[1]; used_asm = used_asms[1]; report( "dequant :" ); return ret;}int check_all( int cpu_ref, int cpu_new ){ return check_pixel( cpu_ref, cpu_new ) + check_dct( cpu_ref, cpu_new ) + check_mc( cpu_ref, cpu_new ) + check_deblock( cpu_ref, cpu_new ) + check_quant( cpu_ref, cpu_new );}int main(){ int ret = 0; int i; buf1 = x264_malloc( 1024 ); /* 32 x 32 */ buf2 = x264_malloc( 1024 ); buf3 = x264_malloc( 1024 ); buf4 = x264_malloc( 1024 ); buf5 = x264_malloc( 1024 ); srand( x264_mdate() ); for( i = 0; i < 1024; i++ ) { buf1[i] = rand() & 0xFF; buf2[i] = rand() & 0xFF; buf3[i] = buf4[i] = 0; }#ifdef HAVE_MMXEXT fprintf( stderr, "x264: MMXEXT against C\n" ); ret = check_all( 0, X264_CPU_MMX | X264_CPU_MMXEXT );#ifdef HAVE_SSE2 if( x264_cpu_detect() & X264_CPU_SSE2 ) { fprintf( stderr, "\nx264: SSE2 against C\n" ); ret |= check_all( X264_CPU_MMX | X264_CPU_MMXEXT, X264_CPU_MMX | X264_CPU_MMXEXT | X264_CPU_SSE | X264_CPU_SSE2 ); }#endif#elif ARCH_PPC fprintf( stderr, "x264: ALTIVEC against C\n" ); ret = check_all( 0, X264_CPU_ALTIVEC );#endif if( ret == 0 ) { fprintf( stderr, "x264: All tests passed Yeah :)\n" ); return 0; } fprintf( stderr, "x264: at least one test has failed. Go and fix that Right Now!\n" ); return -1;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -