Some bug-fixes for images with alpha.

- Fix the off-by-one diff when cropping with simple-filter.
- Fix a bug in incremental decoding in case of alpha.
- In VP8FinishRow(), do not decode alpha when y_start > y_end.
- Correct output of alpha channel for MODE_ARGB.
- Correct output of alpha channel for MODE_RGBA_4444.

Change-Id: I785763a2a704b973cc742ad93ffbb53699d1fc0a
This commit is contained in:
Urvang Joshi
2011-12-07 15:01:35 +05:30
parent 273a12a013
commit 8666a93aae
5 changed files with 84 additions and 10 deletions

View File

@ -249,6 +249,8 @@ static int ParseFilterHeader(VP8BitReader* br, VP8Decoder* const dec) {
int VP8GetHeaders(VP8Decoder* const dec, VP8Io* const io) {
const uint8_t* buf;
uint32_t buf_size;
const uint8_t* alpha_data_tmp;
uint32_t alpha_size_tmp;
uint32_t vp8_chunk_size;
uint32_t bytes_skipped;
VP8FrameHeader* frm_hdr;
@ -270,10 +272,19 @@ int VP8GetHeaders(VP8Decoder* const dec, VP8Io* const io) {
// Process Pre-VP8 chunks.
status = WebPParseHeaders(&buf, &buf_size, &vp8_chunk_size, &bytes_skipped,
&dec->alpha_data_, &dec->alpha_data_size_);
&alpha_data_tmp, &alpha_size_tmp);
if (status != VP8_STATUS_OK) {
return VP8SetError(dec, status, "Incorrect/incomplete header.");
}
if (dec->alpha_data_ == NULL) {
assert(dec->alpha_data_size_ == 0);
// We have NOT set alpha data yet. Set it now.
// (This is to ensure that dec->alpha_data_ is NOT reset to NULL if
// WebPParseHeaders() is called more than once, as in incremental decoding
// case.)
dec->alpha_data_ = alpha_data_tmp;
dec->alpha_data_size_ = alpha_size_tmp;
}
// Process the VP8 frame header.
if (buf_size < 4) {