Mercurial > libavcodec.hg
changeset 12031:5578dcdf030c libavcodec
Optimize vp56 arithmetic decoder
Negate "bits" to eliminate a negate in cache refilling.
author | darkshikari |
---|---|
date | Wed, 30 Jun 2010 23:15:25 +0000 |
parents | 22da8afd75a5 |
children | 572c81b3be19 |
files | vp56.h |
diffstat | 1 files changed, 9 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/vp56.h Wed Jun 30 22:33:38 2010 +0000 +++ b/vp56.h Wed Jun 30 23:15:25 2010 +0000 @@ -48,7 +48,8 @@ typedef struct { int high; - int bits; + int bits; /* Stored negated (i.e. negative "bits" is a positive number of bits left) + * in order to eliminate a negate in cache refilling */ const uint8_t *buffer; const uint8_t *end; unsigned long code_word; @@ -185,7 +186,7 @@ const uint8_t *buf, int buf_size) { c->high = 255; - c->bits = 8; + c->bits = -8; c->buffer = buf; c->end = buf + buf_size; c->code_word = bytestream_get_be16(&c->buffer); @@ -209,10 +210,10 @@ 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; + c->bits += shift; + if(c->bits >= 0 && c->buffer < c->end) { + c->code_word |= *c->buffer++ << c->bits; + c->bits -= 8; } return bit; } @@ -232,8 +233,8 @@ /* normalize */ c->code_word <<= 1; - if (--c->bits == 0 && c->buffer < c->end) { - c->bits = 8; + if (++c->bits == 0 && c->buffer < c->end) { + c->bits = -8; c->code_word |= *c->buffer++; } return bit;