x264_cabac_putbyte( cb );
}
-#ifndef HAVE_MMX
-void x264_cabac_encode_decision( x264_cabac_t *cb, int i_ctx, int b )
+void x264_cabac_encode_decision_c( x264_cabac_t *cb, int i_ctx, int b )
{
int i_state = cb->state[i_ctx];
int i_range_lps = x264_cabac_range_lps[i_state][(cb->i_range>>6)&0x03];
cb->state[i_ctx] = x264_cabac_transition[i_state][b];
x264_cabac_encode_renorm( cb );
}
-#endif
void x264_cabac_encode_bypass( x264_cabac_t *cb, int b )
{
/* encoder only: */
void x264_cabac_encode_init ( x264_cabac_t *cb, uint8_t *p_data, uint8_t *p_end );
-void x264_cabac_encode_decision( x264_cabac_t *cb, int i_ctx, int b );
+void x264_cabac_encode_decision_c( x264_cabac_t *cb, int i_ctx, int b );
+void x264_cabac_encode_decision_asm( x264_cabac_t *cb, int i_ctx, int b );
void x264_cabac_encode_bypass( x264_cabac_t *cb, int b );
void x264_cabac_encode_ue_bypass( x264_cabac_t *cb, int exp_bits, int val );
void x264_cabac_encode_terminal( x264_cabac_t *cb );
void x264_cabac_encode_flush( x264_t *h, x264_cabac_t *cb );
+#ifdef HAVE_MMX
+#define x264_cabac_encode_decision x264_cabac_encode_decision_asm
+#else
+#define x264_cabac_encode_decision x264_cabac_encode_decision_c
+#endif
+
static inline int x264_cabac_pos( x264_cabac_t *cb )
{
return (cb->p - cb->p_start + cb->i_bytes_outstanding) * 8 + cb->i_queue;
%endif
%endmacro
-cglobal x264_cabac_encode_decision, 0,7
+cglobal x264_cabac_encode_decision_asm, 0,7
movifnidn t0d, r0m
movifnidn t1d, r1m
picgetgot t2
/* CABAC: not exactly the same. x264_cabac_size_decision() keeps track of
* fractional bits, but only finite precision. */
+#undef x264_cabac_encode_decision
#define x264_cabac_encode_decision(c,x,v) x264_cabac_size_decision(c,x,v)
#define x264_cabac_encode_terminal(c) x264_cabac_size_decision(c,276,0)
#define x264_cabac_encode_bypass(c,v) ((c)->f8_bits_encoded += 256)
return ret;
}
+#define DECL_CABAC(cpu) \
+static void run_cabac_##cpu( uint8_t *dst )\
+{\
+ int i;\
+ x264_cabac_t cb;\
+ x264_cabac_context_init( &cb, SLICE_TYPE_P, 26, 0 );\
+ x264_cabac_encode_init( &cb, dst, dst+0xff0 );\
+ for( i=0; i<0x400; i++ )\
+ x264_cabac_encode_decision_##cpu( &cb, buf1[i]>>1, buf1[i]&1 );\
+}
+DECL_CABAC(c)
+#ifdef HAVE_MMX
+DECL_CABAC(asm)
+#else
+#define run_cabac_asm run_cabac_c
+#endif
+
+static int check_cabac( int cpu_ref, int cpu_new )
+{
+ int ret = 0, ok, used_asm = 1;
+ if( cpu_ref || run_cabac_c == run_cabac_asm)
+ return 0;
+ memcpy( buf4, buf3, 0x1000 );
+ call_c( run_cabac_c, buf3 );
+ call_a( run_cabac_asm, buf4 );
+ ok = !memcmp( buf3, buf4, 0x1000 );
+ report( "cabac :" );
+ return ret;
+}
+
int check_all( int cpu_ref, int cpu_new )
{
return check_pixel( cpu_ref, cpu_new )
+ check_mc( cpu_ref, cpu_new )
+ check_intra( cpu_ref, cpu_new )
+ check_deblock( cpu_ref, cpu_new )
- + check_quant( cpu_ref, cpu_new );
+ + check_quant( cpu_ref, cpu_new )
+ + check_cabac( cpu_ref, cpu_new );
}
int add_flags( int *cpu_ref, int *cpu_new, int flags, const char *name )