blob: 26696ca7dd4892868a9ce5086b9094bfdba6043f [file] [log] [blame]
msarette16b04a2015-04-15 07:32:19 -07001/*
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 "SkCodec.h"
9#include "SkJpegCodec.h"
10#include "SkJpegDecoderMgr.h"
mtklein525e90a2015-06-18 09:58:57 -070011#include "SkJpegUtility_codec.h"
msarette16b04a2015-04-15 07:32:19 -070012#include "SkCodecPriv.h"
13#include "SkColorPriv.h"
14#include "SkStream.h"
15#include "SkTemplates.h"
16#include "SkTypes.h"
17
msarettf8bf9182015-06-29 10:14:11 -070018// stdio is needed for libjpeg-turbo
msarette16b04a2015-04-15 07:32:19 -070019#include <stdio.h>
20
21extern "C" {
msarettf8bf9182015-06-29 10:14:11 -070022 #include "jpeglibmangler.h"
msarette16b04a2015-04-15 07:32:19 -070023 #include "jerror.h"
msarette16b04a2015-04-15 07:32:19 -070024 #include "jpegint.h"
25 #include "jpeglib.h"
26}
27
msarette16b04a2015-04-15 07:32:19 -070028/*
msarettf8bf9182015-06-29 10:14:11 -070029 * Convert a row of CMYK samples to RGBA in place.
msarette16b04a2015-04-15 07:32:19 -070030 * Note that this method moves the row pointer.
31 * @param width the number of pixels in the row that is being converted
32 * CMYK is stored as four bytes per pixel
33 */
msarettf8bf9182015-06-29 10:14:11 -070034static void convert_CMYK_to_RGBA(uint8_t* row, uint32_t width) {
msarette16b04a2015-04-15 07:32:19 -070035 // We will implement a crude conversion from CMYK -> RGB using formulas
36 // from easyrgb.com.
37 //
38 // CMYK -> CMY
39 // C = C * (1 - K) + K
40 // M = M * (1 - K) + K
41 // Y = Y * (1 - K) + K
42 //
43 // libjpeg actually gives us inverted CMYK, so we must subtract the
44 // original terms from 1.
45 // CMYK -> CMY
46 // C = (1 - C) * (1 - (1 - K)) + (1 - K)
47 // M = (1 - M) * (1 - (1 - K)) + (1 - K)
48 // Y = (1 - Y) * (1 - (1 - K)) + (1 - K)
49 //
50 // Simplifying the above expression.
51 // CMYK -> CMY
52 // C = 1 - CK
53 // M = 1 - MK
54 // Y = 1 - YK
55 //
56 // CMY -> RGB
57 // R = (1 - C) * 255
58 // G = (1 - M) * 255
59 // B = (1 - Y) * 255
60 //
61 // Therefore the full conversion is below. This can be verified at
62 // www.rapidtables.com (assuming inverted CMYK).
63 // CMYK -> RGB
64 // R = C * K * 255
65 // G = M * K * 255
66 // B = Y * K * 255
67 //
68 // As a final note, we have treated the CMYK values as if they were on
69 // a scale from 0-1, when in fact they are 8-bit ints scaling from 0-255.
70 // We must divide each CMYK component by 255 to obtain the true conversion
71 // we should perform.
72 // CMYK -> RGB
73 // R = C * K / 255
74 // G = M * K / 255
75 // B = Y * K / 255
76 for (uint32_t x = 0; x < width; x++, row += 4) {
msarettf8bf9182015-06-29 10:14:11 -070077#if defined(SK_PMCOLOR_IS_RGBA)
msarette16b04a2015-04-15 07:32:19 -070078 row[0] = SkMulDiv255Round(row[0], row[3]);
79 row[1] = SkMulDiv255Round(row[1], row[3]);
80 row[2] = SkMulDiv255Round(row[2], row[3]);
msarettf8bf9182015-06-29 10:14:11 -070081#else
82 uint8_t tmp = row[0];
83 row[0] = SkMulDiv255Round(row[2], row[3]);
84 row[1] = SkMulDiv255Round(row[1], row[3]);
85 row[2] = SkMulDiv255Round(tmp, row[3]);
86#endif
msarette16b04a2015-04-15 07:32:19 -070087 row[3] = 0xFF;
88 }
89}
90
91bool SkJpegCodec::IsJpeg(SkStream* stream) {
92 static const uint8_t jpegSig[] = { 0xFF, 0xD8, 0xFF };
93 char buffer[sizeof(jpegSig)];
94 return stream->read(buffer, sizeof(jpegSig)) == sizeof(jpegSig) &&
95 !memcmp(buffer, jpegSig, sizeof(jpegSig));
96}
97
98bool SkJpegCodec::ReadHeader(SkStream* stream, SkCodec** codecOut,
99 JpegDecoderMgr** decoderMgrOut) {
100
101 // Create a JpegDecoderMgr to own all of the decompress information
102 SkAutoTDelete<JpegDecoderMgr> decoderMgr(SkNEW_ARGS(JpegDecoderMgr, (stream)));
103
104 // libjpeg errors will be caught and reported here
105 if (setjmp(decoderMgr->getJmpBuf())) {
106 return decoderMgr->returnFalse("setjmp");
107 }
108
109 // Initialize the decompress info and the source manager
110 decoderMgr->init();
111
112 // Read the jpeg header
msarettf8bf9182015-06-29 10:14:11 -0700113 if (JPEG_HEADER_OK != turbo_jpeg_read_header(decoderMgr->dinfo(), true)) {
msarette16b04a2015-04-15 07:32:19 -0700114 return decoderMgr->returnFalse("read_header");
115 }
116
117 if (NULL != codecOut) {
118 // Recommend the color type to decode to
119 const SkColorType colorType = decoderMgr->getColorType();
120
121 // Create image info object and the codec
122 const SkImageInfo& imageInfo = SkImageInfo::Make(decoderMgr->dinfo()->image_width,
123 decoderMgr->dinfo()->image_height, colorType, kOpaque_SkAlphaType);
124 *codecOut = SkNEW_ARGS(SkJpegCodec, (imageInfo, stream, decoderMgr.detach()));
125 } else {
126 SkASSERT(NULL != decoderMgrOut);
127 *decoderMgrOut = decoderMgr.detach();
128 }
129 return true;
130}
131
132SkCodec* SkJpegCodec::NewFromStream(SkStream* stream) {
133 SkAutoTDelete<SkStream> streamDeleter(stream);
134 SkCodec* codec = NULL;
135 if (ReadHeader(stream, &codec, NULL)) {
136 // Codec has taken ownership of the stream, we do not need to delete it
137 SkASSERT(codec);
138 streamDeleter.detach();
139 return codec;
140 }
141 return NULL;
142}
143
144SkJpegCodec::SkJpegCodec(const SkImageInfo& srcInfo, SkStream* stream,
145 JpegDecoderMgr* decoderMgr)
146 : INHERITED(srcInfo, stream)
147 , fDecoderMgr(decoderMgr)
148{}
149
150/*
151 * Return a valid set of output dimensions for this decoder, given an input scale
152 */
153SkISize SkJpegCodec::onGetScaledDimensions(float desiredScale) const {
msarettf8bf9182015-06-29 10:14:11 -0700154 // libjpeg-turbo supports scaling by 1/8, 1/4, 3/8, 1/2, 5/8, 3/4, 7/8, and 1/1, so we will
155 // support these as well
156 long num;
157 long denom = 8;
158 if (desiredScale > 0.875f) {
159 num = 8;
160 } else if (desiredScale > 0.75f) {
161 num = 7;
162 } else if (desiredScale > 0.625f) {
163 num = 6;
164 } else if (desiredScale > 0.5f) {
165 num = 5;
msarette16b04a2015-04-15 07:32:19 -0700166 } else if (desiredScale > 0.375f) {
msarettf8bf9182015-06-29 10:14:11 -0700167 num = 4;
168 } else if (desiredScale > 0.25f) {
169 num = 3;
170 } else if (desiredScale > 0.125f) {
171 num = 2;
msarette16b04a2015-04-15 07:32:19 -0700172 } else {
msarettf8bf9182015-06-29 10:14:11 -0700173 num = 1;
msarette16b04a2015-04-15 07:32:19 -0700174 }
175
176 // Set up a fake decompress struct in order to use libjpeg to calculate output dimensions
177 jpeg_decompress_struct dinfo;
mtkleinf7aaadb2015-04-16 06:09:27 -0700178 sk_bzero(&dinfo, sizeof(dinfo));
msarette16b04a2015-04-15 07:32:19 -0700179 dinfo.image_width = this->getInfo().width();
180 dinfo.image_height = this->getInfo().height();
181 dinfo.global_state = DSTATE_READY;
182 dinfo.num_components = 0;
msarettf8bf9182015-06-29 10:14:11 -0700183 dinfo.scale_num = num;
184 dinfo.scale_denom = denom;
185 turbo_jpeg_calc_output_dimensions(&dinfo);
msarette16b04a2015-04-15 07:32:19 -0700186
187 // Return the calculated output dimensions for the given scale
188 return SkISize::Make(dinfo.output_width, dinfo.output_height);
189}
190
191/*
msarett97fdea62015-04-29 08:17:15 -0700192 * Handles rewinding the input stream if it is necessary
193 */
194bool SkJpegCodec::handleRewind() {
195 switch(this->rewindIfNeeded()) {
196 case kCouldNotRewind_RewindState:
197 return fDecoderMgr->returnFalse("could not rewind");
198 case kRewound_RewindState: {
199 JpegDecoderMgr* decoderMgr = NULL;
200 if (!ReadHeader(this->stream(), NULL, &decoderMgr)) {
201 return fDecoderMgr->returnFalse("could not rewind");
202 }
203 SkASSERT(NULL != decoderMgr);
204 fDecoderMgr.reset(decoderMgr);
205 return true;
206 }
207 case kNoRewindNecessary_RewindState:
208 return true;
209 default:
210 SkASSERT(false);
211 return false;
212 }
213}
214
215/*
msarettf8bf9182015-06-29 10:14:11 -0700216 * Checks if the conversion between the input image and the requested output
217 * image has been implemented
218 * Sets the output color space
219 */
220bool SkJpegCodec::setOutputColorSpace(const SkImageInfo& dst) {
221 const SkImageInfo& src = this->getInfo();
222
223 // Ensure that the profile type is unchanged
224 if (dst.profileType() != src.profileType()) {
225 return false;
226 }
227
228 // Ensure that the alpha type is opaque
229 if (kOpaque_SkAlphaType != dst.alphaType()) {
230 return false;
231 }
232
233 // Check if we will decode to CMYK because a conversion to RGBA is not supported
234 J_COLOR_SPACE colorSpace = fDecoderMgr->dinfo()->jpeg_color_space;
235 bool isCMYK = JCS_CMYK == colorSpace || JCS_YCCK == colorSpace;
236
237 // Check for valid color types and set the output color space
238 switch (dst.colorType()) {
239 case kN32_SkColorType:
240 if (isCMYK) {
241 fDecoderMgr->dinfo()->out_color_space = JCS_CMYK;
242 } else {
243 // Check the byte ordering of the RGBA color space for the
244 // current platform
245#if defined(SK_PMCOLOR_IS_RGBA)
246 fDecoderMgr->dinfo()->out_color_space = JCS_EXT_RGBA;
247#else
248 fDecoderMgr->dinfo()->out_color_space = JCS_EXT_BGRA;
249#endif
250 }
251 return true;
252 case kRGB_565_SkColorType:
253 if (isCMYK) {
254 return false;
255 } else {
256 fDecoderMgr->dinfo()->out_color_space = JCS_RGB565;
257 }
258 return true;
259 case kGray_8_SkColorType:
260 if (isCMYK) {
261 return false;
262 } else {
263 // We will enable decodes to gray even if the image is color because this is
264 // much faster than decoding to color and then converting
265 fDecoderMgr->dinfo()->out_color_space = JCS_GRAYSCALE;
266 }
267 return true;
268 default:
269 return false;
270 }
271}
272
273/*
msarett97fdea62015-04-29 08:17:15 -0700274 * Checks if we can scale to the requested dimensions and scales the dimensions
275 * if possible
276 */
277bool SkJpegCodec::scaleToDimensions(uint32_t dstWidth, uint32_t dstHeight) {
msarettf8bf9182015-06-29 10:14:11 -0700278 // libjpeg-turbo can scale to 1/8, 1/4, 3/8, 1/2, 5/8, 3/4, 7/8, and 1/1
279 fDecoderMgr->dinfo()->scale_denom = 8;
280 fDecoderMgr->dinfo()->scale_num = 8;
281 turbo_jpeg_calc_output_dimensions(fDecoderMgr->dinfo());
msarett97fdea62015-04-29 08:17:15 -0700282 while (fDecoderMgr->dinfo()->output_width != dstWidth ||
283 fDecoderMgr->dinfo()->output_height != dstHeight) {
284
285 // Return a failure if we have tried all of the possible scales
msarettf8bf9182015-06-29 10:14:11 -0700286 if (1 == fDecoderMgr->dinfo()->scale_num ||
msarett97fdea62015-04-29 08:17:15 -0700287 dstWidth > fDecoderMgr->dinfo()->output_width ||
288 dstHeight > fDecoderMgr->dinfo()->output_height) {
289 return fDecoderMgr->returnFalse("could not scale to requested dimensions");
290 }
291
292 // Try the next scale
msarettf8bf9182015-06-29 10:14:11 -0700293 fDecoderMgr->dinfo()->scale_num -= 1;
294 turbo_jpeg_calc_output_dimensions(fDecoderMgr->dinfo());
msarett97fdea62015-04-29 08:17:15 -0700295 }
296 return true;
297}
298
299/*
msarette16b04a2015-04-15 07:32:19 -0700300 * Performs the jpeg decode
301 */
302SkCodec::Result SkJpegCodec::onGetPixels(const SkImageInfo& dstInfo,
303 void* dst, size_t dstRowBytes,
304 const Options& options, SkPMColor*, int*) {
msarett97fdea62015-04-29 08:17:15 -0700305
msarette16b04a2015-04-15 07:32:19 -0700306 // Rewind the stream if needed
msarett97fdea62015-04-29 08:17:15 -0700307 if (!this->handleRewind()) {
308 fDecoderMgr->returnFailure("could not rewind stream", kCouldNotRewind);
msarette16b04a2015-04-15 07:32:19 -0700309 }
310
311 // Get a pointer to the decompress info since we will use it quite frequently
312 jpeg_decompress_struct* dinfo = fDecoderMgr->dinfo();
313
314 // Set the jump location for libjpeg errors
315 if (setjmp(fDecoderMgr->getJmpBuf())) {
316 return fDecoderMgr->returnFailure("setjmp", kInvalidInput);
317 }
318
msarettf8bf9182015-06-29 10:14:11 -0700319 // Check if we can decode to the requested destination and set the output color space
320 if (!this->setOutputColorSpace(dstInfo)) {
msarette16b04a2015-04-15 07:32:19 -0700321 return fDecoderMgr->returnFailure("conversion_possible", kInvalidConversion);
322 }
msarette16b04a2015-04-15 07:32:19 -0700323
msarett97fdea62015-04-29 08:17:15 -0700324 // Perform the necessary scaling
325 if (!this->scaleToDimensions(dstInfo.width(), dstInfo.height())) {
msarettf8bf9182015-06-29 10:14:11 -0700326 return fDecoderMgr->returnFailure("cannot scale to requested dims", kInvalidScale);
msarette16b04a2015-04-15 07:32:19 -0700327 }
328
329 // Now, given valid output dimensions, we can start the decompress
msarettf8bf9182015-06-29 10:14:11 -0700330 if (!turbo_jpeg_start_decompress(dinfo)) {
msarette16b04a2015-04-15 07:32:19 -0700331 return fDecoderMgr->returnFailure("startDecompress", kInvalidInput);
332 }
333
msarettf8bf9182015-06-29 10:14:11 -0700334 // The recommended output buffer height should always be 1 in high quality modes.
335 // If it's not, we want to know because it means our strategy is not optimal.
336 SkASSERT(1 == dinfo->rec_outbuf_height);
msarette16b04a2015-04-15 07:32:19 -0700337
msarettf8bf9182015-06-29 10:14:11 -0700338 // Perform the decode a single row at a time
msarett97fdea62015-04-29 08:17:15 -0700339 uint32_t dstHeight = dstInfo.height();
msarettf8bf9182015-06-29 10:14:11 -0700340 JSAMPLE* dstRow = (JSAMPLE*) dst;
341 for (uint32_t y = 0; y < dstHeight; y++) {
msarette16b04a2015-04-15 07:32:19 -0700342 // Read rows of the image
msarettf8bf9182015-06-29 10:14:11 -0700343 uint32_t rowsDecoded = turbo_jpeg_read_scanlines(dinfo, &dstRow, 1);
msarette16b04a2015-04-15 07:32:19 -0700344
345 // If we cannot read enough rows, assume the input is incomplete
msarettf8bf9182015-06-29 10:14:11 -0700346 if (rowsDecoded != 1) {
msarette16b04a2015-04-15 07:32:19 -0700347 // Fill the remainder of the image with black. This error handling
348 // behavior is unspecified but SkCodec consistently uses black as
349 // the fill color for opaque images. If the destination is kGray,
350 // the low 8 bits of SK_ColorBLACK will be used. Conveniently,
351 // these are zeros, which is the representation for black in kGray.
msarettf8bf9182015-06-29 10:14:11 -0700352 SkSwizzler::Fill(dstRow, dstInfo, dstRowBytes, dstHeight - y, SK_ColorBLACK, NULL);
msarette16b04a2015-04-15 07:32:19 -0700353
354 // Prevent libjpeg from failing on incomplete decode
355 dinfo->output_scanline = dstHeight;
356
357 // Finish the decode and indicate that the input was incomplete.
msarettf8bf9182015-06-29 10:14:11 -0700358 turbo_jpeg_finish_decompress(dinfo);
msarette16b04a2015-04-15 07:32:19 -0700359 return fDecoderMgr->returnFailure("Incomplete image data", kIncompleteInput);
360 }
msarettf8bf9182015-06-29 10:14:11 -0700361
362 // Convert to RGBA if necessary
363 if (JCS_CMYK == dinfo->out_color_space) {
364 convert_CMYK_to_RGBA(dstRow, dstInfo.width());
365 }
366
367 // Move to the next row
368 dstRow = SkTAddOffset<JSAMPLE>(dstRow, dstRowBytes);
msarette16b04a2015-04-15 07:32:19 -0700369 }
msarettf8bf9182015-06-29 10:14:11 -0700370 turbo_jpeg_finish_decompress(dinfo);
msarette16b04a2015-04-15 07:32:19 -0700371
372 return kSuccess;
373}
msarett97fdea62015-04-29 08:17:15 -0700374
375/*
376 * Enable scanline decoding for jpegs
377 */
378class SkJpegScanlineDecoder : public SkScanlineDecoder {
379public:
380 SkJpegScanlineDecoder(const SkImageInfo& dstInfo, SkJpegCodec* codec)
381 : INHERITED(dstInfo)
382 , fCodec(codec)
msarettf8bf9182015-06-29 10:14:11 -0700383 {}
msarett97fdea62015-04-29 08:17:15 -0700384
385 SkImageGenerator::Result onGetScanlines(void* dst, int count, size_t rowBytes) override {
386 // Set the jump location for libjpeg errors
387 if (setjmp(fCodec->fDecoderMgr->getJmpBuf())) {
388 return fCodec->fDecoderMgr->returnFailure("setjmp", SkImageGenerator::kInvalidInput);
389 }
390
391 // Read rows one at a time
msarettf8bf9182015-06-29 10:14:11 -0700392 JSAMPLE* dstRow = (JSAMPLE*) dst;
msarett97fdea62015-04-29 08:17:15 -0700393 for (int y = 0; y < count; y++) {
394 // Read row of the image
msarettf8bf9182015-06-29 10:14:11 -0700395 uint32_t rowsDecoded =
396 turbo_jpeg_read_scanlines(fCodec->fDecoderMgr->dinfo(), &dstRow, 1);
msarett97fdea62015-04-29 08:17:15 -0700397 if (rowsDecoded != 1) {
msarettf8bf9182015-06-29 10:14:11 -0700398 SkSwizzler::Fill(
399 dstRow, this->dstInfo(), rowBytes, count - y, SK_ColorBLACK, NULL);
400 fCodec->fDecoderMgr->dinfo()->output_scanline = this->dstInfo().height();
401 turbo_jpeg_finish_decompress(fCodec->fDecoderMgr->dinfo());
msarett97fdea62015-04-29 08:17:15 -0700402 return SkImageGenerator::kIncompleteInput;
403 }
404
msarettf8bf9182015-06-29 10:14:11 -0700405 // Convert to RGBA if necessary
msarett97fdea62015-04-29 08:17:15 -0700406 if (JCS_CMYK == fCodec->fDecoderMgr->dinfo()->out_color_space) {
msarettf8bf9182015-06-29 10:14:11 -0700407 convert_CMYK_to_RGBA(dstRow, this->dstInfo().width());
msarett97fdea62015-04-29 08:17:15 -0700408 }
409
msarettf8bf9182015-06-29 10:14:11 -0700410 // Move to the next row
411 dstRow = SkTAddOffset<JSAMPLE>(dstRow, rowBytes);
msarett97fdea62015-04-29 08:17:15 -0700412 }
413
414 return SkImageGenerator::kSuccess;
415 }
416
msarettf8bf9182015-06-29 10:14:11 -0700417#ifndef TURBO_HAS_SKIP
418#define turbo_jpeg_skip_scanlines(dinfo, count) \
419 SkAutoMalloc storage(dinfo->output_width * dinfo->out_color_components); \
420 uint8_t* storagePtr = static_cast<uint8_t*>(storage.get()); \
421 for (int y = 0; y < count; y++) { \
422 turbo_jpeg_read_scanlines(dinfo, &storagePtr, 1); \
423 }
424#endif
425
msarett97fdea62015-04-29 08:17:15 -0700426 SkImageGenerator::Result onSkipScanlines(int count) override {
427 // Set the jump location for libjpeg errors
428 if (setjmp(fCodec->fDecoderMgr->getJmpBuf())) {
429 return fCodec->fDecoderMgr->returnFailure("setjmp", SkImageGenerator::kInvalidInput);
430 }
431
msarettf8bf9182015-06-29 10:14:11 -0700432 turbo_jpeg_skip_scanlines(fCodec->fDecoderMgr->dinfo(), count);
msarett97fdea62015-04-29 08:17:15 -0700433
434 return SkImageGenerator::kSuccess;
435 }
436
437 void onFinish() override {
438 if (setjmp(fCodec->fDecoderMgr->getJmpBuf())) {
439 SkCodecPrintf("setjmp: Error in libjpeg finish_decompress\n");
440 return;
441 }
442
msarettf8bf9182015-06-29 10:14:11 -0700443 turbo_jpeg_finish_decompress(fCodec->fDecoderMgr->dinfo());
msarett97fdea62015-04-29 08:17:15 -0700444 }
445
446private:
msarettf8bf9182015-06-29 10:14:11 -0700447 SkJpegCodec* fCodec; // unowned
msarett97fdea62015-04-29 08:17:15 -0700448
449 typedef SkScanlineDecoder INHERITED;
450};
451
452SkScanlineDecoder* SkJpegCodec::onGetScanlineDecoder(const SkImageInfo& dstInfo,
453 const Options& options, SkPMColor ctable[], int* ctableCount) {
454
455 // Rewind the stream if needed
456 if (!this->handleRewind()) {
457 SkCodecPrintf("Could not rewind\n");
458 return NULL;
459 }
460
461 // Set the jump location for libjpeg errors
462 if (setjmp(fDecoderMgr->getJmpBuf())) {
463 SkCodecPrintf("setjmp: Error from libjpeg\n");
464 return NULL;
465 }
466
msarettf8bf9182015-06-29 10:14:11 -0700467 // Check if we can decode to the requested destination and set the output color space
468 if (!this->setOutputColorSpace(dstInfo)) {
msarett97fdea62015-04-29 08:17:15 -0700469 SkCodecPrintf("Cannot convert to output type\n");
470 return NULL;
471 }
472
473 // Perform the necessary scaling
474 if (!this->scaleToDimensions(dstInfo.width(), dstInfo.height())) {
msarettf8bf9182015-06-29 10:14:11 -0700475 SkCodecPrintf("Cannot scale to output dimensions\n");
msarett97fdea62015-04-29 08:17:15 -0700476 return NULL;
477 }
478
479 // Now, given valid output dimensions, we can start the decompress
msarettf8bf9182015-06-29 10:14:11 -0700480 if (!turbo_jpeg_start_decompress(fDecoderMgr->dinfo())) {
msarett97fdea62015-04-29 08:17:15 -0700481 SkCodecPrintf("start decompress failed\n");
482 return NULL;
483 }
484
msarett97fdea62015-04-29 08:17:15 -0700485 // Return the new scanline decoder
486 return SkNEW_ARGS(SkJpegScanlineDecoder, (dstInfo, this));
487}