From 86e5474dc4ff7fe0d0850f26f7320e1e57f3fd21 Mon Sep 17 00:00:00 2001 From: dsinclair Date: Wed, 6 Apr 2016 12:30:31 -0700 Subject: Move include/fxcodec to fxcodec/include Review URL: https://codereview.chromium.org/1864153002 --- core/fxcodec/codec/codec_int.h | 2 +- core/fxcodec/codec/fx_codec.cpp | 2 +- core/fxcodec/codec/fx_codec_bmp.cpp | 2 +- core/fxcodec/codec/fx_codec_fax.cpp | 2 +- core/fxcodec/codec/fx_codec_flate.cpp | 4 +- core/fxcodec/codec/fx_codec_gif.cpp | 2 +- core/fxcodec/codec/fx_codec_icc.cpp | 2 +- core/fxcodec/codec/fx_codec_jbig.cpp | 2 +- core/fxcodec/codec/fx_codec_jpeg.cpp | 2 +- core/fxcodec/codec/fx_codec_jpx_opj.cpp | 2 +- core/fxcodec/codec/fx_codec_png.cpp | 2 +- core/fxcodec/codec/fx_codec_progress.cpp | 2 +- core/fxcodec/codec/fx_codec_progress.h | 2 +- core/fxcodec/codec/fx_codec_tiff.cpp | 2 +- core/fxcodec/include/DEPS | 3 + core/fxcodec/include/fx_codec.h | 560 +++++++++++++++++++++++++++++++ core/fxcodec/include/fx_codec_def.h | 92 +++++ core/fxcodec/include/fx_codec_flate.h | 33 ++ core/fxcodec/jbig2/JBig2_Context.h | 2 +- core/fxcodec/jbig2/JBig2_GrdProc.cpp | 2 +- core/fxcodec/jbig2/JBig2_GrdProc.h | 2 +- 21 files changed, 706 insertions(+), 18 deletions(-) create mode 100644 core/fxcodec/include/DEPS create mode 100644 core/fxcodec/include/fx_codec.h create mode 100644 core/fxcodec/include/fx_codec_def.h create mode 100644 core/fxcodec/include/fx_codec_flate.h (limited to 'core/fxcodec') diff --git a/core/fxcodec/codec/codec_int.h b/core/fxcodec/codec/codec_int.h index 7f0aaef379..ed9bcac349 100644 --- a/core/fxcodec/codec/codec_int.h +++ b/core/fxcodec/codec/codec_int.h @@ -14,8 +14,8 @@ #include #include +#include "core/fxcodec/include/fx_codec.h" #include "core/fxcodec/jbig2/JBig2_Context.h" -#include "core/include/fxcodec/fx_codec.h" #include "third_party/libopenjpeg20/openjpeg.h" // For OPJ_SIZE_T. class CFX_IccProfileCache; diff --git a/core/fxcodec/codec/fx_codec.cpp b/core/fxcodec/codec/fx_codec.cpp index ef9414dbe5..77dd363c9d 100644 --- a/core/fxcodec/codec/fx_codec.cpp +++ b/core/fxcodec/codec/fx_codec.cpp @@ -4,7 +4,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "core/include/fxcodec/fx_codec.h" +#include "core/fxcodec/include/fx_codec.h" #include #include diff --git a/core/fxcodec/codec/fx_codec_bmp.cpp b/core/fxcodec/codec/fx_codec_bmp.cpp index 2dc537161b..0fed151217 100644 --- a/core/fxcodec/codec/fx_codec_bmp.cpp +++ b/core/fxcodec/codec/fx_codec_bmp.cpp @@ -5,9 +5,9 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "core/fxcodec/codec/codec_int.h" +#include "core/fxcodec/include/fx_codec.h" #include "core/fxcodec/lbmp/fx_bmp.h" #include "core/fxge/include/fx_dib.h" -#include "core/include/fxcodec/fx_codec.h" struct FXBMP_Context { bmp_decompress_struct_p bmp_ptr; void* parent_ptr; diff --git a/core/fxcodec/codec/fx_codec_fax.cpp b/core/fxcodec/codec/fx_codec_fax.cpp index 6b90b15e51..898b0d0251 100644 --- a/core/fxcodec/codec/fx_codec_fax.cpp +++ b/core/fxcodec/codec/fx_codec_fax.cpp @@ -5,7 +5,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "core/fxcodec/codec/codec_int.h" -#include "core/include/fxcodec/fx_codec.h" +#include "core/fxcodec/include/fx_codec.h" namespace { diff --git a/core/fxcodec/codec/fx_codec_flate.cpp b/core/fxcodec/codec/fx_codec_flate.cpp index 2350eb1a88..16cde3e5ea 100644 --- a/core/fxcodec/codec/fx_codec_flate.cpp +++ b/core/fxcodec/codec/fx_codec_flate.cpp @@ -9,9 +9,9 @@ #include #include +#include "core/fxcodec/include/fx_codec.h" +#include "core/fxcodec/include/fx_codec_flate.h" #include "core/fxcrt/include/fx_ext.h" -#include "core/include/fxcodec/fx_codec.h" -#include "core/include/fxcodec/fx_codec_flate.h" #include "third_party/zlib_v128/zlib.h" extern "C" { diff --git a/core/fxcodec/codec/fx_codec_gif.cpp b/core/fxcodec/codec/fx_codec_gif.cpp index e1806a4001..5fc0d094d8 100644 --- a/core/fxcodec/codec/fx_codec_gif.cpp +++ b/core/fxcodec/codec/fx_codec_gif.cpp @@ -5,9 +5,9 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "core/fxcodec/codec/codec_int.h" +#include "core/fxcodec/include/fx_codec.h" #include "core/fxcodec/lgif/fx_gif.h" #include "core/fxge/include/fx_dib.h" -#include "core/include/fxcodec/fx_codec.h" struct FXGIF_Context { gif_decompress_struct_p gif_ptr; void* parent_ptr; diff --git a/core/fxcodec/codec/fx_codec_icc.cpp b/core/fxcodec/codec/fx_codec_icc.cpp index 13280d7f49..74801e57a0 100644 --- a/core/fxcodec/codec/fx_codec_icc.cpp +++ b/core/fxcodec/codec/fx_codec_icc.cpp @@ -5,7 +5,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "core/fxcodec/codec/codec_int.h" -#include "core/include/fxcodec/fx_codec.h" +#include "core/fxcodec/include/fx_codec.h" #include "third_party/lcms2-2.6/include/lcms2.h" const uint32_t N_COMPONENT_LAB = 3; diff --git a/core/fxcodec/codec/fx_codec_jbig.cpp b/core/fxcodec/codec/fx_codec_jbig.cpp index ddcec6c6bb..96f6836190 100644 --- a/core/fxcodec/codec/fx_codec_jbig.cpp +++ b/core/fxcodec/codec/fx_codec_jbig.cpp @@ -7,7 +7,7 @@ #include #include "core/fxcodec/codec/codec_int.h" -#include "core/include/fxcodec/fx_codec.h" +#include "core/fxcodec/include/fx_codec.h" // Holds per-document JBig2 related data. class JBig2DocumentContext : public CFX_DestructObject { diff --git a/core/fxcodec/codec/fx_codec_jpeg.cpp b/core/fxcodec/codec/fx_codec_jpeg.cpp index 33ebf1ba20..9a2a0ee4a3 100644 --- a/core/fxcodec/codec/fx_codec_jpeg.cpp +++ b/core/fxcodec/codec/fx_codec_jpeg.cpp @@ -7,9 +7,9 @@ #include #include "core/fxcodec/codec/codec_int.h" +#include "core/fxcodec/include/fx_codec.h" #include "core/fxcrt/include/fx_safe_types.h" #include "core/fxge/include/fx_dib.h" -#include "core/include/fxcodec/fx_codec.h" extern "C" { #undef FAR diff --git a/core/fxcodec/codec/fx_codec_jpx_opj.cpp b/core/fxcodec/codec/fx_codec_jpx_opj.cpp index 18d2c8d827..85b0b767ac 100644 --- a/core/fxcodec/codec/fx_codec_jpx_opj.cpp +++ b/core/fxcodec/codec/fx_codec_jpx_opj.cpp @@ -10,8 +10,8 @@ #include "core/fpdfapi/fpdf_page/include/cpdf_colorspace.h" #include "core/fxcodec/codec/codec_int.h" +#include "core/fxcodec/include/fx_codec.h" #include "core/fxcrt/include/fx_safe_types.h" -#include "core/include/fxcodec/fx_codec.h" #include "third_party/lcms2-2.6/include/lcms2.h" #include "third_party/libopenjpeg20/openjpeg.h" diff --git a/core/fxcodec/codec/fx_codec_png.cpp b/core/fxcodec/codec/fx_codec_png.cpp index e625737e34..fd56c93393 100644 --- a/core/fxcodec/codec/fx_codec_png.cpp +++ b/core/fxcodec/codec/fx_codec_png.cpp @@ -7,8 +7,8 @@ #include #include "core/fxcodec/codec/codec_int.h" +#include "core/fxcodec/include/fx_codec.h" #include "core/fxge/include/fx_dib.h" -#include "core/include/fxcodec/fx_codec.h" extern "C" { #undef FAR diff --git a/core/fxcodec/codec/fx_codec_progress.cpp b/core/fxcodec/codec/fx_codec_progress.cpp index ebd69ae1e3..89e4b25dbb 100644 --- a/core/fxcodec/codec/fx_codec_progress.cpp +++ b/core/fxcodec/codec/fx_codec_progress.cpp @@ -6,8 +6,8 @@ #include "core/fxcodec/codec/fx_codec_progress.h" +#include "core/fxcodec/include/fx_codec.h" #include "core/fxge/include/fx_dib.h" -#include "core/include/fxcodec/fx_codec.h" void CFXCODEC_WeightTable::Calc(int dest_len, int dest_min, diff --git a/core/fxcodec/codec/fx_codec_progress.h b/core/fxcodec/codec/fx_codec_progress.h index 2b2ba28e16..e8e885b3b5 100644 --- a/core/fxcodec/codec/fx_codec_progress.h +++ b/core/fxcodec/codec/fx_codec_progress.h @@ -7,10 +7,10 @@ #ifndef CORE_FXCODEC_CODEC_FX_CODEC_PROGRESS_H_ #define CORE_FXCODEC_CODEC_FX_CODEC_PROGRESS_H_ +#include "core/fxcodec/include/fx_codec.h" #include "core/fxcrt/include/fx_memory.h" #include "core/fxcrt/include/fx_system.h" #include "core/fxge/include/fx_dib.h" -#include "core/include/fxcodec/fx_codec.h" #define FXCODEC_BLOCK_SIZE 4096 #define FXCODEC_PNG_GAMMA 2.2 diff --git a/core/fxcodec/codec/fx_codec_tiff.cpp b/core/fxcodec/codec/fx_codec_tiff.cpp index d445769714..f0f2ab2e96 100644 --- a/core/fxcodec/codec/fx_codec_tiff.cpp +++ b/core/fxcodec/codec/fx_codec_tiff.cpp @@ -5,8 +5,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "core/fxcodec/codec/codec_int.h" +#include "core/fxcodec/include/fx_codec.h" #include "core/fxge/include/fx_dib.h" -#include "core/include/fxcodec/fx_codec.h" extern "C" { #include "third_party/libtiff/tiffiop.h" diff --git a/core/fxcodec/include/DEPS b/core/fxcodec/include/DEPS new file mode 100644 index 0000000000..548eb61a3b --- /dev/null +++ b/core/fxcodec/include/DEPS @@ -0,0 +1,3 @@ +include_rules = [ + '+third_party/zlib_v128/zlib.h', +] diff --git a/core/fxcodec/include/fx_codec.h b/core/fxcodec/include/fx_codec.h new file mode 100644 index 0000000000..1c3922ee4f --- /dev/null +++ b/core/fxcodec/include/fx_codec.h @@ -0,0 +1,560 @@ +// Copyright 2014 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_INCLUDE_FX_CODEC_H_ +#define CORE_FXCODEC_INCLUDE_FX_CODEC_H_ + +#include +#include +#include + +#include "core/fxcrt/include/fx_basic.h" +#include "core/fxcrt/include/fx_coordinates.h" // For FX_RECT. +#include "core/fxcodec/include/fx_codec_def.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_Jbig2Encoder; +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 + +#ifdef PDF_ENABLE_XFA +class CFX_DIBAttribute { + public: + CFX_DIBAttribute(); + ~CFX_DIBAttribute(); + + int32_t m_nXDPI; + int32_t m_nYDPI; + FX_FLOAT m_fAspectRatio; + uint16_t m_wDPIUnit; + CFX_ByteString m_strAuthor; + uint8_t m_strTime[20]; + int32_t m_nGifLeft; + int32_t m_nGifTop; + uint32_t* m_pGifLocalPalette; + uint32_t m_nGifLocalPalNum; + int32_t m_nBmpCompressType; + std::map m_Exif; +}; +#endif // PDF_ENABLE_XFA + +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(); } + +#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(); } +#endif // PDF_ENABLE_XFA + + protected: + std::unique_ptr m_pBasicModule; + std::unique_ptr m_pFaxModule; + std::unique_ptr m_pJpegModule; + std::unique_ptr m_pJpxModule; + std::unique_ptr m_pJbig2Module; + std::unique_ptr m_pIccModule; +#ifdef PDF_ENABLE_XFA + std::unique_ptr m_pPngModule; + std::unique_ptr m_pGifModule; + std::unique_ptr m_pBmpModule; + std::unique_ptr m_pTiffModule; +#endif // PDF_ENABLE_XFA + std::unique_ptr 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; + +#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; +#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& 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_Jbig2Encoder { + public: + virtual ~ICodec_Jbig2Encoder() {} +}; + +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; +}; + +void ReverseRGB(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels); +void sRGB_to_AdobeCMYK(FX_FLOAT R, + FX_FLOAT G, + FX_FLOAT B, + FX_FLOAT& c, + FX_FLOAT& m, + FX_FLOAT& y, + FX_FLOAT& k); +void AdobeCMYK_to_sRGB(FX_FLOAT c, + FX_FLOAT m, + FX_FLOAT y, + FX_FLOAT k, + FX_FLOAT& R, + FX_FLOAT& G, + FX_FLOAT& B); +void AdobeCMYK_to_sRGB1(uint8_t c, + uint8_t m, + uint8_t y, + uint8_t k, + uint8_t& R, + uint8_t& G, + uint8_t& B); +FX_BOOL MD5ComputeID(const void* buf, uint32_t dwSize, uint8_t ID[16]); +void FaxG4Decode(const uint8_t* src_buf, + uint32_t src_size, + int* pbitpos, + uint8_t* dest_buf, + int width, + int height, + int pitch); + +#endif // CORE_FXCODEC_INCLUDE_FX_CODEC_H_ diff --git a/core/fxcodec/include/fx_codec_def.h b/core/fxcodec/include/fx_codec_def.h new file mode 100644 index 0000000000..fb1b5bcdac --- /dev/null +++ b/core/fxcodec/include/fx_codec_def.h @@ -0,0 +1,92 @@ +// Copyright 2014 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_INCLUDE_FX_CODEC_DEF_H_ +#define CORE_FXCODEC_INCLUDE_FX_CODEC_DEF_H_ + +enum FXCODEC_STATUS { + FXCODEC_STATUS_ERROR = -1, + FXCODEC_STATUS_FRAME_READY, + FXCODEC_STATUS_FRAME_TOBECONTINUE, + FXCODEC_STATUS_DECODE_READY, + FXCODEC_STATUS_DECODE_TOBECONTINUE, + FXCODEC_STATUS_DECODE_FINISH, +#ifdef PDF_ENABLE_XFA + FXCODEC_STATUS_ERR_MEMORY, +#endif // PDF_ENABLE_XFA + FXCODEC_STATUS_ERR_READ, + FXCODEC_STATUS_ERR_FLUSH, + FXCODEC_STATUS_ERR_FORMAT, + FXCODEC_STATUS_ERR_PARAMS +}; +#define JP2_SPACE_INVALID -1 +#define JPX_SPACE_INVALID -1 +#define JP2_SPACE_bilevel1 0 +#define JP2_SPACE_YCbCr1 1 +#define JP2_SPACE_YCbCr2 3 +#define JP2_SPACE_YCbCr3 4 +#define JP2_SPACE_PhotoYCC 9 +#define JP2_SPACE_CMY 11 +#define JP2_SPACE_CMYK 12 +#define JP2_SPACE_YCCK 13 +#define JP2_SPACE_CIELab 14 +#define JP2_SPACE_bilevel2 15 +#define JP2_SPACE_sRGB 16 +#define JP2_SPACE_sLUM 17 +#define JP2_SPACE_sYCC 18 +#define JP2_SPACE_CIEJab 19 +#define JP2_SPACE_esRGB 20 +#define JP2_SPACE_ROMMRGB 21 +#define JP2_SPACE_YPbPr60 22 +#define JP2_SPACE_YPbPr50 23 +#define JP2_SPACE_esYCC 24 +#define JP2_SPACE_iccLUM 100 +#define JP2_SPACE_iccRGB 101 +#define Icc_INTENT_PERCEPTUAL 0 +#define Icc_INTENT_RELATIVE_COLORIMETRIC 1 +#define Icc_INTENT_SATURATION 2 +#define Icc_INTENT_ABSOLUTE_COLORIMETRIC 3 +#define Icc_FORMAT_DEFAULT 0 +#define Icc_FORMAT_SWAP (1 << 10) +#define Icc_FLAGS_DEFAULT 0x0000 +#define Icc_FLAGS_BLACKPOINTCOMPENSATION 0x2000 +#define Icc_FLAGS_NOWHITEONWHITEFIXUP 0x0004 +#define Icc_FLAGS_HIGHRESPRECALC 0x0400 +#define Icc_FLAGS_LOWRESPRECALC 0x0800 +#define Icc_FLAGS_GAMUTCHECK 0x1000 +#define Icc_FLAGS_SOFTPROOFING 0x4000 +#define Icc_PARAMTYPE_NONE 0 +#define Icc_PARAMTYPE_BUFFER 1 +#define Icc_PARAMTYPE_PARAM 2 +#ifdef PDF_ENABLE_XFA +enum FXCODEC_IMAGE_TYPE { + FXCODEC_IMAGE_UNKNOWN = 0, + FXCODEC_IMAGE_BMP, + FXCODEC_IMAGE_JPG, + FXCODEC_IMAGE_PNG, + FXCODEC_IMAGE_GIF, + FXCODEC_IMAGE_TIF, + FXCODEC_IMAGE_MAX +}; +enum FXCODEC_RESUNIT { + FXCODEC_RESUNIT_NONE = 0, + FXCODEC_RESUNIT_INCH, + FXCODEC_RESUNIT_CENTIMETER, + FXCODEC_RESUNIT_METER +}; +#endif // PDF_ENABLE_XFA +#define EXIFTAG_USHORT_RESUNIT 296 +#define EXIFTAG_FLOAT_DPIX 282 +#define EXIFTAG_FLOAT_DPIY 283 +#define EXIFTAG_USHORT_ORIENTATION 274 +#define EXIFTAG_STRING_MANUFACTURER 271 +#define EXIFTAG_STRING_MODULE 272 +#define EXIFTAG_STRING_SOFTWARE 305 +#define EXIFTAG_STRING_IAMGEDESCRIPTION 270 +#define EXIFTAG_STRING_DATETIME 306 +#define EXIFTAG_STRING_COPYRIGHT 33432 + +#endif // CORE_FXCODEC_INCLUDE_FX_CODEC_DEF_H_ diff --git a/core/fxcodec/include/fx_codec_flate.h b/core/fxcodec/include/fx_codec_flate.h new file mode 100644 index 0000000000..83e9281b48 --- /dev/null +++ b/core/fxcodec/include/fx_codec_flate.h @@ -0,0 +1,33 @@ +// Copyright 2015 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_INCLUDE_FX_CODEC_FLATE_H_ +#define CORE_FXCODEC_INCLUDE_FX_CODEC_FLATE_H_ + +#include "third_party/zlib_v128/zlib.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// Note: Some of these return Z_* status codes from zlib.h. +void* FPDFAPI_FlateInit(void* (*alloc_func)(void*, unsigned int, unsigned int), + void (*free_func)(void*, void*)); +void FPDFAPI_FlateInput(void* context, + const unsigned char* src_buf, + unsigned int src_size); +int FPDFAPI_FlateOutput(void* context, + unsigned char* dest_buf, + unsigned int dest_size); +int FPDFAPI_FlateGetAvailIn(void* context); +int FPDFAPI_FlateGetAvailOut(void* context); +void FPDFAPI_FlateEnd(void* context); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // CORE_FXCODEC_INCLUDE_FX_CODEC_FLATE_H_ diff --git a/core/fxcodec/jbig2/JBig2_Context.h b/core/fxcodec/jbig2/JBig2_Context.h index 4a32e61489..fa68588a4a 100644 --- a/core/fxcodec/jbig2/JBig2_Context.h +++ b/core/fxcodec/jbig2/JBig2_Context.h @@ -12,10 +12,10 @@ #include #include "core/fpdfapi/fpdf_parser/include/cpdf_object.h" +#include "core/fxcodec/include/fx_codec_def.h" #include "core/fxcodec/jbig2/JBig2_List.h" #include "core/fxcodec/jbig2/JBig2_Page.h" #include "core/fxcodec/jbig2/JBig2_Segment.h" -#include "core/include/fxcodec/fx_codec_def.h" class CJBig2_ArithDecoder; class CJBig2_GRDProc; diff --git a/core/fxcodec/jbig2/JBig2_GrdProc.cpp b/core/fxcodec/jbig2/JBig2_GrdProc.cpp index 5f3b47f659..2391fb2b07 100644 --- a/core/fxcodec/jbig2/JBig2_GrdProc.cpp +++ b/core/fxcodec/jbig2/JBig2_GrdProc.cpp @@ -8,10 +8,10 @@ #include +#include "core/fxcodec/include/fx_codec.h" #include "core/fxcodec/jbig2/JBig2_ArithDecoder.h" #include "core/fxcodec/jbig2/JBig2_BitStream.h" #include "core/fxcodec/jbig2/JBig2_Image.h" -#include "core/include/fxcodec/fx_codec.h" CJBig2_GRDProc::CJBig2_GRDProc() : m_loopIndex(0), diff --git a/core/fxcodec/jbig2/JBig2_GrdProc.h b/core/fxcodec/jbig2/JBig2_GrdProc.h index f6a5448769..b24e2f36fa 100644 --- a/core/fxcodec/jbig2/JBig2_GrdProc.h +++ b/core/fxcodec/jbig2/JBig2_GrdProc.h @@ -7,9 +7,9 @@ #ifndef CORE_FXCODEC_JBIG2_JBIG2_GRDPROC_H_ #define CORE_FXCODEC_JBIG2_JBIG2_GRDPROC_H_ +#include "core/fxcodec/include/fx_codec_def.h" #include "core/fxcrt/include/fx_coordinates.h" #include "core/fxcrt/include/fx_system.h" -#include "core/include/fxcodec/fx_codec_def.h" class CJBig2_ArithDecoder; class CJBig2_BitStream; -- cgit v1.2.3