From a681b4f4e51261d339c453893b880ddb42cb311f Mon Sep 17 00:00:00 2001 From: Urvang Joshi Date: Mon, 8 Apr 2013 12:19:29 -0700 Subject: [PATCH] Rename PRE_VP8 state to WEBP_HEADER Also, rename state VP8_FRAME_HEADER to VP8_HEADER (to be consistent with VP8L_HEADER). Change-Id: Ief2d2f483e36d37f00d8d0db87026ad059f27327 --- src/dec/idec.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/dec/idec.c b/src/dec/idec.c index cbf9638e..42d2a923 100644 --- a/src/dec/idec.c +++ b/src/dec/idec.c @@ -29,11 +29,13 @@ extern "C" { //------------------------------------------------------------------------------ // Data structures for memory and states -// Decoding states. State normally flows like HEADER->PARTS0->DATA->DONE. +// Decoding states. State normally flows as: +// WEBP_HEADER->VP8_HEADER->VP8_PARTS0->VP8_DATA->DONE for a lossy image, and +// WEBP_HEADER->VP8L_HEADER->VP8L_DATA->DONE for a lossless image. // If there is any error the decoder goes into state ERROR. typedef enum { - STATE_PRE_VP8, // All data before that of the first VP8 chunk. - STATE_VP8_FRAME_HEADER, // For VP8 Frame header (within VP8 chunk). + STATE_WEBP_HEADER, // All the data before that of the VP8/VP8L chunk. + STATE_VP8_HEADER, // The VP8 Frame header (within the VP8 chunk). STATE_VP8_PARTS0, STATE_VP8_DATA, STATE_VP8L_HEADER, @@ -100,7 +102,7 @@ static WEBP_INLINE size_t MemDataSize(const MemBuffer* mem) { // Check if we need to preserve the compressed alpha data, as it may not have // been decoded yet. static int NeedCompressedAlpha(const WebPIDecoder* const idec) { - if (idec->state_ == STATE_PRE_VP8) { + if (idec->state_ == STATE_WEBP_HEADER) { // We haven't parsed the headers yet, so we don't know whether the image is // lossy or lossless. This also means that we haven't parsed the ALPH chunk. return 0; @@ -109,7 +111,7 @@ static int NeedCompressedAlpha(const WebPIDecoder* const idec) { return 0; // ALPH chunk is not present for lossless images. } else { const VP8Decoder* const dec = (VP8Decoder*)idec->dec_; - assert(dec != NULL); // Must be true as idec->state_ != STATE_PRE_VP8. + assert(dec != NULL); // Must be true as idec->state_ != STATE_WEBP_HEADER. return (dec->alpha_data_ != NULL) && !dec->is_alpha_decoded_; } } @@ -317,7 +319,7 @@ static VP8StatusCode DecodeWebPHeaders(WebPIDecoder* const idec) { #endif dec->alpha_data_ = headers.alpha_data; dec->alpha_data_size_ = headers.alpha_data_size; - ChangeState(idec, STATE_VP8_FRAME_HEADER, headers.offset); + ChangeState(idec, STATE_VP8_HEADER, headers.offset); } else { VP8LDecoder* const dec = VP8LNew(); if (dec == NULL) { @@ -530,14 +532,14 @@ static VP8StatusCode DecodeVP8LData(WebPIDecoder* const idec) { static VP8StatusCode IDecode(WebPIDecoder* idec) { VP8StatusCode status = VP8_STATUS_SUSPENDED; - if (idec->state_ == STATE_PRE_VP8) { + if (idec->state_ == STATE_WEBP_HEADER) { status = DecodeWebPHeaders(idec); } else { if (idec->dec_ == NULL) { return VP8_STATUS_SUSPENDED; // can't continue if we have no decoder. } } - if (idec->state_ == STATE_VP8_FRAME_HEADER) { + if (idec->state_ == STATE_VP8_HEADER) { status = DecodeVP8FrameHeader(idec); } if (idec->state_ == STATE_VP8_PARTS0) { @@ -564,7 +566,7 @@ WebPIDecoder* WebPINewDecoder(WebPDecBuffer* output_buffer) { return NULL; } - idec->state_ = STATE_PRE_VP8; + idec->state_ = STATE_WEBP_HEADER; idec->chunk_size_ = 0; InitMemBuffer(&idec->mem_); @@ -821,7 +823,7 @@ int WebPISetIOHooks(WebPIDecoder* const idec, VP8IoSetupHook setup, VP8IoTeardownHook teardown, void* user_data) { - if (idec == NULL || idec->state_ > STATE_PRE_VP8) { + if (idec == NULL || idec->state_ > STATE_WEBP_HEADER) { return 0; }