1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 #include "ImageLogging.h" // Must appear first
8 #include "gfxPlatform.h"
9 #include "mozilla/TelemetryHistogramEnums.h"
10 #include "nsWebPDecoder.h"
11
12 #include "RasterImage.h"
13 #include "SurfacePipeFactory.h"
14
15 using namespace mozilla::gfx;
16
17 namespace mozilla {
18 namespace image {
19
20 static LazyLogModule sWebPLog("WebPDecoder");
21
nsWebPDecoder(RasterImage * aImage)22 nsWebPDecoder::nsWebPDecoder(RasterImage* aImage)
23 : Decoder(aImage),
24 mDecoder(nullptr),
25 mBlend(BlendMethod::OVER),
26 mDisposal(DisposalMethod::KEEP),
27 mTimeout(FrameTimeout::Forever()),
28 mFormat(SurfaceFormat::OS_RGBX),
29 mLastRow(0),
30 mCurrentFrame(0),
31 mData(nullptr),
32 mLength(0),
33 mIteratorComplete(false),
34 mNeedDemuxer(true),
35 mGotColorProfile(false) {
36 MOZ_LOG(sWebPLog, LogLevel::Debug,
37 ("[this=%p] nsWebPDecoder::nsWebPDecoder", this));
38 }
39
~nsWebPDecoder()40 nsWebPDecoder::~nsWebPDecoder() {
41 MOZ_LOG(sWebPLog, LogLevel::Debug,
42 ("[this=%p] nsWebPDecoder::~nsWebPDecoder", this));
43 if (mDecoder) {
44 WebPIDelete(mDecoder);
45 WebPFreeDecBuffer(&mBuffer);
46 }
47 }
48
ReadData()49 LexerResult nsWebPDecoder::ReadData() {
50 MOZ_ASSERT(mData);
51 MOZ_ASSERT(mLength > 0);
52
53 WebPDemuxer* demuxer = nullptr;
54 bool complete = mIteratorComplete;
55
56 if (mNeedDemuxer) {
57 WebPDemuxState state;
58 WebPData fragment;
59 fragment.bytes = mData;
60 fragment.size = mLength;
61
62 demuxer = WebPDemuxPartial(&fragment, &state);
63 if (state == WEBP_DEMUX_PARSE_ERROR) {
64 MOZ_LOG(
65 sWebPLog, LogLevel::Error,
66 ("[this=%p] nsWebPDecoder::ReadData -- demux parse error\n", this));
67 WebPDemuxDelete(demuxer);
68 return LexerResult(TerminalState::FAILURE);
69 }
70
71 if (state == WEBP_DEMUX_PARSING_HEADER) {
72 WebPDemuxDelete(demuxer);
73 return LexerResult(Yield::NEED_MORE_DATA);
74 }
75
76 if (!demuxer) {
77 MOZ_LOG(sWebPLog, LogLevel::Error,
78 ("[this=%p] nsWebPDecoder::ReadData -- no demuxer\n", this));
79 return LexerResult(TerminalState::FAILURE);
80 }
81
82 complete = complete || state == WEBP_DEMUX_DONE;
83 }
84
85 LexerResult rv(TerminalState::FAILURE);
86 if (!HasSize()) {
87 rv = ReadHeader(demuxer, complete);
88 } else {
89 rv = ReadPayload(demuxer, complete);
90 }
91
92 WebPDemuxDelete(demuxer);
93 return rv;
94 }
95
DoDecode(SourceBufferIterator & aIterator,IResumable * aOnResume)96 LexerResult nsWebPDecoder::DoDecode(SourceBufferIterator& aIterator,
97 IResumable* aOnResume) {
98 while (true) {
99 SourceBufferIterator::State state = SourceBufferIterator::COMPLETE;
100 if (!mIteratorComplete) {
101 state = aIterator.AdvanceOrScheduleResume(SIZE_MAX, aOnResume);
102
103 // We need to remember since we can't advance a complete iterator.
104 mIteratorComplete = state == SourceBufferIterator::COMPLETE;
105 }
106
107 if (state == SourceBufferIterator::WAITING) {
108 return LexerResult(Yield::NEED_MORE_DATA);
109 }
110
111 LexerResult rv = UpdateBuffer(aIterator, state);
112 if (rv.is<Yield>() && rv.as<Yield>() == Yield::NEED_MORE_DATA) {
113 // We need to check the iterator to see if more is available before
114 // giving up unless we are already complete.
115 if (mIteratorComplete) {
116 MOZ_LOG(sWebPLog, LogLevel::Error,
117 ("[this=%p] nsWebPDecoder::DoDecode -- read all data, "
118 "but needs more\n",
119 this));
120 return LexerResult(TerminalState::FAILURE);
121 }
122 continue;
123 }
124
125 return rv;
126 }
127 }
128
UpdateBuffer(SourceBufferIterator & aIterator,SourceBufferIterator::State aState)129 LexerResult nsWebPDecoder::UpdateBuffer(SourceBufferIterator& aIterator,
130 SourceBufferIterator::State aState) {
131 MOZ_ASSERT(!HasError(), "Shouldn't call DoDecode after error!");
132
133 switch (aState) {
134 case SourceBufferIterator::READY:
135 if (!aIterator.IsContiguous()) {
136 // We need to buffer. This should be rare, but expensive.
137 break;
138 }
139 if (!mData) {
140 // For as long as we hold onto an iterator, we know the data pointers
141 // to the chunks cannot change underneath us, so save the pointer to
142 // the first block.
143 MOZ_ASSERT(mLength == 0);
144 mData = reinterpret_cast<const uint8_t*>(aIterator.Data());
145 }
146 mLength += aIterator.Length();
147 return ReadData();
148 case SourceBufferIterator::COMPLETE:
149 if (!mData) {
150 // We must have hit an error, such as an OOM, when buffering the
151 // first set of encoded data.
152 MOZ_LOG(
153 sWebPLog, LogLevel::Error,
154 ("[this=%p] nsWebPDecoder::DoDecode -- complete no data\n", this));
155 return LexerResult(TerminalState::FAILURE);
156 }
157 return ReadData();
158 default:
159 MOZ_LOG(sWebPLog, LogLevel::Error,
160 ("[this=%p] nsWebPDecoder::DoDecode -- bad state\n", this));
161 return LexerResult(TerminalState::FAILURE);
162 }
163
164 // We need to buffer. If we have no data buffered, we need to get everything
165 // from the first chunk of the source buffer before appending the new data.
166 if (mBufferedData.empty()) {
167 MOZ_ASSERT(mData);
168 MOZ_ASSERT(mLength > 0);
169
170 if (!mBufferedData.append(mData, mLength)) {
171 MOZ_LOG(sWebPLog, LogLevel::Error,
172 ("[this=%p] nsWebPDecoder::DoDecode -- oom, initialize %zu\n",
173 this, mLength));
174 return LexerResult(TerminalState::FAILURE);
175 }
176
177 MOZ_LOG(sWebPLog, LogLevel::Debug,
178 ("[this=%p] nsWebPDecoder::DoDecode -- buffered %zu bytes\n", this,
179 mLength));
180 }
181
182 // Append the incremental data from the iterator.
183 if (!mBufferedData.append(aIterator.Data(), aIterator.Length())) {
184 MOZ_LOG(sWebPLog, LogLevel::Error,
185 ("[this=%p] nsWebPDecoder::DoDecode -- oom, append %zu on %zu\n",
186 this, aIterator.Length(), mBufferedData.length()));
187 return LexerResult(TerminalState::FAILURE);
188 }
189
190 MOZ_LOG(sWebPLog, LogLevel::Debug,
191 ("[this=%p] nsWebPDecoder::DoDecode -- buffered %zu -> %zu bytes\n",
192 this, aIterator.Length(), mBufferedData.length()));
193 mData = mBufferedData.begin();
194 mLength = mBufferedData.length();
195 return ReadData();
196 }
197
CreateFrame(const nsIntRect & aFrameRect)198 nsresult nsWebPDecoder::CreateFrame(const nsIntRect& aFrameRect) {
199 MOZ_ASSERT(HasSize());
200 MOZ_ASSERT(!mDecoder);
201
202 MOZ_LOG(
203 sWebPLog, LogLevel::Debug,
204 ("[this=%p] nsWebPDecoder::CreateFrame -- frame %u, (%d, %d) %d x %d\n",
205 this, mCurrentFrame, aFrameRect.x, aFrameRect.y, aFrameRect.width,
206 aFrameRect.height));
207
208 if (aFrameRect.width <= 0 || aFrameRect.height <= 0) {
209 MOZ_LOG(sWebPLog, LogLevel::Error,
210 ("[this=%p] nsWebPDecoder::CreateFrame -- bad frame rect\n", this));
211 return NS_ERROR_FAILURE;
212 }
213
214 // If this is our first frame in an animation and it doesn't cover the
215 // full frame, then we are transparent even if there is no alpha
216 if (mCurrentFrame == 0 && !aFrameRect.IsEqualEdges(FullFrame())) {
217 MOZ_ASSERT(HasAnimation());
218 mFormat = SurfaceFormat::OS_RGBA;
219 PostHasTransparency();
220 }
221
222 WebPInitDecBuffer(&mBuffer);
223
224 switch (SurfaceFormat::OS_RGBA) {
225 case SurfaceFormat::B8G8R8A8:
226 mBuffer.colorspace = MODE_BGRA;
227 break;
228 case SurfaceFormat::A8R8G8B8:
229 mBuffer.colorspace = MODE_ARGB;
230 break;
231 case SurfaceFormat::R8G8B8A8:
232 mBuffer.colorspace = MODE_RGBA;
233 break;
234 default:
235 MOZ_ASSERT_UNREACHABLE("Unknown OS_RGBA");
236 return NS_ERROR_FAILURE;
237 }
238
239 mDecoder = WebPINewDecoder(&mBuffer);
240 if (!mDecoder) {
241 MOZ_LOG(sWebPLog, LogLevel::Error,
242 ("[this=%p] nsWebPDecoder::CreateFrame -- create decoder error\n",
243 this));
244 return NS_ERROR_FAILURE;
245 }
246
247 // WebP doesn't guarantee that the alpha generated matches the hint in the
248 // header, so we always need to claim the input is BGRA. If the output is
249 // BGRX, swizzling will mask off the alpha channel.
250 #if MOZ_BIG_ENDIAN()
251 mBuffer.colorspace = MODE_ARGB;
252 SurfaceFormat inFormat = mFormat;
253 #else
254 SurfaceFormat inFormat = SurfaceFormat::OS_RGBA;
255 #endif
256
257 SurfacePipeFlags pipeFlags = SurfacePipeFlags();
258 if (mFormat == SurfaceFormat::OS_RGBA &&
259 !(GetSurfaceFlags() & SurfaceFlags::NO_PREMULTIPLY_ALPHA)) {
260 pipeFlags |= SurfacePipeFlags::PREMULTIPLY_ALPHA;
261 }
262
263 Maybe<AnimationParams> animParams;
264 if (!IsFirstFrameDecode()) {
265 animParams.emplace(aFrameRect, mTimeout, mCurrentFrame, mBlend, mDisposal);
266 }
267
268 Maybe<SurfacePipe> pipe = SurfacePipeFactory::CreateSurfacePipe(
269 this, Size(), OutputSize(), aFrameRect, inFormat, mFormat, animParams,
270 mTransform, pipeFlags);
271 if (!pipe) {
272 MOZ_LOG(sWebPLog, LogLevel::Error,
273 ("[this=%p] nsWebPDecoder::CreateFrame -- no pipe\n", this));
274 return NS_ERROR_FAILURE;
275 }
276
277 mFrameRect = aFrameRect;
278 mPipe = std::move(*pipe);
279 return NS_OK;
280 }
281
EndFrame()282 void nsWebPDecoder::EndFrame() {
283 MOZ_ASSERT(HasSize());
284 MOZ_ASSERT(mDecoder);
285
286 auto opacity = mFormat == SurfaceFormat::OS_RGBA ? Opacity::SOME_TRANSPARENCY
287 : Opacity::FULLY_OPAQUE;
288
289 MOZ_LOG(sWebPLog, LogLevel::Debug,
290 ("[this=%p] nsWebPDecoder::EndFrame -- frame %u, opacity %d, "
291 "disposal %d, timeout %d, blend %d\n",
292 this, mCurrentFrame, (int)opacity, (int)mDisposal,
293 mTimeout.AsEncodedValueDeprecated(), (int)mBlend));
294
295 PostFrameStop(opacity);
296 WebPIDelete(mDecoder);
297 WebPFreeDecBuffer(&mBuffer);
298 mDecoder = nullptr;
299 mLastRow = 0;
300 ++mCurrentFrame;
301 }
302
ApplyColorProfile(const char * aProfile,size_t aLength)303 void nsWebPDecoder::ApplyColorProfile(const char* aProfile, size_t aLength) {
304 MOZ_ASSERT(!mGotColorProfile);
305 mGotColorProfile = true;
306
307 if (mCMSMode == CMSMode::Off || !GetCMSOutputProfile() ||
308 (mCMSMode == CMSMode::TaggedOnly && !aProfile)) {
309 return;
310 }
311
312 if (!aProfile) {
313 MOZ_LOG(sWebPLog, LogLevel::Debug,
314 ("[this=%p] nsWebPDecoder::ApplyColorProfile -- not tagged, use "
315 "sRGB transform\n",
316 this));
317 mTransform = GetCMSsRGBTransform(SurfaceFormat::OS_RGBA);
318 return;
319 }
320
321 mInProfile = qcms_profile_from_memory(aProfile, aLength);
322 if (!mInProfile) {
323 MOZ_LOG(
324 sWebPLog, LogLevel::Error,
325 ("[this=%p] nsWebPDecoder::ApplyColorProfile -- bad color profile\n",
326 this));
327 return;
328 }
329
330 uint32_t profileSpace = qcms_profile_get_color_space(mInProfile);
331 if (profileSpace != icSigRgbData) {
332 // WebP doesn't produce grayscale data, this must be corrupt.
333 MOZ_LOG(sWebPLog, LogLevel::Error,
334 ("[this=%p] nsWebPDecoder::ApplyColorProfile -- ignoring non-rgb "
335 "color profile\n",
336 this));
337 return;
338 }
339
340 // Calculate rendering intent.
341 int intent = gfxPlatform::GetRenderingIntent();
342 if (intent == -1) {
343 intent = qcms_profile_get_rendering_intent(mInProfile);
344 }
345
346 // Create the color management transform.
347 qcms_data_type type = gfxPlatform::GetCMSOSRGBAType();
348 mTransform = qcms_transform_create(mInProfile, type, GetCMSOutputProfile(),
349 type, (qcms_intent)intent);
350 MOZ_LOG(sWebPLog, LogLevel::Debug,
351 ("[this=%p] nsWebPDecoder::ApplyColorProfile -- use tagged "
352 "transform\n",
353 this));
354 }
355
ReadHeader(WebPDemuxer * aDemuxer,bool aIsComplete)356 LexerResult nsWebPDecoder::ReadHeader(WebPDemuxer* aDemuxer, bool aIsComplete) {
357 MOZ_ASSERT(aDemuxer);
358
359 MOZ_LOG(
360 sWebPLog, LogLevel::Debug,
361 ("[this=%p] nsWebPDecoder::ReadHeader -- %zu bytes\n", this, mLength));
362
363 uint32_t flags = WebPDemuxGetI(aDemuxer, WEBP_FF_FORMAT_FLAGS);
364
365 if (!IsMetadataDecode() && !mGotColorProfile) {
366 if (flags & WebPFeatureFlags::ICCP_FLAG) {
367 WebPChunkIterator iter;
368 if (!WebPDemuxGetChunk(aDemuxer, "ICCP", 1, &iter)) {
369 return aIsComplete ? LexerResult(TerminalState::FAILURE)
370 : LexerResult(Yield::NEED_MORE_DATA);
371 }
372
373 ApplyColorProfile(reinterpret_cast<const char*>(iter.chunk.bytes),
374 iter.chunk.size);
375 WebPDemuxReleaseChunkIterator(&iter);
376 } else {
377 ApplyColorProfile(nullptr, 0);
378 }
379 }
380
381 if (flags & WebPFeatureFlags::ANIMATION_FLAG) {
382 // A metadata decode expects to get the correct first frame timeout which
383 // sadly is not provided by the normal WebP header parsing.
384 WebPIterator iter;
385 if (!WebPDemuxGetFrame(aDemuxer, 1, &iter)) {
386 return aIsComplete ? LexerResult(TerminalState::FAILURE)
387 : LexerResult(Yield::NEED_MORE_DATA);
388 }
389
390 PostIsAnimated(FrameTimeout::FromRawMilliseconds(iter.duration));
391 WebPDemuxReleaseIterator(&iter);
392 } else {
393 // Single frames don't need a demuxer to be created.
394 mNeedDemuxer = false;
395 }
396
397 uint32_t width = WebPDemuxGetI(aDemuxer, WEBP_FF_CANVAS_WIDTH);
398 uint32_t height = WebPDemuxGetI(aDemuxer, WEBP_FF_CANVAS_HEIGHT);
399 if (width > INT32_MAX || height > INT32_MAX) {
400 return LexerResult(TerminalState::FAILURE);
401 }
402
403 PostSize(width, height);
404
405 bool alpha = flags & WebPFeatureFlags::ALPHA_FLAG;
406 if (alpha) {
407 mFormat = SurfaceFormat::OS_RGBA;
408 PostHasTransparency();
409 }
410
411 MOZ_LOG(sWebPLog, LogLevel::Debug,
412 ("[this=%p] nsWebPDecoder::ReadHeader -- %u x %u, alpha %d, "
413 "animation %d, metadata decode %d, first frame decode %d\n",
414 this, width, height, alpha, HasAnimation(), IsMetadataDecode(),
415 IsFirstFrameDecode()));
416
417 if (IsMetadataDecode()) {
418 return LexerResult(TerminalState::SUCCESS);
419 }
420
421 return ReadPayload(aDemuxer, aIsComplete);
422 }
423
ReadPayload(WebPDemuxer * aDemuxer,bool aIsComplete)424 LexerResult nsWebPDecoder::ReadPayload(WebPDemuxer* aDemuxer,
425 bool aIsComplete) {
426 if (!HasAnimation()) {
427 auto rv = ReadSingle(mData, mLength, FullFrame());
428 if (rv.is<TerminalState>() &&
429 rv.as<TerminalState>() == TerminalState::SUCCESS) {
430 PostDecodeDone();
431 }
432 return rv;
433 }
434 return ReadMultiple(aDemuxer, aIsComplete);
435 }
436
ReadSingle(const uint8_t * aData,size_t aLength,const IntRect & aFrameRect)437 LexerResult nsWebPDecoder::ReadSingle(const uint8_t* aData, size_t aLength,
438 const IntRect& aFrameRect) {
439 MOZ_ASSERT(!IsMetadataDecode());
440 MOZ_ASSERT(aData);
441 MOZ_ASSERT(aLength > 0);
442
443 MOZ_LOG(
444 sWebPLog, LogLevel::Debug,
445 ("[this=%p] nsWebPDecoder::ReadSingle -- %zu bytes\n", this, aLength));
446
447 if (!mDecoder && NS_FAILED(CreateFrame(aFrameRect))) {
448 return LexerResult(TerminalState::FAILURE);
449 }
450
451 bool complete;
452 do {
453 VP8StatusCode status = WebPIUpdate(mDecoder, aData, aLength);
454 switch (status) {
455 case VP8_STATUS_OK:
456 complete = true;
457 break;
458 case VP8_STATUS_SUSPENDED:
459 complete = false;
460 break;
461 default:
462 MOZ_LOG(sWebPLog, LogLevel::Error,
463 ("[this=%p] nsWebPDecoder::ReadSingle -- append error %d\n",
464 this, status));
465 return LexerResult(TerminalState::FAILURE);
466 }
467
468 int lastRow = -1;
469 int width = 0;
470 int height = 0;
471 int stride = 0;
472 uint8_t* rowStart =
473 WebPIDecGetRGB(mDecoder, &lastRow, &width, &height, &stride);
474
475 MOZ_LOG(
476 sWebPLog, LogLevel::Debug,
477 ("[this=%p] nsWebPDecoder::ReadSingle -- complete %d, read %d rows, "
478 "has %d rows available\n",
479 this, complete, mLastRow, lastRow));
480
481 if (!rowStart || lastRow == -1 || lastRow == mLastRow) {
482 return LexerResult(Yield::NEED_MORE_DATA);
483 }
484
485 if (width != mFrameRect.width || height != mFrameRect.height ||
486 stride < mFrameRect.width * 4 || lastRow > mFrameRect.height) {
487 MOZ_LOG(sWebPLog, LogLevel::Error,
488 ("[this=%p] nsWebPDecoder::ReadSingle -- bad (w,h,s) = (%d, %d, "
489 "%d)\n",
490 this, width, height, stride));
491 return LexerResult(TerminalState::FAILURE);
492 }
493
494 for (int row = mLastRow; row < lastRow; row++) {
495 uint32_t* src = reinterpret_cast<uint32_t*>(rowStart + row * stride);
496 WriteState result = mPipe.WriteBuffer(src);
497
498 Maybe<SurfaceInvalidRect> invalidRect = mPipe.TakeInvalidRect();
499 if (invalidRect) {
500 PostInvalidation(invalidRect->mInputSpaceRect,
501 Some(invalidRect->mOutputSpaceRect));
502 }
503
504 if (result == WriteState::FAILURE) {
505 MOZ_LOG(sWebPLog, LogLevel::Error,
506 ("[this=%p] nsWebPDecoder::ReadSingle -- write pixels error\n",
507 this));
508 return LexerResult(TerminalState::FAILURE);
509 }
510
511 if (result == WriteState::FINISHED) {
512 MOZ_ASSERT(row == lastRow - 1, "There was more data to read?");
513 complete = true;
514 break;
515 }
516 }
517
518 mLastRow = lastRow;
519 } while (!complete);
520
521 if (!complete) {
522 return LexerResult(Yield::NEED_MORE_DATA);
523 }
524
525 EndFrame();
526 return LexerResult(TerminalState::SUCCESS);
527 }
528
ReadMultiple(WebPDemuxer * aDemuxer,bool aIsComplete)529 LexerResult nsWebPDecoder::ReadMultiple(WebPDemuxer* aDemuxer,
530 bool aIsComplete) {
531 MOZ_ASSERT(!IsMetadataDecode());
532 MOZ_ASSERT(aDemuxer);
533
534 MOZ_LOG(sWebPLog, LogLevel::Debug,
535 ("[this=%p] nsWebPDecoder::ReadMultiple\n", this));
536
537 bool complete = aIsComplete;
538 WebPIterator iter;
539 auto rv = LexerResult(Yield::NEED_MORE_DATA);
540 if (WebPDemuxGetFrame(aDemuxer, mCurrentFrame + 1, &iter)) {
541 switch (iter.blend_method) {
542 case WEBP_MUX_BLEND:
543 mBlend = BlendMethod::OVER;
544 break;
545 case WEBP_MUX_NO_BLEND:
546 mBlend = BlendMethod::SOURCE;
547 break;
548 default:
549 MOZ_ASSERT_UNREACHABLE("Unhandled blend method");
550 break;
551 }
552
553 switch (iter.dispose_method) {
554 case WEBP_MUX_DISPOSE_NONE:
555 mDisposal = DisposalMethod::KEEP;
556 break;
557 case WEBP_MUX_DISPOSE_BACKGROUND:
558 mDisposal = DisposalMethod::CLEAR;
559 break;
560 default:
561 MOZ_ASSERT_UNREACHABLE("Unhandled dispose method");
562 break;
563 }
564
565 mFormat = iter.has_alpha || mCurrentFrame > 0 ? SurfaceFormat::OS_RGBA
566 : SurfaceFormat::OS_RGBX;
567 mTimeout = FrameTimeout::FromRawMilliseconds(iter.duration);
568 nsIntRect frameRect(iter.x_offset, iter.y_offset, iter.width, iter.height);
569
570 rv = ReadSingle(iter.fragment.bytes, iter.fragment.size, frameRect);
571 complete = complete && !WebPDemuxNextFrame(&iter);
572 WebPDemuxReleaseIterator(&iter);
573 }
574
575 if (rv.is<TerminalState>() &&
576 rv.as<TerminalState>() == TerminalState::SUCCESS) {
577 // If we extracted one frame, and it is not the last, we need to yield to
578 // the lexer to allow the upper layers to acknowledge the frame.
579 if (!complete && !IsFirstFrameDecode()) {
580 rv = LexerResult(Yield::OUTPUT_AVAILABLE);
581 } else {
582 uint32_t loopCount = WebPDemuxGetI(aDemuxer, WEBP_FF_LOOP_COUNT);
583
584 MOZ_LOG(sWebPLog, LogLevel::Debug,
585 ("[this=%p] nsWebPDecoder::ReadMultiple -- loop count %u\n", this,
586 loopCount));
587 PostDecodeDone(loopCount - 1);
588 }
589 }
590
591 return rv;
592 }
593
SpeedHistogram() const594 Maybe<Telemetry::HistogramID> nsWebPDecoder::SpeedHistogram() const {
595 return Some(Telemetry::IMAGE_DECODE_SPEED_WEBP);
596 }
597
598 } // namespace image
599 } // namespace mozilla
600