From 6e8530793eb849f6ec17847acd39b69504f8fd49 Mon Sep 17 00:00:00 2001 From: Jason Garrett-Glaser Date: Sun, 29 Aug 2010 22:18:07 -0700 Subject: [PATCH] Faster cabac_encode_ue_bypass Use CLZ + a lut instead of a loop. --- common/cabac.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/common/cabac.c b/common/cabac.c index d0888d09..cd57d904 100644 --- a/common/cabac.c +++ b/common/cabac.c @@ -850,14 +850,19 @@ void x264_cabac_encode_bypass_c( x264_cabac_t *cb, int b ) x264_cabac_putbyte( cb ); } +static const int bypass_lut[16] = +{ + -1, 0x2, 0x14, 0x68, 0x1d0, 0x7a0, 0x1f40, 0x7e80, + 0x1fd00, 0x7fa00, 0x1ff400, 0x7fe800, 0x1ffd000, 0x7ffa000, 0x1fff4000, 0x7ffe8000 +}; + void x264_cabac_encode_ue_bypass( x264_cabac_t *cb, int exp_bits, int val ) { - int k, i; - for( k = exp_bits; val >= (1<i_low <<= i; -- 2.47.3