Mercurial > libavcodec.hg
diff vp56.h @ 12029:934968bd410d libavcodec
renormalize VP5/6/7/8 range coder without loop
author | stefang |
---|---|
date | Wed, 30 Jun 2010 22:05:29 +0000 |
parents | f2007d7c3f1d |
children | 5578dcdf030c |
line wrap: on
line diff
--- a/vp56.h Wed Jun 30 21:46:03 2010 +0000 +++ b/vp56.h Wed Jun 30 22:05:29 2010 +0000 @@ -28,6 +28,7 @@ #include "dsputil.h" #include "get_bits.h" #include "bytestream.h" +#include "cabac.h" #include "vp56dsp.h" typedef struct vp56_context VP56Context; @@ -195,6 +196,7 @@ unsigned int low = 1 + (((c->high - 1) * prob) >> 8); unsigned int low_shift = low << 8; int bit = c->code_word >= low_shift; + int shift; if (bit) { c->high -= low; @@ -204,13 +206,13 @@ } /* normalize */ - while (c->high < 128) { - c->high <<= 1; - c->code_word <<= 1; - if (--c->bits == 0 && c->buffer < c->end) { - c->bits = 8; - c->code_word |= *c->buffer++; - } + shift = ff_h264_norm_shift[c->high] - 1; + c->high <<= shift; + c->code_word <<= shift; + c->bits -= shift; + if(c->bits <= 0 && c->buffer < c->end) { + c->code_word |= *c->buffer++ << -c->bits; + c->bits += 8; } return bit; }