summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/libwebp/dec/webp.c
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/libwebp/dec/webp.c')
-rw-r--r--chromium/third_party/libwebp/dec/webp.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/chromium/third_party/libwebp/dec/webp.c b/chromium/third_party/libwebp/dec/webp.c
index e4fe73dc0a8..302220fecd2 100644
--- a/chromium/third_party/libwebp/dec/webp.c
+++ b/chromium/third_party/libwebp/dec/webp.c
@@ -18,10 +18,6 @@
#include "./webpi.h"
#include "../webp/mux_types.h" // ALPHA_FLAG
-#if defined(__cplusplus) || defined(c_plusplus)
-extern "C" {
-#endif
-
//------------------------------------------------------------------------------
// RIFF layout is:
// Offset tag
@@ -285,6 +281,7 @@ static VP8StatusCode ParseHeadersInternal(const uint8_t* data,
int* const height,
int* const has_alpha,
int* const has_animation,
+ int* const format,
WebPHeaderStructure* const headers) {
int canvas_width = 0;
int canvas_height = 0;
@@ -292,6 +289,9 @@ static VP8StatusCode ParseHeadersInternal(const uint8_t* data,
int image_height = 0;
int found_riff = 0;
int found_vp8x = 0;
+ int animation_present = 0;
+ int fragments_present = 0;
+
VP8StatusCode status;
WebPHeaderStructure hdrs;
@@ -312,13 +312,13 @@ static VP8StatusCode ParseHeadersInternal(const uint8_t* data,
// Skip over VP8X.
{
uint32_t flags = 0;
- int animation_present;
status = ParseVP8X(&data, &data_size, &found_vp8x,
&canvas_width, &canvas_height, &flags);
if (status != VP8_STATUS_OK) {
return status; // Wrong VP8X / insufficient data.
}
animation_present = !!(flags & ANIMATION_FLAG);
+ fragments_present = !!(flags & FRAGMENTS_FLAG);
if (!found_riff && found_vp8x) {
// Note: This restriction may be removed in the future, if it becomes
// necessary to send VP8X chunk to the decoder.
@@ -326,8 +326,10 @@ static VP8StatusCode ParseHeadersInternal(const uint8_t* data,
}
if (has_alpha != NULL) *has_alpha = !!(flags & ALPHA_FLAG);
if (has_animation != NULL) *has_animation = animation_present;
+ if (format != NULL) *format = 0; // default = undefined
- if (found_vp8x && animation_present && headers == NULL) {
+ if (found_vp8x && (animation_present || fragments_present) &&
+ headers == NULL) {
if (width != NULL) *width = canvas_width;
if (height != NULL) *height = canvas_height;
return VP8_STATUS_OK; // Just return features from VP8X header.
@@ -356,6 +358,10 @@ static VP8StatusCode ParseHeadersInternal(const uint8_t* data,
return VP8_STATUS_BITSTREAM_ERROR;
}
+ if (format != NULL && !(animation_present || fragments_present)) {
+ *format = hdrs.is_lossless ? 2 : 1;
+ }
+
if (!hdrs.is_lossless) {
if (data_size < VP8_FRAME_HEADER_SIZE) {
return VP8_STATUS_NOT_ENOUGH_DATA;
@@ -374,7 +380,7 @@ static VP8StatusCode ParseHeadersInternal(const uint8_t* data,
return VP8_STATUS_BITSTREAM_ERROR;
}
}
- // Validates image size coherency. TODO(urvang): what about FRGM?
+ // Validates image size coherency.
if (found_vp8x) {
if (canvas_width != image_width || canvas_height != image_height) {
return VP8_STATUS_BITSTREAM_ERROR;
@@ -402,7 +408,8 @@ VP8StatusCode WebPParseHeaders(WebPHeaderStructure* const headers) {
assert(headers != NULL);
// fill out headers, ignore width/height/has_alpha.
status = ParseHeadersInternal(headers->data, headers->data_size,
- NULL, NULL, NULL, &has_animation, headers);
+ NULL, NULL, NULL, &has_animation,
+ NULL, 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) {
@@ -416,7 +423,7 @@ VP8StatusCode WebPParseHeaders(WebPHeaderStructure* const headers) {
// WebPDecParams
void WebPResetDecParams(WebPDecParams* const params) {
- if (params) {
+ if (params != NULL) {
memset(params, 0, sizeof(*params));
}
}
@@ -449,11 +456,6 @@ static VP8StatusCode DecodeInto(const uint8_t* const data, size_t data_size,
if (dec == NULL) {
return VP8_STATUS_OUT_OF_MEMORY;
}
-#ifdef WEBP_USE_THREAD
- dec->use_threads_ = params->options && (params->options->use_threads > 0);
-#else
- dec->use_threads_ = 0;
-#endif
dec->alpha_data_ = headers.alpha_data;
dec->alpha_data_size_ = headers.alpha_data_size;
@@ -465,6 +467,10 @@ static VP8StatusCode DecodeInto(const uint8_t* const data, size_t data_size,
status = WebPAllocateDecBuffer(io.width, io.height, params->options,
params->output);
if (status == VP8_STATUS_OK) { // Decode
+ // This change must be done before calling VP8Decode()
+ dec->mt_method_ = VP8GetThreadMethod(params->options, &headers,
+ io.width, io.height);
+ VP8InitDithering(params->options, dec);
if (!VP8Decode(dec, &io)) {
status = dec->status_;
}
@@ -651,7 +657,6 @@ uint8_t* WebPDecodeYUV(const uint8_t* data, size_t data_size,
static void DefaultFeatures(WebPBitstreamFeatures* const features) {
assert(features != NULL);
memset(features, 0, sizeof(*features));
- features->bitstream_version = 0;
}
static VP8StatusCode GetFeatures(const uint8_t* const data, size_t data_size,
@@ -665,7 +670,7 @@ static VP8StatusCode GetFeatures(const uint8_t* const data, size_t data_size,
return ParseHeadersInternal(data, data_size,
&features->width, &features->height,
&features->has_alpha, &features->has_animation,
- NULL);
+ &features->format, NULL);
}
//------------------------------------------------------------------------------
@@ -803,6 +808,3 @@ int WebPIoInitFromOptions(const WebPDecoderOptions* const options,
//------------------------------------------------------------------------------
-#if defined(__cplusplus) || defined(c_plusplus)
-} // extern "C"
-#endif