| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkCodec.h" | 8 #include "SkCodec.h" |
| 9 #include "SkMSAN.h" | 9 #include "SkMSAN.h" |
| 10 #include "SkJpegCodec.h" | 10 #include "SkJpegCodec.h" |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 return SkISize::Make(dinfo.output_width, dinfo.output_height); | 332 return SkISize::Make(dinfo.output_width, dinfo.output_height); |
| 333 } | 333 } |
| 334 | 334 |
| 335 bool SkJpegCodec::onRewind() { | 335 bool SkJpegCodec::onRewind() { |
| 336 JpegDecoderMgr* decoderMgr = nullptr; | 336 JpegDecoderMgr* decoderMgr = nullptr; |
| 337 if (!ReadHeader(this->stream(), nullptr, &decoderMgr)) { | 337 if (!ReadHeader(this->stream(), nullptr, &decoderMgr)) { |
| 338 return fDecoderMgr->returnFalse("could not rewind"); | 338 return fDecoderMgr->returnFalse("could not rewind"); |
| 339 } | 339 } |
| 340 SkASSERT(nullptr != decoderMgr); | 340 SkASSERT(nullptr != decoderMgr); |
| 341 fDecoderMgr.reset(decoderMgr); | 341 fDecoderMgr.reset(decoderMgr); |
| 342 | |
| 343 fSwizzler.reset(nullptr); | |
| 344 fSrcRow = nullptr; | |
| 345 fStorage.reset(); | |
| 346 | |
| 347 return true; | 342 return true; |
| 348 } | 343 } |
| 349 | 344 |
| 350 /* | 345 /* |
| 351 * Checks if the conversion between the input image and the requested output | 346 * Checks if the conversion between the input image and the requested output |
| 352 * image has been implemented | 347 * image has been implemented |
| 353 * Sets the output color space | 348 * Sets the output color space |
| 354 */ | 349 */ |
| 355 bool SkJpegCodec::setOutputColorSpace(const SkImageInfo& dst) { | 350 bool SkJpegCodec::setOutputColorSpace(const SkImageInfo& dst) { |
| 356 if (kUnknown_SkAlphaType == dst.alphaType()) { | 351 if (kUnknown_SkAlphaType == dst.alphaType()) { |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 if (setjmp(fDecoderMgr->getJmpBuf())) { | 581 if (setjmp(fDecoderMgr->getJmpBuf())) { |
| 587 SkCodecPrintf("setjmp: Error from libjpeg\n"); | 582 SkCodecPrintf("setjmp: Error from libjpeg\n"); |
| 588 return kInvalidInput; | 583 return kInvalidInput; |
| 589 } | 584 } |
| 590 | 585 |
| 591 // Check if we can decode to the requested destination and set the output co
lor space | 586 // Check if we can decode to the requested destination and set the output co
lor space |
| 592 if (!this->setOutputColorSpace(dstInfo)) { | 587 if (!this->setOutputColorSpace(dstInfo)) { |
| 593 return kInvalidConversion; | 588 return kInvalidConversion; |
| 594 } | 589 } |
| 595 | 590 |
| 591 // Remove objects used for sampling. |
| 592 fSwizzler.reset(nullptr); |
| 593 fSrcRow = nullptr; |
| 594 fStorage.reset(); |
| 595 |
| 596 // Now, given valid output dimensions, we can start the decompress | 596 // Now, given valid output dimensions, we can start the decompress |
| 597 if (!jpeg_start_decompress(fDecoderMgr->dinfo())) { | 597 if (!jpeg_start_decompress(fDecoderMgr->dinfo())) { |
| 598 SkCodecPrintf("start decompress failed\n"); | 598 SkCodecPrintf("start decompress failed\n"); |
| 599 return kInvalidInput; | 599 return kInvalidInput; |
| 600 } | 600 } |
| 601 | 601 |
| 602 if (options.fSubset) { | 602 if (options.fSubset) { |
| 603 fSwizzlerSubset = *options.fSubset; | 603 fSwizzlerSubset = *options.fSubset; |
| 604 } | 604 } |
| 605 | 605 |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 907 | 907 |
| 908 JDIMENSION linesRead = jpeg_read_raw_data(dinfo, yuv, numRowsPerBlock); | 908 JDIMENSION linesRead = jpeg_read_raw_data(dinfo, yuv, numRowsPerBlock); |
| 909 if (linesRead < remainingRows) { | 909 if (linesRead < remainingRows) { |
| 910 // FIXME: Handle incomplete YUV decodes without signalling an error. | 910 // FIXME: Handle incomplete YUV decodes without signalling an error. |
| 911 return kInvalidInput; | 911 return kInvalidInput; |
| 912 } | 912 } |
| 913 } | 913 } |
| 914 | 914 |
| 915 return kSuccess; | 915 return kSuccess; |
| 916 } | 916 } |
| OLD | NEW |