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

Side by Side Diff: Source/platform/image-decoders/webp/WEBPImageDecoder.cpp

Issue 284043003: Looping of animated WebP: Loop count off-by-one (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 } 222 }
223 223
224 ASSERT(ImageDecoder::isSizeAvailable()); 224 ASSERT(ImageDecoder::isSizeAvailable());
225 const size_t newFrameCount = WebPDemuxGetI(m_demux, WEBP_FF_FRAME_COUNT); 225 const size_t newFrameCount = WebPDemuxGetI(m_demux, WEBP_FF_FRAME_COUNT);
226 if (hasAnimation && !m_haveReadAnimationParameters && newFrameCount) { 226 if (hasAnimation && !m_haveReadAnimationParameters && newFrameCount) {
227 // As we have parsed at least one frame (even if partially), 227 // As we have parsed at least one frame (even if partially),
228 // we must already have parsed the animation properties. 228 // we must already have parsed the animation properties.
229 // This is because ANIM chunk always precedes ANMF chunks. 229 // This is because ANIM chunk always precedes ANMF chunks.
230 m_repetitionCount = WebPDemuxGetI(m_demux, WEBP_FF_LOOP_COUNT); 230 m_repetitionCount = WebPDemuxGetI(m_demux, WEBP_FF_LOOP_COUNT);
231 ASSERT(m_repetitionCount == (m_repetitionCount & 0xffff)); // Loop count is always <= 16 bits. 231 ASSERT(m_repetitionCount == (m_repetitionCount & 0xffff)); // Loop count is always <= 16 bits.
232 if (!m_repetitionCount) 232 --m_repetitionCount; // Animation plays 'm_repetitionCount + 1' times.
Peter Kasting 2014/05/14 21:47:04 Nit: This is subtle and deserves more comments:
urvang (Google) 2014/05/14 22:19:50 Done.
233 m_repetitionCount = cAnimationLoopInfinite;
234 m_haveReadAnimationParameters = true; 233 m_haveReadAnimationParameters = true;
235 } 234 }
236 235
237 const size_t oldFrameCount = m_frameBufferCache.size(); 236 const size_t oldFrameCount = m_frameBufferCache.size();
238 if (newFrameCount > oldFrameCount) { 237 if (newFrameCount > oldFrameCount) {
239 m_frameBufferCache.resize(newFrameCount); 238 m_frameBufferCache.resize(newFrameCount);
240 for (size_t i = oldFrameCount; i < newFrameCount; ++i) { 239 for (size_t i = oldFrameCount; i < newFrameCount; ++i) {
241 m_frameBufferCache[i].setPremultiplyAlpha(m_premultiplyAlpha); 240 m_frameBufferCache[i].setPremultiplyAlpha(m_premultiplyAlpha);
242 if (!hasAnimation) { 241 if (!hasAnimation) {
243 ASSERT(!i); 242 ASSERT(!i);
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 return false; 532 return false;
534 } 533 }
535 // FALLTHROUGH 534 // FALLTHROUGH
536 default: 535 default:
537 clear(); 536 clear();
538 return setFailed(); 537 return setFailed();
539 } 538 }
540 } 539 }
541 540
542 } // namespace WebCore 541 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698