Commit aaced086 authored by Loren Merritt's avatar Loren Merritt

faster cabac_encode_ue_bypass

parent 23e52ef3
......@@ -919,6 +919,25 @@ void x264_cabac_encode_bypass( x264_cabac_t *cb, int b )
x264_cabac_putbyte( cb );
}
void x264_cabac_encode_ue_bypass( x264_cabac_t *cb, int exp_bits, int val )
{
int k, i;
uint32_t x;
for( k = exp_bits; val >= (1<<k); k++ )
val -= 1<<k;
x = (((1<<(k-exp_bits))-1)<<(k+1))+val;
k = 2*k+1-exp_bits;
i = ((k-1)&7)+1;
do {
k -= i;
cb->i_low <<= i;
cb->i_low += ((x>>k)&0xff) * cb->i_range;
cb->i_queue += i;
x264_cabac_putbyte( cb );
i = 8;
} while( k > 0 );
}
void x264_cabac_encode_terminal( x264_cabac_t *cb )
{
cb->i_range -= 2;
......
......@@ -55,6 +55,7 @@ void x264_cabac_context_init( x264_cabac_t *cb, int i_slice_type, int i_qp, int
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_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 );
......
......@@ -24,23 +24,6 @@
#include "common/common.h"
#include "macroblock.h"
static inline void x264_cabac_encode_ue_bypass( x264_cabac_t *cb, int exp_bits, int val )
{
#ifdef RDO_SKIP_BS
cb->f8_bits_encoded += ( bs_size_ue( val + (1<<exp_bits)-1 ) - exp_bits ) << 8;
#else
int k;
for( k = exp_bits; val >= (1<<k); k++ )
{
x264_cabac_encode_bypass( cb, 1 );
val -= 1 << k;
}
x264_cabac_encode_bypass( cb, 0 );
while( k-- )
x264_cabac_encode_bypass( cb, (val >> k)&0x01 );
#endif
}
static inline void x264_cabac_mb_type_intra( x264_t *h, x264_cabac_t *cb, int i_mb_type,
int ctx0, int ctx1, int ctx2, int ctx3, int ctx4, int ctx5 )
{
......
......@@ -44,6 +44,7 @@ static int cabac_prefix_size[15][128];
#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)
#define x264_cabac_encode_ue_bypass(c,e,v) ((c)->f8_bits_encoded += (bs_size_ue(v+(1<<e)-1)-e)<<8)
#define x264_cabac_encode_flush(h,c)
#define x264_macroblock_write_cabac x264_macroblock_size_cabac
#include "cabac.c"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment