Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(541)

Unified Diff: src/images/SkImageDecoder_libwebp.cpp

Issue 1178013008: Use the upstream version of libwebp, v0.4.3. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fixes for SkWebpImageDecoder and SkWebpCodec. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/images/SkImageDecoder_libwebp.cpp
diff --git a/src/images/SkImageDecoder_libwebp.cpp b/src/images/SkImageDecoder_libwebp.cpp
index a7c9610d07ad0d7313406dd79d9a644cede5b22f..5b5e73e1a0b91bb5a34fbf95794ee820f9d9a11e 100644
--- a/src/images/SkImageDecoder_libwebp.cpp
+++ b/src/images/SkImageDecoder_libwebp.cpp
@@ -33,6 +33,7 @@ extern "C" {
// If moving libwebp out of skia source tree, path for webp headers must be
// updated accordingly. Here, we enforce using local copy in webp sub-directory.
#include "webp/decode.h"
+#include "webp/demux.h"
#include "webp/encode.h"
}
@@ -67,14 +68,27 @@ static bool webp_parse_header(SkStream* stream, int* width, int* height, int* al
SkASSERT(bytesToRead + totalBytesRead == WEBP_VP8_HEADER_SIZE);
} while (!stream->isAtEnd() && bytesToRead > 0);
- WebPBitstreamFeatures features;
- VP8StatusCode status = WebPGetFeatures(buffer, totalBytesRead, &features);
- if (VP8_STATUS_OK != status) {
- return false; // Invalid WebP file.
+ WebPData demuxData = { buffer, totalBytesRead };
+ WebPDemuxState demuxState;
+ WebPDemuxer* demuxer = WebPDemuxPartial(&demuxData, &demuxState);
+ if (!demuxer) {
+ return false;
}
- *width = features.width;
- *height = features.height;
- *alpha = features.has_alpha;
+
+ SkAutoTCallVProc<WebPDemuxer, WebPDemuxDelete> autoDeleter(demuxer);
+ switch (demuxState) {
+ case WEBP_DEMUX_PARSE_ERROR:
+ case WEBP_DEMUX_PARSING_HEADER:
+ return false;
+ default:
+ // Header parsed.
+ break;
+ }
+
+ *width = WebPDemuxGetI(demuxer, WEBP_FF_CANVAS_WIDTH);
+ *height = WebPDemuxGetI(demuxer, WEBP_FF_CANVAS_HEIGHT);
+ uint32_t format_flags = WebPDemuxGetI(demuxer, WEBP_FF_FORMAT_FLAGS);
+ *alpha = SkToBool(format_flags & ALPHA_FLAG) ? 1 : 0;
// sanity check for image size that's about to be decoded.
{

Powered by Google App Engine
This is Rietveld 408576698