• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2015 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #include "src/codec/SkWebpCodec.h"
9 
10 #include "include/codec/SkCodecAnimation.h"
11 #include "include/core/SkBitmap.h"
12 #include "include/core/SkCanvas.h"
13 #include "include/private/SkTemplates.h"
14 #include "include/private/SkTo.h"
15 #include "src/codec/SkCodecAnimationPriv.h"
16 #include "src/codec/SkCodecPriv.h"
17 #include "src/codec/SkSampler.h"
18 #include "src/core/SkMakeUnique.h"
19 #include "src/core/SkRasterPipeline.h"
20 #include "src/core/SkStreamPriv.h"
21 
22 // A WebP decoder on top of (subset of) libwebp
23 // For more information on WebP image format, and libwebp library, see:
24 //   https://code.google.com/speed/webp/
25 //   http://www.webmproject.org/code/#libwebp-webp-image-library
26 //   https://chromium.googlesource.com/webm/libwebp
27 
28 // If moving libwebp out of skia source tree, path for webp headers must be
29 // updated accordingly. Here, we enforce using local copy in webp sub-directory.
30 #include "webp/decode.h"
31 #include "webp/demux.h"
32 #include "webp/encode.h"
33 
IsWebp(const void * buf,size_t bytesRead)34 bool SkWebpCodec::IsWebp(const void* buf, size_t bytesRead) {
35     // WEBP starts with the following:
36     // RIFFXXXXWEBPVP
37     // Where XXXX is unspecified.
38     const char* bytes = static_cast<const char*>(buf);
39     return bytesRead >= 14 && !memcmp(bytes, "RIFF", 4) && !memcmp(&bytes[8], "WEBPVP", 6);
40 }
41 
42 // Parse headers of RIFF container, and check for valid Webp (VP8) content.
43 // Returns an SkWebpCodec on success
MakeFromStream(std::unique_ptr<SkStream> stream,Result * result)44 std::unique_ptr<SkCodec> SkWebpCodec::MakeFromStream(std::unique_ptr<SkStream> stream,
45                                                      Result* result) {
46     // Webp demux needs a contiguous data buffer.
47     sk_sp<SkData> data = nullptr;
48     if (stream->getMemoryBase()) {
49         // It is safe to make without copy because we'll hold onto the stream.
50         data = SkData::MakeWithoutCopy(stream->getMemoryBase(), stream->getLength());
51     } else {
52         data = SkCopyStreamToData(stream.get());
53 
54         // If we are forced to copy the stream to a data, we can go ahead and delete the stream.
55         stream.reset(nullptr);
56     }
57 
58     // It's a little strange that the |demux| will outlive |webpData|, though it needs the
59     // pointer in |webpData| to remain valid.  This works because the pointer remains valid
60     // until the SkData is freed.
61     WebPData webpData = { data->bytes(), data->size() };
62     WebPDemuxState state;
63     SkAutoTCallVProc<WebPDemuxer, WebPDemuxDelete> demux(WebPDemuxPartial(&webpData, &state));
64     switch (state) {
65         case WEBP_DEMUX_PARSE_ERROR:
66             *result = kInvalidInput;
67             return nullptr;
68         case WEBP_DEMUX_PARSING_HEADER:
69             *result = kIncompleteInput;
70             return nullptr;
71         case WEBP_DEMUX_PARSED_HEADER:
72         case WEBP_DEMUX_DONE:
73             SkASSERT(demux);
74             break;
75     }
76 
77     const int width = WebPDemuxGetI(demux, WEBP_FF_CANVAS_WIDTH);
78     const int height = WebPDemuxGetI(demux, WEBP_FF_CANVAS_HEIGHT);
79 
80     // Sanity check for image size that's about to be decoded.
81     {
82         const int64_t size = sk_64_mul(width, height);
83         // now check that if we are 4-bytes per pixel, we also don't overflow
84         if (!SkTFitsIn<int32_t>(size) || SkTo<int32_t>(size) > (0x7FFFFFFF >> 2)) {
85             *result = kInvalidInput;
86             return nullptr;
87         }
88     }
89 
90     std::unique_ptr<SkEncodedInfo::ICCProfile> profile = nullptr;
91     {
92         WebPChunkIterator chunkIterator;
93         SkAutoTCallVProc<WebPChunkIterator, WebPDemuxReleaseChunkIterator> autoCI(&chunkIterator);
94         if (WebPDemuxGetChunk(demux, "ICCP", 1, &chunkIterator)) {
95             // FIXME: I think this could be MakeWithoutCopy
96             auto chunk = SkData::MakeWithCopy(chunkIterator.chunk.bytes, chunkIterator.chunk.size);
97             profile = SkEncodedInfo::ICCProfile::Make(std::move(chunk));
98         }
99         if (profile && profile->profile()->data_color_space != skcms_Signature_RGB) {
100             profile = nullptr;
101         }
102     }
103 
104     SkEncodedOrigin origin = kDefault_SkEncodedOrigin;
105     {
106         WebPChunkIterator chunkIterator;
107         SkAutoTCallVProc<WebPChunkIterator, WebPDemuxReleaseChunkIterator> autoCI(&chunkIterator);
108         if (WebPDemuxGetChunk(demux, "EXIF", 1, &chunkIterator)) {
109             is_orientation_marker(chunkIterator.chunk.bytes, chunkIterator.chunk.size, &origin);
110         }
111     }
112 
113     // Get the first frame and its "features" to determine the color and alpha types.
114     WebPIterator frame;
115     SkAutoTCallVProc<WebPIterator, WebPDemuxReleaseIterator> autoFrame(&frame);
116     if (!WebPDemuxGetFrame(demux, 1, &frame)) {
117         *result = kIncompleteInput;
118         return nullptr;
119     }
120 
121     WebPBitstreamFeatures features;
122     switch (WebPGetFeatures(frame.fragment.bytes, frame.fragment.size, &features)) {
123         case VP8_STATUS_OK:
124             break;
125         case VP8_STATUS_SUSPENDED:
126         case VP8_STATUS_NOT_ENOUGH_DATA:
127             *result = kIncompleteInput;
128             return nullptr;
129         default:
130             *result = kInvalidInput;
131             return nullptr;
132     }
133 
134     const bool hasAlpha = SkToBool(frame.has_alpha)
135             || frame.width != width || frame.height != height;
136     SkEncodedInfo::Color color;
137     SkEncodedInfo::Alpha alpha;
138     switch (features.format) {
139         case 0:
140             // This indicates a "mixed" format.  We could see this for
141             // animated webps (multiple fragments).
142             // We could also guess kYUV here, but I think it makes more
143             // sense to guess kBGRA which is likely closer to the final
144             // output.  Otherwise, we might end up converting
145             // BGRA->YUVA->BGRA.
146             // Fallthrough:
147         case 2:
148             // This is the lossless format (BGRA).
149             if (hasAlpha) {
150                 color = SkEncodedInfo::kBGRA_Color;
151                 alpha = SkEncodedInfo::kUnpremul_Alpha;
152             } else {
153                 color = SkEncodedInfo::kBGRX_Color;
154                 alpha = SkEncodedInfo::kOpaque_Alpha;
155             }
156             break;
157         case 1:
158             // This is the lossy format (YUV).
159             if (hasAlpha) {
160                 color = SkEncodedInfo::kYUVA_Color;
161                 alpha = SkEncodedInfo::kUnpremul_Alpha;
162             } else {
163                 color = SkEncodedInfo::kYUV_Color;
164                 alpha = SkEncodedInfo::kOpaque_Alpha;
165             }
166             break;
167         default:
168             *result = kInvalidInput;
169             return nullptr;
170     }
171 
172 
173     *result = kSuccess;
174     SkEncodedInfo info = SkEncodedInfo::Make(width, height, color, alpha, 8, std::move(profile));
175     return std::unique_ptr<SkCodec>(new SkWebpCodec(std::move(info), std::move(stream),
176                                                     demux.release(), std::move(data), origin));
177 }
178 
webp_decode_mode(SkColorType dstCT,bool premultiply)179 static WEBP_CSP_MODE webp_decode_mode(SkColorType dstCT, bool premultiply) {
180     switch (dstCT) {
181         case kBGRA_8888_SkColorType:
182             return premultiply ? MODE_bgrA : MODE_BGRA;
183         case kRGBA_8888_SkColorType:
184             return premultiply ? MODE_rgbA : MODE_RGBA;
185         case kRGB_565_SkColorType:
186             return MODE_RGB_565;
187         default:
188             return MODE_LAST;
189     }
190 }
191 
appendNewFrame(bool hasAlpha)192 SkWebpCodec::Frame* SkWebpCodec::FrameHolder::appendNewFrame(bool hasAlpha) {
193     const int i = this->size();
194     fFrames.emplace_back(i, hasAlpha ? SkEncodedInfo::kUnpremul_Alpha
195                                      : SkEncodedInfo::kOpaque_Alpha);
196     return &fFrames[i];
197 }
198 
onGetValidSubset(SkIRect * desiredSubset) const199 bool SkWebpCodec::onGetValidSubset(SkIRect* desiredSubset) const {
200     if (!desiredSubset) {
201         return false;
202     }
203 
204     if (!this->bounds().contains(*desiredSubset)) {
205         return false;
206     }
207 
208     // As stated below, libwebp snaps to even left and top. Make sure top and left are even, so we
209     // decode this exact subset.
210     // Leave right and bottom unmodified, so we suggest a slightly larger subset than requested.
211     desiredSubset->fLeft = (desiredSubset->fLeft >> 1) << 1;
212     desiredSubset->fTop = (desiredSubset->fTop >> 1) << 1;
213     return true;
214 }
215 
onGetRepetitionCount()216 int SkWebpCodec::onGetRepetitionCount() {
217     auto flags = WebPDemuxGetI(fDemux.get(), WEBP_FF_FORMAT_FLAGS);
218     if (!(flags & ANIMATION_FLAG)) {
219         return 0;
220     }
221 
222     const int repCount = WebPDemuxGetI(fDemux.get(), WEBP_FF_LOOP_COUNT);
223     if (0 == repCount) {
224         return kRepetitionCountInfinite;
225     }
226 
227     return repCount;
228 }
229 
onGetFrameCount()230 int SkWebpCodec::onGetFrameCount() {
231     auto flags = WebPDemuxGetI(fDemux.get(), WEBP_FF_FORMAT_FLAGS);
232     if (!(flags & ANIMATION_FLAG)) {
233         return 1;
234     }
235 
236     const uint32_t oldFrameCount = fFrameHolder.size();
237     if (fFailed) {
238         return oldFrameCount;
239     }
240 
241     const uint32_t frameCount = WebPDemuxGetI(fDemux, WEBP_FF_FRAME_COUNT);
242     if (oldFrameCount == frameCount) {
243         // We have already parsed this.
244         return frameCount;
245     }
246 
247     fFrameHolder.reserve(frameCount);
248 
249     for (uint32_t i = oldFrameCount; i < frameCount; i++) {
250         WebPIterator iter;
251         SkAutoTCallVProc<WebPIterator, WebPDemuxReleaseIterator> autoIter(&iter);
252 
253         if (!WebPDemuxGetFrame(fDemux.get(), i + 1, &iter)) {
254             fFailed = true;
255             break;
256         }
257 
258         // libwebp only reports complete frames of an animated image.
259         SkASSERT(iter.complete);
260 
261         Frame* frame = fFrameHolder.appendNewFrame(iter.has_alpha);
262         frame->setXYWH(iter.x_offset, iter.y_offset, iter.width, iter.height);
263         frame->setDisposalMethod(iter.dispose_method == WEBP_MUX_DISPOSE_BACKGROUND ?
264                 SkCodecAnimation::DisposalMethod::kRestoreBGColor :
265                 SkCodecAnimation::DisposalMethod::kKeep);
266         frame->setDuration(iter.duration);
267         if (WEBP_MUX_BLEND != iter.blend_method) {
268             frame->setBlend(SkCodecAnimation::Blend::kBG);
269         }
270         fFrameHolder.setAlphaAndRequiredFrame(frame);
271     }
272 
273     return fFrameHolder.size();
274 
275 }
276 
onGetFrame(int i) const277 const SkFrame* SkWebpCodec::FrameHolder::onGetFrame(int i) const {
278     return static_cast<const SkFrame*>(this->frame(i));
279 }
280 
frame(int i) const281 const SkWebpCodec::Frame* SkWebpCodec::FrameHolder::frame(int i) const {
282     SkASSERT(i >= 0 && i < this->size());
283     return &fFrames[i];
284 }
285 
onGetFrameInfo(int i,FrameInfo * frameInfo) const286 bool SkWebpCodec::onGetFrameInfo(int i, FrameInfo* frameInfo) const {
287     if (i >= fFrameHolder.size()) {
288         return false;
289     }
290 
291     const Frame* frame = fFrameHolder.frame(i);
292     if (!frame) {
293         return false;
294     }
295 
296     if (frameInfo) {
297         frameInfo->fRequiredFrame = frame->getRequiredFrame();
298         frameInfo->fDuration = frame->getDuration();
299         // libwebp only reports fully received frames for an
300         // animated image.
301         frameInfo->fFullyReceived = true;
302         frameInfo->fAlphaType = frame->hasAlpha() ? kUnpremul_SkAlphaType
303                                                   : kOpaque_SkAlphaType;
304         frameInfo->fDisposalMethod = frame->getDisposalMethod();
305     }
306 
307     return true;
308 }
309 
is_8888(SkColorType colorType)310 static bool is_8888(SkColorType colorType) {
311     switch (colorType) {
312         case kRGBA_8888_SkColorType:
313         case kBGRA_8888_SkColorType:
314             return true;
315         default:
316             return false;
317     }
318 }
319 
320 // Requires that the src input be unpremultiplied (or opaque).
blend_line(SkColorType dstCT,void * dst,SkColorType srcCT,const void * src,SkAlphaType dstAt,bool srcHasAlpha,int width)321 static void blend_line(SkColorType dstCT, void* dst,
322                        SkColorType srcCT, const void* src,
323                        SkAlphaType dstAt,
324                        bool srcHasAlpha,
325                        int width) {
326     SkRasterPipeline_MemoryCtx dst_ctx = { (void*)dst, 0 },
327                                src_ctx = { (void*)src, 0 };
328 
329     SkRasterPipeline_<256> p;
330 
331     p.append_load_dst(dstCT, &dst_ctx);
332     if (kUnpremul_SkAlphaType == dstAt) {
333         p.append(SkRasterPipeline::premul_dst);
334     }
335 
336     p.append_load(srcCT, &src_ctx);
337     if (srcHasAlpha) {
338         p.append(SkRasterPipeline::premul);
339     }
340 
341     p.append(SkRasterPipeline::srcover);
342 
343     if (kUnpremul_SkAlphaType == dstAt) {
344         p.append(SkRasterPipeline::unpremul);
345     }
346     p.append_store(dstCT, &dst_ctx);
347 
348     p.run(0,0, width,1);
349 }
350 
onGetPixels(const SkImageInfo & dstInfo,void * dst,size_t rowBytes,const Options & options,int * rowsDecodedPtr)351 SkCodec::Result SkWebpCodec::onGetPixels(const SkImageInfo& dstInfo, void* dst, size_t rowBytes,
352                                          const Options& options, int* rowsDecodedPtr) {
353     const int index = options.fFrameIndex;
354     SkASSERT(0 == index || index < fFrameHolder.size());
355     SkASSERT(0 == index || !options.fSubset);
356 
357     WebPDecoderConfig config;
358     if (0 == WebPInitDecoderConfig(&config)) {
359         // ABI mismatch.
360         // FIXME: New enum for this?
361         return kInvalidInput;
362     }
363 
364     // Free any memory associated with the buffer. Must be called last, so we declare it first.
365     SkAutoTCallVProc<WebPDecBuffer, WebPFreeDecBuffer> autoFree(&(config.output));
366 
367     WebPIterator frame;
368     SkAutoTCallVProc<WebPIterator, WebPDemuxReleaseIterator> autoFrame(&frame);
369     // If this succeeded in onGetFrameCount(), it should succeed again here.
370     SkAssertResult(WebPDemuxGetFrame(fDemux, index + 1, &frame));
371 
372     const bool independent = index == 0 ? true :
373             (fFrameHolder.frame(index)->getRequiredFrame() == kNoFrame);
374     // Get the frameRect.  libwebp will have already signaled an error if this is not fully
375     // contained by the canvas.
376     auto frameRect = SkIRect::MakeXYWH(frame.x_offset, frame.y_offset, frame.width, frame.height);
377     SkASSERT(this->bounds().contains(frameRect));
378     const bool frameIsSubset = frameRect != this->bounds();
379     if (independent && frameIsSubset) {
380         SkSampler::Fill(dstInfo, dst, rowBytes, options.fZeroInitialized);
381     }
382 
383     int dstX = frameRect.x();
384     int dstY = frameRect.y();
385     int subsetWidth = frameRect.width();
386     int subsetHeight = frameRect.height();
387     if (options.fSubset) {
388         SkIRect subset = *options.fSubset;
389         SkASSERT(this->bounds().contains(subset));
390         SkASSERT(SkIsAlign2(subset.fLeft) && SkIsAlign2(subset.fTop));
391         SkASSERT(this->getValidSubset(&subset) && subset == *options.fSubset);
392 
393         if (!SkIRect::IntersectsNoEmptyCheck(subset, frameRect)) {
394             return kSuccess;
395         }
396 
397         int minXOffset = SkTMin(dstX, subset.x());
398         int minYOffset = SkTMin(dstY, subset.y());
399         dstX -= minXOffset;
400         dstY -= minYOffset;
401         frameRect.offset(-minXOffset, -minYOffset);
402         subset.offset(-minXOffset, -minYOffset);
403 
404         // Just like we require that the requested subset x and y offset are even, libwebp
405         // guarantees that the frame x and y offset are even (it's actually impossible to specify
406         // an odd frame offset).  So we can still guarantee that the adjusted offsets are even.
407         SkASSERT(SkIsAlign2(subset.fLeft) && SkIsAlign2(subset.fTop));
408 
409         SkIRect intersection;
410         SkAssertResult(intersection.intersect(frameRect, subset));
411         subsetWidth = intersection.width();
412         subsetHeight = intersection.height();
413 
414         config.options.use_cropping = 1;
415         config.options.crop_left = subset.x();
416         config.options.crop_top = subset.y();
417         config.options.crop_width = subsetWidth;
418         config.options.crop_height = subsetHeight;
419     }
420 
421     // Ignore the frame size and offset when determining if scaling is necessary.
422     int scaledWidth = subsetWidth;
423     int scaledHeight = subsetHeight;
424     SkISize srcSize = options.fSubset ? options.fSubset->size() : this->dimensions();
425     if (srcSize != dstInfo.dimensions()) {
426         config.options.use_scaling = 1;
427 
428         if (frameIsSubset) {
429             float scaleX = ((float) dstInfo.width()) / srcSize.width();
430             float scaleY = ((float) dstInfo.height()) / srcSize.height();
431 
432             // We need to be conservative here and floor rather than round.
433             // Otherwise, we may find ourselves decoding off the end of memory.
434             dstX = scaleX * dstX;
435             scaledWidth = scaleX * scaledWidth;
436             dstY = scaleY * dstY;
437             scaledHeight = scaleY * scaledHeight;
438             if (0 == scaledWidth || 0 == scaledHeight) {
439                 return kSuccess;
440             }
441         } else {
442             scaledWidth = dstInfo.width();
443             scaledHeight = dstInfo.height();
444         }
445 
446         config.options.scaled_width = scaledWidth;
447         config.options.scaled_height = scaledHeight;
448     }
449 
450     const bool blendWithPrevFrame = !independent && frame.blend_method == WEBP_MUX_BLEND
451         && frame.has_alpha;
452 
453     SkBitmap webpDst;
454     auto webpInfo = dstInfo;
455     if (!frame.has_alpha) {
456         webpInfo = webpInfo.makeAlphaType(kOpaque_SkAlphaType);
457     }
458     if (this->colorXform()) {
459         // Swizzling between RGBA and BGRA is zero cost in a color transform.  So when we have a
460         // color transform, we should decode to whatever is easiest for libwebp, and then let the
461         // color transform swizzle if necessary.
462         // Lossy webp is encoded as YUV (so RGBA and BGRA are the same cost).  Lossless webp is
463         // encoded as BGRA. This means decoding to BGRA is either faster or the same cost as RGBA.
464         webpInfo = webpInfo.makeColorType(kBGRA_8888_SkColorType);
465 
466         if (webpInfo.alphaType() == kPremul_SkAlphaType) {
467             webpInfo = webpInfo.makeAlphaType(kUnpremul_SkAlphaType);
468         }
469     }
470 
471     if ((this->colorXform() && !is_8888(dstInfo.colorType())) || blendWithPrevFrame) {
472         // We will decode the entire image and then perform the color transform.  libwebp
473         // does not provide a row-by-row API.  This is a shame particularly when we do not want
474         // 8888, since we will need to create another image sized buffer.
475         webpDst.allocPixels(webpInfo);
476     } else {
477         // libwebp can decode directly into the output memory.
478         webpDst.installPixels(webpInfo, dst, rowBytes);
479     }
480 
481     config.output.colorspace = webp_decode_mode(webpInfo.colorType(),
482             frame.has_alpha && dstInfo.alphaType() == kPremul_SkAlphaType && !this->colorXform());
483     config.output.is_external_memory = 1;
484 
485     config.output.u.RGBA.rgba = reinterpret_cast<uint8_t*>(webpDst.getAddr(dstX, dstY));
486     config.output.u.RGBA.stride = static_cast<int>(webpDst.rowBytes());
487     config.output.u.RGBA.size = webpDst.computeByteSize();
488 
489     SkAutoTCallVProc<WebPIDecoder, WebPIDelete> idec(WebPIDecode(nullptr, 0, &config));
490     if (!idec) {
491         return kInvalidInput;
492     }
493 
494     int rowsDecoded = 0;
495     SkCodec::Result result;
496     switch (WebPIUpdate(idec, frame.fragment.bytes, frame.fragment.size)) {
497         case VP8_STATUS_OK:
498             rowsDecoded = scaledHeight;
499             result = kSuccess;
500             break;
501         case VP8_STATUS_SUSPENDED:
502             if (!WebPIDecGetRGB(idec, &rowsDecoded, nullptr, nullptr, nullptr)
503                     || rowsDecoded <= 0) {
504                 return kInvalidInput;
505             }
506             *rowsDecodedPtr = rowsDecoded + dstY;
507             result = kIncompleteInput;
508             break;
509         default:
510             return kInvalidInput;
511     }
512 
513     const size_t dstBpp = dstInfo.bytesPerPixel();
514     dst = SkTAddOffset<void>(dst, dstBpp * dstX + rowBytes * dstY);
515     const size_t srcRowBytes = config.output.u.RGBA.stride;
516 
517     const auto dstCT = dstInfo.colorType();
518     if (this->colorXform()) {
519         uint32_t* xformSrc = (uint32_t*) config.output.u.RGBA.rgba;
520         SkBitmap tmp;
521         void* xformDst;
522 
523         if (blendWithPrevFrame) {
524             // Xform into temporary bitmap big enough for one row.
525             tmp.allocPixels(dstInfo.makeWH(scaledWidth, 1));
526             xformDst = tmp.getPixels();
527         } else {
528             xformDst = dst;
529         }
530 
531         for (int y = 0; y < rowsDecoded; y++) {
532             this->applyColorXform(xformDst, xformSrc, scaledWidth);
533             if (blendWithPrevFrame) {
534                 blend_line(dstCT, dst, dstCT, xformDst,
535                         dstInfo.alphaType(), frame.has_alpha, scaledWidth);
536                 dst = SkTAddOffset<void>(dst, rowBytes);
537             } else {
538                 xformDst = SkTAddOffset<void>(xformDst, rowBytes);
539             }
540             xformSrc = SkTAddOffset<uint32_t>(xformSrc, srcRowBytes);
541         }
542     } else if (blendWithPrevFrame) {
543         const uint8_t* src = config.output.u.RGBA.rgba;
544 
545         for (int y = 0; y < rowsDecoded; y++) {
546             blend_line(dstCT, dst, webpDst.colorType(), src,
547                     dstInfo.alphaType(), frame.has_alpha, scaledWidth);
548             src = SkTAddOffset<const uint8_t>(src, srcRowBytes);
549             dst = SkTAddOffset<void>(dst, rowBytes);
550         }
551     }
552 
553     return result;
554 }
555 
SkWebpCodec(SkEncodedInfo && info,std::unique_ptr<SkStream> stream,WebPDemuxer * demux,sk_sp<SkData> data,SkEncodedOrigin origin)556 SkWebpCodec::SkWebpCodec(SkEncodedInfo&& info, std::unique_ptr<SkStream> stream,
557                          WebPDemuxer* demux, sk_sp<SkData> data, SkEncodedOrigin origin)
558     : INHERITED(std::move(info), skcms_PixelFormat_BGRA_8888, std::move(stream),
559                 origin)
560     , fDemux(demux)
561     , fData(std::move(data))
562     , fFailed(false)
563 {
564     const auto& eInfo = this->getEncodedInfo();
565     fFrameHolder.setScreenSize(eInfo.width(), eInfo.height());
566 }
567