summaryrefslogtreecommitdiff
path: root/core/fxcodec
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxcodec')
-rw-r--r--core/fxcodec/codec/ccodec_basicmodule.h32
-rw-r--r--core/fxcodec/codec/ccodec_bmpmodule.h46
-rw-r--r--core/fxcodec/codec/ccodec_faxmodule.h34
-rw-r--r--core/fxcodec/codec/ccodec_flatemodule.h51
-rw-r--r--core/fxcodec/codec/ccodec_gifmodule.h63
-rw-r--r--core/fxcodec/codec/ccodec_iccmodule.h95
-rw-r--r--core/fxcodec/codec/ccodec_jbig2module.h34
-rw-r--r--core/fxcodec/codec/ccodec_jpegmodule.h68
-rw-r--r--core/fxcodec/codec/ccodec_jpxmodule.h36
-rw-r--r--core/fxcodec/codec/ccodec_pngmodule.h42
-rw-r--r--core/fxcodec/codec/ccodec_scanlinedecoder.h46
-rw-r--r--core/fxcodec/codec/ccodec_tiffmodule.h35
-rw-r--r--core/fxcodec/codec/codec_int.h354
-rw-r--r--core/fxcodec/codec/fx_codec.cpp13
-rw-r--r--core/fxcodec/codec/fx_codec_bmp.cpp79
-rw-r--r--core/fxcodec/codec/fx_codec_fax.cpp2
-rw-r--r--core/fxcodec/codec/fx_codec_flate.cpp2
-rw-r--r--core/fxcodec/codec/fx_codec_gif.cpp103
-rw-r--r--core/fxcodec/codec/fx_codec_icc.cpp44
-rw-r--r--core/fxcodec/codec/fx_codec_jbig.cpp20
-rw-r--r--core/fxcodec/codec/fx_codec_jpeg.cpp92
-rw-r--r--core/fxcodec/codec/fx_codec_png.cpp50
-rw-r--r--core/fxcodec/codec/fx_codec_progress.cpp69
-rw-r--r--core/fxcodec/codec/fx_codec_tiff.cpp30
-rw-r--r--core/fxcodec/codec/include/ccodec_progressivedecoder.h (renamed from core/fxcodec/codec/fx_codec_progress.h)273
-rw-r--r--core/fxcodec/include/fx_codec.h505
26 files changed, 1032 insertions, 1186 deletions
diff --git a/core/fxcodec/codec/ccodec_basicmodule.h b/core/fxcodec/codec/ccodec_basicmodule.h
new file mode 100644
index 0000000000..4151b4f0f1
--- /dev/null
+++ b/core/fxcodec/codec/ccodec_basicmodule.h
@@ -0,0 +1,32 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FXCODEC_CODEC_CCODEC_BASICMODULE_H_
+#define CORE_FXCODEC_CODEC_CCODEC_BASICMODULE_H_
+
+#include "core/fxcrt/include/fx_system.h"
+
+class CCodec_ScanlineDecoder;
+
+class CCodec_BasicModule {
+ public:
+ FX_BOOL RunLengthEncode(const uint8_t* src_buf,
+ uint32_t src_size,
+ uint8_t*& dest_buf,
+ uint32_t& dest_size);
+ FX_BOOL A85Encode(const uint8_t* src_buf,
+ uint32_t src_size,
+ uint8_t*& dest_buf,
+ uint32_t& dest_size);
+ CCodec_ScanlineDecoder* CreateRunLengthDecoder(const uint8_t* src_buf,
+ uint32_t src_size,
+ int width,
+ int height,
+ int nComps,
+ int bpc);
+};
+
+#endif // CORE_FXCODEC_CODEC_CCODEC_BASICMODULE_H_
diff --git a/core/fxcodec/codec/ccodec_bmpmodule.h b/core/fxcodec/codec/ccodec_bmpmodule.h
new file mode 100644
index 0000000000..b465edd874
--- /dev/null
+++ b/core/fxcodec/codec/ccodec_bmpmodule.h
@@ -0,0 +1,46 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FXCODEC_CODEC_CCODEC_BMPMODULE_H_
+#define CORE_FXCODEC_CODEC_CCODEC_BMPMODULE_H_
+
+#include "core/fxcrt/include/fx_system.h"
+
+struct FXBMP_Context;
+class CFX_DIBAttribute;
+
+class CCodec_BmpModule {
+ public:
+ CCodec_BmpModule() { FXSYS_memset(m_szLastError, 0, sizeof(m_szLastError)); }
+
+ FXBMP_Context* Start(void* pModule);
+ void Finish(FXBMP_Context* pContext);
+
+ uint32_t GetAvailInput(FXBMP_Context* pContext, uint8_t** avail_buf_ptr);
+ void Input(FXBMP_Context* pContext,
+ const uint8_t* src_buf,
+ uint32_t src_size);
+
+ int32_t ReadHeader(FXBMP_Context* pContext,
+ int32_t* width,
+ int32_t* height,
+ FX_BOOL* tb_flag,
+ int32_t* components,
+ int32_t* pal_num,
+ uint32_t** pal_pp,
+ CFX_DIBAttribute* pAttribute);
+ int32_t LoadImage(FXBMP_Context* pContext);
+
+ FX_BOOL (*InputImagePositionBufCallback)(void* pModule, uint32_t rcd_pos);
+ void (*ReadScanlineCallback)(void* pModule,
+ int32_t row_num,
+ uint8_t* row_buf);
+
+ protected:
+ FX_CHAR m_szLastError[256];
+};
+
+#endif // CORE_FXCODEC_CODEC_CCODEC_BMPMODULE_H_
diff --git a/core/fxcodec/codec/ccodec_faxmodule.h b/core/fxcodec/codec/ccodec_faxmodule.h
new file mode 100644
index 0000000000..ad7e9b6063
--- /dev/null
+++ b/core/fxcodec/codec/ccodec_faxmodule.h
@@ -0,0 +1,34 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FXCODEC_CODEC_CCODEC_FAXMODULE_H_
+#define CORE_FXCODEC_CODEC_CCODEC_FAXMODULE_H_
+
+#include "core/fxcrt/include/fx_system.h"
+
+class CCodec_ScanlineDecoder;
+
+class CCodec_FaxModule {
+ public:
+ CCodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf,
+ uint32_t src_size,
+ int width,
+ int height,
+ int K,
+ FX_BOOL EndOfLine,
+ FX_BOOL EncodedByteAlign,
+ FX_BOOL BlackIs1,
+ int Columns,
+ int Rows);
+ FX_BOOL Encode(const uint8_t* src_buf,
+ int width,
+ int height,
+ int pitch,
+ uint8_t*& dest_buf,
+ uint32_t& dest_size);
+};
+
+#endif // CORE_FXCODEC_CODEC_CCODEC_FAXMODULE_H_
diff --git a/core/fxcodec/codec/ccodec_flatemodule.h b/core/fxcodec/codec/ccodec_flatemodule.h
new file mode 100644
index 0000000000..aee03719de
--- /dev/null
+++ b/core/fxcodec/codec/ccodec_flatemodule.h
@@ -0,0 +1,51 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FXCODEC_CODEC_CCODEC_FLATEMODULE_H_
+#define CORE_FXCODEC_CODEC_CCODEC_FLATEMODULE_H_
+
+#include "core/fxcrt/include/fx_system.h"
+
+class CCodec_ScanlineDecoder;
+
+class CCodec_FlateModule {
+ public:
+ CCodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf,
+ uint32_t src_size,
+ int width,
+ int height,
+ int nComps,
+ int bpc,
+ int predictor,
+ int Colors,
+ int BitsPerComponent,
+ int Columns);
+ uint32_t FlateOrLZWDecode(FX_BOOL bLZW,
+ const uint8_t* src_buf,
+ uint32_t src_size,
+ FX_BOOL bEarlyChange,
+ int predictor,
+ int Colors,
+ int BitsPerComponent,
+ int Columns,
+ uint32_t estimated_size,
+ uint8_t*& dest_buf,
+ uint32_t& dest_size);
+ FX_BOOL Encode(const uint8_t* src_buf,
+ uint32_t src_size,
+ int predictor,
+ int Colors,
+ int BitsPerComponent,
+ int Columns,
+ uint8_t*& dest_buf,
+ uint32_t& dest_size);
+ FX_BOOL Encode(const uint8_t* src_buf,
+ uint32_t src_size,
+ uint8_t*& dest_buf,
+ uint32_t& dest_size);
+};
+
+#endif // CORE_FXCODEC_CODEC_CCODEC_FLATEMODULE_H_
diff --git a/core/fxcodec/codec/ccodec_gifmodule.h b/core/fxcodec/codec/ccodec_gifmodule.h
new file mode 100644
index 0000000000..4878074407
--- /dev/null
+++ b/core/fxcodec/codec/ccodec_gifmodule.h
@@ -0,0 +1,63 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FXCODEC_CODEC_CCODEC_GIFMODULE_H_
+#define CORE_FXCODEC_CODEC_CCODEC_GIFMODULE_H_
+
+#include "core/fxcrt/include/fx_system.h"
+
+struct FXGIF_Context;
+
+class CCodec_GifModule {
+ public:
+ CCodec_GifModule() { FXSYS_memset(m_szLastError, 0, sizeof(m_szLastError)); }
+
+ FXGIF_Context* Start(void* pModule);
+ void Finish(FXGIF_Context* pContext);
+
+ uint32_t GetAvailInput(FXGIF_Context* pContext,
+ uint8_t** avail_buf_ptr = nullptr);
+ void Input(FXGIF_Context* pContext,
+ const uint8_t* src_buf,
+ uint32_t src_size);
+
+ int32_t ReadHeader(FXGIF_Context* pContext,
+ int* width,
+ int* height,
+ int* pal_num,
+ void** pal_pp,
+ int* bg_index,
+ CFX_DIBAttribute* pAttribute);
+
+ int32_t LoadFrameInfo(FXGIF_Context* pContext, int* frame_num);
+
+ int32_t LoadFrame(FXGIF_Context* pContext,
+ int frame_num,
+ CFX_DIBAttribute* pAttribute);
+
+ void (*RecordCurrentPositionCallback)(void* pModule, uint32_t& cur_pos);
+ uint8_t* (*AskLocalPaletteBufCallback)(void* pModule,
+ int32_t frame_num,
+ int32_t pal_size);
+ FX_BOOL (*InputRecordPositionBufCallback)(void* pModule,
+ uint32_t rcd_pos,
+ const FX_RECT& img_rc,
+ int32_t pal_num,
+ void* pal_ptr,
+ int32_t delay_time,
+ FX_BOOL user_input,
+ int32_t trans_index,
+ int32_t disposal_method,
+ FX_BOOL interlace);
+ void (*ReadScanlineCallback)(void* pModule,
+ int32_t row_num,
+ uint8_t* row_buf);
+
+ protected:
+ FX_CHAR m_szLastError[256];
+};
+
+#endif // CORE_FXCODEC_CODEC_CCODEC_GIFMODULE_H_
diff --git a/core/fxcodec/codec/ccodec_iccmodule.h b/core/fxcodec/codec/ccodec_iccmodule.h
new file mode 100644
index 0000000000..9eabd38482
--- /dev/null
+++ b/core/fxcodec/codec/ccodec_iccmodule.h
@@ -0,0 +1,95 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FXCODEC_CODEC_CCODEC_ICCMODULE_H_
+#define CORE_FXCODEC_CODEC_CCODEC_ICCMODULE_H_
+
+#include "core/fxcodec/include/fx_codec_def.h"
+#include "core/fxcrt/include/fx_string.h"
+#include "core/fxcrt/include/fx_system.h"
+
+class CFX_BinaryBuf;
+class CFX_IccProfileCache;
+class CFX_IccTransformCache;
+class CFX_PrivateData;
+class IFX_FileRead;
+
+class CCodec_IccModule {
+ public:
+ enum IccCS {
+ IccCS_Unknown = 0,
+ IccCS_XYZ,
+ IccCS_Lab,
+ IccCS_Luv,
+ IccCS_YCbCr,
+ IccCS_Yxy,
+ IccCS_Hsv,
+ IccCS_Hls,
+ IccCS_Gray,
+ IccCS_Rgb,
+ IccCS_Cmyk,
+ IccCS_Cmy
+ };
+
+ struct IccParam {
+ uint32_t Version;
+ IccCS ColorSpace;
+ uint32_t dwProfileType;
+ uint32_t dwFormat;
+ uint8_t* pProfileData;
+ uint32_t dwProfileSize;
+ double Gamma;
+ };
+
+ ~CCodec_IccModule();
+
+ IccCS GetProfileCS(const uint8_t* pProfileData, unsigned int dwProfileSize);
+ IccCS GetProfileCS(IFX_FileRead* pFile);
+ void* CreateTransform(CCodec_IccModule::IccParam* pInputParam,
+ CCodec_IccModule::IccParam* pOutputParam,
+ CCodec_IccModule::IccParam* pProofParam = nullptr,
+ uint32_t dwIntent = Icc_INTENT_PERCEPTUAL,
+ uint32_t dwFlag = Icc_FLAGS_DEFAULT,
+ uint32_t dwPrfIntent = Icc_INTENT_ABSOLUTE_COLORIMETRIC,
+ uint32_t dwPrfFlag = Icc_FLAGS_SOFTPROOFING);
+ void* CreateTransform_sRGB(const uint8_t* pProfileData,
+ uint32_t dwProfileSize,
+ uint32_t& nComponents,
+ int32_t intent = 0,
+ uint32_t dwSrcFormat = Icc_FORMAT_DEFAULT);
+ void* CreateTransform_CMYK(const uint8_t* pSrcProfileData,
+ uint32_t dwSrcProfileSize,
+ uint32_t& nSrcComponents,
+ const uint8_t* pDstProfileData,
+ uint32_t dwDstProfileSize,
+ int32_t intent = 0,
+ uint32_t dwSrcFormat = Icc_FORMAT_DEFAULT,
+ uint32_t dwDstFormat = Icc_FORMAT_DEFAULT);
+ void DestroyTransform(void* pTransform);
+ void Translate(void* pTransform, FX_FLOAT* pSrcValues, FX_FLOAT* pDestValues);
+ void TranslateScanline(void* pTransform,
+ uint8_t* pDest,
+ const uint8_t* pSrc,
+ int pixels);
+ void SetComponents(uint32_t nComponents) { m_nComponents = nComponents; }
+
+ protected:
+ enum Icc_CLASS {
+ Icc_CLASS_INPUT = 0,
+ Icc_CLASS_OUTPUT,
+ Icc_CLASS_PROOF,
+ Icc_CLASS_MAX
+ };
+ void* CreateProfile(CCodec_IccModule::IccParam* pIccParam,
+ Icc_CLASS ic,
+ CFX_BinaryBuf* pTransformKey);
+
+ uint32_t m_nComponents;
+ std::map<CFX_ByteString, CFX_IccTransformCache*> m_MapTranform;
+ std::map<CFX_ByteString, CFX_IccProfileCache*> m_MapProfile;
+};
+
+#endif // CORE_FXCODEC_CODEC_CCODEC_ICCMODULE_H_
diff --git a/core/fxcodec/codec/ccodec_jbig2module.h b/core/fxcodec/codec/ccodec_jbig2module.h
new file mode 100644
index 0000000000..20578c8cdb
--- /dev/null
+++ b/core/fxcodec/codec/ccodec_jbig2module.h
@@ -0,0 +1,34 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FXCODEC_CODEC_CCODEC_JBIG2MODULE_H_
+#define CORE_FXCODEC_CODEC_CCODEC_JBIG2MODULE_H_
+
+#include "core/fxcrt/include/fx_system.h"
+
+class CPDF_StreamAcc;
+class IFX_Pause;
+
+class CCodec_Jbig2Module {
+ public:
+ CCodec_Jbig2Module() {}
+ ~CCodec_Jbig2Module();
+
+ void* CreateJbig2Context();
+ FXCODEC_STATUS StartDecode(void* pJbig2Context,
+ CFX_PrivateData* pPrivateData,
+ uint32_t width,
+ uint32_t height,
+ CPDF_StreamAcc* src_stream,
+ CPDF_StreamAcc* global_stream,
+ uint8_t* dest_buf,
+ uint32_t dest_pitch,
+ IFX_Pause* pPause);
+ FXCODEC_STATUS ContinueDecode(void* pJbig2Context, IFX_Pause* pPause);
+ void DestroyJbig2Context(void* pJbig2Context);
+};
+
+#endif // CORE_FXCODEC_CODEC_CCODEC_JBIG2MODULE_H_
diff --git a/core/fxcodec/codec/ccodec_jpegmodule.h b/core/fxcodec/codec/ccodec_jpegmodule.h
new file mode 100644
index 0000000000..98554fea1c
--- /dev/null
+++ b/core/fxcodec/codec/ccodec_jpegmodule.h
@@ -0,0 +1,68 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FXCODEC_CODEC_CCODEC_JPEGMODULE_H_
+#define CORE_FXCODEC_CODEC_CCODEC_JPEGMODULE_H_
+
+#include "core/fxcrt/include/fx_system.h"
+
+class CCodec_ScanlineDecoder;
+class CFX_DIBSource;
+struct FXJPEG_Context;
+
+#ifdef PDF_ENABLE_XFA
+class CFX_DIBAttribute;
+#endif // PDF_ENABLE_XFA
+
+class CCodec_JpegModule {
+ public:
+ CCodec_JpegModule() {}
+ CCodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf,
+ uint32_t src_size,
+ int width,
+ int height,
+ int nComps,
+ FX_BOOL ColorTransform);
+ FX_BOOL LoadInfo(const uint8_t* src_buf,
+ uint32_t src_size,
+ int& width,
+ int& height,
+ int& num_components,
+ int& bits_per_components,
+ FX_BOOL& color_transform,
+ uint8_t** icc_buf_ptr = nullptr,
+ uint32_t* icc_length = nullptr);
+ FX_BOOL Encode(const CFX_DIBSource* pSource,
+ uint8_t*& dest_buf,
+ FX_STRSIZE& dest_size,
+ int quality = 75,
+ const uint8_t* icc_buf = nullptr,
+ uint32_t icc_length = 0);
+ FXJPEG_Context* Start();
+ void Finish(FXJPEG_Context* pContext);
+ void Input(FXJPEG_Context* pContext,
+ const uint8_t* src_buf,
+ uint32_t src_size);
+
+#ifndef PDF_ENABLE_XFA
+ int ReadHeader(FXJPEG_Context* pContext,
+ int* width,
+ int* height,
+ int* nComps);
+#else // PDF_ENABLE_XFA
+ int ReadHeader(FXJPEG_Context* pContext,
+ int* width,
+ int* height,
+ int* nComps,
+ CFX_DIBAttribute* pAttribute);
+#endif // PDF_ENABLE_XFA
+
+ int StartScanline(FXJPEG_Context* pContext, int down_scale);
+ FX_BOOL ReadScanline(FXJPEG_Context* pContext, uint8_t* dest_buf);
+ uint32_t GetAvailInput(FXJPEG_Context* pContext, uint8_t** avail_buf_ptr);
+};
+
+#endif // CORE_FXCODEC_CODEC_CCODEC_JPEGMODULE_H_
diff --git a/core/fxcodec/codec/ccodec_jpxmodule.h b/core/fxcodec/codec/ccodec_jpxmodule.h
new file mode 100644
index 0000000000..149e8a7c9a
--- /dev/null
+++ b/core/fxcodec/codec/ccodec_jpxmodule.h
@@ -0,0 +1,36 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FXCODEC_CODEC_CCODEC_JPXMODULE_H_
+#define CORE_FXCODEC_CODEC_CCODEC_JPXMODULE_H_
+
+#include <vector>
+
+#include "core/fxcrt/include/fx_system.h"
+
+class CJPX_Decoder;
+class CPDF_ColorSpace;
+
+class CCodec_JpxModule {
+ public:
+ CCodec_JpxModule();
+ ~CCodec_JpxModule();
+
+ CJPX_Decoder* CreateDecoder(const uint8_t* src_buf,
+ uint32_t src_size,
+ CPDF_ColorSpace* cs);
+ void GetImageInfo(CJPX_Decoder* pDecoder,
+ uint32_t* width,
+ uint32_t* height,
+ uint32_t* components);
+ bool Decode(CJPX_Decoder* pDecoder,
+ uint8_t* dest_data,
+ int pitch,
+ const std::vector<uint8_t>& offsets);
+ void DestroyDecoder(CJPX_Decoder* pDecoder);
+};
+
+#endif // CORE_FXCODEC_CODEC_CCODEC_JPXMODULE_H_
diff --git a/core/fxcodec/codec/ccodec_pngmodule.h b/core/fxcodec/codec/ccodec_pngmodule.h
new file mode 100644
index 0000000000..23b5d4b5b9
--- /dev/null
+++ b/core/fxcodec/codec/ccodec_pngmodule.h
@@ -0,0 +1,42 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FXCODEC_CODEC_CCODEC_PNGMODULE_H_
+#define CORE_FXCODEC_CODEC_CCODEC_PNGMODULE_H_
+
+#include "core/fxcrt/include/fx_system.h"
+
+class CFX_DIBAttribute;
+struct FXPNG_Context;
+
+#define PNG_ERROR_SIZE 256
+
+class CCodec_PngModule {
+ public:
+ CCodec_PngModule() { FXSYS_memset(m_szLastError, 0, sizeof(m_szLastError)); }
+
+ FXPNG_Context* Start(void* pModule);
+ void Finish(FXPNG_Context* pContext);
+ FX_BOOL Input(FXPNG_Context* pContext,
+ const uint8_t* src_buf,
+ uint32_t src_size,
+ CFX_DIBAttribute* pAttribute);
+
+ FX_BOOL (*ReadHeaderCallback)(void* pModule,
+ int width,
+ int height,
+ int bpc,
+ int pass,
+ int* color_type,
+ double* gamma);
+ FX_BOOL (*AskScanlineBufCallback)(void* pModule, int line, uint8_t*& src_buf);
+ void (*FillScanlineBufCompletedCallback)(void* pModule, int pass, int line);
+
+ protected:
+ FX_CHAR m_szLastError[PNG_ERROR_SIZE];
+};
+
+#endif // CORE_FXCODEC_CODEC_CCODEC_PNGMODULE_H_
diff --git a/core/fxcodec/codec/ccodec_scanlinedecoder.h b/core/fxcodec/codec/ccodec_scanlinedecoder.h
new file mode 100644
index 0000000000..cd18c8d76e
--- /dev/null
+++ b/core/fxcodec/codec/ccodec_scanlinedecoder.h
@@ -0,0 +1,46 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FXCODEC_CODEC_CCODEC_SCANLINEDECODER_H_
+#define CORE_FXCODEC_CODEC_CCODEC_SCANLINEDECODER_H_
+
+#include "core/fxcrt/include/fx_system.h"
+
+class IFX_Pause;
+
+class CCodec_ScanlineDecoder {
+ public:
+ CCodec_ScanlineDecoder();
+ virtual ~CCodec_ScanlineDecoder();
+
+ const uint8_t* GetScanline(int line);
+ FX_BOOL SkipToScanline(int line, IFX_Pause* pPause);
+
+ int GetWidth() { return m_OutputWidth; }
+ int GetHeight() { return m_OutputHeight; }
+ int CountComps() { return m_nComps; }
+ int GetBPC() { return m_bpc; }
+
+ virtual uint32_t GetSrcOffset() = 0;
+
+ protected:
+ virtual FX_BOOL v_Rewind() = 0;
+ virtual uint8_t* v_GetNextLine() = 0;
+
+ uint8_t* ReadNextLine();
+
+ int m_OrigWidth;
+ int m_OrigHeight;
+ int m_OutputWidth;
+ int m_OutputHeight;
+ int m_nComps;
+ int m_bpc;
+ uint32_t m_Pitch;
+ int m_NextLine;
+ uint8_t* m_pLastScanline;
+};
+
+#endif // CORE_FXCODEC_CODEC_CCODEC_SCANLINEDECODER_H_
diff --git a/core/fxcodec/codec/ccodec_tiffmodule.h b/core/fxcodec/codec/ccodec_tiffmodule.h
new file mode 100644
index 0000000000..d746bb7e85
--- /dev/null
+++ b/core/fxcodec/codec/ccodec_tiffmodule.h
@@ -0,0 +1,35 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FXCODEC_CODEC_CCODEC_TIFFMODULE_H_
+#define CORE_FXCODEC_CODEC_CCODEC_TIFFMODULE_H_
+
+#include "core/fxcrt/include/fx_system.h"
+
+class CCodec_TiffContext;
+class CFX_DIBAttribute;
+class CFX_DIBitmap;
+class IFX_FileRead;
+
+class CCodec_TiffModule {
+ public:
+ ~CCodec_TiffModule() {}
+
+ CCodec_TiffContext* CreateDecoder(IFX_FileRead* file_ptr);
+
+ void GetFrames(CCodec_TiffContext* ctx, int32_t& frames);
+ FX_BOOL LoadFrameInfo(CCodec_TiffContext* ctx,
+ int32_t frame,
+ uint32_t& width,
+ uint32_t& height,
+ uint32_t& comps,
+ uint32_t& bpc,
+ CFX_DIBAttribute* pAttribute);
+ FX_BOOL Decode(CCodec_TiffContext* ctx, class CFX_DIBitmap* pDIBitmap);
+ void DestroyDecoder(CCodec_TiffContext* ctx);
+};
+
+#endif // CORE_FXCODEC_CODEC_CCODEC_TIFFMODULE_H_
diff --git a/core/fxcodec/codec/codec_int.h b/core/fxcodec/codec/codec_int.h
index ed9bcac349..e0d2ff494f 100644
--- a/core/fxcodec/codec/codec_int.h
+++ b/core/fxcodec/codec/codec_int.h
@@ -16,362 +16,10 @@
#include "core/fxcodec/include/fx_codec.h"
#include "core/fxcodec/jbig2/JBig2_Context.h"
-#include "third_party/libopenjpeg20/openjpeg.h" // For OPJ_SIZE_T.
+#include "third_party/libopenjpeg20/openjpeg.h"
-class CFX_IccProfileCache;
-class CFX_IccTransformCache;
class CPDF_ColorSpace;
-class CCodec_BasicModule : public ICodec_BasicModule {
- public:
- // ICodec_BasicModule:
- FX_BOOL RunLengthEncode(const uint8_t* src_buf,
- uint32_t src_size,
- uint8_t*& dest_buf,
- uint32_t& dest_size) override;
- FX_BOOL A85Encode(const uint8_t* src_buf,
- uint32_t src_size,
- uint8_t*& dest_buf,
- uint32_t& dest_size) override;
- ICodec_ScanlineDecoder* CreateRunLengthDecoder(const uint8_t* src_buf,
- uint32_t src_size,
- int width,
- int height,
- int nComps,
- int bpc) override;
-};
-
-class CCodec_ScanlineDecoder : public ICodec_ScanlineDecoder {
- public:
- CCodec_ScanlineDecoder();
- ~CCodec_ScanlineDecoder() override;
-
- // ICodec_ScanlineDecoder
- const uint8_t* GetScanline(int line) override;
- FX_BOOL SkipToScanline(int line, IFX_Pause* pPause) override;
- int GetWidth() override { return m_OutputWidth; }
- int GetHeight() override { return m_OutputHeight; }
- int CountComps() override { return m_nComps; }
- int GetBPC() override { return m_bpc; }
-
- protected:
- virtual FX_BOOL v_Rewind() = 0;
- virtual uint8_t* v_GetNextLine() = 0;
-
- uint8_t* ReadNextLine();
-
- int m_OrigWidth;
- int m_OrigHeight;
- int m_OutputWidth;
- int m_OutputHeight;
- int m_nComps;
- int m_bpc;
- uint32_t m_Pitch;
- int m_NextLine;
- uint8_t* m_pLastScanline;
-};
-
-class CCodec_FaxModule : public ICodec_FaxModule {
- public:
- // ICodec_FaxModule:
- ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf,
- uint32_t src_size,
- int width,
- int height,
- int K,
- FX_BOOL EndOfLine,
- FX_BOOL EncodedByteAlign,
- FX_BOOL BlackIs1,
- int Columns,
- int Rows) override;
- FX_BOOL Encode(const uint8_t* src_buf,
- int width,
- int height,
- int pitch,
- uint8_t*& dest_buf,
- uint32_t& dest_size) override;
-};
-
-class CCodec_FlateModule : public ICodec_FlateModule {
- public:
- virtual ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf,
- uint32_t src_size,
- int width,
- int height,
- int nComps,
- int bpc,
- int predictor,
- int Colors,
- int BitsPerComponent,
- int Columns);
- virtual uint32_t FlateOrLZWDecode(FX_BOOL bLZW,
- const uint8_t* src_buf,
- uint32_t src_size,
- FX_BOOL bEarlyChange,
- int predictor,
- int Colors,
- int BitsPerComponent,
- int Columns,
- uint32_t estimated_size,
- uint8_t*& dest_buf,
- uint32_t& dest_size);
- virtual FX_BOOL Encode(const uint8_t* src_buf,
- uint32_t src_size,
- int predictor,
- int Colors,
- int BitsPerComponent,
- int Columns,
- uint8_t*& dest_buf,
- uint32_t& dest_size);
- virtual FX_BOOL Encode(const uint8_t* src_buf,
- uint32_t src_size,
- uint8_t*& dest_buf,
- uint32_t& dest_size);
-};
-
-class CCodec_JpegModule : public ICodec_JpegModule {
- public:
- CCodec_JpegModule() {}
- ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf,
- uint32_t src_size,
- int width,
- int height,
- int nComps,
- FX_BOOL ColorTransform) override;
- FX_BOOL LoadInfo(const uint8_t* src_buf,
- uint32_t src_size,
- int& width,
- int& height,
- int& num_components,
- int& bits_per_components,
- FX_BOOL& color_transform,
- uint8_t** icc_buf_ptr,
- uint32_t* icc_length) override;
- FX_BOOL Encode(const CFX_DIBSource* pSource,
- uint8_t*& dest_buf,
- FX_STRSIZE& dest_size,
- int quality,
- const uint8_t* icc_buf,
- uint32_t icc_length) override;
- void* Start() override;
- void Finish(void* pContext) override;
- void Input(void* pContext,
- const uint8_t* src_buf,
- uint32_t src_size) override;
-#ifndef PDF_ENABLE_XFA
- int ReadHeader(void* pContext, int* width, int* height, int* nComps) override;
-#else // PDF_ENABLE_XFA
- int ReadHeader(void* pContext,
- int* width,
- int* height,
- int* nComps,
- CFX_DIBAttribute* pAttribute) override;
-#endif // PDF_ENABLE_XFA
- int StartScanline(void* pContext, int down_scale) override;
- FX_BOOL ReadScanline(void* pContext, uint8_t* dest_buf) override;
- uint32_t GetAvailInput(void* pContext, uint8_t** avail_buf_ptr) override;
-};
-
-#ifdef PDF_ENABLE_XFA
-#define PNG_ERROR_SIZE 256
-class CCodec_PngModule : public ICodec_PngModule {
- public:
- CCodec_PngModule() { FXSYS_memset(m_szLastError, '\0', PNG_ERROR_SIZE); }
-
- virtual void* Start(void* pModule);
- virtual void Finish(void* pContext);
- virtual FX_BOOL Input(void* pContext,
- const uint8_t* src_buf,
- uint32_t src_size,
- CFX_DIBAttribute* pAttribute);
-
- protected:
- FX_CHAR m_szLastError[PNG_ERROR_SIZE];
-};
-class CCodec_GifModule : public ICodec_GifModule {
- public:
- CCodec_GifModule() { FXSYS_memset(m_szLastError, '\0', 256); }
- virtual void* Start(void* pModule);
- virtual void Finish(void* pContext);
- virtual uint32_t GetAvailInput(void* pContext, uint8_t** avail_buf_ptr);
- virtual void Input(void* pContext, const uint8_t* src_buf, uint32_t src_size);
-
- virtual int32_t ReadHeader(void* pContext,
- int* width,
- int* height,
- int* pal_num,
- void** pal_pp,
- int* bg_index,
- CFX_DIBAttribute* pAttribute);
-
- virtual int32_t LoadFrameInfo(void* pContext, int* frame_num);
-
- virtual int32_t LoadFrame(void* pContext,
- int frame_num,
- CFX_DIBAttribute* pAttribute);
-
- protected:
- FX_CHAR m_szLastError[256];
-};
-class CCodec_BmpModule : public ICodec_BmpModule {
- public:
- CCodec_BmpModule() { FXSYS_memset(m_szLastError, 0, sizeof(m_szLastError)); }
- void* Start(void* pModule) override;
- void Finish(void* pContext) override;
- uint32_t GetAvailInput(void* pContext, uint8_t** avail_buf_ptr) override;
- void Input(void* pContext,
- const uint8_t* src_buf,
- uint32_t src_size) override;
- int32_t ReadHeader(void* pContext,
- int32_t* width,
- int32_t* height,
- FX_BOOL* tb_flag,
- int32_t* components,
- int32_t* pal_num,
- uint32_t** pal_pp,
- CFX_DIBAttribute* pAttribute) override;
- int32_t LoadImage(void* pContext) override;
-
- protected:
- FX_CHAR m_szLastError[256];
-};
-#endif // PDF_ENABLE_XFA
-
-class CCodec_IccModule : public ICodec_IccModule {
- public:
- ~CCodec_IccModule() override;
-
- // ICodec_IccModule:
- IccCS GetProfileCS(const uint8_t* pProfileData,
- unsigned int dwProfileSize) override;
- IccCS GetProfileCS(IFX_FileRead* pFile) override;
- void* CreateTransform(ICodec_IccModule::IccParam* pInputParam,
- ICodec_IccModule::IccParam* pOutputParam,
- ICodec_IccModule::IccParam* pProofParam = NULL,
- uint32_t dwIntent = Icc_INTENT_PERCEPTUAL,
- uint32_t dwFlag = Icc_FLAGS_DEFAULT,
- uint32_t dwPrfIntent = Icc_INTENT_ABSOLUTE_COLORIMETRIC,
- uint32_t dwPrfFlag = Icc_FLAGS_SOFTPROOFING) override;
- void* CreateTransform_sRGB(
- const uint8_t* pProfileData,
- uint32_t dwProfileSize,
- uint32_t& nComponents,
- int32_t intent = 0,
- uint32_t dwSrcFormat = Icc_FORMAT_DEFAULT) override;
- void* CreateTransform_CMYK(
- const uint8_t* pSrcProfileData,
- uint32_t dwSrcProfileSize,
- uint32_t& nSrcComponents,
- const uint8_t* pDstProfileData,
- uint32_t dwDstProfileSize,
- int32_t intent = 0,
- uint32_t dwSrcFormat = Icc_FORMAT_DEFAULT,
- uint32_t dwDstFormat = Icc_FORMAT_DEFAULT) override;
- void DestroyTransform(void* pTransform) override;
- void Translate(void* pTransform,
- FX_FLOAT* pSrcValues,
- FX_FLOAT* pDestValues) override;
- void TranslateScanline(void* pTransform,
- uint8_t* pDest,
- const uint8_t* pSrc,
- int pixels) override;
- void SetComponents(uint32_t nComponents) override {
- m_nComponents = nComponents;
- }
-
- protected:
- enum Icc_CLASS {
- Icc_CLASS_INPUT = 0,
- Icc_CLASS_OUTPUT,
- Icc_CLASS_PROOF,
- Icc_CLASS_MAX
- };
- void* CreateProfile(ICodec_IccModule::IccParam* pIccParam,
- Icc_CLASS ic,
- CFX_BinaryBuf* pTransformKey);
-
- uint32_t m_nComponents;
- std::map<CFX_ByteString, CFX_IccTransformCache*> m_MapTranform;
- std::map<CFX_ByteString, CFX_IccProfileCache*> m_MapProfile;
-};
-
-class CCodec_JpxModule : public ICodec_JpxModule {
- public:
- CCodec_JpxModule();
- ~CCodec_JpxModule() override;
-
- // ICodec_JpxModule:
- CJPX_Decoder* CreateDecoder(const uint8_t* src_buf,
- uint32_t src_size,
- CPDF_ColorSpace* cs) override;
- void GetImageInfo(CJPX_Decoder* pDecoder,
- uint32_t* width,
- uint32_t* height,
- uint32_t* components) override;
- bool Decode(CJPX_Decoder* pDecoder,
- uint8_t* dest_data,
- int pitch,
- const std::vector<uint8_t>& offsets) override;
- void DestroyDecoder(CJPX_Decoder* pDecoder) override;
-};
-
-#ifdef PDF_ENABLE_XFA
-class CCodec_TiffModule : public ICodec_TiffModule {
- public:
- // ICodec_TiffModule
- void* CreateDecoder(IFX_FileRead* file_ptr) override;
- void GetFrames(void* ctx, int32_t& frames) override;
- FX_BOOL LoadFrameInfo(void* ctx,
- int32_t frame,
- uint32_t& width,
- uint32_t& height,
- uint32_t& comps,
- uint32_t& bpc,
- CFX_DIBAttribute* pAttribute) override;
- FX_BOOL Decode(void* ctx, class CFX_DIBitmap* pDIBitmap) override;
- void DestroyDecoder(void* ctx) override;
-
- protected:
- ~CCodec_TiffModule() override {}
-};
-#endif // PDF_ENABLE_XFA
-
-class CCodec_Jbig2Context {
- public:
- CCodec_Jbig2Context();
- ~CCodec_Jbig2Context() {}
-
- uint32_t m_width;
- uint32_t m_height;
- CPDF_StreamAcc* m_pGlobalStream;
- CPDF_StreamAcc* m_pSrcStream;
- uint8_t* m_dest_buf;
- uint32_t m_dest_pitch;
- IFX_Pause* m_pPause;
- CJBig2_Context* m_pContext;
- CJBig2_Image* m_dest_image;
-};
-class CCodec_Jbig2Module : public ICodec_Jbig2Module {
- public:
- CCodec_Jbig2Module() {}
- ~CCodec_Jbig2Module() override;
-
- // ICodec_Jbig2Module
- void* CreateJbig2Context() override;
- FXCODEC_STATUS StartDecode(void* pJbig2Context,
- CFX_PrivateData* pPrivateData,
- uint32_t width,
- uint32_t height,
- CPDF_StreamAcc* src_stream,
- CPDF_StreamAcc* global_stream,
- uint8_t* dest_buf,
- uint32_t dest_pitch,
- IFX_Pause* pPause) override;
- FXCODEC_STATUS ContinueDecode(void* pJbig2Context,
- IFX_Pause* pPause) override;
- void DestroyJbig2Context(void* pJbig2Context) override;
-};
-
struct DecodeData {
public:
DecodeData(unsigned char* src_data, OPJ_SIZE_T src_size)
diff --git a/core/fxcodec/codec/fx_codec.cpp b/core/fxcodec/codec/fx_codec.cpp
index 77dd363c9d..a0356929a5 100644
--- a/core/fxcodec/codec/fx_codec.cpp
+++ b/core/fxcodec/codec/fx_codec.cpp
@@ -7,6 +7,7 @@
#include "core/fxcodec/include/fx_codec.h"
#include <cmath>
+#include <memory>
#include <utility>
#include "core/fxcodec/codec/codec_int.h"
@@ -397,18 +398,20 @@ void CCodec_RLScanlineDecoder::UpdateOperator(uint8_t used_bytes) {
count -= used_bytes;
m_Operator = 257 - count;
}
-ICodec_ScanlineDecoder* CCodec_BasicModule::CreateRunLengthDecoder(
+
+CCodec_ScanlineDecoder* CCodec_BasicModule::CreateRunLengthDecoder(
const uint8_t* src_buf,
uint32_t src_size,
int width,
int height,
int nComps,
int bpc) {
- CCodec_RLScanlineDecoder* pRLScanlineDecoder = new CCodec_RLScanlineDecoder;
+ std::unique_ptr<CCodec_RLScanlineDecoder> pRLScanlineDecoder(
+ new CCodec_RLScanlineDecoder);
if (!pRLScanlineDecoder->Create(src_buf, src_size, width, height, nComps,
bpc)) {
- delete pRLScanlineDecoder;
- return NULL;
+ return nullptr;
}
- return pRLScanlineDecoder;
+
+ return pRLScanlineDecoder.release();
}
diff --git a/core/fxcodec/codec/fx_codec_bmp.cpp b/core/fxcodec/codec/fx_codec_bmp.cpp
index 0fed151217..03390cfea3 100644
--- a/core/fxcodec/codec/fx_codec_bmp.cpp
+++ b/core/fxcodec/codec/fx_codec_bmp.cpp
@@ -42,24 +42,25 @@ static FX_BOOL bmp_get_data_position(bmp_decompress_struct_p bmp_ptr,
CCodec_BmpModule* pModule = (CCodec_BmpModule*)p->parent_ptr;
return pModule->InputImagePositionBufCallback(p->child_ptr, rcd_pos);
}
-void* CCodec_BmpModule::Start(void* pModule) {
- FXBMP_Context* p = (FXBMP_Context*)FX_Alloc(uint8_t, sizeof(FXBMP_Context));
- if (p == NULL) {
- return NULL;
- }
+
+FXBMP_Context* CCodec_BmpModule::Start(void* pModule) {
+ FXBMP_Context* p = FX_Alloc(FXBMP_Context, 1);
+ if (!p)
+ return nullptr;
+
FXSYS_memset(p, 0, sizeof(FXBMP_Context));
- if (p == NULL) {
- return NULL;
- }
+ if (!p)
+ return nullptr;
+
p->m_AllocFunc = bmp_alloc_func;
p->m_FreeFunc = bmp_free_func;
- p->bmp_ptr = NULL;
+ p->bmp_ptr = nullptr;
p->parent_ptr = (void*)this;
p->child_ptr = pModule;
p->bmp_ptr = bmp_create_decompress();
- if (p->bmp_ptr == NULL) {
+ if (!p->bmp_ptr) {
FX_Free(p);
- return NULL;
+ return nullptr;
}
p->bmp_ptr->context_ptr = (void*)p;
p->bmp_ptr->err_ptr = m_szLastError;
@@ -68,14 +69,14 @@ void* CCodec_BmpModule::Start(void* pModule) {
p->bmp_ptr->bmp_get_data_position_fn = bmp_get_data_position;
return p;
}
-void CCodec_BmpModule::Finish(void* pContext) {
- FXBMP_Context* p = (FXBMP_Context*)pContext;
- if (p) {
- bmp_destroy_decompress(&p->bmp_ptr);
- p->m_FreeFunc(p);
+
+void CCodec_BmpModule::Finish(FXBMP_Context* ctx) {
+ if (ctx) {
+ bmp_destroy_decompress(&ctx->bmp_ptr);
+ ctx->m_FreeFunc(ctx);
}
}
-int32_t CCodec_BmpModule::ReadHeader(void* pContext,
+int32_t CCodec_BmpModule::ReadHeader(FXBMP_Context* ctx,
int32_t* width,
int32_t* height,
FX_BOOL* tb_flag,
@@ -83,43 +84,41 @@ int32_t CCodec_BmpModule::ReadHeader(void* pContext,
int32_t* pal_num,
uint32_t** pal_pp,
CFX_DIBAttribute* pAttribute) {
- FXBMP_Context* p = (FXBMP_Context*)pContext;
- if (setjmp(p->bmp_ptr->jmpbuf)) {
+ if (setjmp(ctx->bmp_ptr->jmpbuf)) {
return 0;
}
- int32_t ret = bmp_read_header(p->bmp_ptr);
+ int32_t ret = bmp_read_header(ctx->bmp_ptr);
if (ret != 1) {
return ret;
}
- *width = p->bmp_ptr->width;
- *height = p->bmp_ptr->height;
- *tb_flag = p->bmp_ptr->imgTB_flag;
- *components = p->bmp_ptr->components;
- *pal_num = p->bmp_ptr->pal_num;
- *pal_pp = p->bmp_ptr->pal_ptr;
+ *width = ctx->bmp_ptr->width;
+ *height = ctx->bmp_ptr->height;
+ *tb_flag = ctx->bmp_ptr->imgTB_flag;
+ *components = ctx->bmp_ptr->components;
+ *pal_num = ctx->bmp_ptr->pal_num;
+ *pal_pp = ctx->bmp_ptr->pal_ptr;
if (pAttribute) {
pAttribute->m_wDPIUnit = FXCODEC_RESUNIT_METER;
- pAttribute->m_nXDPI = p->bmp_ptr->dpi_x;
- pAttribute->m_nYDPI = p->bmp_ptr->dpi_y;
- pAttribute->m_nBmpCompressType = p->bmp_ptr->compress_flag;
+ pAttribute->m_nXDPI = ctx->bmp_ptr->dpi_x;
+ pAttribute->m_nYDPI = ctx->bmp_ptr->dpi_y;
+ pAttribute->m_nBmpCompressType = ctx->bmp_ptr->compress_flag;
}
return 1;
}
-int32_t CCodec_BmpModule::LoadImage(void* pContext) {
- FXBMP_Context* p = (FXBMP_Context*)pContext;
- if (setjmp(p->bmp_ptr->jmpbuf)) {
+
+int32_t CCodec_BmpModule::LoadImage(FXBMP_Context* ctx) {
+ if (setjmp(ctx->bmp_ptr->jmpbuf))
return 0;
- }
- return bmp_decode_image(p->bmp_ptr);
+ return bmp_decode_image(ctx->bmp_ptr);
}
-uint32_t CCodec_BmpModule::GetAvailInput(void* pContext,
+
+uint32_t CCodec_BmpModule::GetAvailInput(FXBMP_Context* ctx,
uint8_t** avial_buf_ptr) {
- FXBMP_Context* p = (FXBMP_Context*)pContext;
- return bmp_get_avail_input(p->bmp_ptr, avial_buf_ptr);
+ return bmp_get_avail_input(ctx->bmp_ptr, avial_buf_ptr);
}
-void CCodec_BmpModule::Input(void* pContext,
+
+void CCodec_BmpModule::Input(FXBMP_Context* ctx,
const uint8_t* src_buf,
uint32_t src_size) {
- FXBMP_Context* p = (FXBMP_Context*)pContext;
- bmp_input_buffer(p->bmp_ptr, (uint8_t*)src_buf, src_size);
+ bmp_input_buffer(ctx->bmp_ptr, (uint8_t*)src_buf, src_size);
}
diff --git a/core/fxcodec/codec/fx_codec_fax.cpp b/core/fxcodec/codec/fx_codec_fax.cpp
index 898b0d0251..91f9eb2eb8 100644
--- a/core/fxcodec/codec/fx_codec_fax.cpp
+++ b/core/fxcodec/codec/fx_codec_fax.cpp
@@ -810,7 +810,7 @@ FX_BOOL CCodec_FaxModule::Encode(const uint8_t* src_buf,
encoder.Encode(dest_buf, dest_size);
return TRUE;
}
-ICodec_ScanlineDecoder* CCodec_FaxModule::CreateDecoder(
+CCodec_ScanlineDecoder* CCodec_FaxModule::CreateDecoder(
const uint8_t* src_buf,
uint32_t src_size,
int width,
diff --git a/core/fxcodec/codec/fx_codec_flate.cpp b/core/fxcodec/codec/fx_codec_flate.cpp
index 16cde3e5ea..d1b4a5f985 100644
--- a/core/fxcodec/codec/fx_codec_flate.cpp
+++ b/core/fxcodec/codec/fx_codec_flate.cpp
@@ -897,7 +897,7 @@ uint32_t CCodec_FlateScanlineDecoder::GetSrcOffset() {
return FPDFAPI_FlateGetTotalIn(m_pFlate);
}
-ICodec_ScanlineDecoder* CCodec_FlateModule::CreateDecoder(
+CCodec_ScanlineDecoder* CCodec_FlateModule::CreateDecoder(
const uint8_t* src_buf,
uint32_t src_size,
int width,
diff --git a/core/fxcodec/codec/fx_codec_gif.cpp b/core/fxcodec/codec/fx_codec_gif.cpp
index 5fc0d094d8..b7362ca4b3 100644
--- a/core/fxcodec/codec/fx_codec_gif.cpp
+++ b/core/fxcodec/codec/fx_codec_gif.cpp
@@ -69,21 +69,22 @@ static FX_BOOL gif_get_record_position(gif_decompress_struct_p gif_ptr,
pal_num, pal_ptr, delay_time, user_input, trans_index, disposal_method,
interlace);
}
-void* CCodec_GifModule::Start(void* pModule) {
- FXGIF_Context* p = (FXGIF_Context*)FX_Alloc(uint8_t, sizeof(FXGIF_Context));
- if (p == NULL) {
- return NULL;
- }
+
+FXGIF_Context* CCodec_GifModule::Start(void* pModule) {
+ FXGIF_Context* p = FX_Alloc(FXGIF_Context, 1);
+ if (!p)
+ return nullptr;
+
FXSYS_memset(p, 0, sizeof(FXGIF_Context));
p->m_AllocFunc = gif_alloc_func;
p->m_FreeFunc = gif_free_func;
- p->gif_ptr = NULL;
+ p->gif_ptr = nullptr;
p->parent_ptr = (void*)this;
p->child_ptr = pModule;
p->gif_ptr = gif_create_decompress();
- if (p->gif_ptr == NULL) {
+ if (!p->gif_ptr) {
FX_Free(p);
- return NULL;
+ return nullptr;
}
p->gif_ptr->context_ptr = (void*)p;
p->gif_ptr->err_ptr = m_szLastError;
@@ -94,68 +95,66 @@ void* CCodec_GifModule::Start(void* pModule) {
p->gif_ptr->gif_get_record_position_fn = gif_get_record_position;
return p;
}
-void CCodec_GifModule::Finish(void* pContext) {
- FXGIF_Context* p = (FXGIF_Context*)pContext;
- if (p) {
- gif_destroy_decompress(&p->gif_ptr);
- p->m_FreeFunc(p);
+
+void CCodec_GifModule::Finish(FXGIF_Context* ctx) {
+ if (ctx) {
+ gif_destroy_decompress(&ctx->gif_ptr);
+ ctx->m_FreeFunc(ctx);
}
}
-int32_t CCodec_GifModule::ReadHeader(void* pContext,
+
+int32_t CCodec_GifModule::ReadHeader(FXGIF_Context* ctx,
int* width,
int* height,
int* pal_num,
void** pal_pp,
int* bg_index,
CFX_DIBAttribute* pAttribute) {
- FXGIF_Context* p = (FXGIF_Context*)pContext;
- if (setjmp(p->gif_ptr->jmpbuf)) {
+ if (setjmp(ctx->gif_ptr->jmpbuf))
return 0;
- }
- int32_t ret = gif_read_header(p->gif_ptr);
- if (ret != 1) {
+
+ int32_t ret = gif_read_header(ctx->gif_ptr);
+ if (ret != 1)
return ret;
- }
- if (pAttribute) {
- }
- *width = p->gif_ptr->width;
- *height = p->gif_ptr->height;
- *pal_num = p->gif_ptr->global_pal_num;
- *pal_pp = p->gif_ptr->global_pal_ptr;
- *bg_index = p->gif_ptr->bc_index;
+
+ *width = ctx->gif_ptr->width;
+ *height = ctx->gif_ptr->height;
+ *pal_num = ctx->gif_ptr->global_pal_num;
+ *pal_pp = ctx->gif_ptr->global_pal_ptr;
+ *bg_index = ctx->gif_ptr->bc_index;
return 1;
}
-int32_t CCodec_GifModule::LoadFrameInfo(void* pContext, int* frame_num) {
- FXGIF_Context* p = (FXGIF_Context*)pContext;
- if (setjmp(p->gif_ptr->jmpbuf)) {
+
+int32_t CCodec_GifModule::LoadFrameInfo(FXGIF_Context* ctx, int* frame_num) {
+ if (setjmp(ctx->gif_ptr->jmpbuf))
return 0;
- }
- int32_t ret = gif_get_frame(p->gif_ptr);
- if (ret != 1) {
+
+ int32_t ret = gif_get_frame(ctx->gif_ptr);
+ if (ret != 1)
return ret;
- }
- *frame_num = gif_get_frame_num(p->gif_ptr);
+
+ *frame_num = gif_get_frame_num(ctx->gif_ptr);
return 1;
}
-int32_t CCodec_GifModule::LoadFrame(void* pContext,
+
+int32_t CCodec_GifModule::LoadFrame(FXGIF_Context* ctx,
int frame_num,
CFX_DIBAttribute* pAttribute) {
- FXGIF_Context* p = (FXGIF_Context*)pContext;
- if (setjmp(p->gif_ptr->jmpbuf)) {
+ if (setjmp(ctx->gif_ptr->jmpbuf))
return 0;
- }
- int32_t ret = gif_load_frame(p->gif_ptr, frame_num);
+
+ int32_t ret = gif_load_frame(ctx->gif_ptr, frame_num);
if (ret == 1) {
if (pAttribute) {
pAttribute->m_nGifLeft =
- p->gif_ptr->img_ptr_arr_ptr->GetAt(frame_num)->image_info_ptr->left;
+ ctx->gif_ptr->img_ptr_arr_ptr->GetAt(frame_num)->image_info_ptr->left;
pAttribute->m_nGifTop =
- p->gif_ptr->img_ptr_arr_ptr->GetAt(frame_num)->image_info_ptr->top;
- pAttribute->m_fAspectRatio = p->gif_ptr->pixel_aspect;
- if (p->gif_ptr->cmt_data_ptr) {
+ ctx->gif_ptr->img_ptr_arr_ptr->GetAt(frame_num)->image_info_ptr->top;
+ pAttribute->m_fAspectRatio = ctx->gif_ptr->pixel_aspect;
+ if (ctx->gif_ptr->cmt_data_ptr) {
const uint8_t* buf =
- (const uint8_t*)p->gif_ptr->cmt_data_ptr->GetBuffer(0);
- uint32_t len = p->gif_ptr->cmt_data_ptr->GetLength();
+ (const uint8_t*)ctx->gif_ptr->cmt_data_ptr->GetBuffer(0);
+ uint32_t len = ctx->gif_ptr->cmt_data_ptr->GetLength();
if (len > 21) {
uint8_t size = *buf++;
if (size) {
@@ -174,14 +173,14 @@ int32_t CCodec_GifModule::LoadFrame(void* pContext,
}
return ret;
}
-uint32_t CCodec_GifModule::GetAvailInput(void* pContext,
+
+uint32_t CCodec_GifModule::GetAvailInput(FXGIF_Context* ctx,
uint8_t** avial_buf_ptr) {
- FXGIF_Context* p = (FXGIF_Context*)pContext;
- return gif_get_avail_input(p->gif_ptr, avial_buf_ptr);
+ return gif_get_avail_input(ctx->gif_ptr, avial_buf_ptr);
}
-void CCodec_GifModule::Input(void* pContext,
+
+void CCodec_GifModule::Input(FXGIF_Context* ctx,
const uint8_t* src_buf,
uint32_t src_size) {
- FXGIF_Context* p = (FXGIF_Context*)pContext;
- gif_input_buffer(p->gif_ptr, (uint8_t*)src_buf, src_size);
+ gif_input_buffer(ctx->gif_ptr, (uint8_t*)src_buf, src_size);
}
diff --git a/core/fxcodec/codec/fx_codec_icc.cpp b/core/fxcodec/codec/fx_codec_icc.cpp
index 74801e57a0..324c01ad0b 100644
--- a/core/fxcodec/codec/fx_codec_icc.cpp
+++ b/core/fxcodec/codec/fx_codec_icc.cpp
@@ -251,41 +251,41 @@ void* CreateProfile_Gray(double gamma) {
cmsFreeToneCurve(curve);
return profile;
}
-ICodec_IccModule::IccCS GetProfileCSFromHandle(void* pProfile) {
+CCodec_IccModule::IccCS GetProfileCSFromHandle(void* pProfile) {
if (!pProfile) {
- return ICodec_IccModule::IccCS_Unknown;
+ return CCodec_IccModule::IccCS_Unknown;
}
switch (cmsGetColorSpace(pProfile)) {
case cmsSigXYZData:
- return ICodec_IccModule::IccCS_XYZ;
+ return CCodec_IccModule::IccCS_XYZ;
case cmsSigLabData:
- return ICodec_IccModule::IccCS_Lab;
+ return CCodec_IccModule::IccCS_Lab;
case cmsSigLuvData:
- return ICodec_IccModule::IccCS_Luv;
+ return CCodec_IccModule::IccCS_Luv;
case cmsSigYCbCrData:
- return ICodec_IccModule::IccCS_YCbCr;
+ return CCodec_IccModule::IccCS_YCbCr;
case cmsSigYxyData:
- return ICodec_IccModule::IccCS_Yxy;
+ return CCodec_IccModule::IccCS_Yxy;
case cmsSigRgbData:
- return ICodec_IccModule::IccCS_Rgb;
+ return CCodec_IccModule::IccCS_Rgb;
case cmsSigGrayData:
- return ICodec_IccModule::IccCS_Gray;
+ return CCodec_IccModule::IccCS_Gray;
case cmsSigHsvData:
- return ICodec_IccModule::IccCS_Hsv;
+ return CCodec_IccModule::IccCS_Hsv;
case cmsSigHlsData:
- return ICodec_IccModule::IccCS_Hls;
+ return CCodec_IccModule::IccCS_Hls;
case cmsSigCmykData:
- return ICodec_IccModule::IccCS_Cmyk;
+ return CCodec_IccModule::IccCS_Cmyk;
case cmsSigCmyData:
- return ICodec_IccModule::IccCS_Cmy;
+ return CCodec_IccModule::IccCS_Cmy;
default:
- return ICodec_IccModule::IccCS_Unknown;
+ return CCodec_IccModule::IccCS_Unknown;
}
}
-ICodec_IccModule::IccCS CCodec_IccModule::GetProfileCS(
+CCodec_IccModule::IccCS CCodec_IccModule::GetProfileCS(
const uint8_t* pProfileData,
uint32_t dwProfileSize) {
- ICodec_IccModule::IccCS cs;
+ CCodec_IccModule::IccCS cs;
cmsHPROFILE hProfile =
cmsOpenProfileFromMem((void*)pProfileData, dwProfileSize);
if (!hProfile) {
@@ -297,11 +297,11 @@ ICodec_IccModule::IccCS CCodec_IccModule::GetProfileCS(
}
return cs;
}
-ICodec_IccModule::IccCS CCodec_IccModule::GetProfileCS(IFX_FileRead* pFile) {
+CCodec_IccModule::IccCS CCodec_IccModule::GetProfileCS(IFX_FileRead* pFile) {
if (!pFile) {
return IccCS_Unknown;
}
- ICodec_IccModule::IccCS cs;
+ CCodec_IccModule::IccCS cs;
uint32_t dwSize = (uint32_t)pFile->GetSize();
uint8_t* pBuf = FX_Alloc(uint8_t, dwSize);
pFile->ReadBlock(pBuf, 0, dwSize);
@@ -406,7 +406,7 @@ CFX_ByteStringKey& CFX_ByteStringKey::operator<<(uint32_t i) {
AppendBlock(&i, sizeof(uint32_t));
return *this;
}
-void* CCodec_IccModule::CreateProfile(ICodec_IccModule::IccParam* pIccParam,
+void* CCodec_IccModule::CreateProfile(CCodec_IccModule::IccParam* pIccParam,
Icc_CLASS ic,
CFX_BinaryBuf* pTransformKey) {
CFX_IccProfileCache* pCache = NULL;
@@ -469,9 +469,9 @@ void* CCodec_IccModule::CreateProfile(ICodec_IccModule::IccParam* pIccParam,
return pCache->m_pProfile;
}
void* CCodec_IccModule::CreateTransform(
- ICodec_IccModule::IccParam* pInputParam,
- ICodec_IccModule::IccParam* pOutputParam,
- ICodec_IccModule::IccParam* pProofParam,
+ CCodec_IccModule::IccParam* pInputParam,
+ CCodec_IccModule::IccParam* pOutputParam,
+ CCodec_IccModule::IccParam* pProofParam,
uint32_t dwIntent,
uint32_t dwFlag,
uint32_t dwPrfIntent,
diff --git a/core/fxcodec/codec/fx_codec_jbig.cpp b/core/fxcodec/codec/fx_codec_jbig.cpp
index 96f6836190..b5e32f130d 100644
--- a/core/fxcodec/codec/fx_codec_jbig.cpp
+++ b/core/fxcodec/codec/fx_codec_jbig.cpp
@@ -9,6 +9,26 @@
#include "core/fxcodec/codec/codec_int.h"
#include "core/fxcodec/include/fx_codec.h"
+namespace {
+
+class CCodec_Jbig2Context {
+ public:
+ CCodec_Jbig2Context();
+ ~CCodec_Jbig2Context() {}
+
+ uint32_t m_width;
+ uint32_t m_height;
+ CPDF_StreamAcc* m_pGlobalStream;
+ CPDF_StreamAcc* m_pSrcStream;
+ uint8_t* m_dest_buf;
+ uint32_t m_dest_pitch;
+ IFX_Pause* m_pPause;
+ CJBig2_Context* m_pContext;
+ CJBig2_Image* m_dest_image;
+};
+
+} // namespace
+
// Holds per-document JBig2 related data.
class JBig2DocumentContext : public CFX_DestructObject {
public:
diff --git a/core/fxcodec/codec/fx_codec_jpeg.cpp b/core/fxcodec/codec/fx_codec_jpeg.cpp
index 9a2a0ee4a3..608bf52969 100644
--- a/core/fxcodec/codec/fx_codec_jpeg.cpp
+++ b/core/fxcodec/codec/fx_codec_jpeg.cpp
@@ -476,7 +476,7 @@ uint8_t* CCodec_JpegDecoder::v_GetNextLine() {
uint32_t CCodec_JpegDecoder::GetSrcOffset() {
return (uint32_t)(m_SrcSize - src.bytes_in_buffer);
}
-ICodec_ScanlineDecoder* CCodec_JpegModule::CreateDecoder(
+CCodec_ScanlineDecoder* CCodec_JpegModule::CreateDecoder(
const uint8_t* src_buf,
uint32_t src_size,
int width,
@@ -551,7 +551,7 @@ static void* jpeg_alloc_func(unsigned int size) {
static void jpeg_free_func(void* p) {
FX_Free(p);
}
-void* CCodec_JpegModule::Start() {
+FXJPEG_Context* CCodec_JpegModule::Start() {
FXJPEG_Context* p = FX_Alloc(FXJPEG_Context, 1);
p->m_AllocFunc = jpeg_alloc_func;
p->m_FreeFunc = jpeg_free_func;
@@ -575,85 +575,83 @@ void* CCodec_JpegModule::Start() {
p->m_SkipSize = 0;
return p;
}
-void CCodec_JpegModule::Finish(void* pContext) {
- FXJPEG_Context* p = (FXJPEG_Context*)pContext;
- jpeg_destroy_decompress(&p->m_Info);
- p->m_FreeFunc(p);
+
+void CCodec_JpegModule::Finish(FXJPEG_Context* ctx) {
+ jpeg_destroy_decompress(&ctx->m_Info);
+ ctx->m_FreeFunc(ctx);
}
-void CCodec_JpegModule::Input(void* pContext,
+
+void CCodec_JpegModule::Input(FXJPEG_Context* ctx,
const unsigned char* src_buf,
uint32_t src_size) {
- FXJPEG_Context* p = (FXJPEG_Context*)pContext;
- if (p->m_SkipSize) {
- if (p->m_SkipSize > src_size) {
- p->m_SrcMgr.bytes_in_buffer = 0;
- p->m_SkipSize -= src_size;
+ if (ctx->m_SkipSize) {
+ if (ctx->m_SkipSize > src_size) {
+ ctx->m_SrcMgr.bytes_in_buffer = 0;
+ ctx->m_SkipSize -= src_size;
return;
}
- src_size -= p->m_SkipSize;
- src_buf += p->m_SkipSize;
- p->m_SkipSize = 0;
+ src_size -= ctx->m_SkipSize;
+ src_buf += ctx->m_SkipSize;
+ ctx->m_SkipSize = 0;
}
- p->m_SrcMgr.next_input_byte = src_buf;
- p->m_SrcMgr.bytes_in_buffer = src_size;
+ ctx->m_SrcMgr.next_input_byte = src_buf;
+ ctx->m_SrcMgr.bytes_in_buffer = src_size;
}
#ifdef PDF_ENABLE_XFA
-int CCodec_JpegModule::ReadHeader(void* pContext,
+int CCodec_JpegModule::ReadHeader(FXJPEG_Context* ctx,
int* width,
int* height,
int* nComps,
CFX_DIBAttribute* pAttribute) {
#else // PDF_ENABLE_XFA
-int CCodec_JpegModule::ReadHeader(void* pContext,
+int CCodec_JpegModule::ReadHeader(FXJPEG_Context* ctx,
int* width,
int* height,
int* nComps) {
#endif // PDF_ENABLE_XFA
- FXJPEG_Context* p = (FXJPEG_Context*)pContext;
- if (setjmp(p->m_JumpMark) == -1) {
+ if (setjmp(ctx->m_JumpMark) == -1)
return 1;
- }
- int ret = jpeg_read_header(&p->m_Info, true);
- if (ret == JPEG_SUSPENDED) {
+
+ int ret = jpeg_read_header(&ctx->m_Info, true);
+ if (ret == JPEG_SUSPENDED)
return 2;
- }
- if (ret != JPEG_HEADER_OK) {
+ if (ret != JPEG_HEADER_OK)
return 1;
- }
- *width = p->m_Info.image_width;
- *height = p->m_Info.image_height;
- *nComps = p->m_Info.num_components;
+
+ *width = ctx->m_Info.image_width;
+ *height = ctx->m_Info.image_height;
+ *nComps = ctx->m_Info.num_components;
#ifdef PDF_ENABLE_XFA
- _JpegLoadAttribute(&p->m_Info, pAttribute);
+ _JpegLoadAttribute(&ctx->m_Info, pAttribute);
#endif
return 0;
}
-int CCodec_JpegModule::StartScanline(void* pContext, int down_scale) {
- FXJPEG_Context* p = (FXJPEG_Context*)pContext;
- if (setjmp(p->m_JumpMark) == -1) {
+
+int CCodec_JpegModule::StartScanline(FXJPEG_Context* ctx, int down_scale) {
+ if (setjmp(ctx->m_JumpMark) == -1)
return 0;
- }
- p->m_Info.scale_denom = down_scale;
- return jpeg_start_decompress(&p->m_Info);
+
+ ctx->m_Info.scale_denom = down_scale;
+ return jpeg_start_decompress(&ctx->m_Info);
}
-FX_BOOL CCodec_JpegModule::ReadScanline(void* pContext,
+
+FX_BOOL CCodec_JpegModule::ReadScanline(FXJPEG_Context* ctx,
unsigned char* dest_buf) {
- FXJPEG_Context* p = (FXJPEG_Context*)pContext;
- if (setjmp(p->m_JumpMark) == -1) {
+ if (setjmp(ctx->m_JumpMark) == -1)
return FALSE;
- }
- int nlines = jpeg_read_scanlines(&p->m_Info, &dest_buf, 1);
+
+ int nlines = jpeg_read_scanlines(&ctx->m_Info, &dest_buf, 1);
return nlines == 1;
}
-uint32_t CCodec_JpegModule::GetAvailInput(void* pContext,
+
+uint32_t CCodec_JpegModule::GetAvailInput(FXJPEG_Context* ctx,
uint8_t** avail_buf_ptr) {
if (avail_buf_ptr) {
*avail_buf_ptr = NULL;
- if (((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer > 0) {
- *avail_buf_ptr =
- (uint8_t*)((FXJPEG_Context*)pContext)->m_SrcMgr.next_input_byte;
+ if (ctx->m_SrcMgr.bytes_in_buffer > 0) {
+ *avail_buf_ptr = (uint8_t*)ctx->m_SrcMgr.next_input_byte;
}
}
- return (uint32_t)((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer;
+ return (uint32_t)ctx->m_SrcMgr.bytes_in_buffer;
}
diff --git a/core/fxcodec/codec/fx_codec_png.cpp b/core/fxcodec/codec/fx_codec_png.cpp
index 29ea794b5d..61d4cebdbb 100644
--- a/core/fxcodec/codec/fx_codec_png.cpp
+++ b/core/fxcodec/codec/fx_codec_png.cpp
@@ -195,34 +195,36 @@ static void _png_get_row_func(png_structp png_ptr,
}
pModule->FillScanlineBufCompletedCallback(p->child_ptr, pass, row_num);
}
-void* CCodec_PngModule::Start(void* pModule) {
+
+FXPNG_Context* CCodec_PngModule::Start(void* pModule) {
FXPNG_Context* p = (FXPNG_Context*)FX_Alloc(uint8_t, sizeof(FXPNG_Context));
- if (p == NULL) {
- return NULL;
- }
+ if (!p)
+ return nullptr;
+
p->m_AllocFunc = _png_alloc_func;
p->m_FreeFunc = _png_free_func;
- p->png_ptr = NULL;
- p->info_ptr = NULL;
+ p->png_ptr = nullptr;
+ p->info_ptr = nullptr;
p->parent_ptr = (void*)this;
p->child_ptr = pModule;
- p->png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
- if (p->png_ptr == NULL) {
+ p->png_ptr =
+ png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);
+ if (!p->png_ptr) {
FX_Free(p);
- return NULL;
+ return nullptr;
}
p->info_ptr = png_create_info_struct(p->png_ptr);
- if (p->info_ptr == NULL) {
- png_destroy_read_struct(&(p->png_ptr), (png_infopp)NULL, (png_infopp)NULL);
+ if (!p->info_ptr) {
+ png_destroy_read_struct(&(p->png_ptr), nullptr, nullptr);
FX_Free(p);
- return NULL;
+ return nullptr;
}
if (setjmp(png_jmpbuf(p->png_ptr))) {
if (p) {
- png_destroy_read_struct(&(p->png_ptr), &(p->info_ptr), (png_infopp)NULL);
+ png_destroy_read_struct(&(p->png_ptr), &(p->info_ptr), nullptr);
FX_Free(p);
}
- return NULL;
+ return nullptr;
}
png_set_progressive_read_fn(p->png_ptr, p, _png_get_header_func,
_png_get_row_func, _png_get_end_func);
@@ -230,25 +232,25 @@ void* CCodec_PngModule::Start(void* pModule) {
(png_error_ptr)_png_warning_data);
return p;
}
-void CCodec_PngModule::Finish(void* pContext) {
- FXPNG_Context* p = (FXPNG_Context*)pContext;
- if (p) {
- png_destroy_read_struct(&(p->png_ptr), &(p->info_ptr), (png_infopp)NULL);
- p->m_FreeFunc(p);
+
+void CCodec_PngModule::Finish(FXPNG_Context* ctx) {
+ if (ctx) {
+ png_destroy_read_struct(&(ctx->png_ptr), &(ctx->info_ptr), nullptr);
+ ctx->m_FreeFunc(ctx);
}
}
-FX_BOOL CCodec_PngModule::Input(void* pContext,
+
+FX_BOOL CCodec_PngModule::Input(FXPNG_Context* ctx,
const uint8_t* src_buf,
uint32_t src_size,
CFX_DIBAttribute* pAttribute) {
- FXPNG_Context* p = (FXPNG_Context*)pContext;
- if (setjmp(png_jmpbuf(p->png_ptr))) {
+ if (setjmp(png_jmpbuf(ctx->png_ptr))) {
if (pAttribute &&
0 == FXSYS_strcmp(m_szLastError, "Read Header Callback Error")) {
- _png_load_bmp_attribute(p->png_ptr, p->info_ptr, pAttribute);
+ _png_load_bmp_attribute(ctx->png_ptr, ctx->info_ptr, pAttribute);
}
return FALSE;
}
- png_process_data(p->png_ptr, p->info_ptr, (uint8_t*)src_buf, src_size);
+ png_process_data(ctx->png_ptr, ctx->info_ptr, (uint8_t*)src_buf, src_size);
return TRUE;
}
diff --git a/core/fxcodec/codec/fx_codec_progress.cpp b/core/fxcodec/codec/fx_codec_progress.cpp
index 89e4b25dbb..95a90b3e68 100644
--- a/core/fxcodec/codec/fx_codec_progress.cpp
+++ b/core/fxcodec/codec/fx_codec_progress.cpp
@@ -4,18 +4,26 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "core/fxcodec/codec/fx_codec_progress.h"
+#include "core/fxcodec/codec/include/ccodec_progressivedecoder.h"
#include "core/fxcodec/include/fx_codec.h"
#include "core/fxge/include/fx_dib.h"
-void CFXCODEC_WeightTable::Calc(int dest_len,
- int dest_min,
- int dest_max,
- int src_len,
- int src_min,
- int src_max,
- FX_BOOL bInterpol) {
+#define FXCODEC_BLOCK_SIZE 4096
+#define FXCODEC_PNG_GAMMA 2.2
+
+#if _FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_IOS_
+#undef FXCODEC_PNG_GAMMA
+#define FXCODEC_PNG_GAMMA 1.7
+#endif
+
+void CCodec_ProgressiveDecoder::CFXCODEC_WeightTable::Calc(int dest_len,
+ int dest_min,
+ int dest_max,
+ int src_len,
+ int src_min,
+ int src_max,
+ FX_BOOL bInterpol) {
if (m_pWeightTables) {
FX_Free(m_pWeightTables);
}
@@ -113,7 +121,9 @@ void CFXCODEC_WeightTable::Calc(int dest_len,
}
}
}
-void CFXCODEC_HorzTable::Calc(int dest_len, int src_len, FX_BOOL bInterpol) {
+void CCodec_ProgressiveDecoder::CFXCODEC_HorzTable::Calc(int dest_len,
+ int src_len,
+ FX_BOOL bInterpol) {
if (m_pWeightTables) {
FX_Free(m_pWeightTables);
}
@@ -173,7 +183,8 @@ void CFXCODEC_HorzTable::Calc(int dest_len, int src_len, FX_BOOL bInterpol) {
pWeight->m_Weights[1] = 0;
}
}
-void CFXCODEC_VertTable::Calc(int dest_len, int src_len) {
+void CCodec_ProgressiveDecoder::CFXCODEC_VertTable::Calc(int dest_len,
+ int src_len) {
if (m_pWeightTables) {
FX_Free(m_pWeightTables);
}
@@ -294,7 +305,7 @@ CCodec_ProgressiveDecoder::~CCodec_ProgressiveDecoder() {
FX_Free(m_pSrcPalette);
}
FX_BOOL CCodec_ProgressiveDecoder::JpegReadMoreData(
- ICodec_JpegModule* pJpegModule,
+ CCodec_JpegModule* pJpegModule,
FXCODEC_STATUS& err_status) {
uint32_t dwSize = (uint32_t)m_pFile->GetSize();
if (dwSize <= m_offSet) {
@@ -552,7 +563,7 @@ void CCodec_ProgressiveDecoder::PngFillScanlineBufCompletedFunc(void* pModule,
}
}
}
-FX_BOOL CCodec_ProgressiveDecoder::GifReadMoreData(ICodec_GifModule* pGifModule,
+FX_BOOL CCodec_ProgressiveDecoder::GifReadMoreData(CCodec_GifModule* pGifModule,
FXCODEC_STATUS& err_status) {
uint32_t dwSize = (uint32_t)m_pFile->GetSize();
if (dwSize <= m_offSet) {
@@ -834,7 +845,7 @@ void CCodec_ProgressiveDecoder::GifDoubleLineResampleVert(
GifDoubleLineResampleVert(pDeviceBitmap, scale_y, des_row + (int)scale_y);
}
}
-FX_BOOL CCodec_ProgressiveDecoder::BmpReadMoreData(ICodec_BmpModule* pBmpModule,
+FX_BOOL CCodec_ProgressiveDecoder::BmpReadMoreData(CCodec_BmpModule* pBmpModule,
FXCODEC_STATUS& err_status) {
uint32_t dwSize = (uint32_t)m_pFile->GetSize();
if (dwSize <= m_offSet) {
@@ -1008,7 +1019,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType(
m_SrcSize = size;
switch (imageType) {
case FXCODEC_IMAGE_BMP: {
- ICodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule();
+ CCodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule();
if (pBmpModule == NULL) {
m_status = FXCODEC_STATUS_ERR_MEMORY;
return FALSE;
@@ -1063,7 +1074,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType(
return FALSE;
} break;
case FXCODEC_IMAGE_JPG: {
- ICodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule();
+ CCodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule();
if (pJpegModule == NULL) {
m_status = FXCODEC_STATUS_ERR_MEMORY;
return FALSE;
@@ -1106,7 +1117,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType(
return FALSE;
} break;
case FXCODEC_IMAGE_PNG: {
- ICodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule();
+ CCodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule();
if (pPngModule == NULL) {
m_status = FXCODEC_STATUS_ERR_MEMORY;
return FALSE;
@@ -1167,7 +1178,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType(
}
} break;
case FXCODEC_IMAGE_GIF: {
- ICodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule();
+ CCodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule();
if (pGifModule == NULL) {
m_status = FXCODEC_STATUS_ERR_MEMORY;
return FALSE;
@@ -1219,7 +1230,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType(
return FALSE;
} break;
case FXCODEC_IMAGE_TIF: {
- ICodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule();
+ CCodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule();
if (pTiffModule == NULL) {
m_status = FXCODEC_STATUS_ERR_FORMAT;
return FALSE;
@@ -1799,7 +1810,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::GetFrames(int32_t& frames,
frames = m_FrameNumber = 1;
return m_status = FXCODEC_STATUS_DECODE_READY;
case FXCODEC_IMAGE_GIF: {
- ICodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule();
+ CCodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule();
while (TRUE) {
int32_t readResult =
pGifModule->LoadFrameInfo(m_pGifContext, &m_FrameNumber);
@@ -1888,7 +1899,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap,
}
switch (m_imagType) {
case FXCODEC_IMAGE_JPG: {
- ICodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule();
+ CCodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule();
int down_scale = 1;
GetDownScale(down_scale);
FX_BOOL bStart = pJpegModule->StartScanline(m_pJpegContext, down_scale);
@@ -1924,7 +1935,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap,
return m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE;
} break;
case FXCODEC_IMAGE_PNG: {
- ICodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule();
+ CCodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule();
if (pPngModule == NULL) {
m_pDeviceBitmap = NULL;
m_pFile = NULL;
@@ -1972,7 +1983,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap,
return m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE;
} break;
case FXCODEC_IMAGE_GIF: {
- ICodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule();
+ CCodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule();
if (pGifModule == NULL) {
m_pDeviceBitmap = NULL;
m_pFile = NULL;
@@ -1991,7 +2002,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap,
return m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE;
} break;
case FXCODEC_IMAGE_BMP: {
- ICodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule();
+ CCodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule();
if (pBmpModule == NULL) {
m_pDeviceBitmap = NULL;
m_pFile = NULL;
@@ -2031,7 +2042,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
}
switch (m_imagType) {
case FXCODEC_IMAGE_JPG: {
- ICodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule();
+ CCodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule();
while (TRUE) {
FX_BOOL readRes =
pJpegModule->ReadScanline(m_pJpegContext, m_pDecodeBuf);
@@ -2061,7 +2072,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
}
} break;
case FXCODEC_IMAGE_PNG: {
- ICodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule();
+ CCodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule();
while (TRUE) {
uint32_t remain_size = (uint32_t)m_pFile->GetSize() - m_offSet;
uint32_t input_size =
@@ -2101,7 +2112,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
}
} break;
case FXCODEC_IMAGE_GIF: {
- ICodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule();
+ CCodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule();
while (TRUE) {
int32_t readRes =
pGifModule->LoadFrame(m_pGifContext, m_FrameCur, nullptr);
@@ -2128,7 +2139,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
}
} break;
case FXCODEC_IMAGE_BMP: {
- ICodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule();
+ CCodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule();
while (TRUE) {
int32_t readRes = pBmpModule->LoadImage(m_pBmpContext);
while (readRes == 2) {
@@ -2154,7 +2165,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
}
} break;
case FXCODEC_IMAGE_TIF: {
- ICodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule();
+ CCodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule();
FX_BOOL ret = FALSE;
if (m_pDeviceBitmap->GetBPP() == 32 &&
m_pDeviceBitmap->GetWidth() == m_SrcWidth && m_SrcWidth == m_sizeX &&
@@ -2296,6 +2307,6 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
}
return FXCODEC_STATUS_ERROR;
}
-ICodec_ProgressiveDecoder* CCodec_ModuleMgr::CreateProgressiveDecoder() {
+CCodec_ProgressiveDecoder* CCodec_ModuleMgr::CreateProgressiveDecoder() {
return new CCodec_ProgressiveDecoder(this);
}
diff --git a/core/fxcodec/codec/fx_codec_tiff.cpp b/core/fxcodec/codec/fx_codec_tiff.cpp
index f0f2ab2e96..d4dc139265 100644
--- a/core/fxcodec/codec/fx_codec_tiff.cpp
+++ b/core/fxcodec/codec/fx_codec_tiff.cpp
@@ -512,33 +512,35 @@ FX_BOOL CCodec_TiffContext::Decode(CFX_DIBitmap* pDIBitmap) {
}
return FALSE;
}
-void* CCodec_TiffModule::CreateDecoder(IFX_FileRead* file_ptr) {
+
+CCodec_TiffContext* CCodec_TiffModule::CreateDecoder(IFX_FileRead* file_ptr) {
CCodec_TiffContext* pDecoder = new CCodec_TiffContext;
if (!pDecoder->InitDecoder(file_ptr)) {
delete pDecoder;
- return NULL;
+ return nullptr;
}
return pDecoder;
}
-void CCodec_TiffModule::GetFrames(void* ctx, int32_t& frames) {
- CCodec_TiffContext* pDecoder = (CCodec_TiffContext*)ctx;
- pDecoder->GetFrames(frames);
+
+void CCodec_TiffModule::GetFrames(CCodec_TiffContext* ctx, int32_t& frames) {
+ ctx->GetFrames(frames);
}
-FX_BOOL CCodec_TiffModule::LoadFrameInfo(void* ctx,
+
+FX_BOOL CCodec_TiffModule::LoadFrameInfo(CCodec_TiffContext* ctx,
int32_t frame,
uint32_t& width,
uint32_t& height,
uint32_t& comps,
uint32_t& bpc,
CFX_DIBAttribute* pAttribute) {
- CCodec_TiffContext* pDecoder = (CCodec_TiffContext*)ctx;
- return pDecoder->LoadFrameInfo(frame, width, height, comps, bpc, pAttribute);
+ return ctx->LoadFrameInfo(frame, width, height, comps, bpc, pAttribute);
}
-FX_BOOL CCodec_TiffModule::Decode(void* ctx, class CFX_DIBitmap* pDIBitmap) {
- CCodec_TiffContext* pDecoder = (CCodec_TiffContext*)ctx;
- return pDecoder->Decode(pDIBitmap);
+
+FX_BOOL CCodec_TiffModule::Decode(CCodec_TiffContext* ctx,
+ class CFX_DIBitmap* pDIBitmap) {
+ return ctx->Decode(pDIBitmap);
}
-void CCodec_TiffModule::DestroyDecoder(void* ctx) {
- CCodec_TiffContext* pDecoder = (CCodec_TiffContext*)ctx;
- delete pDecoder;
+
+void CCodec_TiffModule::DestroyDecoder(CCodec_TiffContext* ctx) {
+ delete ctx;
}
diff --git a/core/fxcodec/codec/fx_codec_progress.h b/core/fxcodec/codec/include/ccodec_progressivedecoder.h
index e8e885b3b5..83b73e1ba7 100644
--- a/core/fxcodec/codec/fx_codec_progress.h
+++ b/core/fxcodec/codec/include/ccodec_progressivedecoder.h
@@ -4,108 +4,161 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef CORE_FXCODEC_CODEC_FX_CODEC_PROGRESS_H_
-#define CORE_FXCODEC_CODEC_FX_CODEC_PROGRESS_H_
+#ifndef CORE_FXCODEC_CODEC_INCLUDE_CCODEC_PROGRESSIVEDECODER_H_
+#define CORE_FXCODEC_CODEC_INCLUDE_CCODEC_PROGRESSIVEDECODER_H_
-#include "core/fxcodec/include/fx_codec.h"
-#include "core/fxcrt/include/fx_memory.h"
+#include "core/fxcodec/include/fx_codec_def.h"
#include "core/fxcrt/include/fx_system.h"
#include "core/fxge/include/fx_dib.h"
-#define FXCODEC_BLOCK_SIZE 4096
-#define FXCODEC_PNG_GAMMA 2.2
-
-#if _FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_IOS_
-#undef FXCODEC_PNG_GAMMA
-#define FXCODEC_PNG_GAMMA 1.7
-#endif
-
-struct PixelWeight {
- int m_SrcStart;
- int m_SrcEnd;
- int m_Weights[1];
-};
-
-class CFXCODEC_WeightTable {
- public:
- CFXCODEC_WeightTable() { m_pWeightTables = NULL; }
- ~CFXCODEC_WeightTable() { FX_Free(m_pWeightTables); }
-
- void Calc(int dest_len,
- int dest_min,
- int dest_max,
- int src_len,
- int src_min,
- int src_max,
- FX_BOOL bInterpol);
- PixelWeight* GetPixelWeight(int pixel) {
- return (PixelWeight*)(m_pWeightTables + (pixel - m_DestMin) * m_ItemSize);
- }
-
- int m_DestMin, m_ItemSize;
- uint8_t* m_pWeightTables;
-};
-class CFXCODEC_HorzTable {
+class CCodec_BmpModule;
+class CCodec_GifContext;
+class CCodec_GifModule;
+class CCodec_JpegModule;
+class CCodec_ModuleMgr;
+class CCodec_PngContext;
+class CCodec_TiffContext;
+class CFX_DIBAttribute;
+class IFX_FileRead;
+class IFX_Pause;
+struct FXBMP_Context;
+struct FXGIF_Context;
+struct FXJPEG_Context;
+struct FXPNG_Context;
+
+class CCodec_ProgressiveDecoder {
public:
- CFXCODEC_HorzTable() { m_pWeightTables = NULL; }
- ~CFXCODEC_HorzTable() { FX_Free(m_pWeightTables); }
+ enum FXCodec_Format {
+ FXCodec_Invalid = 0,
+ FXCodec_1bppGray = 0x101,
+ FXCodec_1bppRgb = 0x001,
+ FXCodec_8bppGray = 0x108,
+ FXCodec_8bppRgb = 0x008,
+ FXCodec_Rgb = 0x018,
+ FXCodec_Rgb32 = 0x020,
+ FXCodec_Argb = 0x220,
+ FXCodec_Cmyk = 0x120
+ };
- void Calc(int dest_len, int src_len, FX_BOOL bInterpol);
- PixelWeight* GetPixelWeight(int pixel) {
- return (PixelWeight*)(m_pWeightTables + pixel * m_ItemSize);
- }
-
- int m_ItemSize;
- uint8_t* m_pWeightTables;
-};
-class CFXCODEC_VertTable {
- public:
- CFXCODEC_VertTable() { m_pWeightTables = NULL; }
- ~CFXCODEC_VertTable() { FX_Free(m_pWeightTables); }
- void Calc(int dest_len, int src_len);
- PixelWeight* GetPixelWeight(int pixel) {
- return (PixelWeight*)(m_pWeightTables + pixel * m_ItemSize);
- }
- int m_ItemSize;
- uint8_t* m_pWeightTables;
-};
-enum FXCodec_Format {
- FXCodec_Invalid = 0,
- FXCodec_1bppGray = 0x101,
- FXCodec_1bppRgb = 0x001,
- FXCodec_8bppGray = 0x108,
- FXCodec_8bppRgb = 0x008,
- FXCodec_Rgb = 0x018,
- FXCodec_Rgb32 = 0x020,
- FXCodec_Argb = 0x220,
- FXCodec_Cmyk = 0x120
-};
-class CCodec_ProgressiveDecoder : public ICodec_ProgressiveDecoder {
- public:
CCodec_ProgressiveDecoder(CCodec_ModuleMgr* pCodecMgr);
- ~CCodec_ProgressiveDecoder() override;
+ ~CCodec_ProgressiveDecoder();
FXCODEC_STATUS LoadImageInfo(IFX_FileRead* pFile,
FXCODEC_IMAGE_TYPE imageType,
- CFX_DIBAttribute* pAttribute) override;
+ CFX_DIBAttribute* pAttribute);
- FXCODEC_IMAGE_TYPE GetType() const override { return m_imagType; }
- int32_t GetWidth() const override { return m_SrcWidth; }
- int32_t GetHeight() const override { return m_SrcHeight; }
- int32_t GetNumComponents() const override { return m_SrcComponents; }
- int32_t GetBPC() const override { return m_SrcBPC; }
- void SetClipBox(FX_RECT* clip) override;
+ FXCODEC_IMAGE_TYPE GetType() const { return m_imagType; }
+ int32_t GetWidth() const { return m_SrcWidth; }
+ int32_t GetHeight() const { return m_SrcHeight; }
+ int32_t GetNumComponents() const { return m_SrcComponents; }
+ int32_t GetBPC() const { return m_SrcBPC; }
+ void SetClipBox(FX_RECT* clip);
- FXCODEC_STATUS GetFrames(int32_t& frames, IFX_Pause* pPause) override;
+ FXCODEC_STATUS GetFrames(int32_t& frames, IFX_Pause* pPause = nullptr);
FXCODEC_STATUS StartDecode(CFX_DIBitmap* pDIBitmap,
int start_x,
int start_y,
int size_x,
int size_y,
- int32_t frames,
- FX_BOOL bInterpol) override;
+ int32_t frames = 0,
+ FX_BOOL bInterpol = TRUE);
+
+ FXCODEC_STATUS ContinueDecode(IFX_Pause* pPause = nullptr);
+
+ struct PixelWeight {
+ int m_SrcStart;
+ int m_SrcEnd;
+ int m_Weights[1];
+ };
+
+ class CFXCODEC_WeightTable {
+ public:
+ CFXCODEC_WeightTable() { m_pWeightTables = NULL; }
+ ~CFXCODEC_WeightTable() { FX_Free(m_pWeightTables); }
+
+ void Calc(int dest_len,
+ int dest_min,
+ int dest_max,
+ int src_len,
+ int src_min,
+ int src_max,
+ FX_BOOL bInterpol);
+ PixelWeight* GetPixelWeight(int pixel) {
+ return (PixelWeight*)(m_pWeightTables + (pixel - m_DestMin) * m_ItemSize);
+ }
+
+ int m_DestMin, m_ItemSize;
+ uint8_t* m_pWeightTables;
+ };
+
+ class CFXCODEC_HorzTable {
+ public:
+ CFXCODEC_HorzTable() { m_pWeightTables = NULL; }
+ ~CFXCODEC_HorzTable() { FX_Free(m_pWeightTables); }
+
+ void Calc(int dest_len, int src_len, FX_BOOL bInterpol);
+ PixelWeight* GetPixelWeight(int pixel) {
+ return (PixelWeight*)(m_pWeightTables + pixel * m_ItemSize);
+ }
+
+ int m_ItemSize;
+ uint8_t* m_pWeightTables;
+ };
+
+ class CFXCODEC_VertTable {
+ public:
+ CFXCODEC_VertTable() { m_pWeightTables = NULL; }
+ ~CFXCODEC_VertTable() { FX_Free(m_pWeightTables); }
+ void Calc(int dest_len, int src_len);
+ PixelWeight* GetPixelWeight(int pixel) {
+ return (PixelWeight*)(m_pWeightTables + pixel * m_ItemSize);
+ }
+ int m_ItemSize;
+ uint8_t* m_pWeightTables;
+ };
- FXCODEC_STATUS ContinueDecode(IFX_Pause* pPause) override;
+ IFX_FileRead* m_pFile;
+ CCodec_ModuleMgr* m_pCodecMgr;
+ FXJPEG_Context* m_pJpegContext;
+ FXPNG_Context* m_pPngContext;
+ FXGIF_Context* m_pGifContext;
+ FXBMP_Context* m_pBmpContext;
+ CCodec_TiffContext* m_pTiffContext;
+ FXCODEC_IMAGE_TYPE m_imagType;
+ uint32_t m_offSet;
+ uint8_t* m_pSrcBuf;
+ uint32_t m_SrcSize;
+ uint8_t* m_pDecodeBuf;
+ int m_ScanlineSize;
+ CFX_DIBitmap* m_pDeviceBitmap;
+ FX_BOOL m_bInterpol;
+ CFXCODEC_WeightTable m_WeightHorz;
+ CFXCODEC_VertTable m_WeightVert;
+ CFXCODEC_HorzTable m_WeightHorzOO;
+ int m_SrcWidth;
+ int m_SrcHeight;
+ int m_SrcComponents;
+ int m_SrcBPC;
+ FX_RECT m_clipBox;
+ int m_startX;
+ int m_startY;
+ int m_sizeX;
+ int m_sizeY;
+ int m_TransMethod;
+ FX_ARGB* m_pSrcPalette;
+ int m_SrcPaletteNumber;
+ int m_SrcRow;
+ FXCodec_Format m_SrcFormat;
+ int m_SrcPassNumber;
+ int m_FrameNumber;
+ int m_FrameCur;
+ int m_GifBgIndex;
+ uint8_t* m_pGifPalette;
+ int32_t m_GifPltNumber;
+ int m_GifTransIndex;
+ FX_RECT m_GifFrameRect;
+ FX_BOOL m_BmpIsTopBottom;
+ FXCODEC_STATUS m_status;
protected:
static FX_BOOL PngReadHeaderFunc(void* pModule,
@@ -158,64 +211,20 @@ class CCodec_ProgressiveDecoder : public ICodec_ProgressiveDecoder {
uint8_t* src_scan,
FXCodec_Format src_format);
void ResampleVert(CFX_DIBitmap* pDeviceBitmap, double scale_y, int des_row);
- FX_BOOL JpegReadMoreData(ICodec_JpegModule* pJpegModule,
+ FX_BOOL JpegReadMoreData(CCodec_JpegModule* pJpegModule,
FXCODEC_STATUS& err_status);
void PngOneOneMapResampleHorz(CFX_DIBitmap* pDeviceBitmap,
int32_t des_line,
uint8_t* src_scan,
FXCodec_Format src_format);
- FX_BOOL GifReadMoreData(ICodec_GifModule* pGifModule,
+ FX_BOOL GifReadMoreData(CCodec_GifModule* pGifModule,
FXCODEC_STATUS& err_status);
void GifDoubleLineResampleVert(CFX_DIBitmap* pDeviceBitmap,
double scale_y,
int des_row);
- FX_BOOL BmpReadMoreData(ICodec_BmpModule* pBmpModule,
+ FX_BOOL BmpReadMoreData(CCodec_BmpModule* pBmpModule,
FXCODEC_STATUS& err_status);
void ResampleVertBT(CFX_DIBitmap* pDeviceBitmap, double scale_y, int des_row);
-
- public:
- IFX_FileRead* m_pFile;
- CCodec_ModuleMgr* m_pCodecMgr;
- void* m_pJpegContext;
- void* m_pPngContext;
- void* m_pGifContext;
- void* m_pBmpContext;
- void* m_pTiffContext;
- FXCODEC_IMAGE_TYPE m_imagType;
- uint32_t m_offSet;
- uint8_t* m_pSrcBuf;
- uint32_t m_SrcSize;
- uint8_t* m_pDecodeBuf;
- int m_ScanlineSize;
- CFX_DIBitmap* m_pDeviceBitmap;
- FX_BOOL m_bInterpol;
- CFXCODEC_WeightTable m_WeightHorz;
- CFXCODEC_VertTable m_WeightVert;
- CFXCODEC_HorzTable m_WeightHorzOO;
- int m_SrcWidth;
- int m_SrcHeight;
- int m_SrcComponents;
- int m_SrcBPC;
- FX_RECT m_clipBox;
- int m_startX;
- int m_startY;
- int m_sizeX;
- int m_sizeY;
- int m_TransMethod;
- FX_ARGB* m_pSrcPalette;
- int m_SrcPaletteNumber;
- int m_SrcRow;
- FXCodec_Format m_SrcFormat;
- int m_SrcPassNumber;
- int m_FrameNumber;
- int m_FrameCur;
- int m_GifBgIndex;
- uint8_t* m_pGifPalette;
- int32_t m_GifPltNumber;
- int m_GifTransIndex;
- FX_RECT m_GifFrameRect;
- FX_BOOL m_BmpIsTopBottom;
- FXCODEC_STATUS m_status;
};
-#endif // CORE_FXCODEC_CODEC_FX_CODEC_PROGRESS_H_
+#endif // CORE_FXCODEC_CODEC_INCLUDE_CCODEC_PROGRESSIVEDECODER_H_
diff --git a/core/fxcodec/include/fx_codec.h b/core/fxcodec/include/fx_codec.h
index 4e7dbd5a8d..4853e26a6a 100644
--- a/core/fxcodec/include/fx_codec.h
+++ b/core/fxcodec/include/fx_codec.h
@@ -11,32 +11,31 @@
#include <memory>
#include <vector>
-#include "core/fxcrt/include/fx_basic.h"
-#include "core/fxcrt/include/fx_coordinates.h" // For FX_RECT.
+#include "core/fxcodec/codec/ccodec_basicmodule.h"
+#include "core/fxcodec/codec/ccodec_faxmodule.h"
+#include "core/fxcodec/codec/ccodec_flatemodule.h"
+#include "core/fxcodec/codec/ccodec_iccmodule.h"
+#include "core/fxcodec/codec/ccodec_jbig2module.h"
+#include "core/fxcodec/codec/ccodec_jpegmodule.h"
+#include "core/fxcodec/codec/ccodec_jpxmodule.h"
+#include "core/fxcodec/codec/ccodec_scanlinedecoder.h"
#include "core/fxcodec/include/fx_codec_def.h"
+#include "core/fxcrt/include/fx_basic.h"
+#include "core/fxcrt/include/fx_coordinates.h"
class CFX_DIBSource;
class CJPX_Decoder;
class CPDF_ColorSpace;
class CPDF_StreamAcc;
-class ICodec_BasicModule;
-class ICodec_FaxModule;
-class ICodec_FlateModule;
-class ICodec_IccModule;
-class ICodec_Jbig2Module;
-class ICodec_JpegModule;
-class ICodec_JpxModule;
-class ICodec_ScanlineDecoder;
#ifdef PDF_ENABLE_XFA
-class ICodec_BmpModule;
-class ICodec_GifModule;
-class ICodec_PngModule;
-class ICodec_ProgressiveDecoder;
-class ICodec_TiffModule;
-#endif // PDF_ENABLE_XFA
+#include "core/fxcodec/codec/ccodec_bmpmodule.h"
+#include "core/fxcodec/codec/ccodec_gifmodule.h"
+#include "core/fxcodec/codec/ccodec_pngmodule.h"
+#include "core/fxcodec/codec/ccodec_tiffmodule.h"
+
+class CCodec_ProgressiveDecoder;
-#ifdef PDF_ENABLE_XFA
class CFX_DIBAttribute {
public:
CFX_DIBAttribute();
@@ -61,464 +60,38 @@ class CCodec_ModuleMgr {
public:
CCodec_ModuleMgr();
- ICodec_BasicModule* GetBasicModule() const { return m_pBasicModule.get(); }
- ICodec_FaxModule* GetFaxModule() const { return m_pFaxModule.get(); }
- ICodec_JpegModule* GetJpegModule() const { return m_pJpegModule.get(); }
- ICodec_JpxModule* GetJpxModule() const { return m_pJpxModule.get(); }
- ICodec_Jbig2Module* GetJbig2Module() const { return m_pJbig2Module.get(); }
- ICodec_IccModule* GetIccModule() const { return m_pIccModule.get(); }
- ICodec_FlateModule* GetFlateModule() const { return m_pFlateModule.get(); }
+ CCodec_BasicModule* GetBasicModule() const { return m_pBasicModule.get(); }
+ CCodec_FaxModule* GetFaxModule() const { return m_pFaxModule.get(); }
+ CCodec_JpegModule* GetJpegModule() const { return m_pJpegModule.get(); }
+ CCodec_JpxModule* GetJpxModule() const { return m_pJpxModule.get(); }
+ CCodec_Jbig2Module* GetJbig2Module() const { return m_pJbig2Module.get(); }
+ CCodec_IccModule* GetIccModule() const { return m_pIccModule.get(); }
+ CCodec_FlateModule* GetFlateModule() const { return m_pFlateModule.get(); }
#ifdef PDF_ENABLE_XFA
- ICodec_ProgressiveDecoder* CreateProgressiveDecoder();
- ICodec_PngModule* GetPngModule() const { return m_pPngModule.get(); }
- ICodec_GifModule* GetGifModule() const { return m_pGifModule.get(); }
- ICodec_BmpModule* GetBmpModule() const { return m_pBmpModule.get(); }
- ICodec_TiffModule* GetTiffModule() const { return m_pTiffModule.get(); }
+ CCodec_ProgressiveDecoder* CreateProgressiveDecoder();
+ CCodec_PngModule* GetPngModule() const { return m_pPngModule.get(); }
+ CCodec_GifModule* GetGifModule() const { return m_pGifModule.get(); }
+ CCodec_BmpModule* GetBmpModule() const { return m_pBmpModule.get(); }
+ CCodec_TiffModule* GetTiffModule() const { return m_pTiffModule.get(); }
#endif // PDF_ENABLE_XFA
protected:
- std::unique_ptr<ICodec_BasicModule> m_pBasicModule;
- std::unique_ptr<ICodec_FaxModule> m_pFaxModule;
- std::unique_ptr<ICodec_JpegModule> m_pJpegModule;
- std::unique_ptr<ICodec_JpxModule> m_pJpxModule;
- std::unique_ptr<ICodec_Jbig2Module> m_pJbig2Module;
- std::unique_ptr<ICodec_IccModule> m_pIccModule;
-#ifdef PDF_ENABLE_XFA
- std::unique_ptr<ICodec_PngModule> m_pPngModule;
- std::unique_ptr<ICodec_GifModule> m_pGifModule;
- std::unique_ptr<ICodec_BmpModule> m_pBmpModule;
- std::unique_ptr<ICodec_TiffModule> m_pTiffModule;
-#endif // PDF_ENABLE_XFA
- std::unique_ptr<ICodec_FlateModule> m_pFlateModule;
-};
-class ICodec_BasicModule {
- public:
- virtual ~ICodec_BasicModule() {}
- virtual FX_BOOL RunLengthEncode(const uint8_t* src_buf,
- uint32_t src_size,
- uint8_t*& dest_buf,
- uint32_t& dest_size) = 0;
- virtual FX_BOOL A85Encode(const uint8_t* src_buf,
- uint32_t src_size,
- uint8_t*& dest_buf,
- uint32_t& dest_size) = 0;
- virtual ICodec_ScanlineDecoder* CreateRunLengthDecoder(const uint8_t* src_buf,
- uint32_t src_size,
- int width,
- int height,
- int nComps,
- int bpc) = 0;
-};
-
-class ICodec_ScanlineDecoder {
- public:
- virtual ~ICodec_ScanlineDecoder() {}
-
- virtual uint32_t GetSrcOffset() = 0;
-
- virtual const uint8_t* GetScanline(int line) = 0;
-
- virtual FX_BOOL SkipToScanline(int line, IFX_Pause* pPause) = 0;
-
- virtual int GetWidth() = 0;
-
- virtual int GetHeight() = 0;
-
- virtual int CountComps() = 0;
-
- virtual int GetBPC() = 0;
-};
-
-class ICodec_FlateModule {
- public:
- virtual ~ICodec_FlateModule() {}
- virtual ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf,
- uint32_t src_size,
- int width,
- int height,
- int nComps,
- int bpc,
- int predictor,
- int Colors,
- int BitsPerComponent,
- int Columns) = 0;
- virtual uint32_t FlateOrLZWDecode(FX_BOOL bLZW,
- const uint8_t* src_buf,
- uint32_t src_size,
- FX_BOOL bEarlyChange,
- int predictor,
- int Colors,
- int BitsPerComponent,
- int Columns,
- uint32_t estimated_size,
- uint8_t*& dest_buf,
- uint32_t& dest_size) = 0;
- virtual FX_BOOL Encode(const uint8_t* src_buf,
- uint32_t src_size,
- int predictor,
- int Colors,
- int BitsPerComponent,
- int Columns,
- uint8_t*& dest_buf,
- uint32_t& dest_size) = 0;
- virtual FX_BOOL Encode(const uint8_t* src_buf,
- uint32_t src_size,
- uint8_t*& dest_buf,
- uint32_t& dest_size) = 0;
-};
-class ICodec_FaxModule {
- public:
- virtual ~ICodec_FaxModule() {}
-
- virtual ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf,
- uint32_t src_size,
- int width,
- int height,
- int K,
- FX_BOOL EndOfLine,
- FX_BOOL EncodedByteAlign,
- FX_BOOL BlackIs1,
- int Columns,
- int Rows) = 0;
-
- virtual FX_BOOL Encode(const uint8_t* src_buf,
- int width,
- int height,
- int pitch,
- uint8_t*& dest_buf,
- uint32_t& dest_size) = 0;
-};
-class ICodec_JpegModule {
- public:
- virtual ~ICodec_JpegModule() {}
-
- virtual ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf,
- uint32_t src_size,
- int width,
- int height,
- int nComps,
- FX_BOOL ColorTransform) = 0;
-
- virtual FX_BOOL LoadInfo(const uint8_t* src_buf,
- uint32_t src_size,
- int& width,
- int& height,
- int& num_components,
- int& bits_per_components,
- FX_BOOL& color_transform,
- uint8_t** icc_buf_ptr = NULL,
- uint32_t* icc_length = NULL) = 0;
-
- virtual FX_BOOL Encode(const class CFX_DIBSource* pSource,
- uint8_t*& dest_buf,
- FX_STRSIZE& dest_size,
- int quality = 75,
- const uint8_t* icc_buf = NULL,
- uint32_t icc_length = 0) = 0;
-
- virtual void* Start() = 0;
-
- virtual void Finish(void* pContext) = 0;
-
- virtual void Input(void* pContext,
- const uint8_t* src_buf,
- uint32_t src_size) = 0;
+ std::unique_ptr<CCodec_BasicModule> m_pBasicModule;
+ std::unique_ptr<CCodec_FaxModule> m_pFaxModule;
+ std::unique_ptr<CCodec_JpegModule> m_pJpegModule;
+ std::unique_ptr<CCodec_JpxModule> m_pJpxModule;
+ std::unique_ptr<CCodec_Jbig2Module> m_pJbig2Module;
+ std::unique_ptr<CCodec_IccModule> m_pIccModule;
#ifdef PDF_ENABLE_XFA
- virtual int ReadHeader(void* pContext,
- int* width,
- int* height,
- int* nComps,
- CFX_DIBAttribute* pAttribute) = 0;
-#else // PDF_ENABLE_XFA
- virtual int ReadHeader(void* pContext,
- int* width,
- int* height,
- int* nComps) = 0;
+ std::unique_ptr<CCodec_PngModule> m_pPngModule;
+ std::unique_ptr<CCodec_GifModule> m_pGifModule;
+ std::unique_ptr<CCodec_BmpModule> m_pBmpModule;
+ std::unique_ptr<CCodec_TiffModule> m_pTiffModule;
#endif // PDF_ENABLE_XFA
- virtual int StartScanline(void* pContext, int down_scale) = 0;
-
- virtual FX_BOOL ReadScanline(void* pContext, uint8_t* dest_buf) = 0;
-
- virtual uint32_t GetAvailInput(void* pContext,
- uint8_t** avail_buf_ptr = NULL) = 0;
-};
-
-class ICodec_JpxModule {
- public:
- virtual ~ICodec_JpxModule() {}
-
- virtual CJPX_Decoder* CreateDecoder(const uint8_t* src_buf,
- uint32_t src_size,
- CPDF_ColorSpace* cs) = 0;
-
- virtual void GetImageInfo(CJPX_Decoder* pDecoder,
- uint32_t* width,
- uint32_t* height,
- uint32_t* components) = 0;
-
- virtual bool Decode(CJPX_Decoder* pDecoder,
- uint8_t* dest_data,
- int pitch,
- const std::vector<uint8_t>& offsets) = 0;
-
- virtual void DestroyDecoder(CJPX_Decoder* pDecoder) = 0;
-};
-#ifdef PDF_ENABLE_XFA
-class ICodec_PngModule {
- public:
- virtual ~ICodec_PngModule() {}
-
- virtual void* Start(void* pModule) = 0;
-
- virtual void Finish(void* pContext) = 0;
-
- virtual FX_BOOL Input(void* pContext,
- const uint8_t* src_buf,
- uint32_t src_size,
- CFX_DIBAttribute* pAttribute) = 0;
-
- FX_BOOL (*ReadHeaderCallback)(void* pModule,
- int width,
- int height,
- int bpc,
- int pass,
- int* color_type,
- double* gamma);
-
- FX_BOOL (*AskScanlineBufCallback)(void* pModule, int line, uint8_t*& src_buf);
-
- void (*FillScanlineBufCompletedCallback)(void* pModule, int pass, int line);
-};
-class ICodec_GifModule {
- public:
- virtual ~ICodec_GifModule() {}
-
- virtual void* Start(void* pModule) = 0;
-
- virtual void Finish(void* pContext) = 0;
-
- virtual uint32_t GetAvailInput(void* pContext,
- uint8_t** avail_buf_ptr = NULL) = 0;
-
- virtual void Input(void* pContext,
- const uint8_t* src_buf,
- uint32_t src_size) = 0;
-
- virtual int32_t ReadHeader(void* pContext,
- int* width,
- int* height,
- int* pal_num,
- void** pal_pp,
- int* bg_index,
- CFX_DIBAttribute* pAttribute) = 0;
-
- virtual int32_t LoadFrameInfo(void* pContext, int* frame_num) = 0;
-
- void (*RecordCurrentPositionCallback)(void* pModule, uint32_t& cur_pos);
-
- uint8_t* (*AskLocalPaletteBufCallback)(void* pModule,
- int32_t frame_num,
- int32_t pal_size);
-
- virtual int32_t LoadFrame(void* pContext,
- int frame_num,
- CFX_DIBAttribute* pAttribute) = 0;
-
- FX_BOOL (*InputRecordPositionBufCallback)(void* pModule,
- uint32_t rcd_pos,
- const FX_RECT& img_rc,
- int32_t pal_num,
- void* pal_ptr,
- int32_t delay_time,
- FX_BOOL user_input,
- int32_t trans_index,
- int32_t disposal_method,
- FX_BOOL interlace);
-
- void (*ReadScanlineCallback)(void* pModule,
- int32_t row_num,
- uint8_t* row_buf);
-};
-class ICodec_BmpModule {
- public:
- virtual ~ICodec_BmpModule() {}
-
- virtual void* Start(void* pModule) = 0;
-
- virtual void Finish(void* pContext) = 0;
-
- virtual uint32_t GetAvailInput(void* pContext,
- uint8_t** avail_buf_ptr = NULL) = 0;
-
- virtual void Input(void* pContext,
- const uint8_t* src_buf,
- uint32_t src_size) = 0;
-
- virtual int32_t ReadHeader(void* pContext,
- int32_t* width,
- int32_t* height,
- FX_BOOL* tb_flag,
- int32_t* components,
- int* pal_num,
- uint32_t** pal_pp,
- CFX_DIBAttribute* pAttribute) = 0;
-
- virtual int32_t LoadImage(void* pContext) = 0;
-
- FX_BOOL (*InputImagePositionBufCallback)(void* pModule, uint32_t rcd_pos);
-
- void (*ReadScanlineCallback)(void* pModule,
- int32_t row_num,
- uint8_t* row_buf);
-};
-class ICodec_TiffModule {
- public:
- virtual ~ICodec_TiffModule() {}
-
- virtual void* CreateDecoder(IFX_FileRead* file_ptr) = 0;
-
- virtual void GetFrames(void* ctx, int32_t& frames) = 0;
-
- virtual FX_BOOL LoadFrameInfo(void* ctx,
- int32_t frame,
- uint32_t& width,
- uint32_t& height,
- uint32_t& comps,
- uint32_t& bpc,
- CFX_DIBAttribute* pAttribute) = 0;
-
- virtual FX_BOOL Decode(void* ctx, class CFX_DIBitmap* pDIBitmap) = 0;
-
- virtual void DestroyDecoder(void* ctx) = 0;
-};
-#endif
-
-class ICodec_Jbig2Module {
- public:
- virtual ~ICodec_Jbig2Module() {}
-
- virtual void* CreateJbig2Context() = 0;
-
- virtual FXCODEC_STATUS StartDecode(void* pJbig2Context,
- CFX_PrivateData* pPrivateData,
- uint32_t width,
- uint32_t height,
- CPDF_StreamAcc* src_stream,
- CPDF_StreamAcc* global_stream,
- uint8_t* dest_buf,
- uint32_t dest_pitch,
- IFX_Pause* pPause) = 0;
-
- virtual FXCODEC_STATUS ContinueDecode(void* pJbig2Content,
- IFX_Pause* pPause) = 0;
- virtual void DestroyJbig2Context(void* pJbig2Content) = 0;
-};
-#ifdef PDF_ENABLE_XFA
-class ICodec_ProgressiveDecoder {
- public:
- virtual ~ICodec_ProgressiveDecoder() {}
-
- virtual FXCODEC_STATUS LoadImageInfo(IFX_FileRead* pFile,
- FXCODEC_IMAGE_TYPE imageType,
- CFX_DIBAttribute* pAttribute) = 0;
-
- virtual FXCODEC_IMAGE_TYPE GetType() const = 0;
- virtual int32_t GetWidth() const = 0;
- virtual int32_t GetHeight() const = 0;
- virtual int32_t GetNumComponents() const = 0;
- virtual int32_t GetBPC() const = 0;
-
- virtual void SetClipBox(FX_RECT* clip) = 0;
-
- virtual FXCODEC_STATUS GetFrames(int32_t& frames,
- IFX_Pause* pPause = NULL) = 0;
-
- virtual FXCODEC_STATUS StartDecode(class CFX_DIBitmap* pDIBitmap,
- int32_t start_x,
- int32_t start_y,
- int32_t size_x,
- int32_t size_y,
- int32_t frames = 0,
- FX_BOOL bInterpol = TRUE) = 0;
-
- virtual FXCODEC_STATUS ContinueDecode(IFX_Pause* pPause = NULL) = 0;
-};
-#endif // PDF_ENABLE_XFA
-
-class ICodec_IccModule {
- public:
- enum IccCS {
- IccCS_Unknown = 0,
- IccCS_XYZ,
- IccCS_Lab,
- IccCS_Luv,
- IccCS_YCbCr,
- IccCS_Yxy,
- IccCS_Hsv,
- IccCS_Hls,
- IccCS_Gray,
- IccCS_Rgb,
- IccCS_Cmyk,
- IccCS_Cmy
- };
-
- struct IccParam {
- uint32_t Version;
- IccCS ColorSpace;
- uint32_t dwProfileType;
- uint32_t dwFormat;
- uint8_t* pProfileData;
- uint32_t dwProfileSize;
- double Gamma;
- };
-
- virtual ~ICodec_IccModule() {}
-
- virtual IccCS GetProfileCS(const uint8_t* pProfileData,
- unsigned int dwProfileSize) = 0;
-
- virtual IccCS GetProfileCS(IFX_FileRead* pFile) = 0;
-
- virtual void* CreateTransform(
- ICodec_IccModule::IccParam* pInputParam,
- ICodec_IccModule::IccParam* pOutputParam,
- ICodec_IccModule::IccParam* pProofParam = NULL,
- uint32_t dwIntent = Icc_INTENT_PERCEPTUAL,
- uint32_t dwFlag = Icc_FLAGS_DEFAULT,
- uint32_t dwPrfIntent = Icc_INTENT_ABSOLUTE_COLORIMETRIC,
- uint32_t dwPrfFlag = Icc_FLAGS_SOFTPROOFING) = 0;
-
- virtual void* CreateTransform_sRGB(
- const uint8_t* pProfileData,
- uint32_t dwProfileSize,
- uint32_t& nComponents,
- int32_t intent = 0,
- uint32_t dwSrcFormat = Icc_FORMAT_DEFAULT) = 0;
-
- virtual void* CreateTransform_CMYK(
- const uint8_t* pSrcProfileData,
- uint32_t dwSrcProfileSize,
- uint32_t& nSrcComponents,
- const uint8_t* pDstProfileData,
- uint32_t dwDstProfileSize,
- int32_t intent = 0,
- uint32_t dwSrcFormat = Icc_FORMAT_DEFAULT,
- uint32_t dwDstFormat = Icc_FORMAT_DEFAULT) = 0;
-
- virtual void DestroyTransform(void* pTransform) = 0;
-
- virtual void Translate(void* pTransform,
- FX_FLOAT* pSrcValues,
- FX_FLOAT* pDestValues) = 0;
-
- virtual void TranslateScanline(void* pTransform,
- uint8_t* pDest,
- const uint8_t* pSrc,
- int pixels) = 0;
- virtual void SetComponents(uint32_t nComponents) = 0;
+ std::unique_ptr<CCodec_FlateModule> m_pFlateModule;
};
void ReverseRGB(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels);