diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/include/fxcodec/fx_codec.h | 122 | ||||
-rw-r--r-- | core/src/fxcodec/codec/codec_int.h | 64 | ||||
-rw-r--r-- | core/src/fxcodec/codec/fx_codec_progress.cpp | 14 | ||||
-rw-r--r-- | core/src/fxcodec/codec/fx_codec_progress.h | 93 |
4 files changed, 153 insertions, 140 deletions
diff --git a/core/include/fxcodec/fx_codec.h b/core/include/fxcodec/fx_codec.h index 9b5e4f1641..82af1aa560 100644 --- a/core/include/fxcodec/fx_codec.h +++ b/core/include/fxcodec/fx_codec.h @@ -12,35 +12,53 @@ #include "../../../third_party/base/nonstd_unique_ptr.h" #include "../fxcrt/fx_basic.h" -#include "../fxcrt/fx_coordinates.h" #include "fx_codec_def.h" #include "fx_codec_provider.h" +#include "../fxcrt/fx_coordinates.h" // For FX_RECT. + class CFX_DIBSource; class CJPX_Decoder; class CPDF_PrivateData; class CPDF_StreamAcc; -class ICodec_ScanlineDecoder; -class ICodec_ProgressiveDecoder; class ICodec_BasicModule; class ICodec_FaxModule; -class ICodec_JpegModule; -class ICodec_JpxModule; -class ICodec_Jbig2Module; -class ICodec_IccModule; class ICodec_FlateModule; +class ICodec_IccModule; class ICodec_Jbig2Encoder; -class ICodec_PngModule; -class ICodec_GifModule; +class ICodec_Jbig2Module; +class ICodec_JpegModule; +class ICodec_JpxModule; +class ICodec_ScanlineDecoder; + class ICodec_BmpModule; +class ICodec_GifModule; +class ICodec_PngModule; +class ICodec_ProgressiveDecoder; class ICodec_TiffModule; -class CFX_DIBAttribute; -class ICodec_ScanlineDecoder; + +class CFX_DIBAttribute { + public: + CFX_DIBAttribute(); + ~CFX_DIBAttribute(); + + int32_t m_nXDPI; + int32_t m_nYDPI; + FX_FLOAT m_fAspectRatio; + FX_WORD m_wDPIUnit; + CFX_ByteString m_strAuthor; + uint8_t m_strTime[20]; + int32_t m_nGifLeft; + int32_t m_nGifTop; + FX_DWORD* m_pGifLocalPalette; + FX_DWORD m_nGifLocalPalNum; + int32_t m_nBmpCompressType; + std::map<FX_DWORD, void*> m_Exif; +}; class CCodec_ModuleMgr { public: CCodec_ModuleMgr(); - ICodec_ProgressiveDecoder* CreateProgressiveDecoder(); ICodec_Jbig2Encoder* CreateJbig2Encoder(); ICodec_BasicModule* GetBasicModule() const { return m_pBasicModule.get(); } ICodec_FaxModule* GetFaxModule() const { return m_pFaxModule.get(); } @@ -49,6 +67,8 @@ class CCodec_ModuleMgr { ICodec_Jbig2Module* GetJbig2Module() const { return m_pJbig2Module.get(); } ICodec_IccModule* GetIccModule() const { return m_pIccModule.get(); } ICodec_FlateModule* GetFlateModule() const { return m_pFlateModule.get(); } + + 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(); } @@ -62,6 +82,7 @@ class CCodec_ModuleMgr { nonstd::unique_ptr<ICodec_Jbig2Module> m_pJbig2Module; nonstd::unique_ptr<ICodec_IccModule> m_pIccModule; nonstd::unique_ptr<ICodec_FlateModule> m_pFlateModule; + nonstd::unique_ptr<ICodec_PngModule> m_pPngModule; nonstd::unique_ptr<ICodec_GifModule> m_pGifModule; nonstd::unique_ptr<ICodec_BmpModule> m_pBmpModule; @@ -212,7 +233,7 @@ class ICodec_JpegModule { int* width, int* height, int* nComps, - CFX_DIBAttribute* pAttribute = NULL) = 0; + CFX_DIBAttribute* pAttribute) = 0; virtual int StartScanline(void* pContext, int down_scale) = 0; @@ -253,9 +274,15 @@ class ICodec_PngModule { virtual FX_BOOL Input(void* pContext, const uint8_t* src_buf, FX_DWORD src_size, - CFX_DIBAttribute* pAttribute = NULL) = 0; + CFX_DIBAttribute* pAttribute) = 0; - FX_BOOL (*ReadHeaderCallback)(void* pModule, int width, int height, int bpc, int pass, int* color_type, double* gamma); + 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); @@ -282,7 +309,7 @@ class ICodec_GifModule { int* pal_num, void** pal_pp, int* bg_index, - CFX_DIBAttribute* pAttribute = NULL) = 0; + CFX_DIBAttribute* pAttribute) = 0; virtual int32_t LoadFrameInfo(void* pContext, int* frame_num) = 0; @@ -294,12 +321,18 @@ class ICodec_GifModule { virtual int32_t LoadFrame(void* pContext, int frame_num, - CFX_DIBAttribute* pAttribute = NULL) = 0; - - FX_BOOL (*InputRecordPositionBufCallback)(void* pModule, FX_DWORD 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); + CFX_DIBAttribute* pAttribute) = 0; + + FX_BOOL (*InputRecordPositionBufCallback)(void* pModule, + FX_DWORD 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, @@ -327,7 +360,7 @@ class ICodec_BmpModule { int32_t* components, int* pal_num, FX_DWORD** pal_pp, - CFX_DIBAttribute* pAttribute = NULL) = 0; + CFX_DIBAttribute* pAttribute) = 0; virtual int32_t LoadImage(void* pContext) = 0; @@ -351,7 +384,7 @@ class ICodec_TiffModule { FX_DWORD& height, FX_DWORD& comps, FX_DWORD& bpc, - CFX_DIBAttribute* pAttribute = NULL) = 0; + CFX_DIBAttribute* pAttribute) = 0; virtual FX_BOOL Decode(void* ctx, class CFX_DIBitmap* pDIBitmap) = 0; @@ -382,20 +415,15 @@ class ICodec_ProgressiveDecoder { public: virtual ~ICodec_ProgressiveDecoder() {} - virtual FXCODEC_STATUS LoadImageInfo( - IFX_FileRead* pFile, - FXCODEC_IMAGE_TYPE imageType = FXCODEC_IMAGE_UNKNOWN, - CFX_DIBAttribute* pAttribute = NULL) = 0; + virtual FXCODEC_STATUS LoadImageInfo(IFX_FileRead* pFile, + FXCODEC_IMAGE_TYPE imageType, + CFX_DIBAttribute* pAttribute) = 0; - virtual FXCODEC_IMAGE_TYPE GetType() = 0; - - virtual int32_t GetWidth() = 0; - - virtual int32_t GetHeight() = 0; - - virtual int32_t GetNumComponents() = 0; - - virtual int32_t GetBPC() = 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; @@ -503,26 +531,6 @@ void AdobeCMYK_to_sRGB1(uint8_t c, uint8_t& G, uint8_t& B); FX_BOOL MD5ComputeID(const void* buf, FX_DWORD dwSize, uint8_t ID[16]); - -class CFX_DIBAttribute { - public: - CFX_DIBAttribute(); - ~CFX_DIBAttribute(); - - int32_t m_nXDPI; - int32_t m_nYDPI; - FX_FLOAT m_fAspectRatio; - FX_WORD m_wDPIUnit; - CFX_ByteString m_strAuthor; - uint8_t m_strTime[20]; - int32_t m_nGifLeft; - int32_t m_nGifTop; - FX_DWORD* m_pGifLocalPalette; - FX_DWORD m_nGifLocalPalNum; - int32_t m_nBmpCompressType; - std::map<FX_DWORD, void*> m_Exif; -}; - void FaxG4Decode(const uint8_t* src_buf, FX_DWORD src_size, int* pbitpos, diff --git a/core/src/fxcodec/codec/codec_int.h b/core/src/fxcodec/codec/codec_int.h index 36716411b7..fbf44c0564 100644 --- a/core/src/fxcodec/codec/codec_int.h +++ b/core/src/fxcodec/codec/codec_int.h @@ -159,13 +159,13 @@ class CCodec_FlateModule : public ICodec_FlateModule { class CCodec_JpegModule : public ICodec_JpegModule { public: CCodec_JpegModule() : m_pExtProvider(NULL) {} - void SetPovider(IFX_JpegProvider* pJP) { m_pExtProvider = pJP; } + void SetPovider(IFX_JpegProvider* pJP) override { m_pExtProvider = pJP; } ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf, FX_DWORD src_size, int width, int height, int nComps, - FX_BOOL ColorTransform); + FX_BOOL ColorTransform) override; FX_BOOL LoadInfo(const uint8_t* src_buf, FX_DWORD src_size, int& width, @@ -174,24 +174,26 @@ class CCodec_JpegModule : public ICodec_JpegModule { int& bits_per_components, FX_BOOL& color_transform, uint8_t** icc_buf_ptr, - FX_DWORD* icc_length); + FX_DWORD* 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, - FX_DWORD icc_length); - virtual void* Start(); - virtual void Finish(void* pContext); - virtual void Input(void* pContext, const uint8_t* src_buf, FX_DWORD src_size); - virtual int ReadHeader(void* pContext, - int* width, - int* height, - int* nComps, - CFX_DIBAttribute* pAttribute = NULL); - virtual int StartScanline(void* pContext, int down_scale); - virtual FX_BOOL ReadScanline(void* pContext, uint8_t* dest_buf); - virtual FX_DWORD GetAvailInput(void* pContext, uint8_t** avail_buf_ptr); + FX_DWORD icc_length) override; + void* Start() override; + void Finish(void* pContext) override; + void Input(void* pContext, + const uint8_t* src_buf, + FX_DWORD src_size) override; + int ReadHeader(void* pContext, + int* width, + int* height, + int* nComps, + CFX_DIBAttribute* pAttribute) override; + int StartScanline(void* pContext, int down_scale) override; + FX_BOOL ReadScanline(void* pContext, uint8_t* dest_buf) override; + FX_DWORD GetAvailInput(void* pContext, uint8_t** avail_buf_ptr) override; protected: IFX_JpegProvider* m_pExtProvider; @@ -238,20 +240,22 @@ class CCodec_GifModule : public ICodec_GifModule { }; class CCodec_BmpModule : public ICodec_BmpModule { public: - CCodec_BmpModule() { FXSYS_memset(m_szLastError, '\0', 256); } - virtual void* Start(void* pModule); - virtual void Finish(void* pContext); - virtual FX_DWORD GetAvailInput(void* pContext, uint8_t** avail_buf_ptr); - virtual void Input(void* pContext, const uint8_t* src_buf, FX_DWORD src_size); - virtual int32_t ReadHeader(void* pContext, - int32_t* width, - int32_t* height, - FX_BOOL* tb_flag, - int32_t* components, - int32_t* pal_num, - FX_DWORD** pal_pp, - CFX_DIBAttribute* pAttribute); - virtual int32_t LoadImage(void* pContext); + CCodec_BmpModule() { FXSYS_memset(m_szLastError, 0, sizeof(m_szLastError)); } + void* Start(void* pModule) override; + void Finish(void* pContext) override; + FX_DWORD GetAvailInput(void* pContext, uint8_t** avail_buf_ptr) override; + void Input(void* pContext, + const uint8_t* src_buf, + FX_DWORD 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, + FX_DWORD** pal_pp, + CFX_DIBAttribute* pAttribute) override; + int32_t LoadImage(void* pContext) override; protected: FX_CHAR m_szLastError[256]; @@ -342,7 +346,7 @@ class CCodec_TiffModule : public ICodec_TiffModule { FX_DWORD& height, FX_DWORD& comps, FX_DWORD& bpc, - CFX_DIBAttribute* pAttribute = NULL) override; + CFX_DIBAttribute* pAttribute) override; FX_BOOL Decode(void* ctx, class CFX_DIBitmap* pDIBitmap) override; void DestroyDecoder(void* ctx) override; diff --git a/core/src/fxcodec/codec/fx_codec_progress.cpp b/core/src/fxcodec/codec/fx_codec_progress.cpp index 885b751a1b..82bbee99be 100644 --- a/core/src/fxcodec/codec/fx_codec_progress.cpp +++ b/core/src/fxcodec/codec/fx_codec_progress.cpp @@ -641,7 +641,7 @@ FX_BOOL CCodec_ProgressiveDecoder::GifInputRecordPositionBufCallback( }
pCodec->m_SrcPaletteNumber = pal_num;
for (int i = 0; i < pal_num; i++) {
- register FX_DWORD j = i * 3;
+ FX_DWORD j = i * 3;
pCodec->m_pSrcPalette[i] =
ArgbEncode(0xff, pPalette[j], pPalette[j + 1], pPalette[j + 2]);
}
@@ -1215,7 +1215,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( m_SrcComponents = 1;
int32_t readResult = pGifModule->ReadHeader(
m_pGifContext, &m_SrcWidth, &m_SrcHeight, &m_GifPltNumber,
- (void**)&m_pGifPalette, &m_GifBgIndex);
+ (void**)&m_pGifPalette, &m_GifBgIndex, nullptr);
while (readResult == 2) {
FXCODEC_STATUS error_status = FXCODEC_STATUS_ERR_FORMAT;
if (!GifReadMoreData(pGifModule, error_status)) {
@@ -1224,7 +1224,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( }
readResult = pGifModule->ReadHeader(
m_pGifContext, &m_SrcWidth, &m_SrcHeight, &m_GifPltNumber,
- (void**)&m_pGifPalette, &m_GifBgIndex);
+ (void**)&m_pGifPalette, &m_GifBgIndex, nullptr);
}
if (readResult == 1) {
m_SrcBPC = 8;
@@ -2143,7 +2143,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { return m_status = FXCODEC_STATUS_ERR_READ;
}
m_offSet += input_size;
- bResult = pPngModule->Input(m_pPngContext, m_pSrcBuf, input_size);
+ bResult =
+ pPngModule->Input(m_pPngContext, m_pSrcBuf, input_size, nullptr);
if (!bResult) {
m_pDeviceBitmap = NULL;
m_pFile = NULL;
@@ -2157,7 +2158,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { case FXCODEC_IMAGE_GIF: {
ICodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule();
while (TRUE) {
- int32_t readRes = pGifModule->LoadFrame(m_pGifContext, m_FrameCur);
+ int32_t readRes =
+ pGifModule->LoadFrame(m_pGifContext, m_FrameCur, nullptr);
while (readRes == 2) {
FXCODEC_STATUS error_status = FXCODEC_STATUS_DECODE_FINISH;
if (!GifReadMoreData(pGifModule, error_status)) {
@@ -2168,7 +2170,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { if (pPause && pPause->NeedToPauseNow()) {
return m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE;
}
- readRes = pGifModule->LoadFrame(m_pGifContext, m_FrameCur);
+ readRes = pGifModule->LoadFrame(m_pGifContext, m_FrameCur, nullptr);
}
if (readRes == 1) {
m_pDeviceBitmap = NULL;
diff --git a/core/src/fxcodec/codec/fx_codec_progress.h b/core/src/fxcodec/codec/fx_codec_progress.h index 45dc6d7b4e..cee8b39c50 100644 --- a/core/src/fxcodec/codec/fx_codec_progress.h +++ b/core/src/fxcodec/codec/fx_codec_progress.h @@ -86,47 +86,31 @@ enum FXCodec_Format { class CCodec_ProgressiveDecoder : public ICodec_ProgressiveDecoder {
public:
CCodec_ProgressiveDecoder(CCodec_ModuleMgr* pCodecMgr);
- virtual ~CCodec_ProgressiveDecoder();
+ ~CCodec_ProgressiveDecoder() override;
- public:
- virtual FXCODEC_STATUS LoadImageInfo(IFX_FileRead* pFile,
- FXCODEC_IMAGE_TYPE imageType,
- CFX_DIBAttribute* pAttribute);
+ FXCODEC_STATUS LoadImageInfo(IFX_FileRead* pFile,
+ FXCODEC_IMAGE_TYPE imageType,
+ CFX_DIBAttribute* pAttribute) override;
- virtual FXCODEC_IMAGE_TYPE GetType() { return m_imagType; }
- virtual int32_t GetWidth() { return m_SrcWidth; }
- virtual int32_t GetHeight() { return m_SrcHeight; }
- virtual int32_t GetNumComponents() { return m_SrcComponents; }
- virtual int32_t GetBPC() { return m_SrcBPC; }
- virtual void SetClipBox(FX_RECT* clip);
- virtual FXCODEC_STATUS GetFrames(int32_t& frames, IFX_Pause* pPause);
+ 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;
- virtual FXCODEC_STATUS StartDecode(CFX_DIBitmap* pDIBitmap,
- int start_x,
- int start_y,
- int size_x,
- int size_y,
- int32_t frames,
- FX_BOOL bInterpol);
+ FXCODEC_STATUS GetFrames(int32_t& frames, IFX_Pause* pPause) override;
+ 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;
- virtual FXCODEC_STATUS ContinueDecode(IFX_Pause* pPause);
+ FXCODEC_STATUS ContinueDecode(IFX_Pause* pPause) override;
protected:
- FX_BOOL DetectImageType(FXCODEC_IMAGE_TYPE imageType,
- CFX_DIBAttribute* pAttribute = NULL);
- void GetDownScale(int& down_scale);
- void GetTransMethod(FXDIB_Format des_format, FXCodec_Format src_format);
- void ReSampleScanline(CFX_DIBitmap* pDeviceBitmap,
- int32_t des_line,
- uint8_t* src_scan,
- FXCodec_Format src_format);
- void Resample(CFX_DIBitmap* pDeviceBitmap,
- int32_t src_line,
- 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,
- FXCODEC_STATUS& err_status);
static FX_BOOL PngReadHeaderFunc(void* pModule,
int width,
int height,
@@ -140,13 +124,6 @@ class CCodec_ProgressiveDecoder : public ICodec_ProgressiveDecoder { static void PngFillScanlineBufCompletedFunc(void* pModule,
int pass,
int line);
- void PngOneOneMapResampleHorz(CFX_DIBitmap* pDeviceBitmap,
- int32_t des_line,
- uint8_t* src_scan,
- FXCodec_Format src_format);
-
- FX_BOOL GifReadMoreData(ICodec_GifModule* pGifModule,
- FXCODEC_STATUS& err_status);
static void GifRecordCurrentPositionCallback(void* pModule,
FX_DWORD& cur_pos);
static uint8_t* GifAskLocalPaletteBufCallback(void* pModule,
@@ -165,16 +142,38 @@ class CCodec_ProgressiveDecoder : public ICodec_ProgressiveDecoder { static void GifReadScanlineCallback(void* pModule,
int32_t row_num,
uint8_t* row_buf);
- void GifDoubleLineResampleVert(CFX_DIBitmap* pDeviceBitmap,
- double scale_y,
- int des_row);
- FX_BOOL BmpReadMoreData(ICodec_BmpModule* pBmpModule,
- FXCODEC_STATUS& err_status);
static FX_BOOL BmpInputImagePositionBufCallback(void* pModule,
FX_DWORD rcd_pos);
static void BmpReadScanlineCallback(void* pModule,
int32_t row_num,
uint8_t* row_buf);
+
+ FX_BOOL DetectImageType(FXCODEC_IMAGE_TYPE imageType,
+ CFX_DIBAttribute* pAttribute);
+ void GetDownScale(int& down_scale);
+ void GetTransMethod(FXDIB_Format des_format, FXCodec_Format src_format);
+ void ReSampleScanline(CFX_DIBitmap* pDeviceBitmap,
+ int32_t des_line,
+ uint8_t* src_scan,
+ FXCodec_Format src_format);
+ void Resample(CFX_DIBitmap* pDeviceBitmap,
+ int32_t src_line,
+ 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,
+ 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,
+ FXCODEC_STATUS& err_status);
+ void GifDoubleLineResampleVert(CFX_DIBitmap* pDeviceBitmap,
+ double scale_y,
+ int des_row);
+ FX_BOOL BmpReadMoreData(ICodec_BmpModule* pBmpModule,
+ FXCODEC_STATUS& err_status);
void ResampleVertBT(CFX_DIBitmap* pDeviceBitmap, double scale_y, int des_row);
public:
|