Index: third_party/libwebp/dec/webp.c |
diff --git a/third_party/libwebp/dec/webp.c b/third_party/libwebp/dec/webp.c |
index 7455da9415047d560a864beeb60f573e01d95bc9..39d901888edfa6aac3fe9a25fe6cf50f4247cd0b 100644 |
--- a/third_party/libwebp/dec/webp.c |
+++ b/third_party/libwebp/dec/webp.c |
@@ -14,7 +14,7 @@ |
#include "./vp8i.h" |
#include "./vp8li.h" |
#include "./webpi.h" |
-#include "../webp/format_constants.h" |
+#include "../webp/mux_types.h" // ALPHA_FLAG |
#if defined(__cplusplus) || defined(c_plusplus) |
extern "C" { |
@@ -40,8 +40,8 @@ extern "C" { |
// 20..23 VP8X flags bit-map corresponding to the chunk-types present. |
// 24..26 Width of the Canvas Image. |
// 27..29 Height of the Canvas Image. |
-// There can be extra chunks after the "VP8X" chunk (ICCP, TILE, FRM, VP8, |
-// META ...) |
+// There can be extra chunks after the "VP8X" chunk (ICCP, FRGM, ANMF, VP8, |
+// VP8L, XMP, EXIF ...) |
// All sizes are in little-endian order. |
// Note: chunk data size must be padded to multiple of 2 when written. |
@@ -276,6 +276,7 @@ static VP8StatusCode ParseHeadersInternal(const uint8_t* data, |
int* const width, |
int* const height, |
int* const has_alpha, |
+ int* const has_animation, |
WebPHeaderStructure* const headers) { |
int found_riff = 0; |
int found_vp8x = 0; |
@@ -308,7 +309,8 @@ static VP8StatusCode ParseHeadersInternal(const uint8_t* data, |
// necessary to send VP8X chunk to the decoder. |
return VP8_STATUS_BITSTREAM_ERROR; |
} |
- if (has_alpha != NULL) *has_alpha = !!(flags & ALPHA_FLAG_BIT); |
+ if (has_alpha != NULL) *has_alpha = !!(flags & ALPHA_FLAG); |
+ if (has_animation != NULL) *has_animation = !!(flags & ANIMATION_FLAG); |
if (found_vp8x && headers == NULL) { |
return VP8_STATUS_OK; // Return features from VP8X header. |
} |
@@ -370,10 +372,19 @@ static VP8StatusCode ParseHeadersInternal(const uint8_t* data, |
} |
VP8StatusCode WebPParseHeaders(WebPHeaderStructure* const headers) { |
+ VP8StatusCode status; |
+ int has_animation = 0; |
assert(headers != NULL); |
// fill out headers, ignore width/height/has_alpha. |
- return ParseHeadersInternal(headers->data, headers->data_size, |
- NULL, NULL, NULL, headers); |
+ status = ParseHeadersInternal(headers->data, headers->data_size, |
+ NULL, NULL, NULL, &has_animation, headers); |
+ if (status == VP8_STATUS_OK || status == VP8_STATUS_NOT_ENOUGH_DATA) { |
+ // TODO(jzern): full support of animation frames will require API additions. |
+ if (has_animation) { |
+ status = VP8_STATUS_UNSUPPORTED_FEATURE; |
+ } |
+ } |
+ return status; |
} |
//------------------------------------------------------------------------------ |
@@ -625,10 +636,11 @@ static VP8StatusCode GetFeatures(const uint8_t* const data, size_t data_size, |
} |
DefaultFeatures(features); |
- // Only parse enough of the data to retrieve width/height/has_alpha. |
+ // Only parse enough of the data to retrieve the features. |
return ParseHeadersInternal(data, data_size, |
&features->width, &features->height, |
- &features->has_alpha, NULL); |
+ &features->has_alpha, &features->has_animation, |
+ NULL); |
} |
//------------------------------------------------------------------------------ |
@@ -672,19 +684,13 @@ int WebPInitDecoderConfigInternal(WebPDecoderConfig* config, |
VP8StatusCode WebPGetFeaturesInternal(const uint8_t* data, size_t data_size, |
WebPBitstreamFeatures* features, |
int version) { |
- VP8StatusCode status; |
if (WEBP_ABI_IS_INCOMPATIBLE(version, WEBP_DECODER_ABI_VERSION)) { |
return VP8_STATUS_INVALID_PARAM; // version mismatch |
} |
if (features == NULL) { |
return VP8_STATUS_INVALID_PARAM; |
} |
- |
- status = GetFeatures(data, data_size, features); |
- if (status == VP8_STATUS_NOT_ENOUGH_DATA) { |
- return VP8_STATUS_BITSTREAM_ERROR; // Not-enough-data treated as error. |
- } |
- return status; |
+ return GetFeatures(data, data_size, features); |
} |
VP8StatusCode WebPDecode(const uint8_t* data, size_t data_size, |