split the VP8 and VP8L decoding properly

* each with their own decoder instances.
* Refactor the incremental buffer-update code a lot.
* remove br_offset_ for VP8LDecoder along the way
* make VP8GetHeaders() be used only for VP8, not VP8L bitstream
* remove VP8LInitDecoder()
* rename VP8LBitReaderResize() to VP8LBitReaderSetBuffer()
(cherry picked from commit 5529a2e6d47212a721ca4ab003215f97bd88ebb4)

Change-Id: I58f0b8abe1ef31c8b0e1a6175d2d86b863793ead
This commit is contained in:
Pascal Massimino
2012-04-05 09:31:10 +00:00
committed by James Zern
parent f2623dbe58
commit 6f01b830e2
8 changed files with 222 additions and 243 deletions

View File

@ -260,28 +260,16 @@ int VP8GetHeaders(VP8Decoder* const dec, VP8Io* const io) {
"null VP8Io passed to VP8GetHeaders()");
}
// Process Pre-VP8 chunks.
headers.data = io->data;
headers.data_size = io->data_size;
// Process Pre-VP8 chunks.
status = WebPParseHeaders(&headers);
if (status != VP8_STATUS_OK) {
return VP8SetError(dec, status, "Incorrect/incomplete header.");
}
if (headers.is_lossless) {
int ok;
VP8LDecoder* const vp8l_decoder = &dec->vp8l_decoder_;
VP8LInitDecoder(vp8l_decoder);
vp8l_decoder->br_offset_ = headers.offset;
ok = VP8LDecodeHeader(vp8l_decoder, io);
if (!ok) {
VP8LClear(vp8l_decoder);
return VP8SetError(dec, vp8l_decoder->status_,
"Incorrect/incomplete header.");
} else {
dec->is_lossless_ = 1;
}
return ok;
return VP8SetError(dec, VP8_STATUS_BITSTREAM_ERROR,
"Unexpected lossless format encountered.");
}
if (dec->alpha_data_ == NULL) {
@ -741,9 +729,6 @@ int VP8Decode(VP8Decoder* const dec, VP8Io* const io) {
}
assert(dec->ready_);
// TODO: Implement lossless decoding. Error till then.
if (dec->is_lossless_) goto Error;
// Finish setting up the decoding parameter. Will call io->setup().
ok = (VP8EnterCritical(dec, io) == VP8_STATUS_OK);
if (ok) { // good to go.
@ -757,7 +742,6 @@ int VP8Decode(VP8Decoder* const dec, VP8Io* const io) {
ok &= VP8ExitCritical(dec, io);
}
Error:
if (!ok) {
VP8Clear(dec);
return 0;