aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar msarett <msarett@google.com>2015-10-02 13:44:12 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-10-02 13:44:13 -0700
commit19ae315dd06b01312de8fd40b8388aae4de9f05e (patch)
tree8912952809865ca3541b2174f6cafeeac20b98f1
parente7fc14b55bb8c41ba054abf0bfa09cdd6ec84671 (diff)
Stop calling jpeg_finish_decompress()
jpeg_finish_decompress() does several things: (1) Reads to the end of the image stream. (2) Calls term_src(), a client provided function that indicates we are done with the memory stream. Our current implementation of term_src() does nothing. (3) Calls jpeg_abort() which aborts the decode and cleans up some memory. I don't think we need to call this anymore. (1) seems irrelevant. It seems a little dangerous to get rid of (2), but it is fine while our implementation of term_src() does nothing. (3) We will call jpeg_destroy() on destruction of the JpegDecoderManager. This should free all the memory, making it unnecessary to call jpeg_abort() beforehand. BUG=skia:4040 Review URL: https://codereview.chromium.org/1370323004
-rw-r--r--src/codec/SkJpegCodec.cpp20
-rw-r--r--src/codec/SkJpegCodec.h2
-rw-r--r--src/codec/SkJpegUtility_codec.cpp7
3 files changed, 6 insertions, 23 deletions
diff --git a/src/codec/SkJpegCodec.cpp b/src/codec/SkJpegCodec.cpp
index c9dee9a663..30c1a39f06 100644
--- a/src/codec/SkJpegCodec.cpp
+++ b/src/codec/SkJpegCodec.cpp
@@ -373,11 +373,6 @@ SkCodec::Result SkJpegCodec::onGetPixels(const SkImageInfo& dstInfo,
SkSwizzler::Fill(dstRow, dstInfo, dstRowBytes, dstHeight - y,
SK_ColorBLACK, nullptr, options.fZeroInitialized);
- // 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);
return fDecoderMgr->returnFailure("Incomplete image data", kIncompleteInput);
}
@@ -389,7 +384,6 @@ SkCodec::Result SkJpegCodec::onGetPixels(const SkImageInfo& dstInfo,
// Move to the next row
dstRow = SkTAddOffset<JSAMPLE>(dstRow, dstRowBytes);
}
- jpeg_finish_decompress(dinfo);
return kSuccess;
}
@@ -458,20 +452,6 @@ SkCodec::Result SkJpegCodec::onStartScanlineDecode(const SkImageInfo& dstInfo,
return kSuccess;
}
-SkJpegCodec::~SkJpegCodec() {
- // FIXME: This probably does not need to be called after a full decode
- // FIXME: Is it safe to call when it doesn't need to be called?
- if (setjmp(fDecoderMgr->getJmpBuf())) {
- SkCodecPrintf("setjmp: Error in libjpeg finish_decompress\n");
- return;
- }
-
- // 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());
-}
-
SkCodec::Result SkJpegCodec::onGetScanlines(void* dst, int count, size_t rowBytes) {
// Set the jump location for libjpeg errors
if (setjmp(fDecoderMgr->getJmpBuf())) {
diff --git a/src/codec/SkJpegCodec.h b/src/codec/SkJpegCodec.h
index 24594c1226..6377c9d469 100644
--- a/src/codec/SkJpegCodec.h
+++ b/src/codec/SkJpegCodec.h
@@ -95,8 +95,6 @@ private:
*/
SkJpegCodec(const SkImageInfo& srcInfo, SkStream* stream, JpegDecoderMgr* decoderMgr);
- ~SkJpegCodec() override;
-
/*
* Checks if the conversion between the input image and the requested output
* image has been implemented
diff --git a/src/codec/SkJpegUtility_codec.cpp b/src/codec/SkJpegUtility_codec.cpp
index 75a562a004..19ece5e6ad 100644
--- a/src/codec/SkJpegUtility_codec.cpp
+++ b/src/codec/SkJpegUtility_codec.cpp
@@ -61,7 +61,12 @@ static void sk_skip_input_data(j_decompress_ptr dinfo, long numBytes) {
* We do not need to do anything to terminate our stream
*/
static void sk_term_source(j_decompress_ptr dinfo)
-{}
+{
+ // The current implementation of SkJpegCodec does not call
+ // jpeg_finish_decompress(), so this function is never called.
+ // If we want to modify this function to do something, we also
+ // need to modify SkJpegCodec to call jpeg_finish_decompress().
+}
/*
* Constructor for the source manager that we provide to libjpeg