Merge "Bugfix: Incremental decode of lossy-alpha"

This commit is contained in:
James Zern 2014-04-22 16:33:12 -07:00 committed by Gerrit Code Review
commit c0220460e9

View File

@ -141,14 +141,24 @@ void VP8LInitBitReader(VP8LBitReader* const br,
}
}
// Special version that assumes br->pos_ <= br_len_.
static int IsEndOfStreamSpecial(const VP8LBitReader* const br) {
assert(br->pos_ <= br->len_);
return br->pos_ == br->len_ && br->bit_pos_ >= LBITS;
}
static int IsEndOfStream(const VP8LBitReader* const br) {
return (br->pos_ > br->len_) || IsEndOfStreamSpecial(br);
}
void VP8LBitReaderSetBuffer(VP8LBitReader* const br,
const uint8_t* const buf, size_t len) {
assert(br != NULL);
assert(buf != NULL);
assert(len < 0xfffffff8u); // can't happen with a RIFF chunk.
br->eos_ = (br->pos_ >= len);
br->buf_ = buf;
br->len_ = len;
br->eos_ = IsEndOfStream(br);
}
// If not at EOS, reload up to LBITS byte-by-byte
@ -175,9 +185,7 @@ void VP8LFillBitWindow(VP8LBitReader* const br) {
}
#endif
ShiftBytes(br); // Slow path.
if (br->pos_ == br->len_ && br->bit_pos_ >= LBITS) {
br->eos_ = 1;
}
br->eos_ = IsEndOfStreamSpecial(br);
}
}
@ -190,11 +198,7 @@ uint32_t VP8LReadBits(VP8LBitReader* const br, int n_bits) {
const int new_bits = br->bit_pos_ + n_bits;
br->bit_pos_ = new_bits;
// If this read is going to cross the read buffer, set the eos flag.
if (br->pos_ == br->len_) {
if (new_bits >= LBITS) {
br->eos_ = 1;
}
}
br->eos_ = IsEndOfStreamSpecial(br);
ShiftBytes(br);
return val;
} else {