Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 228 ASSERT(m_demuxState > WEBP_DEMUX_PARSING_HEADER); | 228 ASSERT(m_demuxState > WEBP_DEMUX_PARSING_HEADER); |
| 229 if (!WebPDemuxGetI(m_demux, WEBP_FF_FRAME_COUNT)) | 229 if (!WebPDemuxGetI(m_demux, WEBP_FF_FRAME_COUNT)) |
| 230 return false; // Wait until the encoded image frame data arrives. | 230 return false; // Wait until the encoded image frame data arrives. |
| 231 | 231 |
| 232 if (!isDecodedSizeAvailable()) { | 232 if (!isDecodedSizeAvailable()) { |
| 233 int width = WebPDemuxGetI(m_demux, WEBP_FF_CANVAS_WIDTH); | 233 int width = WebPDemuxGetI(m_demux, WEBP_FF_CANVAS_WIDTH); |
| 234 int height = WebPDemuxGetI(m_demux, WEBP_FF_CANVAS_HEIGHT); | 234 int height = WebPDemuxGetI(m_demux, WEBP_FF_CANVAS_HEIGHT); |
| 235 if (!setSize(width, height)) | 235 if (!setSize(width, height)) |
| 236 return setFailed(); | 236 return setFailed(); |
| 237 | 237 |
| 238 size_t frameCount = WebPDemuxGetI(m_demux, WEBP_FF_FRAME_COUNT); | |
|
urvang
2016/10/10 21:30:50
No, this is not the right place. "!isDecodedSizeAv
cblume
2016/10/10 21:36:38
Done.
| |
| 239 updateAggressivePurging(frameCount); | |
| 240 | |
| 238 m_formatFlags = WebPDemuxGetI(m_demux, WEBP_FF_FORMAT_FLAGS); | 241 m_formatFlags = WebPDemuxGetI(m_demux, WEBP_FF_FORMAT_FLAGS); |
| 239 if (!(m_formatFlags & ANIMATION_FLAG)) { | 242 if (!(m_formatFlags & ANIMATION_FLAG)) { |
| 240 m_repetitionCount = cAnimationNone; | 243 m_repetitionCount = cAnimationNone; |
| 241 } else { | 244 } else { |
| 242 // Since we have parsed at least one frame, even if partially, | 245 // Since we have parsed at least one frame, even if partially, |
| 243 // the global animation (ANIM) properties have been read since | 246 // the global animation (ANIM) properties have been read since |
| 244 // an ANIM chunk must precede the ANMF frame chunks. | 247 // an ANIM chunk must precede the ANMF frame chunks. |
| 245 m_repetitionCount = WebPDemuxGetI(m_demux, WEBP_FF_LOOP_COUNT); | 248 m_repetitionCount = WebPDemuxGetI(m_demux, WEBP_FF_LOOP_COUNT); |
| 246 // Repetition count is always <= 16 bits. | 249 // Repetition count is always <= 16 bits. |
| 247 ASSERT(m_repetitionCount == (m_repetitionCount & 0xffff)); | 250 ASSERT(m_repetitionCount == (m_repetitionCount & 0xffff)); |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 479 } else { | 482 } else { |
| 480 decodeSingleFrame(webpFrame.fragment.bytes, webpFrame.fragment.size, *i); | 483 decodeSingleFrame(webpFrame.fragment.bytes, webpFrame.fragment.size, *i); |
| 481 WebPDemuxReleaseIterator(&webpFrame); | 484 WebPDemuxReleaseIterator(&webpFrame); |
| 482 } | 485 } |
| 483 if (failed()) | 486 if (failed()) |
| 484 return; | 487 return; |
| 485 | 488 |
| 486 // We need more data to continue decoding. | 489 // We need more data to continue decoding. |
| 487 if (m_frameBufferCache[*i].getStatus() != ImageFrame::FrameComplete) | 490 if (m_frameBufferCache[*i].getStatus() != ImageFrame::FrameComplete) |
| 488 break; | 491 break; |
| 492 | |
| 493 if (m_purgeAggressively) | |
| 494 clearCacheExceptFrame(*i); | |
| 489 } | 495 } |
| 490 | 496 |
| 491 // It is also a fatal error if all data is received and we have decoded all | 497 // It is also a fatal error if all data is received and we have decoded all |
| 492 // frames available but the file is truncated. | 498 // frames available but the file is truncated. |
| 493 if (index >= m_frameBufferCache.size() - 1 && isAllDataReceived() && | 499 if (index >= m_frameBufferCache.size() - 1 && isAllDataReceived() && |
| 494 m_demux && m_demuxState != WEBP_DEMUX_DONE) | 500 m_demux && m_demuxState != WEBP_DEMUX_DONE) |
| 495 setFailed(); | 501 setFailed(); |
| 496 } | 502 } |
| 497 | 503 |
| 498 bool WEBPImageDecoder::decodeSingleFrame(const uint8_t* dataBytes, | 504 bool WEBPImageDecoder::decodeSingleFrame(const uint8_t* dataBytes, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 557 return false; | 563 return false; |
| 558 } | 564 } |
| 559 // FALLTHROUGH | 565 // FALLTHROUGH |
| 560 default: | 566 default: |
| 561 clear(); | 567 clear(); |
| 562 return setFailed(); | 568 return setFailed(); |
| 563 } | 569 } |
| 564 } | 570 } |
| 565 | 571 |
| 566 } // namespace blink | 572 } // namespace blink |
| OLD | NEW |