mirror of
https://github.com/webmproject/libwebp.git
synced 2024-11-20 04:18:26 +01:00
Bugfix: Incremental decode of lossy-alpha
When remapping buffer, br->eos_ was wrongly being set to true for certain images. Also, refactored the end-of-stream detection as a function. Reported in http://crbug.com/364830 Change-Id: I716ce082ef2b505fe24246b9c14912d8e97b5d84
This commit is contained in:
parent
b1dabe3767
commit
8c7cd722f6
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user