make the bitreader preload at least 8bits, instead of post-load them

(this makes initialization easier and will be helpful for incremental
decoding).
Modify ParsePartitions() to accommodate for truncated input.

Change-Id: I62f52078d6b7a2314a11880a20d9eac5b4714bd0
This commit is contained in:
Pascal Massimino
2011-03-10 15:05:59 -08:00
parent f4888f7702
commit 13e50da6f8
3 changed files with 65 additions and 52 deletions

View File

@ -18,16 +18,17 @@ extern "C" {
//-----------------------------------------------------------------------------
// VP8BitReader
void VP8Init(VP8BitReader* const br, const uint8_t* buf, uint32_t size) {
void VP8InitBitReader(VP8BitReader* const br,
const uint8_t* const start, const uint8_t* const end) {
assert(br);
assert(buf);
br->range_ = 255 - 1;
br->buf_ = buf;
br->buf_end_ = buf + size;
// Need two initial bytes.
br->value_ = (VP8GetByte(br) << 8) | VP8GetByte(br);
br->left_ = -8;
br->eof_ = 0;
assert(start);
assert(start <= end);
br->range_ = 255 - 1;
br->buf_ = start;
br->buf_end_ = end;
br->value_ = 0;
br->missing_ = 8;
br->eof_ = 0;
}
const uint8_t kVP8Log2Range[128] = {