summaryrefslogtreecommitdiff
path: root/core/fxcodec/codec/cjpx_decoder.h
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2017-09-08 10:10:26 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-09-08 15:44:34 +0000
commit808b52ac76bb5d9ee3e6a8371ddab25f62c8ed51 (patch)
treea71d8749c8c9a4a99f509b110ef287321141ab74 /core/fxcodec/codec/cjpx_decoder.h
parentf76741e65e9947b168f108842b715cdaeb74f4f7 (diff)
downloadpdfium-808b52ac76bb5d9ee3e6a8371ddab25f62c8ed51.tar.xz
Move decompressing of JPX out of Init and into Decode
In the existing implementation of the JPX decoder, Init extracts the header from the image and then immediately decompresses it. This is problematic if it is a very large image that we won't be able to allocate a bitmap for. The code has been changed to instead delay decompression until the Decode method, since things like dest Bitmap generation can be performed using just the header information. There is also a bit of renaming/casting cleanup, because I was having a hard time parsing what was a local vs member variable. BUG=chromium:761005 Change-Id: I55a55c0be2f88a5352a6ca056c2a816137d7c749 Reviewed-on: https://pdfium-review.googlesource.com/13550 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'core/fxcodec/codec/cjpx_decoder.h')
-rw-r--r--core/fxcodec/codec/cjpx_decoder.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/core/fxcodec/codec/cjpx_decoder.h b/core/fxcodec/codec/cjpx_decoder.h
index a62b41aafc..9e6c79cafc 100644
--- a/core/fxcodec/codec/cjpx_decoder.h
+++ b/core/fxcodec/codec/cjpx_decoder.h
@@ -7,8 +7,10 @@
#ifndef CORE_FXCODEC_CODEC_CJPX_DECODER_H_
#define CORE_FXCODEC_CODEC_CJPX_DECODER_H_
+#include <memory>
#include <vector>
+#include "core/fxcodec/codec/codec_int.h"
#include "core/fxcrt/cfx_unowned_ptr.h"
#include "third_party/libopenjpeg20/openjpeg.h"
@@ -28,9 +30,12 @@ class CJPX_Decoder {
private:
const uint8_t* m_SrcData;
uint32_t m_SrcSize;
- opj_image_t* image;
- opj_codec_t* l_codec;
- opj_stream_t* l_stream;
+ // TODO(rharrison): Convert these to unowned ptrs, if possible.
+ opj_image_t* m_Image;
+ opj_codec_t* m_Codec;
+ std::unique_ptr<DecodeData> m_DecodeData;
+ opj_stream_t* m_Stream;
+ opj_dparameters_t m_Parameters;
CFX_UnownedPtr<const CPDF_ColorSpace> const m_ColorSpace;
};