mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-28 14:38:21 +01:00
Cleaned up VP8GetHeaders() so that it parses only frame header
Removed a call to WebPParseHeaders() inside VP8GetHeaders(). This was not needed anyway, as all call flows already call WebPParseHeaders() before calling VP8GetHeaders(). This avoids duplicate calls to WebPParseHeaders(). Change-Id: Icb2d618bd26c44220d956c17a69c9c45a62d5237
This commit is contained in:
parent
b66caee410
commit
ea1b21cfdb
@ -130,7 +130,8 @@ static WEBP_INLINE int VP8InitIo(VP8Io* const io) {
|
|||||||
return VP8InitIoInternal(io, WEBP_DECODER_ABI_VERSION);
|
return VP8InitIoInternal(io, WEBP_DECODER_ABI_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start decoding a new picture. Returns true if ok.
|
// Decode the VP8 frame header. Returns true if ok.
|
||||||
|
// Note: 'io->data' must be pointing to the start of the VP8 frame header.
|
||||||
int VP8GetHeaders(VP8Decoder* const dec, VP8Io* const io);
|
int VP8GetHeaders(VP8Decoder* const dec, VP8Io* const io);
|
||||||
|
|
||||||
// Decode a picture. Will call VP8GetHeaders() if it wasn't done already.
|
// Decode a picture. Will call VP8GetHeaders() if it wasn't done already.
|
||||||
|
@ -247,7 +247,6 @@ int VP8GetHeaders(VP8Decoder* const dec, VP8Io* const io) {
|
|||||||
VP8PictureHeader* pic_hdr;
|
VP8PictureHeader* pic_hdr;
|
||||||
VP8BitReader* br;
|
VP8BitReader* br;
|
||||||
VP8StatusCode status;
|
VP8StatusCode status;
|
||||||
WebPHeaderStructure headers;
|
|
||||||
|
|
||||||
if (dec == NULL) {
|
if (dec == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -257,33 +256,8 @@ int VP8GetHeaders(VP8Decoder* const dec, VP8Io* const io) {
|
|||||||
return VP8SetError(dec, VP8_STATUS_INVALID_PARAM,
|
return VP8SetError(dec, VP8_STATUS_INVALID_PARAM,
|
||||||
"null VP8Io passed to VP8GetHeaders()");
|
"null VP8Io passed to VP8GetHeaders()");
|
||||||
}
|
}
|
||||||
|
buf = io->data;
|
||||||
// Process Pre-VP8 chunks.
|
buf_size = io->data_size;
|
||||||
headers.data = io->data;
|
|
||||||
headers.data_size = io->data_size;
|
|
||||||
status = WebPParseHeaders(&headers);
|
|
||||||
if (status != VP8_STATUS_OK) {
|
|
||||||
return VP8SetError(dec, status, "Incorrect/incomplete header.");
|
|
||||||
}
|
|
||||||
if (headers.is_lossless) {
|
|
||||||
return VP8SetError(dec, VP8_STATUS_BITSTREAM_ERROR,
|
|
||||||
"Unexpected lossless format encountered.");
|
|
||||||
}
|
|
||||||
|
|
||||||
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_ = headers.alpha_data;
|
|
||||||
dec->alpha_data_size_ = headers.alpha_data_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Process the VP8 frame header.
|
|
||||||
buf = headers.data + headers.offset;
|
|
||||||
buf_size = headers.data_size - headers.offset;
|
|
||||||
assert(headers.data_size >= headers.offset); // WebPParseHeaders' guarantee
|
|
||||||
if (buf_size < 4) {
|
if (buf_size < 4) {
|
||||||
return VP8SetError(dec, VP8_STATUS_NOT_ENOUGH_DATA,
|
return VP8SetError(dec, VP8_STATUS_NOT_ENOUGH_DATA,
|
||||||
"Truncated header.");
|
"Truncated header.");
|
||||||
|
Loading…
Reference in New Issue
Block a user