mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-13 14:34:33 +02:00
add lossless incremental decoding support
* We don't need to change DecodeAlpha, since incremental decoding is not useful for Alpha (we already decode progressively along the RGB) * Similarly, we don't do incremental decoding for level>0 planes: the metadata don't turn into visible pixel (only the ones in level0), so... (No visible speed change) Change-Id: I2fd4b9ba227561a7dbede647686584b752be7baa
This commit is contained in:
@ -502,7 +502,12 @@ static VP8StatusCode DecodeVP8LHeader(WebPIDecoder* const idec) {
|
||||
dec->status_ = VP8_STATUS_SUSPENDED;
|
||||
return ErrorStatusLossless(idec, dec->status_);
|
||||
}
|
||||
|
||||
if (!VP8LDecodeHeader(dec, io)) {
|
||||
if (dec->status_ == VP8_STATUS_BITSTREAM_ERROR &&
|
||||
curr_size < idec->chunk_size_) {
|
||||
dec->status_ = VP8_STATUS_SUSPENDED;
|
||||
}
|
||||
return ErrorStatusLossless(idec, dec->status_);
|
||||
}
|
||||
// Allocate/verify output buffer now.
|
||||
@ -521,23 +526,15 @@ static VP8StatusCode DecodeVP8LData(WebPIDecoder* const idec) {
|
||||
const size_t curr_size = MemDataSize(&idec->mem_);
|
||||
assert(idec->is_lossless_);
|
||||
|
||||
// At present Lossless decoder can't decode image incrementally. So wait till
|
||||
// all the image data is aggregated before image can be decoded.
|
||||
if (curr_size < idec->chunk_size_) {
|
||||
return VP8_STATUS_SUSPENDED;
|
||||
}
|
||||
// Switch to incremental decoding if we don't have all the bytes available.
|
||||
dec->incremental_ = (curr_size < idec->chunk_size_);
|
||||
|
||||
if (!VP8LDecodeImage(dec)) {
|
||||
// The decoding is called after all the data-bytes are aggregated. Change
|
||||
// the error to VP8_BITSTREAM_ERROR in case lossless decoder fails to decode
|
||||
// all the pixels (VP8_STATUS_SUSPENDED).
|
||||
if (dec->status_ == VP8_STATUS_SUSPENDED) {
|
||||
dec->status_ = VP8_STATUS_BITSTREAM_ERROR;
|
||||
}
|
||||
return ErrorStatusLossless(idec, dec->status_);
|
||||
}
|
||||
|
||||
return FinishDecoding(idec);
|
||||
assert(dec->status_ == VP8_STATUS_OK || dec->status_ == VP8_STATUS_SUSPENDED);
|
||||
return (dec->status_ == VP8_STATUS_SUSPENDED) ? dec->status_
|
||||
: FinishDecoding(idec);
|
||||
}
|
||||
|
||||
// Main decoding loop
|
||||
@ -853,4 +850,3 @@ int WebPISetIOHooks(WebPIDecoder* const idec,
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user