mirror of
https://github.com/webmproject/libwebp.git
synced 2025-02-20 19:02:52 +01:00
remove br->error_ field
it's somewhat redundant with br->eos_ also make the status-check coherent. Change-Id: I98e755e037d45acb0760baf2344bf11fb5fb5cda
This commit is contained in:
parent
38128cb9df
commit
248f3aed22
@ -291,7 +291,7 @@ static int ReadHuffmanCode(int alphabet_size, VP8LDecoder* const dec,
|
|||||||
code_lengths);
|
code_lengths);
|
||||||
}
|
}
|
||||||
|
|
||||||
ok = ok && !br->error_;
|
ok = ok && !br->eos_;
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
dec->status_ = VP8_STATUS_BITSTREAM_ERROR;
|
dec->status_ = VP8_STATUS_BITSTREAM_ERROR;
|
||||||
return 0;
|
return 0;
|
||||||
@ -336,7 +336,7 @@ static int ReadHuffmanCodes(VP8LDecoder* const dec, int xsize, int ysize,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (br->error_) goto Error;
|
if (br->eos_) goto Error;
|
||||||
|
|
||||||
// Find maximum alphabet size for the htree group.
|
// Find maximum alphabet size for the htree group.
|
||||||
for (j = 0; j < HUFFMAN_CODES_PER_META_CODE; ++j) {
|
for (j = 0; j < HUFFMAN_CODES_PER_META_CODE; ++j) {
|
||||||
@ -948,14 +948,12 @@ static int DecodeAlphaData(VP8LDecoder* const dec, uint8_t* const data,
|
|||||||
goto End;
|
goto End;
|
||||||
}
|
}
|
||||||
assert(br->eos_ == VP8LIsEndOfStream(br));
|
assert(br->eos_ == VP8LIsEndOfStream(br));
|
||||||
ok = !br->error_;
|
|
||||||
if (!ok) goto End;
|
|
||||||
}
|
}
|
||||||
// Process the remaining rows corresponding to last row-block.
|
// Process the remaining rows corresponding to last row-block.
|
||||||
ExtractPalettedAlphaRows(dec, row);
|
ExtractPalettedAlphaRows(dec, row);
|
||||||
|
|
||||||
End:
|
End:
|
||||||
if (br->error_ || !ok || (br->eos_ && pos < end)) {
|
if (!ok || (br->eos_ && pos < end)) {
|
||||||
ok = 0;
|
ok = 0;
|
||||||
dec->status_ = br->eos_ ? VP8_STATUS_SUSPENDED
|
dec->status_ = br->eos_ ? VP8_STATUS_SUSPENDED
|
||||||
: VP8_STATUS_BITSTREAM_ERROR;
|
: VP8_STATUS_BITSTREAM_ERROR;
|
||||||
@ -1068,14 +1066,12 @@ static int DecodeImageData(VP8LDecoder* const dec, uint32_t* const data,
|
|||||||
goto End;
|
goto End;
|
||||||
}
|
}
|
||||||
assert(br->eos_ == VP8LIsEndOfStream(br));
|
assert(br->eos_ == VP8LIsEndOfStream(br));
|
||||||
ok = !br->error_;
|
|
||||||
if (!ok) goto End;
|
|
||||||
}
|
}
|
||||||
// Process the remaining rows corresponding to last row-block.
|
// Process the remaining rows corresponding to last row-block.
|
||||||
if (process_func != NULL) process_func(dec, row);
|
if (process_func != NULL) process_func(dec, row);
|
||||||
|
|
||||||
End:
|
End:
|
||||||
if (br->error_ || !ok || (br->eos_ && src < src_end)) {
|
if (!ok || (br->eos_ && src < src_end)) {
|
||||||
ok = 0;
|
ok = 0;
|
||||||
dec->status_ = br->eos_ ? VP8_STATUS_SUSPENDED
|
dec->status_ = br->eos_ ? VP8_STATUS_SUSPENDED
|
||||||
: VP8_STATUS_BITSTREAM_ERROR;
|
: VP8_STATUS_BITSTREAM_ERROR;
|
||||||
@ -1310,17 +1306,17 @@ static int DecodeImageStream(int xsize, int ysize,
|
|||||||
// Use the Huffman trees to decode the LZ77 encoded data.
|
// Use the Huffman trees to decode the LZ77 encoded data.
|
||||||
ok = DecodeImageData(dec, data, transform_xsize, transform_ysize,
|
ok = DecodeImageData(dec, data, transform_xsize, transform_ysize,
|
||||||
transform_ysize, NULL);
|
transform_ysize, NULL);
|
||||||
ok = ok && !br->error_;
|
ok = ok && !br->eos_;
|
||||||
|
|
||||||
End:
|
End:
|
||||||
|
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
WebPSafeFree(data);
|
WebPSafeFree(data);
|
||||||
ClearMetadata(hdr);
|
ClearMetadata(hdr);
|
||||||
// If not enough data (br.eos_) resulted in BIT_STREAM_ERROR, update the
|
// Check status coherency.
|
||||||
// status appropriately.
|
if (dec->br_.eos_) {
|
||||||
if (dec->status_ == VP8_STATUS_BITSTREAM_ERROR && dec->br_.eos_) {
|
assert(dec->status_ == VP8_STATUS_SUSPENDED);
|
||||||
dec->status_ = VP8_STATUS_SUSPENDED;
|
} else {
|
||||||
|
assert(dec->status_ == VP8_STATUS_BITSTREAM_ERROR);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (decoded_data != NULL) {
|
if (decoded_data != NULL) {
|
||||||
|
@ -136,7 +136,6 @@ void VP8LInitBitReader(VP8LBitReader* const br, const uint8_t* const start,
|
|||||||
br->val_ = 0;
|
br->val_ = 0;
|
||||||
br->bit_pos_ = 0;
|
br->bit_pos_ = 0;
|
||||||
br->eos_ = 0;
|
br->eos_ = 0;
|
||||||
br->error_ = 0;
|
|
||||||
|
|
||||||
if (length > sizeof(br->val_)) {
|
if (length > sizeof(br->val_)) {
|
||||||
length = sizeof(br->val_);
|
length = sizeof(br->val_);
|
||||||
@ -157,8 +156,7 @@ void VP8LBitReaderSetBuffer(VP8LBitReader* const br,
|
|||||||
br->buf_ = buf;
|
br->buf_ = buf;
|
||||||
br->len_ = len;
|
br->len_ = len;
|
||||||
// pos_ > len_ should be considered a param error.
|
// pos_ > len_ should be considered a param error.
|
||||||
br->error_ = (br->pos_ > br->len_);
|
br->eos_ = (br->pos_ > br->len_) || VP8LIsEndOfStream(br);
|
||||||
br->eos_ = br->error_ || VP8LIsEndOfStream(br);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If not at EOS, reload up to VP8L_LBITS byte-by-byte
|
// If not at EOS, reload up to VP8L_LBITS byte-by-byte
|
||||||
@ -202,7 +200,7 @@ uint32_t VP8LReadBits(VP8LBitReader* const br, int n_bits) {
|
|||||||
ShiftBytes(br);
|
ShiftBytes(br);
|
||||||
return val;
|
return val;
|
||||||
} else {
|
} else {
|
||||||
br->error_ = 1;
|
br->eos_ = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,8 +118,7 @@ typedef struct {
|
|||||||
size_t len_; // buffer length
|
size_t len_; // buffer length
|
||||||
size_t pos_; // byte position in buf_
|
size_t pos_; // byte position in buf_
|
||||||
int bit_pos_; // current bit-reading position in val_
|
int bit_pos_; // current bit-reading position in val_
|
||||||
int eos_; // bitstream is finished
|
int eos_; // true if a bit was read past the end of buffer
|
||||||
int error_; // an error occurred (buffer overflow attempt...)
|
|
||||||
} VP8LBitReader;
|
} VP8LBitReader;
|
||||||
|
|
||||||
void VP8LInitBitReader(VP8LBitReader* const br,
|
void VP8LInitBitReader(VP8LBitReader* const br,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user