Commit 63c68af2 authored by arpi_esp's avatar arpi_esp

get_bits() specialization, gives 4\speedup


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@32 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 89fcee42
......@@ -80,6 +80,47 @@ static inline unsigned int get_bits(GetBitContext *s, int n){
return get_bits_long(s,n);
}
static inline unsigned int get_bits1(GetBitContext *s){
if(s->bit_cnt>0){
/* most common case here */
unsigned int val = s->bit_buf >> 31;
s->bit_buf <<= 1;
s->bit_cnt--;
#ifdef STATS
st_bit_counts[st_current_index]++;
#endif
return val;
}
return get_bits_long(s,1);
}
static inline void skip_bits(GetBitContext *s, int n){
if(s->bit_cnt>=n){
/* most common case here */
s->bit_buf <<= n;
s->bit_cnt -= n;
#ifdef STATS
st_bit_counts[st_current_index] += n;
#endif
} else {
get_bits_long(s,n);
}
}
static inline void skip_bits1(GetBitContext *s){
if(s->bit_cnt>0){
/* most common case here */
s->bit_buf <<= 1;
s->bit_cnt--;
#ifdef STATS
st_bit_counts[st_current_index]++;
#endif
} else {
get_bits_long(s,1);
}
}
void align_get_bits(GetBitContext *s);
int init_vlc(VLC *vlc, int nb_bits, int nb_codes,
const void *bits, int bits_wrap, int bits_size,
......
This diff is collapsed.
This diff is collapsed.
......@@ -601,11 +601,11 @@ int msmpeg4_decode_init_vlc(MpegEncContext *s)
static int decode012(GetBitContext *gb)
{
int n;
n = get_bits(gb, 1);
n = get_bits1(gb);
if (n == 0)
return 0;
else
return get_bits(gb, 1) + 1;
return get_bits1(gb) + 1;
}
int msmpeg4_decode_picture_header(MpegEncContext * s)
......@@ -629,17 +629,17 @@ int msmpeg4_decode_picture_header(MpegEncContext * s)
s->rl_chroma_table_index = decode012(&s->gb);
s->rl_table_index = decode012(&s->gb);
s->dc_table_index = get_bits(&s->gb, 1);
s->dc_table_index = get_bits1(&s->gb);
s->no_rounding = 1;
} else {
s->use_skip_mb_code = get_bits(&s->gb, 1);
s->use_skip_mb_code = get_bits1(&s->gb);
s->rl_table_index = decode012(&s->gb);
s->rl_chroma_table_index = s->rl_table_index;
s->dc_table_index = get_bits(&s->gb, 1);
s->dc_table_index = get_bits1(&s->gb);
s->mv_table_index = get_bits(&s->gb, 1);
s->mv_table_index = get_bits1(&s->gb);
s->no_rounding ^= 1;
}
#ifdef DEBUG
......@@ -685,7 +685,7 @@ int msmpeg4_decode_mb(MpegEncContext *s,
if (s->pict_type == P_TYPE) {
set_stat(ST_INTER_MB);
if (s->use_skip_mb_code) {
if (get_bits(&s->gb, 1)) {
if (get_bits1(&s->gb)) {
/* skip mb */
s->mb_intra = 0;
for(i=0;i<6;i++)
......@@ -739,7 +739,7 @@ int msmpeg4_decode_mb(MpegEncContext *s,
s->mv[0][0][1] = my;
} else {
set_stat(ST_INTRA_MB);
s->ac_pred = get_bits(&s->gb, 1);
s->ac_pred = get_bits1(&s->gb);
}
for (i = 0; i < 6; i++) {
......@@ -801,10 +801,10 @@ static int msmpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
return -1;
if (code == rl->n) {
/* escape */
if (get_bits(&s->gb, 1) == 0) {
if (get_bits(&s->gb, 1) == 0) {
if (get_bits1(&s->gb) == 0) {
if (get_bits1(&s->gb) == 0) {
/* third escape */
last = get_bits(&s->gb, 1);
last = get_bits1(&s->gb);
run = get_bits(&s->gb, 6);
level = get_bits(&s->gb, 8);
level = (level << 24) >> 24; /* sign extend */
......@@ -817,7 +817,7 @@ static int msmpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
level = rl->table_level[code];
last = code >= rl->last;
run += rl->max_run[last][level] + run_diff;
if (get_bits(&s->gb, 1))
if (get_bits1(&s->gb))
level = -level;
}
} else {
......@@ -829,14 +829,14 @@ static int msmpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
level = rl->table_level[code];
last = code >= rl->last;
level += rl->max_level[last][run];
if (get_bits(&s->gb, 1))
if (get_bits1(&s->gb))
level = -level;
}
} else {
run = rl->table_run[code];
level = rl->table_level[code];
last = code >= rl->last;
if (get_bits(&s->gb, 1))
if (get_bits1(&s->gb))
level = -level;
}
i += run;
......@@ -875,10 +875,10 @@ static int msmpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr)
if (level == DC_MAX) {
level = get_bits(&s->gb, 8);
if (get_bits(&s->gb, 1))
if (get_bits1(&s->gb))
level = -level;
} else if (level != 0) {
if (get_bits(&s->gb, 1))
if (get_bits1(&s->gb))
level = -level;
}
......
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