[x264-devel] commit: checkasm cabac (Loren Merritt )
git version control
git at videolan.org
Tue Apr 22 09:26:45 CEST 2008
x264 | branch: master | Loren Merritt <pengvado at akuvian.org> | Sun Apr 20 12:19:46 2008 -0600| [15f3190277ee18b110a1825a7a98e989756659e9]
checkasm cabac
> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=15f3190277ee18b110a1825a7a98e989756659e9
---
common/cabac.c | 4 +---
common/cabac.h | 9 ++++++++-
common/x86/cabac-a.asm | 2 +-
encoder/rdo.c | 1 +
tools/checkasm.c | 33 ++++++++++++++++++++++++++++++++-
5 files changed, 43 insertions(+), 6 deletions(-)
diff --git a/common/cabac.c b/common/cabac.c
index ad5d203..162978e 100644
--- a/common/cabac.c
+++ b/common/cabac.c
@@ -895,8 +895,7 @@ static inline void x264_cabac_encode_renorm( x264_cabac_t *cb )
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];
@@ -909,7 +908,6 @@ void x264_cabac_encode_decision( x264_cabac_t *cb, int i_ctx, int b )
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 )
{
diff --git a/common/cabac.h b/common/cabac.h
index 1c762b8..091992f 100644
--- a/common/cabac.h
+++ b/common/cabac.h
@@ -53,12 +53,19 @@ void x264_cabac_context_init( x264_cabac_t *cb, int i_slice_type, int i_qp, int
/* 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;
diff --git a/common/x86/cabac-a.asm b/common/x86/cabac-a.asm
index 26a20d0..e0c5235 100644
--- a/common/x86/cabac-a.asm
+++ b/common/x86/cabac-a.asm
@@ -81,7 +81,7 @@ endstruc
%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
diff --git a/encoder/rdo.c b/encoder/rdo.c
index bd481cf..8607e07 100644
--- a/encoder/rdo.c
+++ b/encoder/rdo.c
@@ -41,6 +41,7 @@ static uint16_t cabac_prefix_size[15][128];
/* 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)
diff --git a/tools/checkasm.c b/tools/checkasm.c
index 05c25bd..73faf12 100644
--- a/tools/checkasm.c
+++ b/tools/checkasm.c
@@ -854,6 +854,36 @@ static int check_intra( int cpu_ref, int cpu_new )
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 )
@@ -861,7 +891,8 @@ int check_all( int cpu_ref, int 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 )
More information about the x264-devel
mailing list