diff options
author | msarett <msarett@google.com> | 2015-07-01 14:41:02 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-07-01 14:41:02 -0700 |
commit | 40141b57f061fbfcc2fa38da942d9efe25aca4d0 (patch) | |
tree | 78e10510f9c8a7eed7f09b83970ac30750aea312 /src | |
parent | c50acf2321d7a934c80d754e9cbe936dfb8eb4cc (diff) |
Add libjpeg-turbo library (depends on yasm)
Mangle external function names to avoid conflict with libjpeg
Take advantage of direct color conversion (RGBA, BGRA, 565)
Prepare to use jpeg_skip_scanlines (when it is upstreamed)
BUG=skia:
Committed: https://skia.googlesource.com/skia/+/b60c3f8291529303299262dba19b1a896060bd2d
Committed: https://skia.googlesource.com/skia/+/f8bf9181d7b0463c8e371755cfbb9ece90b34fc5
Committed: https://skia.googlesource.com/skia/+/e9e3ee33f30c14c31afd5fc3fe4dda7f15783c75
Review URL: https://codereview.chromium.org/1180983002
Diffstat (limited to 'src')
-rw-r--r-- | src/codec/SkCodec.cpp | 4 | ||||
-rw-r--r-- | src/codec/SkJpegCodec.cpp | 315 | ||||
-rw-r--r-- | src/codec/SkJpegCodec.h | 9 | ||||
-rw-r--r-- | src/codec/SkJpegDecoderMgr.cpp | 15 | ||||
-rw-r--r-- | src/codec/SkJpegDecoderMgr.h | 1 | ||||
-rw-r--r-- | src/codec/SkJpegUtility_codec.cpp | 2 | ||||
-rw-r--r-- | src/codec/SkJpegUtility_codec.h | 1 |
7 files changed, 163 insertions, 184 deletions
diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp index 93db0e58ee..c24bb548ba 100644 --- a/src/codec/SkCodec.cpp +++ b/src/codec/SkCodec.cpp @@ -13,7 +13,9 @@ #include "SkCodec_libpng.h" #include "SkCodec_wbmp.h" #include "SkCodecPriv.h" +#ifndef SK_BUILD_FOR_ANDROID_FRAMEWORK #include "SkJpegCodec.h" +#endif #include "SkStream.h" #include "SkWebpCodec.h" @@ -24,7 +26,9 @@ struct DecoderProc { static const DecoderProc gDecoderProcs[] = { { SkPngCodec::IsPng, SkPngCodec::NewFromStream }, +#ifndef SK_BUILD_FOR_ANDROID_FRAMEWORK { SkJpegCodec::IsJpeg, SkJpegCodec::NewFromStream }, +#endif { SkWebpCodec::IsWebp, SkWebpCodec::NewFromStream }, { SkGifCodec::IsGif, SkGifCodec::NewFromStream }, { SkIcoCodec::IsIco, SkIcoCodec::NewFromStream }, diff --git a/src/codec/SkJpegCodec.cpp b/src/codec/SkJpegCodec.cpp index 9c9bd77c13..5e24b17848 100644 --- a/src/codec/SkJpegCodec.cpp +++ b/src/codec/SkJpegCodec.cpp @@ -15,53 +15,23 @@ #include "SkTemplates.h" #include "SkTypes.h" -// stdio is needed for jpeglib +// stdio is needed for libjpeg-turbo #include <stdio.h> extern "C" { + #include "jpeglibmangler.h" #include "jerror.h" - #include "jmorecfg.h" #include "jpegint.h" #include "jpeglib.h" } -// ANDROID_RGB -// If this is defined in the jpeg headers it indicates that jpeg offers -// support for two additional formats: JCS_RGBA_8888 and JCS_RGB_565. - /* - * Get the source configuarion for the swizzler - */ -SkSwizzler::SrcConfig get_src_config(const jpeg_decompress_struct& dinfo) { - if (JCS_CMYK == dinfo.out_color_space) { - // We will need to perform a manual conversion - return SkSwizzler::kRGBX; - } - if (3 == dinfo.out_color_components && JCS_RGB == dinfo.out_color_space) { - return SkSwizzler::kRGB; - } -#ifdef ANDROID_RGB - if (JCS_RGBA_8888 == dinfo.out_color_space) { - return SkSwizzler::kRGBX; - } - - if (JCS_RGB_565 == dinfo.out_color_space) { - return SkSwizzler::kRGB_565; - } -#endif - if (1 == dinfo.out_color_components && JCS_GRAYSCALE == dinfo.out_color_space) { - return SkSwizzler::kGray; - } - return SkSwizzler::kUnknown; -} - -/* - * Convert a row of CMYK samples to RGBX in place. + * Convert a row of CMYK samples to RGBA in place. * Note that this method moves the row pointer. * @param width the number of pixels in the row that is being converted * CMYK is stored as four bytes per pixel */ -static void convert_CMYK_to_RGB(uint8_t* row, uint32_t width) { +static void convert_CMYK_to_RGBA(uint8_t* row, uint32_t width) { // We will implement a crude conversion from CMYK -> RGB using formulas // from easyrgb.com. // @@ -104,9 +74,16 @@ static void convert_CMYK_to_RGB(uint8_t* row, uint32_t width) { // G = M * K / 255 // B = Y * K / 255 for (uint32_t x = 0; x < width; x++, row += 4) { +#if defined(SK_PMCOLOR_IS_RGBA) row[0] = SkMulDiv255Round(row[0], row[3]); row[1] = SkMulDiv255Round(row[1], row[3]); row[2] = SkMulDiv255Round(row[2], row[3]); +#else + uint8_t tmp = row[0]; + row[0] = SkMulDiv255Round(row[2], row[3]); + row[1] = SkMulDiv255Round(row[1], row[3]); + row[2] = SkMulDiv255Round(tmp, row[3]); +#endif row[3] = 0xFF; } } @@ -133,7 +110,7 @@ bool SkJpegCodec::ReadHeader(SkStream* stream, SkCodec** codecOut, decoderMgr->init(); // Read the jpeg header - if (JPEG_HEADER_OK != jpeg_read_header(decoderMgr->dinfo(), true)) { + if (JPEG_HEADER_OK != turbo_jpeg_read_header(decoderMgr->dinfo(), true)) { return decoderMgr->returnFalse("read_header"); } @@ -168,24 +145,32 @@ SkJpegCodec::SkJpegCodec(const SkImageInfo& srcInfo, SkStream* stream, JpegDecoderMgr* decoderMgr) : INHERITED(srcInfo, stream) , fDecoderMgr(decoderMgr) - , fSwizzler(NULL) - , fSrcRowBytes(0) {} /* * Return a valid set of output dimensions for this decoder, given an input scale */ SkISize SkJpegCodec::onGetScaledDimensions(float desiredScale) const { - // libjpeg supports scaling by 1/1, 1/2, 1/4, and 1/8, so we will support these as well - long scale; - if (desiredScale > 0.75f) { - scale = 1; + // 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 + // support these as well + long num; + long denom = 8; + if (desiredScale > 0.875f) { + num = 8; + } else if (desiredScale > 0.75f) { + num = 7; + } else if (desiredScale > 0.625f) { + num = 6; + } else if (desiredScale > 0.5f) { + num = 5; } else if (desiredScale > 0.375f) { - scale = 2; - } else if (desiredScale > 0.1875f) { - scale = 4; + num = 4; + } else if (desiredScale > 0.25f) { + num = 3; + } else if (desiredScale > 0.125f) { + num = 2; } else { - scale = 8; + num = 1; } // Set up a fake decompress struct in order to use libjpeg to calculate output dimensions @@ -195,40 +180,15 @@ SkISize SkJpegCodec::onGetScaledDimensions(float desiredScale) const { dinfo.image_height = this->getInfo().height(); dinfo.global_state = DSTATE_READY; dinfo.num_components = 0; - dinfo.scale_num = 1; - dinfo.scale_denom = scale; - jpeg_calc_output_dimensions(&dinfo); + dinfo.scale_num = num; + dinfo.scale_denom = denom; + turbo_jpeg_calc_output_dimensions(&dinfo); // Return the calculated output dimensions for the given scale return SkISize::Make(dinfo.output_width, dinfo.output_height); } /* - * Checks if the conversion between the input image and the requested output - * image has been implemented - */ -static bool conversion_possible(const SkImageInfo& dst, - const SkImageInfo& src) { - // Ensure that the profile type is unchanged - if (dst.profileType() != src.profileType()) { - return false; - } - - // Ensure that the alpha type is opaque - if (kOpaque_SkAlphaType != dst.alphaType()) { - return false; - } - - // Always allow kN32 as the color type - if (kN32_SkColorType == dst.colorType()) { - return true; - } - - // Otherwise require that the destination color type match our recommendation - return dst.colorType() == src.colorType(); -} - -/* * Handles rewinding the input stream if it is necessary */ bool SkJpegCodec::handleRewind() { @@ -253,44 +213,90 @@ bool SkJpegCodec::handleRewind() { } /* + * Checks if the conversion between the input image and the requested output + * image has been implemented + * Sets the output color space + */ +bool SkJpegCodec::setOutputColorSpace(const SkImageInfo& dst) { + const SkImageInfo& src = this->getInfo(); + + // Ensure that the profile type is unchanged + if (dst.profileType() != src.profileType()) { + return false; + } + + // Ensure that the alpha type is opaque + if (kOpaque_SkAlphaType != dst.alphaType()) { + return false; + } + + // Check if we will decode to CMYK because a conversion to RGBA is not supported + J_COLOR_SPACE colorSpace = fDecoderMgr->dinfo()->jpeg_color_space; + bool isCMYK = JCS_CMYK == colorSpace || JCS_YCCK == colorSpace; + + // Check for valid color types and set the output color space + switch (dst.colorType()) { + case kN32_SkColorType: + if (isCMYK) { + fDecoderMgr->dinfo()->out_color_space = JCS_CMYK; + } else { + // Check the byte ordering of the RGBA color space for the + // current platform +#if defined(SK_PMCOLOR_IS_RGBA) + fDecoderMgr->dinfo()->out_color_space = JCS_EXT_RGBA; +#else + fDecoderMgr->dinfo()->out_color_space = JCS_EXT_BGRA; +#endif + } + return true; + case kRGB_565_SkColorType: + if (isCMYK) { + return false; + } else { + fDecoderMgr->dinfo()->out_color_space = JCS_RGB565; + } + return true; + case kGray_8_SkColorType: + if (isCMYK) { + return false; + } else { + // We will enable decodes to gray even if the image is color because this is + // much faster than decoding to color and then converting + fDecoderMgr->dinfo()->out_color_space = JCS_GRAYSCALE; + } + return true; + default: + return false; + } +} + +/* * Checks if we can scale to the requested dimensions and scales the dimensions * if possible */ bool SkJpegCodec::scaleToDimensions(uint32_t dstWidth, uint32_t dstHeight) { - // libjpeg can scale to 1/1, 1/2, 1/4, and 1/8 - SkASSERT(1 == fDecoderMgr->dinfo()->scale_num); - SkASSERT(1 == fDecoderMgr->dinfo()->scale_denom); - jpeg_calc_output_dimensions(fDecoderMgr->dinfo()); + // libjpeg-turbo can scale to 1/8, 1/4, 3/8, 1/2, 5/8, 3/4, 7/8, and 1/1 + fDecoderMgr->dinfo()->scale_denom = 8; + fDecoderMgr->dinfo()->scale_num = 8; + turbo_jpeg_calc_output_dimensions(fDecoderMgr->dinfo()); while (fDecoderMgr->dinfo()->output_width != dstWidth || fDecoderMgr->dinfo()->output_height != dstHeight) { // Return a failure if we have tried all of the possible scales - if (8 == fDecoderMgr->dinfo()->scale_denom || + if (1 == fDecoderMgr->dinfo()->scale_num || dstWidth > fDecoderMgr->dinfo()->output_width || dstHeight > fDecoderMgr->dinfo()->output_height) { return fDecoderMgr->returnFalse("could not scale to requested dimensions"); } // Try the next scale - fDecoderMgr->dinfo()->scale_denom *= 2; - jpeg_calc_output_dimensions(fDecoderMgr->dinfo()); + fDecoderMgr->dinfo()->scale_num -= 1; + turbo_jpeg_calc_output_dimensions(fDecoderMgr->dinfo()); } return true; } /* - * Create the swizzler based on the encoded format - */ -void SkJpegCodec::initializeSwizzler(const SkImageInfo& dstInfo, - void* dst, size_t dstRowBytes, - const Options& options) { - SkSwizzler::SrcConfig srcConfig = get_src_config(*fDecoderMgr->dinfo()); - fSwizzler.reset(SkSwizzler::CreateSwizzler(srcConfig, NULL, dstInfo, dst, dstRowBytes, - options.fZeroInitialized)); - fSrcRowBytes = SkSwizzler::BytesPerPixel(srcConfig) * dstInfo.width(); -} - -/* * Performs the jpeg decode */ SkCodec::Result SkJpegCodec::onGetPixels(const SkImageInfo& dstInfo, @@ -316,79 +322,58 @@ SkCodec::Result SkJpegCodec::onGetPixels(const SkImageInfo& dstInfo, return fDecoderMgr->returnFailure("setjmp", kInvalidInput); } - // Check if we can decode to the requested destination - if (!conversion_possible(dstInfo, this->getInfo())) { + // Check if we can decode to the requested destination and set the output color space + if (!this->setOutputColorSpace(dstInfo)) { return fDecoderMgr->returnFailure("conversion_possible", kInvalidConversion); } // Perform the necessary scaling if (!this->scaleToDimensions(dstInfo.width(), dstInfo.height())) { - fDecoderMgr->returnFailure("cannot scale to requested dims", kInvalidScale); + return fDecoderMgr->returnFailure("cannot scale to requested dims", kInvalidScale); } // Now, given valid output dimensions, we can start the decompress - if (!jpeg_start_decompress(dinfo)) { + if (!turbo_jpeg_start_decompress(dinfo)) { return fDecoderMgr->returnFailure("startDecompress", kInvalidInput); } - // Create the swizzler - this->initializeSwizzler(dstInfo, dst, dstRowBytes, options); - if (NULL == fSwizzler) { - return fDecoderMgr->returnFailure("getSwizzler", kUnimplemented); - } - - // This is usually 1, but can also be 2 or 4. - // If we wanted to always read one row at a time, we could, but we will save space and time - // by using the recommendation from libjpeg. - const uint32_t rowsPerDecode = dinfo->rec_outbuf_height; - SkASSERT(rowsPerDecode <= 4); - - // Create a buffer to contain decoded rows (libjpeg requires a 2D array) - SkASSERT(0 != fSrcRowBytes); - SkAutoTDeleteArray<uint8_t> srcBuffer(SkNEW_ARRAY(uint8_t, fSrcRowBytes * rowsPerDecode)); - JSAMPLE* srcRows[4]; - uint8_t* srcPtr = srcBuffer.get(); - for (uint8_t i = 0; i < rowsPerDecode; i++) { - srcRows[i] = (JSAMPLE*) srcPtr; - srcPtr += fSrcRowBytes; - } + // The recommended output buffer height should always be 1 in high quality modes. + // If it's not, we want to know because it means our strategy is not optimal. + SkASSERT(1 == dinfo->rec_outbuf_height); - // Ensure that we loop enough times to decode all of the rows - // libjpeg will prevent us from reading past the bottom of the image + // Perform the decode a single row at a time uint32_t dstHeight = dstInfo.height(); - for (uint32_t y = 0; y < dstHeight + rowsPerDecode - 1; y += rowsPerDecode) { + JSAMPLE* dstRow = (JSAMPLE*) dst; + for (uint32_t y = 0; y < dstHeight; y++) { // Read rows of the image - uint32_t rowsDecoded = jpeg_read_scanlines(dinfo, srcRows, rowsPerDecode); - - // Convert to RGB if necessary - if (JCS_CMYK == dinfo->out_color_space) { - convert_CMYK_to_RGB(srcRows[0], dstInfo.width() * rowsDecoded); - } - - // Swizzle to output destination - for (uint32_t i = 0; i < rowsDecoded; i++) { - fSwizzler->next(srcRows[i]); - } + uint32_t rowsDecoded = turbo_jpeg_read_scanlines(dinfo, &dstRow, 1); // If we cannot read enough rows, assume the input is incomplete - if (rowsDecoded < rowsPerDecode && y + rowsDecoded < dstHeight) { + if (rowsDecoded != 1) { // Fill the remainder of the image with black. This error handling // behavior is unspecified but SkCodec consistently uses black as // the fill color for opaque images. If the destination is kGray, // the low 8 bits of SK_ColorBLACK will be used. Conveniently, // these are zeros, which is the representation for black in kGray. - SkSwizzler::Fill(fSwizzler->getDstRow(), dstInfo, dstRowBytes, - dstHeight - y - rowsDecoded, SK_ColorBLACK, NULL); + SkSwizzler::Fill(dstRow, dstInfo, dstRowBytes, dstHeight - y, SK_ColorBLACK, NULL); // Prevent libjpeg from failing on incomplete decode dinfo->output_scanline = dstHeight; // Finish the decode and indicate that the input was incomplete. - jpeg_finish_decompress(dinfo); + turbo_jpeg_finish_decompress(dinfo); return fDecoderMgr->returnFailure("Incomplete image data", kIncompleteInput); } + + // Convert to RGBA if necessary + if (JCS_CMYK == dinfo->out_color_space) { + convert_CMYK_to_RGBA(dstRow, dstInfo.width()); + } + + // Move to the next row + dstRow = SkTAddOffset<JSAMPLE>(dstRow, dstRowBytes); } - jpeg_finish_decompress(dinfo); + turbo_jpeg_finish_decompress(dinfo); return kSuccess; } @@ -408,7 +393,7 @@ SkJpegCodec::~SkJpegCodec() { // We may not have decoded the entire image. Prevent libjpeg-turbo from failing on a // partial decode. fDecoderMgr->dinfo()->output_scanline = this->getInfo().height(); - jpeg_finish_decompress(fDecoderMgr->dinfo()); + turbo_jpeg_finish_decompress(fDecoderMgr->dinfo()); } } @@ -420,10 +405,7 @@ public: SkJpegScanlineDecoder(const SkImageInfo& dstInfo, SkJpegCodec* codec) : INHERITED(dstInfo) , fCodec(codec) - { - fStorage.reset(fCodec->fSrcRowBytes); - fSrcRow = static_cast<uint8_t*>(fStorage.get()); - } + {} SkImageGenerator::Result onGetScanlines(void* dst, int count, size_t rowBytes) override { // Set the jump location for libjpeg errors @@ -432,46 +414,52 @@ public: } // Read rows one at a time + JSAMPLE* dstRow = (JSAMPLE*) dst; for (int y = 0; y < count; y++) { // Read row of the image - uint32_t rowsDecoded = jpeg_read_scanlines(fCodec->fDecoderMgr->dinfo(), &fSrcRow, 1); + uint32_t rowsDecoded = + turbo_jpeg_read_scanlines(fCodec->fDecoderMgr->dinfo(), &dstRow, 1); if (rowsDecoded != 1) { - SkSwizzler::Fill(dst, this->dstInfo(), rowBytes, count - y, SK_ColorBLACK, NULL); + SkSwizzler::Fill( + dstRow, this->dstInfo(), rowBytes, count - y, SK_ColorBLACK, NULL); + fCodec->fDecoderMgr->dinfo()->output_scanline = this->dstInfo().height(); return SkImageGenerator::kIncompleteInput; } - // Convert to RGB if necessary + // Convert to RGBA if necessary if (JCS_CMYK == fCodec->fDecoderMgr->dinfo()->out_color_space) { - convert_CMYK_to_RGB(fSrcRow, dstInfo().width()); + convert_CMYK_to_RGBA(dstRow, this->dstInfo().width()); } - // Swizzle to output destination - fCodec->fSwizzler->setDstRow(dst); - fCodec->fSwizzler->next(fSrcRow); - dst = SkTAddOffset<void>(dst, rowBytes); + // Move to the next row + dstRow = SkTAddOffset<JSAMPLE>(dstRow, rowBytes); } return SkImageGenerator::kSuccess; } +#ifndef TURBO_HAS_SKIP +#define turbo_jpeg_skip_scanlines(dinfo, count) \ + SkAutoMalloc storage(dinfo->output_width * dinfo->out_color_components); \ + uint8_t* storagePtr = static_cast<uint8_t*>(storage.get()); \ + for (int y = 0; y < count; y++) { \ + turbo_jpeg_read_scanlines(dinfo, &storagePtr, 1); \ + } +#endif + SkImageGenerator::Result onSkipScanlines(int count) override { // Set the jump location for libjpeg errors if (setjmp(fCodec->fDecoderMgr->getJmpBuf())) { return fCodec->fDecoderMgr->returnFailure("setjmp", SkImageGenerator::kInvalidInput); } - // Read rows but ignore the output - for (int y = 0; y < count; y++) { - jpeg_read_scanlines(fCodec->fDecoderMgr->dinfo(), &fSrcRow, 1); - } + turbo_jpeg_skip_scanlines(fCodec->fDecoderMgr->dinfo(), count); return SkImageGenerator::kSuccess; } private: - SkJpegCodec* fCodec; // unowned - SkAutoMalloc fStorage; - uint8_t* fSrcRow; // ptr into fStorage + SkJpegCodec* fCodec; // unowned typedef SkScanlineDecoder INHERITED; }; @@ -491,31 +479,24 @@ SkScanlineDecoder* SkJpegCodec::onGetScanlineDecoder(const SkImageInfo& dstInfo, return NULL; } - // Check if we can decode to the requested destination - if (!conversion_possible(dstInfo, this->getInfo())) { + // Check if we can decode to the requested destination and set the output color space + if (!this->setOutputColorSpace(dstInfo)) { SkCodecPrintf("Cannot convert to output type\n"); return NULL; } // Perform the necessary scaling if (!this->scaleToDimensions(dstInfo.width(), dstInfo.height())) { - SkCodecPrintf("Cannot scale ot output dimensions\n"); + SkCodecPrintf("Cannot scale to output dimensions\n"); return NULL; } // Now, given valid output dimensions, we can start the decompress - if (!jpeg_start_decompress(fDecoderMgr->dinfo())) { + if (!turbo_jpeg_start_decompress(fDecoderMgr->dinfo())) { SkCodecPrintf("start decompress failed\n"); return NULL; } - // Create the swizzler - this->initializeSwizzler(dstInfo, NULL, dstInfo.minRowBytes(), options); - if (NULL == fSwizzler) { - SkCodecPrintf("Could not create swizzler\n"); - return NULL; - } - // Return the new scanline decoder return SkNEW_ARGS(SkJpegScanlineDecoder, (dstInfo, this)); } diff --git a/src/codec/SkJpegCodec.h b/src/codec/SkJpegCodec.h index f39bc49910..122c6e4453 100644 --- a/src/codec/SkJpegCodec.h +++ b/src/codec/SkJpegCodec.h @@ -106,6 +106,13 @@ private: bool handleRewind(); /* + * Checks if the conversion between the input image and the requested output + * image has been implemented + * Sets the output color space + */ + bool setOutputColorSpace(const SkImageInfo& dst); + + /* * Checks if we can scale to the requested dimensions and scales the dimensions * if possible */ @@ -118,8 +125,6 @@ private: const Options& options); SkAutoTDelete<JpegDecoderMgr> fDecoderMgr; - SkAutoTDelete<SkSwizzler> fSwizzler; - size_t fSrcRowBytes; friend class SkJpegScanlineDecoder; diff --git a/src/codec/SkJpegDecoderMgr.cpp b/src/codec/SkJpegDecoderMgr.cpp index f0ed4522ca..b5a12297a0 100644 --- a/src/codec/SkJpegDecoderMgr.cpp +++ b/src/codec/SkJpegDecoderMgr.cpp @@ -39,22 +39,9 @@ SkCodec::Result JpegDecoderMgr::returnFailure(const char caller[], SkCodec::Resu SkColorType JpegDecoderMgr::getColorType() { switch (fDInfo.jpeg_color_space) { - case JCS_CMYK: - case JCS_YCCK: - // libjpeg cannot convert from CMYK or YCCK to RGB. - // Here, we ask libjpeg to give us CMYK samples back and - // we will later manually convert them to RGB. - fDInfo.out_color_space = JCS_CMYK; - return kN32_SkColorType; case JCS_GRAYSCALE: - fDInfo.out_color_space = JCS_GRAYSCALE; return kGray_8_SkColorType; default: -#ifdef ANDROID_RGB - fDInfo.out_color_space = JCS_RGBA_8888; -#else - fDInfo.out_color_space = JCS_RGB; -#endif return kN32_SkColorType; } } @@ -64,7 +51,7 @@ JpegDecoderMgr::JpegDecoderMgr(SkStream* stream) , fInit(false) { // Error manager must be set before any calls to libjeg in order to handle failures - fDInfo.err = jpeg_std_error(&fErrorMgr); + fDInfo.err = turbo_jpeg_std_error(&fErrorMgr); fErrorMgr.error_exit = skjpeg_err_exit; } diff --git a/src/codec/SkJpegDecoderMgr.h b/src/codec/SkJpegDecoderMgr.h index 0775dc07f0..e65ef52c5a 100644 --- a/src/codec/SkJpegDecoderMgr.h +++ b/src/codec/SkJpegDecoderMgr.h @@ -18,6 +18,7 @@ #include <stdio.h> extern "C" { + #include "jpeglibmangler.h" #include "jpeglib.h" } diff --git a/src/codec/SkJpegUtility_codec.cpp b/src/codec/SkJpegUtility_codec.cpp index 75a562a004..418c899cbb 100644 --- a/src/codec/SkJpegUtility_codec.cpp +++ b/src/codec/SkJpegUtility_codec.cpp @@ -73,7 +73,7 @@ skjpeg_source_mgr::skjpeg_source_mgr(SkStream* stream) init_source = sk_init_source; fill_input_buffer = sk_fill_input_buffer; skip_input_data = sk_skip_input_data; - resync_to_restart = jpeg_resync_to_restart; + resync_to_restart = turbo_jpeg_resync_to_restart; term_source = sk_term_source; } diff --git a/src/codec/SkJpegUtility_codec.h b/src/codec/SkJpegUtility_codec.h index 43391017b5..4b3f1ab23b 100644 --- a/src/codec/SkJpegUtility_codec.h +++ b/src/codec/SkJpegUtility_codec.h @@ -16,6 +16,7 @@ #include <stdio.h> extern "C" { + #include "jpeglibmangler.h" #include "jpeglib.h" #include "jerror.h" } |