6 #include "common/common.h"
7 #include "common/cpu.h"
9 #include "common/i386/pixel.h"
10 #include "common/i386/dct.h"
11 #include "common/i386/mc.h"
14 #include "common/ppc/pixel.h"
15 #include "common/ppc/mc.h"
18 /* buf1, buf2: initialised to random data and shouldn't write into them */
19 uint8_t * buf1, * buf2;
20 /* buf3, buf4: used to store output */
21 uint8_t * buf3, * buf4;
25 #define report( name ) { \
27 fprintf( stderr, " - %-21s [%s]\n", name, ok ? "OK" : "FAILED" ); \
31 static int check_pixel( int cpu_ref, int cpu_new )
33 x264_pixel_function_t pixel_c;
34 x264_pixel_function_t pixel_ref;
35 x264_pixel_function_t pixel_asm;
36 x264_predict_t predict_16x16[4+3];
37 x264_predict_t predict_8x8c[4+3];
38 x264_predict_t predict_4x4[9+3];
39 x264_predict8x8_t predict_8x8[9+3];
40 DECLARE_ALIGNED( uint8_t, edge[33], 8 );
41 int ret = 0, ok, used_asm;
44 x264_pixel_init( 0, &pixel_c );
45 x264_pixel_init( cpu_ref, &pixel_ref );
46 x264_pixel_init( cpu_new, &pixel_asm );
47 x264_predict_16x16_init( 0, predict_16x16 );
48 x264_predict_8x8c_init( 0, predict_8x8c );
49 x264_predict_8x8_init( 0, predict_8x8 );
50 x264_predict_4x4_init( 0, predict_4x4 );
51 x264_predict_8x8_filter( buf2+40, edge, ALL_NEIGHBORS, ALL_NEIGHBORS );
53 #define TEST_PIXEL( name ) \
54 for( i = 0, ok = 1, used_asm = 0; i < 7; i++ ) \
57 if( pixel_asm.name[i] != pixel_ref.name[i] ) \
60 res_c = pixel_c.name[i]( buf1, 32, buf2, 16 ); \
61 res_asm = pixel_asm.name[i]( buf1, 32, buf2, 16 ); \
62 if( res_c != res_asm ) \
65 fprintf( stderr, #name "[%d]: %d != %d [FAILED]\n", i, res_c, res_asm ); \
69 report( "pixel " #name " :" );
76 #define TEST_PIXEL_X( N ) \
77 for( i = 0, ok = 1, used_asm = 0; i < 7; i++ ) \
79 int res_c[4]={0}, res_asm[4]={0}; \
80 if( pixel_asm.sad_x##N[i] && pixel_asm.sad_x##N[i] != pixel_ref.sad_x##N[i] ) \
83 res_c[0] = pixel_c.sad[i]( buf1, 16, buf2, 32 ); \
84 res_c[1] = pixel_c.sad[i]( buf1, 16, buf2+30, 32 ); \
85 res_c[2] = pixel_c.sad[i]( buf1, 16, buf2+1, 32 ); \
88 res_c[3] = pixel_c.sad[i]( buf1, 16, buf2+99, 32 ); \
89 pixel_asm.sad_x4[i]( buf1, buf2, buf2+30, buf2+1, buf2+99, 32, res_asm ); \
92 pixel_asm.sad_x3[i]( buf1, buf2, buf2+30, buf2+1, 32, res_asm ); \
93 if( memcmp(res_c, res_asm, sizeof(res_c)) ) \
96 fprintf( stderr, "sad_x"#N"[%d]: %d,%d,%d,%d != %d,%d,%d,%d [FAILED]\n", \
97 i, res_c[0], res_c[1], res_c[2], res_c[3], \
98 res_asm[0], res_asm[1], res_asm[2], res_asm[3] ); \
102 report( "pixel sad_x"#N" :" );
107 #define TEST_INTRA_SATD( name, pred, satd, i8x8, ... ) \
108 if( pixel_asm.name && pixel_asm.name != pixel_ref.name ) \
110 int res_c[3], res_asm[3]; \
112 memcpy( buf3, buf2, 1024 ); \
113 for( i=0; i<3; i++ ) \
115 pred[i]( buf3+40, ##__VA_ARGS__ ); \
116 res_c[i] = pixel_c.satd( buf1+40, 16, buf3+40, 32 ); \
118 pixel_asm.name( buf1+40, i8x8 ? edge : buf3+40, res_asm ); \
119 if( memcmp(res_c, res_asm, sizeof(res_c)) ) \
122 fprintf( stderr, #name": %d,%d,%d != %d,%d,%d [FAILED]\n", \
123 res_c[0], res_c[1], res_c[2], \
124 res_asm[0], res_asm[1], res_asm[2] ); \
128 ok = 1; used_asm = 0;
129 TEST_INTRA_SATD( intra_satd_x3_16x16, predict_16x16, satd[PIXEL_16x16], 0 );
130 TEST_INTRA_SATD( intra_satd_x3_8x8c, predict_8x8c, satd[PIXEL_8x8], 0 );
131 TEST_INTRA_SATD( intra_satd_x3_4x4, predict_4x4, satd[PIXEL_4x4], 0 );
132 TEST_INTRA_SATD( intra_sa8d_x3_8x8, predict_8x8, sa8d[PIXEL_8x8], 1, edge );
133 report( "intra satd_x3 :" );
135 if( pixel_asm.ssim_4x4x2_core != pixel_ref.ssim_4x4x2_core ||
136 pixel_asm.ssim_end4 != pixel_ref.ssim_end4 )
140 x264_cpu_restore( cpu_new );
141 res_c = x264_pixel_ssim_wxh( &pixel_c, buf1+2, 32, buf2+2, 32, 32, 28 );
142 res_a = x264_pixel_ssim_wxh( &pixel_asm, buf1+2, 32, buf2+2, 32, 32, 28 );
143 if( fabs(res_c - res_a) > 1e-8 )
146 fprintf( stderr, "ssim: %.7f != %.7f [FAILED]\n", res_c, res_a );
151 ok = 1; used_asm = 0;
153 if( pixel_asm.ads[i] != pixel_ref.ads[i] )
155 uint16_t res_a[32], res_c[32];
158 for( j=0; j<72; j++ )
159 sums[j] = rand() & 0x3fff;
161 dc[j] = rand() & 0x3fff;
163 pixel_c.ads[i]( dc, sums, 32, res_c, 32 );
164 pixel_asm.ads[i]( dc, sums, 32, res_a, 32 );
165 if( memcmp(res_a, res_c, sizeof(res_c)) )
168 report( "esa ads:" );
173 static int check_dct( int cpu_ref, int cpu_new )
175 x264_dct_function_t dct_c;
176 x264_dct_function_t dct_ref;
177 x264_dct_function_t dct_asm;
178 int ret = 0, ok, used_asm;
179 int16_t dct1[16][4][4] __attribute__((aligned(16)));
180 int16_t dct2[16][4][4] __attribute__((aligned(16)));
182 x264_dct_init( 0, &dct_c );
183 x264_dct_init( cpu_ref, &dct_ref);
184 x264_dct_init( cpu_new, &dct_asm );
185 #define TEST_DCT( name, t1, t2, size ) \
186 if( dct_asm.name != dct_ref.name ) \
189 dct_c.name( t1, buf1, buf2 ); \
190 dct_asm.name( t2, buf1, buf2 ); \
191 if( memcmp( t1, t2, size ) ) \
194 fprintf( stderr, #name " [FAILED]\n" ); \
197 ok = 1; used_asm = 0;
198 TEST_DCT( sub4x4_dct, dct1[0], dct2[0], 16*2 );
199 TEST_DCT( sub8x8_dct, dct1, dct2, 16*2*4 );
200 TEST_DCT( sub16x16_dct, dct1, dct2, 16*2*16 );
201 report( "sub_dct4 :" );
203 ok = 1; used_asm = 0;
204 TEST_DCT( sub8x8_dct8, (void*)dct1[0], (void*)dct2[0], 64*2 );
205 TEST_DCT( sub16x16_dct8, (void*)dct1, (void*)dct2, 64*2*4 );
206 report( "sub_dct8 :" );
209 /* copy coefs because idct8 modifies them in place */
210 memcpy( buf5, dct1, 512 );
212 #define TEST_IDCT( name ) \
213 if( dct_asm.name != dct_ref.name ) \
216 memcpy( buf3, buf1, 32*32 ); \
217 memcpy( buf4, buf1, 32*32 ); \
218 memcpy( dct1, buf5, 512 ); \
219 memcpy( dct2, buf5, 512 ); \
220 dct_c.name( buf3, (void*)dct1 ); \
221 dct_asm.name( buf4, (void*)dct2 ); \
222 if( memcmp( buf3, buf4, 32*32 ) ) \
225 fprintf( stderr, #name " [FAILED]\n" ); \
228 ok = 1; used_asm = 0;
229 TEST_IDCT( add4x4_idct );
230 TEST_IDCT( add8x8_idct );
231 TEST_IDCT( add16x16_idct );
232 report( "add_idct4 :" );
234 ok = 1; used_asm = 0;
235 TEST_IDCT( add8x8_idct8 );
236 TEST_IDCT( add16x16_idct8 );
237 report( "add_idct8 :" );
240 ok = 1; used_asm = 0;
241 if( dct_asm.dct4x4dc != dct_ref.dct4x4dc )
243 int16_t dct1[4][4] __attribute((aligned(16))) = { {-12, 42, 23, 67},{2, 90, 89,56}, {67,43,-76,91},{56,-78,-54,1}};
244 int16_t dct2[4][4] __attribute((aligned(16))) = { {-12, 42, 23, 67},{2, 90, 89,56}, {67,43,-76,91},{56,-78,-54,1}};
246 dct_c.dct4x4dc( dct1 );
247 dct_asm.dct4x4dc( dct2 );
248 if( memcmp( dct1, dct2, 32 ) )
251 fprintf( stderr, " - dct4x4dc : [FAILED]\n" );
254 if( dct_asm.dct4x4dc != dct_ref.dct4x4dc )
256 int16_t dct1[4][4] __attribute((aligned(16))) = { {-12, 42, 23, 67},{2, 90, 89,56}, {67,43,-76,91},{56,-78,-54,1}};
257 int16_t dct2[4][4] __attribute((aligned(16))) = { {-12, 42, 23, 67},{2, 90, 89,56}, {67,43,-76,91},{56,-78,-54,1}};
259 dct_c.idct4x4dc( dct1 );
260 dct_asm.idct4x4dc( dct2 );
261 if( memcmp( dct1, dct2, 32 ) )
264 fprintf( stderr, " - idct4x4dc : [FAILED]\n" );
267 report( "(i)dct4x4dc :" );
269 ok = 1; used_asm = 0;
270 if( dct_asm.dct2x2dc != dct_ref.dct2x2dc )
272 int16_t dct1[2][2] __attribute((aligned(16))) = { {-12, 42},{2, 90}};
273 int16_t dct2[2][2] __attribute((aligned(16))) = { {-12, 42},{2, 90}};
275 dct_c.dct2x2dc( dct1 );
276 dct_asm.dct2x2dc( dct2 );
277 if( memcmp( dct1, dct2, 4*2 ) )
280 fprintf( stderr, " - dct2x2dc : [FAILED]\n" );
283 if( dct_asm.idct2x2dc != dct_ref.idct2x2dc )
285 int16_t dct1[2][2] __attribute((aligned(16))) = { {-12, 42},{2, 90}};
286 int16_t dct2[2][2] __attribute((aligned(16))) = { {-12, 42},{2, 90}};
288 dct_c.idct2x2dc( dct1 );
289 dct_asm.idct2x2dc( dct2 );
290 if( memcmp( dct1, dct2, 4*2 ) )
293 fprintf( stderr, " - idct2x2dc : [FAILED]\n" );
296 report( "(i)dct2x2dc :" );
301 static int check_mc( int cpu_ref, int cpu_new )
303 x264_mc_functions_t mc_c;
304 x264_mc_functions_t mc_ref;
305 x264_mc_functions_t mc_a;
307 uint8_t *src = &buf1[2*32+2];
308 uint8_t *src2[4] = { &buf1[2*32+2], &buf1[7*32+2],
309 &buf1[12*32+2], &buf1[17*32+2] };
310 uint8_t *dst1 = &buf3[2*32+2];
311 uint8_t *dst2 = &buf4[2*32+2];
314 int ret = 0, ok, used_asm;
316 x264_mc_init( 0, &mc_c );
317 x264_mc_init( cpu_ref, &mc_ref );
318 x264_mc_init( cpu_new, &mc_a );
320 #define MC_TEST_LUMA( w, h ) \
321 if( mc_a.mc_luma != mc_ref.mc_luma ) \
324 memset(buf3, 0xCD, 1024); \
325 memset(buf4, 0xCD, 1024); \
326 mc_c.mc_luma( src2, 32, dst1, 16, dx, dy, w, h ); \
327 mc_a.mc_luma( src2, 32, dst2, 16, dx, dy, w, h ); \
328 if( memcmp( buf3, buf4, 1024 ) ) \
330 fprintf( stderr, "mc_luma[mv(%d,%d) %2dx%-2d] [FAILED]\n", dx, dy, w, h ); \
335 #define MC_TEST_CHROMA( w, h ) \
336 if( mc_a.mc_chroma != mc_ref.mc_chroma ) \
339 memset(buf3, 0xCD, 1024); \
340 memset(buf4, 0xCD, 1024); \
341 mc_c.mc_chroma( src, 32, dst1, 16, dx, dy, w, h ); \
342 mc_a.mc_chroma( src, 32, dst2, 16, dx, dy, w, h ); \
343 /* mc_chroma width=2 may write garbage to the right of dst. ignore that. */\
344 for( j=0; j<h; j++ ) \
345 for( i=w; i<4; i++ ) \
346 dst2[i+j*16] = dst1[i+j*16]; \
347 if( memcmp( buf3, buf4, 1024 ) ) \
349 fprintf( stderr, "mc_chroma[mv(%d,%d) %2dx%-2d] [FAILED]\n", dx, dy, w, h ); \
353 ok = 1; used_asm = 0;
354 for( dy = 0; dy < 4; dy++ )
355 for( dx = 0; dx < 4; dx++ )
357 MC_TEST_LUMA( 16, 16 );
358 MC_TEST_LUMA( 16, 8 );
359 MC_TEST_LUMA( 8, 16 );
360 MC_TEST_LUMA( 8, 8 );
361 MC_TEST_LUMA( 8, 4 );
362 MC_TEST_LUMA( 4, 8 );
363 MC_TEST_LUMA( 4, 4 );
365 report( "mc luma :" );
367 ok = 1; used_asm = 0;
368 for( dy = -1; dy < 9; dy++ )
369 for( dx = -1; dx < 9; dx++ )
371 MC_TEST_CHROMA( 8, 8 );
372 MC_TEST_CHROMA( 8, 4 );
373 MC_TEST_CHROMA( 4, 8 );
374 MC_TEST_CHROMA( 4, 4 );
375 MC_TEST_CHROMA( 4, 2 );
376 MC_TEST_CHROMA( 2, 4 );
377 MC_TEST_CHROMA( 2, 2 );
379 report( "mc chroma :" );
381 #undef MC_TEST_CHROMA
383 #define MC_TEST_AVG( name, ... ) \
384 for( i = 0, ok = 1, used_asm = 0; i < 10; i++ ) \
386 memcpy( buf3, buf1, 1024 ); \
387 memcpy( buf4, buf1, 1024 ); \
388 if( mc_a.name[i] != mc_ref.name[i] ) \
391 mc_c.name[i]( buf3, 32, buf2, 16, ##__VA_ARGS__ ); \
392 mc_a.name[i]( buf4, 32, buf2, 16, ##__VA_ARGS__ ); \
393 if( memcmp( buf3, buf4, 1024 ) ) \
396 fprintf( stderr, #name "[%d]: [FAILED]\n", i ); \
401 report( "mc avg :" );
402 for( w = -64; w <= 128 && ok; w++ )
403 MC_TEST_AVG( avg_weight, w );
404 report( "mc wpredb :" );
409 static int check_deblock( int cpu_ref, int cpu_new )
411 x264_deblock_function_t db_c;
412 x264_deblock_function_t db_ref;
413 x264_deblock_function_t db_a;
414 int ret = 0, ok = 1, used_asm = 0;
415 int alphas[36], betas[36];
419 x264_deblock_init( 0, &db_c );
420 x264_deblock_init( cpu_ref, &db_ref );
421 x264_deblock_init( cpu_new, &db_a );
423 /* not exactly the real values of a,b,tc but close enough */
425 for( i = 35; i >= 0; i-- )
429 tcs[i][0] = tcs[i][2] = (c+6)/10;
430 tcs[i][1] = tcs[i][3] = (c+9)/20;
435 #define TEST_DEBLOCK( name, ... ) \
436 for( i = 0; i < 36; i++ ) \
438 for( j = 0; j < 1024; j++ ) \
439 /* two distributions of random to excersize different failure modes */\
440 buf1[j] = rand() & (i&1 ? 0xf : 0xff ); \
441 memcpy( buf3, buf1, 1024 ); \
442 memcpy( buf4, buf1, 1024 ); \
443 if( db_a.name != db_ref.name ) \
446 db_c.name( &buf3[8*32], 32, alphas[i], betas[i], ##__VA_ARGS__ ); \
447 db_a.name( &buf4[8*32], 32, alphas[i], betas[i], ##__VA_ARGS__ ); \
448 if( memcmp( buf3, buf4, 1024 ) ) \
451 fprintf( stderr, #name "(a=%d, b=%d): [FAILED]\n", alphas[i], betas[i] ); \
457 TEST_DEBLOCK( deblock_h_luma, tcs[i] );
458 TEST_DEBLOCK( deblock_v_luma, tcs[i] );
459 TEST_DEBLOCK( deblock_h_chroma, tcs[i] );
460 TEST_DEBLOCK( deblock_v_chroma, tcs[i] );
461 TEST_DEBLOCK( deblock_h_luma_intra );
462 TEST_DEBLOCK( deblock_v_luma_intra );
463 TEST_DEBLOCK( deblock_h_chroma_intra );
464 TEST_DEBLOCK( deblock_v_chroma_intra );
466 report( "deblock :" );
471 static int check_quant( int cpu_ref, int cpu_new )
473 x264_quant_function_t qf_c;
474 x264_quant_function_t qf_ref;
475 x264_quant_function_t qf_a;
476 int16_t dct1[64] __attribute__((__aligned__(16)));
477 int16_t dct2[64] __attribute__((__aligned__(16)));
478 uint8_t cqm_buf[64] __attribute__((__aligned__(16)));
479 int ret = 0, ok, used_asm;
480 int oks[2] = {1,1}, used_asms[2] = {0,0};
484 h->pps = h->pps_array;
485 x264_param_default( &h->param );
486 h->param.rc.i_qp_min = 26;
488 for( i_cqm = 0; i_cqm < 4; i_cqm++ )
491 for( i = 0; i < 6; i++ )
492 h->pps->scaling_list[i] = x264_cqm_flat16;
493 else if( i_cqm == 1 )
494 for( i = 0; i < 6; i++ )
495 h->pps->scaling_list[i] = x264_cqm_jvt[i];
499 for( i = 0; i < 64; i++ )
500 cqm_buf[i] = 10 + rand() % 246;
502 for( i = 0; i < 64; i++ )
504 for( i = 0; i < 6; i++ )
505 h->pps->scaling_list[i] = cqm_buf;
509 x264_quant_init( h, 0, &qf_c );
510 x264_quant_init( h, cpu_ref, &qf_ref );
511 x264_quant_init( h, cpu_new, &qf_a );
513 #define INIT_QUANT8() \
515 static const int scale1d[8] = {32,31,24,31,32,31,24,31}; \
517 for( y = 0; y < 8; y++ ) \
518 for( x = 0; x < 8; x++ ) \
520 unsigned int scale = (255*scale1d[y]*scale1d[x])/16; \
521 dct1[y*8+x] = dct2[y*8+x] = (rand()%(2*scale+1))-scale; \
525 #define INIT_QUANT4() \
527 static const int scale1d[4] = {4,6,4,6}; \
529 for( y = 0; y < 4; y++ ) \
530 for( x = 0; x < 4; x++ ) \
532 unsigned int scale = 255*scale1d[y]*scale1d[x]; \
533 dct1[y*4+x] = dct2[y*4+x] = (rand()%(2*scale+1))-scale; \
537 #define TEST_QUANT_DC( name, cqm ) \
538 if( qf_a.name != qf_ref.name ) \
541 for( qp = 51; qp > 0; qp-- ) \
543 for( i = 0; i < 16; i++ ) \
544 dct1[i] = dct2[i] = (rand() & 0x1fff) - 0xfff; \
545 qf_c.name( (void*)dct1, h->quant4_mf[CQM_4IY][qp][0], h->quant4_bias[CQM_4IY][qp][0] ); \
546 qf_a.name( (void*)dct2, h->quant4_mf[CQM_4IY][qp][0], h->quant4_bias[CQM_4IY][qp][0] ); \
547 if( memcmp( dct1, dct2, 16*2 ) ) \
550 fprintf( stderr, #name "(cqm=%d): [FAILED]\n", i_cqm ); \
556 #define TEST_QUANT( qname, block, w ) \
557 if( qf_a.qname != qf_ref.qname ) \
560 for( qp = 51; qp > 0; qp-- ) \
563 qf_c.qname( (void*)dct1, h->quant##w##_mf[block][qp], h->quant##w##_bias[block][qp] ); \
564 qf_a.qname( (void*)dct2, h->quant##w##_mf[block][qp], h->quant##w##_bias[block][qp] ); \
565 if( memcmp( dct1, dct2, w*w*2 ) ) \
568 fprintf( stderr, #qname "(qp=%d, cqm=%d, block="#block"): [FAILED]\n", qp, i_cqm ); \
574 TEST_QUANT( quant_8x8, CQM_8IY, 8 );
575 TEST_QUANT( quant_8x8, CQM_8PY, 8 );
576 TEST_QUANT( quant_4x4, CQM_4IY, 4 );
577 TEST_QUANT( quant_4x4, CQM_4PY, 4 );
578 TEST_QUANT_DC( quant_4x4_dc, **h->quant4_mf[CQM_4IY] );
579 TEST_QUANT_DC( quant_2x2_dc, **h->quant4_mf[CQM_4IC] );
581 #define TEST_DEQUANT( qname, dqname, block, w ) \
582 if( qf_a.dqname != qf_ref.dqname ) \
585 for( qp = 51; qp > 0; qp-- ) \
588 qf_c.qname( (void*)dct1, h->quant##w##_mf[block][qp], h->quant##w##_bias[block][qp] ); \
589 memcpy( dct2, dct1, w*w*2 ); \
590 qf_c.dqname( (void*)dct1, h->dequant##w##_mf[block], qp ); \
591 qf_a.dqname( (void*)dct2, h->dequant##w##_mf[block], qp ); \
592 if( memcmp( dct1, dct2, w*w*2 ) ) \
595 fprintf( stderr, #dqname "(qp=%d, cqm=%d, block="#block"): [FAILED]\n", qp, i_cqm ); \
601 TEST_DEQUANT( quant_8x8, dequant_8x8, CQM_8IY, 8 );
602 TEST_DEQUANT( quant_8x8, dequant_8x8, CQM_8PY, 8 );
603 TEST_DEQUANT( quant_4x4, dequant_4x4, CQM_4IY, 4 );
604 TEST_DEQUANT( quant_4x4, dequant_4x4, CQM_4PY, 4 );
607 ok = oks[0]; used_asm = used_asms[0];
610 ok = oks[1]; used_asm = used_asms[1];
611 report( "dequant :" );
616 static int check_intra( int cpu_ref, int cpu_new )
618 int ret = 0, ok = 1, used_asm = 0;
620 DECLARE_ALIGNED( uint8_t, edge[33], 8 );
623 x264_predict_t predict_16x16[4+3];
624 x264_predict_t predict_8x8c[4+3];
625 x264_predict8x8_t predict_8x8[9+3];
626 x264_predict_t predict_4x4[9+3];
627 } ip_c, ip_ref, ip_a;
629 x264_predict_16x16_init( 0, ip_c.predict_16x16 );
630 x264_predict_8x8c_init( 0, ip_c.predict_8x8c );
631 x264_predict_8x8_init( 0, ip_c.predict_8x8 );
632 x264_predict_4x4_init( 0, ip_c.predict_4x4 );
634 x264_predict_16x16_init( cpu_ref, ip_ref.predict_16x16 );
635 x264_predict_8x8c_init( cpu_ref, ip_ref.predict_8x8c );
636 x264_predict_8x8_init( cpu_ref, ip_ref.predict_8x8 );
637 x264_predict_4x4_init( cpu_ref, ip_ref.predict_4x4 );
639 x264_predict_16x16_init( cpu_new, ip_a.predict_16x16 );
640 x264_predict_8x8c_init( cpu_new, ip_a.predict_8x8c );
641 x264_predict_8x8_init( cpu_new, ip_a.predict_8x8 );
642 x264_predict_4x4_init( cpu_new, ip_a.predict_4x4 );
644 x264_predict_8x8_filter( buf1+48, edge, ALL_NEIGHBORS, ALL_NEIGHBORS );
646 #define INTRA_TEST( name, dir, ... ) \
647 if( ip_a.name[dir] != ip_ref.name[dir] )\
650 memcpy( buf3, buf1, 32*20 );\
651 memcpy( buf4, buf1, 32*20 );\
652 ip_c.name[dir]( buf3+48, ##__VA_ARGS__ );\
653 ip_a.name[dir]( buf4+48, ##__VA_ARGS__ );\
654 if( memcmp( buf3, buf4, 32*20 ) )\
656 fprintf( stderr, #name "[%d] : [FAILED]\n", dir );\
659 for(k=-1; k<16; k++)\
660 printf("%2x ", edge[16+k]);\
663 printf("%2x ", edge[j]);\
665 printf("%2x ", buf4[48+k+j*32]);\
672 printf("%2x ", buf3[48+k+j*32]);\
678 for( i = 0; i < 12; i++ )
679 INTRA_TEST( predict_4x4, i );
680 for( i = 0; i < 7; i++ )
681 INTRA_TEST( predict_8x8c, i );
682 for( i = 0; i < 7; i++ )
683 INTRA_TEST( predict_16x16, i );
684 for( i = 0; i < 12; i++ )
685 INTRA_TEST( predict_8x8, i, edge );
687 report( "intra pred :" );
691 int check_all( int cpu_ref, int cpu_new )
693 return check_pixel( cpu_ref, cpu_new )
694 + check_dct( cpu_ref, cpu_new )
695 + check_mc( cpu_ref, cpu_new )
696 + check_intra( cpu_ref, cpu_new )
697 + check_deblock( cpu_ref, cpu_new )
698 + check_quant( cpu_ref, cpu_new );
701 int main(int argc, char *argv[])
704 int cpu0 = 0, cpu1 = 0;
707 buf1 = x264_malloc( 1024 ); /* 32 x 32 */
708 buf2 = x264_malloc( 1024 );
709 buf3 = x264_malloc( 1024 );
710 buf4 = x264_malloc( 1024 );
711 buf5 = x264_malloc( 1024 );
713 i = ( argc > 1 ) ? atoi(argv[1]) : x264_mdate();
714 fprintf( stderr, "x264: using random seed %u\n", i );
717 for( i = 0; i < 1024; i++ )
719 buf1[i] = rand() & 0xFF;
720 buf2[i] = rand() & 0xFF;
721 buf3[i] = buf4[i] = 0;
725 fprintf( stderr, "x264: MMXEXT against C\n" );
726 cpu1 = X264_CPU_MMX | X264_CPU_MMXEXT;
727 ret = check_all( 0, cpu1 );
729 if( x264_cpu_detect() & X264_CPU_SSE2 )
731 fprintf( stderr, "\nx264: SSE2 against C\n" );
733 cpu1 |= X264_CPU_SSE | X264_CPU_SSE2;
734 ret |= check_all( cpu0, cpu1 );
736 if( x264_cpu_detect() & X264_CPU_SSSE3 )
738 fprintf( stderr, "\nx264: SSSE3 against C\n" );
740 cpu1 |= X264_CPU_SSE3 | X264_CPU_SSSE3;
741 ret |= check_all( cpu0, cpu1 );
745 if( x264_cpu_detect() & X264_CPU_ALTIVEC )
747 fprintf( stderr, "x264: ALTIVEC against C\n" );
748 ret = check_all( 0, X264_CPU_ALTIVEC );
754 fprintf( stderr, "x264: All tests passed Yeah :)\n" );
757 fprintf( stderr, "x264: at least one test has failed. Go and fix that Right Now!\n" );