mirror of
https://github.com/webmproject/libwebp.git
synced 2025-02-13 15:32:53 +01:00
Merge "Bugfix: Incremental decode of lossy-alpha"
This commit is contained in:
commit
c0220460e9
@ -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,
|
void VP8LBitReaderSetBuffer(VP8LBitReader* const br,
|
||||||
const uint8_t* const buf, size_t len) {
|
const uint8_t* const buf, size_t len) {
|
||||||
assert(br != NULL);
|
assert(br != NULL);
|
||||||
assert(buf != NULL);
|
assert(buf != NULL);
|
||||||
assert(len < 0xfffffff8u); // can't happen with a RIFF chunk.
|
assert(len < 0xfffffff8u); // can't happen with a RIFF chunk.
|
||||||
br->eos_ = (br->pos_ >= len);
|
|
||||||
br->buf_ = buf;
|
br->buf_ = buf;
|
||||||
br->len_ = len;
|
br->len_ = len;
|
||||||
|
br->eos_ = IsEndOfStream(br);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If not at EOS, reload up to LBITS byte-by-byte
|
// If not at EOS, reload up to LBITS byte-by-byte
|
||||||
@ -175,9 +185,7 @@ void VP8LFillBitWindow(VP8LBitReader* const br) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
ShiftBytes(br); // Slow path.
|
ShiftBytes(br); // Slow path.
|
||||||
if (br->pos_ == br->len_ && br->bit_pos_ >= LBITS) {
|
br->eos_ = IsEndOfStreamSpecial(br);
|
||||||
br->eos_ = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,11 +198,7 @@ uint32_t VP8LReadBits(VP8LBitReader* const br, int n_bits) {
|
|||||||
const int new_bits = br->bit_pos_ + n_bits;
|
const int new_bits = br->bit_pos_ + n_bits;
|
||||||
br->bit_pos_ = new_bits;
|
br->bit_pos_ = new_bits;
|
||||||
// If this read is going to cross the read buffer, set the eos flag.
|
// If this read is going to cross the read buffer, set the eos flag.
|
||||||
if (br->pos_ == br->len_) {
|
br->eos_ = IsEndOfStreamSpecial(br);
|
||||||
if (new_bits >= LBITS) {
|
|
||||||
br->eos_ = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ShiftBytes(br);
|
ShiftBytes(br);
|
||||||
return val;
|
return val;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user