Commit b3d755ec authored by David Conrad's avatar David Conrad

Split renorm of vp56 arith decoder to its own function

Originally committed as revision 24466 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 24675b80
...@@ -191,16 +191,30 @@ static inline void vp56_init_range_decoder(VP56RangeCoder *c, ...@@ -191,16 +191,30 @@ static inline void vp56_init_range_decoder(VP56RangeCoder *c,
c->code_word = bytestream_get_be16(&c->buffer); c->code_word = bytestream_get_be16(&c->buffer);
} }
static av_always_inline void vp56_rac_renorm(VP56RangeCoder *c, unsigned int code_word)
{
int shift = ff_h264_norm_shift[c->high] - 1;
int bits = c->bits;
c->high <<= shift;
code_word <<= shift;
bits += shift;
if(bits >= 0 && c->buffer < c->end) {
code_word |= *c->buffer++ << bits;
bits -= 8;
}
c->bits = bits;
c->code_word = code_word;
}
static inline int vp56_rac_get_prob(VP56RangeCoder *c, uint8_t prob) static inline int vp56_rac_get_prob(VP56RangeCoder *c, uint8_t prob)
{ {
/* Don't put c->high in a local variable; if we do that, gcc gets /* Don't put c->high in a local variable; if we do that, gcc gets
* the stupids and turns the code below into a branch again. */ * the stupids and turns the code below into a branch again. */
int bits = c->bits;
unsigned int code_word = c->code_word; unsigned int code_word = c->code_word;
unsigned int low = 1 + (((c->high - 1) * prob) >> 8); unsigned int low = 1 + (((c->high - 1) * prob) >> 8);
unsigned int low_shift = low << 8; unsigned int low_shift = low << 8;
int bit = code_word >= low_shift; int bit = code_word >= low_shift;
int shift;
/* Incantation to convince GCC to turn these into conditional moves /* Incantation to convince GCC to turn these into conditional moves
* instead of branches -- faster, as this branch is basically * instead of branches -- faster, as this branch is basically
...@@ -208,17 +222,7 @@ static inline int vp56_rac_get_prob(VP56RangeCoder *c, uint8_t prob) ...@@ -208,17 +222,7 @@ static inline int vp56_rac_get_prob(VP56RangeCoder *c, uint8_t prob)
c->high = bit ? c->high - low : low; c->high = bit ? c->high - low : low;
code_word = bit ? code_word - low_shift : code_word; code_word = bit ? code_word - low_shift : code_word;
/* normalize */ vp56_rac_renorm(c, code_word);
shift = ff_h264_norm_shift[c->high] - 1;
c->high <<= shift;
code_word <<= shift;
bits += shift;
if(bits >= 0 && c->buffer < c->end) {
code_word |= *c->buffer++ << bits;
bits -= 8;
}
c->bits = bits;
c->code_word = code_word;
return bit; return bit;
} }
......
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