From 12f3e4a58f05850b93af35619cb04f0231d86acc Mon Sep 17 00:00:00 2001 From: tsepez Date: Wed, 2 Nov 2016 15:17:29 -0700 Subject: Remove FX_BOOL from core Review-Url: https://codereview.chromium.org/2477443002 --- core/fxcodec/codec/ccodec_bmpmodule.h | 4 +- core/fxcodec/codec/ccodec_flatemodule.h | 4 +- core/fxcodec/codec/ccodec_gifmodule.h | 20 +-- core/fxcodec/codec/ccodec_jpegmodule.h | 6 +- core/fxcodec/codec/ccodec_pngmodule.h | 26 ++-- core/fxcodec/codec/ccodec_progressivedecoder.h | 67 ++++----- core/fxcodec/codec/ccodec_scanlinedecoder.h | 4 +- core/fxcodec/codec/fx_codec.cpp | 68 ++++----- core/fxcodec/codec/fx_codec_bmp.cpp | 6 +- core/fxcodec/codec/fx_codec_fax.cpp | 76 +++++----- core/fxcodec/codec/fx_codec_flate.cpp | 50 +++---- core/fxcodec/codec/fx_codec_gif.cpp | 26 ++-- core/fxcodec/codec/fx_codec_icc.cpp | 28 ++-- core/fxcodec/codec/fx_codec_jpeg.cpp | 107 +++++++------- core/fxcodec/codec/fx_codec_jpx_opj.cpp | 24 +-- core/fxcodec/codec/fx_codec_png.cpp | 12 +- core/fxcodec/codec/fx_codec_progress.cpp | 195 ++++++++++++------------- core/fxcodec/fx_codec.h | 2 +- core/fxcodec/jbig2/JBig2_BitStream.cpp | 2 +- core/fxcodec/jbig2/JBig2_BitStream.h | 2 +- core/fxcodec/jbig2/JBig2_Context.cpp | 6 +- core/fxcodec/jbig2/JBig2_GrdProc.h | 6 +- core/fxcodec/jbig2/JBig2_GrrdProc.h | 2 +- core/fxcodec/jbig2/JBig2_GsidProc.h | 4 +- core/fxcodec/jbig2/JBig2_HtrdProc.h | 6 +- core/fxcodec/jbig2/JBig2_Image.cpp | 74 +++++----- core/fxcodec/jbig2/JBig2_Image.h | 48 +++--- core/fxcodec/jbig2/JBig2_Page.h | 2 +- core/fxcodec/jbig2/JBig2_PddProc.h | 2 +- core/fxcodec/jbig2/JBig2_SddProc.cpp | 12 +- core/fxcodec/jbig2/JBig2_SddProc.h | 4 +- core/fxcodec/jbig2/JBig2_TrdProc.cpp | 2 +- core/fxcodec/jbig2/JBig2_TrdProc.h | 8 +- core/fxcodec/lbmp/fx_bmp.cpp | 20 +-- core/fxcodec/lbmp/fx_bmp.h | 14 +- core/fxcodec/lgif/fx_gif.cpp | 85 ++++++----- core/fxcodec/lgif/fx_gif.h | 39 ++--- 37 files changed, 525 insertions(+), 538 deletions(-) (limited to 'core/fxcodec') diff --git a/core/fxcodec/codec/ccodec_bmpmodule.h b/core/fxcodec/codec/ccodec_bmpmodule.h index f5e5417924..605bd620c2 100644 --- a/core/fxcodec/codec/ccodec_bmpmodule.h +++ b/core/fxcodec/codec/ccodec_bmpmodule.h @@ -27,14 +27,14 @@ class CCodec_BmpModule { int32_t ReadHeader(FXBMP_Context* pContext, int32_t* width, int32_t* height, - FX_BOOL* tb_flag, + 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); + bool (*InputImagePositionBufCallback)(void* pModule, uint32_t rcd_pos); void (*ReadScanlineCallback)(void* pModule, int32_t row_num, uint8_t* row_buf); diff --git a/core/fxcodec/codec/ccodec_flatemodule.h b/core/fxcodec/codec/ccodec_flatemodule.h index 0b91f0a8c3..ee8fd8defd 100644 --- a/core/fxcodec/codec/ccodec_flatemodule.h +++ b/core/fxcodec/codec/ccodec_flatemodule.h @@ -23,10 +23,10 @@ class CCodec_FlateModule { int Colors, int BitsPerComponent, int Columns); - uint32_t FlateOrLZWDecode(FX_BOOL bLZW, + uint32_t FlateOrLZWDecode(bool bLZW, const uint8_t* src_buf, uint32_t src_size, - FX_BOOL bEarlyChange, + bool bEarlyChange, int predictor, int Colors, int BitsPerComponent, diff --git a/core/fxcodec/codec/ccodec_gifmodule.h b/core/fxcodec/codec/ccodec_gifmodule.h index 0281e69c33..fac621d256 100644 --- a/core/fxcodec/codec/ccodec_gifmodule.h +++ b/core/fxcodec/codec/ccodec_gifmodule.h @@ -42,16 +42,16 @@ class CCodec_GifModule { 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); + bool (*InputRecordPositionBufCallback)(void* pModule, + uint32_t rcd_pos, + const FX_RECT& img_rc, + int32_t pal_num, + void* pal_ptr, + int32_t delay_time, + bool user_input, + int32_t trans_index, + int32_t disposal_method, + bool interlace); void (*ReadScanlineCallback)(void* pModule, int32_t row_num, uint8_t* row_buf); diff --git a/core/fxcodec/codec/ccodec_jpegmodule.h b/core/fxcodec/codec/ccodec_jpegmodule.h index 225fd98467..db7f3dfb77 100644 --- a/core/fxcodec/codec/ccodec_jpegmodule.h +++ b/core/fxcodec/codec/ccodec_jpegmodule.h @@ -26,7 +26,7 @@ class CCodec_JpegModule { int width, int height, int nComps, - FX_BOOL ColorTransform); + bool ColorTransform); bool LoadInfo(const uint8_t* src_buf, uint32_t src_size, int* width, @@ -53,8 +53,8 @@ class CCodec_JpegModule { CFX_DIBAttribute* pAttribute); #endif // PDF_ENABLE_XFA - FX_BOOL StartScanline(FXJPEG_Context* pContext, int down_scale); - FX_BOOL ReadScanline(FXJPEG_Context* pContext, uint8_t* dest_buf); + bool StartScanline(FXJPEG_Context* pContext, int down_scale); + bool ReadScanline(FXJPEG_Context* pContext, uint8_t* dest_buf); uint32_t GetAvailInput(FXJPEG_Context* pContext, uint8_t** avail_buf_ptr); }; diff --git a/core/fxcodec/codec/ccodec_pngmodule.h b/core/fxcodec/codec/ccodec_pngmodule.h index 747d346afc..77c4af3946 100644 --- a/core/fxcodec/codec/ccodec_pngmodule.h +++ b/core/fxcodec/codec/ccodec_pngmodule.h @@ -20,19 +20,19 @@ class CCodec_PngModule { 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); + bool Input(FXPNG_Context* pContext, + const uint8_t* src_buf, + uint32_t src_size, + CFX_DIBAttribute* pAttribute); + + bool (*ReadHeaderCallback)(void* pModule, + int width, + int height, + int bpc, + int pass, + int* color_type, + double* gamma); + bool (*AskScanlineBufCallback)(void* pModule, int line, uint8_t*& src_buf); void (*FillScanlineBufCompletedCallback)(void* pModule, int pass, int line); protected: diff --git a/core/fxcodec/codec/ccodec_progressivedecoder.h b/core/fxcodec/codec/ccodec_progressivedecoder.h index b760c2ec1c..de7542e485 100644 --- a/core/fxcodec/codec/ccodec_progressivedecoder.h +++ b/core/fxcodec/codec/ccodec_progressivedecoder.h @@ -64,7 +64,7 @@ class CCodec_ProgressiveDecoder { int size_x, int size_y, int32_t frames = 0, - FX_BOOL bInterpol = TRUE); + bool bInterpol = true); FXCODEC_STATUS ContinueDecode(IFX_Pause* pPause = nullptr); @@ -85,7 +85,7 @@ class CCodec_ProgressiveDecoder { int src_len, int src_min, int src_max, - FX_BOOL bInterpol); + bool bInterpol); PixelWeight* GetPixelWeight(int pixel) { return reinterpret_cast(m_pWeightTables.data() + (pixel - m_DestMin) * m_ItemSize); @@ -101,7 +101,7 @@ class CCodec_ProgressiveDecoder { CFXCODEC_HorzTable(); ~CFXCODEC_HorzTable(); - void Calc(int dest_len, int src_len, FX_BOOL bInterpol); + void Calc(int dest_len, int src_len, bool bInterpol); PixelWeight* GetPixelWeight(int pixel) { return reinterpret_cast(m_pWeightTables.data() + pixel * m_ItemSize); @@ -139,7 +139,7 @@ class CCodec_ProgressiveDecoder { uint8_t* m_pDecodeBuf; int m_ScanlineSize; CFX_DIBitmap* m_pDeviceBitmap; - FX_BOOL m_bInterpol; + bool m_bInterpol; CFXCODEC_WeightTable m_WeightHorz; CFXCODEC_VertTable m_WeightVert; CFXCODEC_HorzTable m_WeightHorzOO; @@ -165,20 +165,18 @@ class CCodec_ProgressiveDecoder { int32_t m_GifPltNumber; int m_GifTransIndex; FX_RECT m_GifFrameRect; - FX_BOOL m_BmpIsTopBottom; + bool m_BmpIsTopBottom; FXCODEC_STATUS m_status; protected: - static FX_BOOL PngReadHeaderFunc(void* pModule, - int width, - int height, - int bpc, - int pass, - int* color_type, - double* gamma); - static FX_BOOL PngAskScanlineBufFunc(void* pModule, - int line, - uint8_t*& src_buf); + static bool PngReadHeaderFunc(void* pModule, + int width, + int height, + int bpc, + int pass, + int* color_type, + double* gamma); + static bool PngAskScanlineBufFunc(void* pModule, int line, uint8_t*& src_buf); static void PngFillScanlineBufCompletedFunc(void* pModule, int pass, int line); @@ -187,27 +185,26 @@ class CCodec_ProgressiveDecoder { static uint8_t* GifAskLocalPaletteBufCallback(void* pModule, int32_t frame_num, int32_t pal_size); - static FX_BOOL GifInputRecordPositionBufCallback(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); + static bool GifInputRecordPositionBufCallback(void* pModule, + uint32_t rcd_pos, + const FX_RECT& img_rc, + int32_t pal_num, + void* pal_ptr, + int32_t delay_time, + bool user_input, + int32_t trans_index, + int32_t disposal_method, + bool interlace); static void GifReadScanlineCallback(void* pModule, int32_t row_num, uint8_t* row_buf); - static FX_BOOL BmpInputImagePositionBufCallback(void* pModule, - uint32_t rcd_pos); + static bool BmpInputImagePositionBufCallback(void* pModule, uint32_t 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); + 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, @@ -219,19 +216,19 @@ class CCodec_ProgressiveDecoder { uint8_t* src_scan, FXCodec_Format src_format); void ResampleVert(CFX_DIBitmap* pDeviceBitmap, double scale_y, int des_row); - FX_BOOL JpegReadMoreData(CCodec_JpegModule* pJpegModule, - FXCODEC_STATUS& err_status); + 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(CCodec_GifModule* pGifModule, - FXCODEC_STATUS& err_status); + bool GifReadMoreData(CCodec_GifModule* pGifModule, + FXCODEC_STATUS& err_status); void GifDoubleLineResampleVert(CFX_DIBitmap* pDeviceBitmap, double scale_y, int des_row); - FX_BOOL BmpReadMoreData(CCodec_BmpModule* pBmpModule, - FXCODEC_STATUS& err_status); + bool BmpReadMoreData(CCodec_BmpModule* pBmpModule, + FXCODEC_STATUS& err_status); void ResampleVertBT(CFX_DIBitmap* pDeviceBitmap, double scale_y, int des_row); }; diff --git a/core/fxcodec/codec/ccodec_scanlinedecoder.h b/core/fxcodec/codec/ccodec_scanlinedecoder.h index 14eb6b628a..06bb6d5abe 100644 --- a/core/fxcodec/codec/ccodec_scanlinedecoder.h +++ b/core/fxcodec/codec/ccodec_scanlinedecoder.h @@ -24,7 +24,7 @@ class CCodec_ScanlineDecoder { virtual ~CCodec_ScanlineDecoder(); const uint8_t* GetScanline(int line); - FX_BOOL SkipToScanline(int line, IFX_Pause* pPause); + bool SkipToScanline(int line, IFX_Pause* pPause); int GetWidth() { return m_OutputWidth; } int GetHeight() { return m_OutputHeight; } @@ -34,7 +34,7 @@ class CCodec_ScanlineDecoder { virtual uint32_t GetSrcOffset() = 0; protected: - virtual FX_BOOL v_Rewind() = 0; + virtual bool v_Rewind() = 0; virtual uint8_t* v_GetNextLine() = 0; uint8_t* ReadNextLine(); diff --git a/core/fxcodec/codec/fx_codec.cpp b/core/fxcodec/codec/fx_codec.cpp index dfac86fbf9..2f4a81155c 100644 --- a/core/fxcodec/codec/fx_codec.cpp +++ b/core/fxcodec/codec/fx_codec.cpp @@ -73,9 +73,9 @@ const uint8_t* CCodec_ScanlineDecoder::GetScanline(int line) { return m_pLastScanline; } -FX_BOOL CCodec_ScanlineDecoder::SkipToScanline(int line, IFX_Pause* pPause) { +bool CCodec_ScanlineDecoder::SkipToScanline(int line, IFX_Pause* pPause) { if (m_NextLine == line || m_NextLine == line + 1) - return FALSE; + return false; if (m_NextLine < 0 || m_NextLine > line) { v_Rewind(); @@ -86,10 +86,10 @@ FX_BOOL CCodec_ScanlineDecoder::SkipToScanline(int line, IFX_Pause* pPause) { m_pLastScanline = ReadNextLine(); m_NextLine++; if (pPause && pPause->NeedToPauseNow()) { - return TRUE; + return true; } } - return FALSE; + return false; } uint8_t* CCodec_ScanlineDecoder::ReadNextLine() { @@ -120,20 +120,20 @@ class CCodec_RLScanlineDecoder : public CCodec_ScanlineDecoder { CCodec_RLScanlineDecoder(); ~CCodec_RLScanlineDecoder() override; - FX_BOOL Create(const uint8_t* src_buf, - uint32_t src_size, - int width, - int height, - int nComps, - int bpc); + bool Create(const uint8_t* src_buf, + uint32_t src_size, + int width, + int height, + int nComps, + int bpc); // CCodec_ScanlineDecoder - FX_BOOL v_Rewind() override; + bool v_Rewind() override; uint8_t* v_GetNextLine() override; uint32_t GetSrcOffset() override { return m_SrcOffset; } protected: - FX_BOOL CheckDestSize(); + bool CheckDestSize(); void GetNextOperator(); void UpdateOperator(uint8_t used_bytes); @@ -142,7 +142,7 @@ class CCodec_RLScanlineDecoder : public CCodec_ScanlineDecoder { uint32_t m_SrcSize; uint32_t m_dwLineBytes; uint32_t m_SrcOffset; - FX_BOOL m_bEOD; + bool m_bEOD; uint8_t m_Operator; }; CCodec_RLScanlineDecoder::CCodec_RLScanlineDecoder() @@ -151,12 +151,12 @@ CCodec_RLScanlineDecoder::CCodec_RLScanlineDecoder() m_SrcSize(0), m_dwLineBytes(0), m_SrcOffset(0), - m_bEOD(FALSE), + m_bEOD(false), m_Operator(0) {} CCodec_RLScanlineDecoder::~CCodec_RLScanlineDecoder() { FX_Free(m_pScanline); } -FX_BOOL CCodec_RLScanlineDecoder::CheckDestSize() { +bool CCodec_RLScanlineDecoder::CheckDestSize() { uint32_t i = 0; uint32_t old_size = 0; uint32_t dest_size = 0; @@ -165,14 +165,14 @@ FX_BOOL CCodec_RLScanlineDecoder::CheckDestSize() { old_size = dest_size; dest_size += m_pSrcBuf[i] + 1; if (dest_size < old_size) { - return FALSE; + return false; } i += m_pSrcBuf[i] + 2; } else if (m_pSrcBuf[i] > 128) { old_size = dest_size; dest_size += 257 - m_pSrcBuf[i]; if (dest_size < old_size) { - return FALSE; + return false; } i += 2; } else { @@ -181,16 +181,16 @@ FX_BOOL CCodec_RLScanlineDecoder::CheckDestSize() { } if (((uint32_t)m_OrigWidth * m_nComps * m_bpc * m_OrigHeight + 7) / 8 > dest_size) { - return FALSE; + return false; } - return TRUE; + return true; } -FX_BOOL CCodec_RLScanlineDecoder::Create(const uint8_t* src_buf, - uint32_t src_size, - int width, - int height, - int nComps, - int bpc) { +bool CCodec_RLScanlineDecoder::Create(const uint8_t* src_buf, + uint32_t src_size, + int width, + int height, + int nComps, + int bpc) { m_pSrcBuf = src_buf; m_SrcSize = src_size; m_OutputWidth = m_OrigWidth = width; @@ -205,7 +205,7 @@ FX_BOOL CCodec_RLScanlineDecoder::Create(const uint8_t* src_buf, pitch /= 32; pitch *= 4; if (!pitch.IsValid()) { - return FALSE; + return false; } m_Pitch = pitch.ValueOrDie(); // Overflow should already have been checked before this is called. @@ -213,12 +213,12 @@ FX_BOOL CCodec_RLScanlineDecoder::Create(const uint8_t* src_buf, m_pScanline = FX_Alloc(uint8_t, m_Pitch); return CheckDestSize(); } -FX_BOOL CCodec_RLScanlineDecoder::v_Rewind() { +bool CCodec_RLScanlineDecoder::v_Rewind() { FXSYS_memset(m_pScanline, 0, m_Pitch); m_SrcOffset = 0; - m_bEOD = FALSE; + m_bEOD = false; m_Operator = 0; - return TRUE; + return true; } uint8_t* CCodec_RLScanlineDecoder::v_GetNextLine() { if (m_SrcOffset == 0) { @@ -230,17 +230,17 @@ uint8_t* CCodec_RLScanlineDecoder::v_GetNextLine() { } FXSYS_memset(m_pScanline, 0, m_Pitch); uint32_t col_pos = 0; - FX_BOOL eol = FALSE; + bool eol = false; while (m_SrcOffset < m_SrcSize && !eol) { if (m_Operator < 128) { uint32_t copy_len = m_Operator + 1; if (col_pos + copy_len >= m_dwLineBytes) { copy_len = m_dwLineBytes - col_pos; - eol = TRUE; + eol = true; } if (copy_len >= m_SrcSize - m_SrcOffset) { copy_len = m_SrcSize - m_SrcOffset; - m_bEOD = TRUE; + m_bEOD = true; } FXSYS_memcpy(m_pScanline + col_pos, m_pSrcBuf + m_SrcOffset, copy_len); col_pos += copy_len; @@ -253,13 +253,13 @@ uint8_t* CCodec_RLScanlineDecoder::v_GetNextLine() { uint32_t duplicate_len = 257 - m_Operator; if (col_pos + duplicate_len >= m_dwLineBytes) { duplicate_len = m_dwLineBytes - col_pos; - eol = TRUE; + eol = true; } FXSYS_memset(m_pScanline + col_pos, fill, duplicate_len); col_pos += duplicate_len; UpdateOperator((uint8_t)duplicate_len); } else { - m_bEOD = TRUE; + m_bEOD = true; break; } } diff --git a/core/fxcodec/codec/fx_codec_bmp.cpp b/core/fxcodec/codec/fx_codec_bmp.cpp index 45025a188f..ae83d3f1ef 100644 --- a/core/fxcodec/codec/fx_codec_bmp.cpp +++ b/core/fxcodec/codec/fx_codec_bmp.cpp @@ -36,8 +36,8 @@ static void bmp_read_scanline(bmp_decompress_struct_p bmp_ptr, CCodec_BmpModule* pModule = (CCodec_BmpModule*)p->parent_ptr; pModule->ReadScanlineCallback(p->child_ptr, row_num, row_buf); } -static FX_BOOL bmp_get_data_position(bmp_decompress_struct_p bmp_ptr, - uint32_t rcd_pos) { +static bool bmp_get_data_position(bmp_decompress_struct_p bmp_ptr, + uint32_t rcd_pos) { FXBMP_Context* p = (FXBMP_Context*)bmp_ptr->context_ptr; CCodec_BmpModule* pModule = (CCodec_BmpModule*)p->parent_ptr; return pModule->InputImagePositionBufCallback(p->child_ptr, rcd_pos); @@ -79,7 +79,7 @@ void CCodec_BmpModule::Finish(FXBMP_Context* ctx) { int32_t CCodec_BmpModule::ReadHeader(FXBMP_Context* ctx, int32_t* width, int32_t* height, - FX_BOOL* tb_flag, + bool* tb_flag, int32_t* components, int32_t* pal_num, uint32_t** pal_pp, diff --git a/core/fxcodec/codec/fx_codec_fax.cpp b/core/fxcodec/codec/fx_codec_fax.cpp index 9af812381a..5102c778a4 100644 --- a/core/fxcodec/codec/fx_codec_fax.cpp +++ b/core/fxcodec/codec/fx_codec_fax.cpp @@ -273,17 +273,17 @@ int FaxGetRun(const uint8_t* ins_array, } } -FX_BOOL FaxG4GetRow(const uint8_t* src_buf, - int bitsize, - int* bitpos, - uint8_t* dest_buf, - const std::vector& ref_buf, - int columns) { +bool FaxG4GetRow(const uint8_t* src_buf, + int bitsize, + int* bitpos, + uint8_t* dest_buf, + const std::vector& ref_buf, + int columns) { int a0 = -1; bool a0color = true; while (1) { if (*bitpos >= bitsize) - return FALSE; + return false; int a1; int a2; @@ -294,13 +294,13 @@ FX_BOOL FaxG4GetRow(const uint8_t* src_buf, int v_delta = 0; if (!NextBit(src_buf, bitpos)) { if (*bitpos >= bitsize) - return FALSE; + return false; - FX_BOOL bit1 = NextBit(src_buf, bitpos); + bool bit1 = NextBit(src_buf, bitpos); if (*bitpos >= bitsize) - return FALSE; + return false; - FX_BOOL bit2 = NextBit(src_buf, bitpos); + bool bit2 = NextBit(src_buf, bitpos); if (bit1) { v_delta = bit2 ? 1 : -1; } else if (bit2) { @@ -337,47 +337,47 @@ FX_BOOL FaxG4GetRow(const uint8_t* src_buf, if (a0 < columns) continue; - return TRUE; + return true; } else { if (*bitpos >= bitsize) - return FALSE; + return false; if (NextBit(src_buf, bitpos)) { if (!a0color) FaxFillBits(dest_buf, columns, a0, b2); if (b2 >= columns) - return TRUE; + return true; a0 = b2; continue; } if (*bitpos >= bitsize) - return FALSE; + return false; - FX_BOOL next_bit1 = NextBit(src_buf, bitpos); + bool next_bit1 = NextBit(src_buf, bitpos); if (*bitpos >= bitsize) - return FALSE; + return false; - FX_BOOL next_bit2 = NextBit(src_buf, bitpos); + bool next_bit2 = NextBit(src_buf, bitpos); if (next_bit1) { v_delta = next_bit2 ? 2 : -2; } else if (next_bit2) { if (*bitpos >= bitsize) - return FALSE; + return false; v_delta = NextBit(src_buf, bitpos) ? 3 : -3; } else { if (*bitpos >= bitsize) - return FALSE; + return false; if (NextBit(src_buf, bitpos)) { *bitpos += 3; continue; } *bitpos += 5; - return TRUE; + return true; } } } @@ -386,39 +386,39 @@ FX_BOOL FaxG4GetRow(const uint8_t* src_buf, FaxFillBits(dest_buf, columns, a0, a1); if (a1 >= columns) - return TRUE; + return true; // The position of picture element must be monotonic increasing. if (a0 >= a1) - return FALSE; + return false; a0 = a1; a0color = !a0color; } } -FX_BOOL FaxSkipEOL(const uint8_t* src_buf, int bitsize, int* bitpos) { +bool FaxSkipEOL(const uint8_t* src_buf, int bitsize, int* bitpos) { int startbit = *bitpos; while (*bitpos < bitsize) { if (!NextBit(src_buf, bitpos)) continue; if (*bitpos - startbit <= 11) *bitpos = startbit; - return TRUE; + return true; } - return FALSE; + return false; } -FX_BOOL FaxGet1DLine(const uint8_t* src_buf, - int bitsize, - int* bitpos, - std::vector* dest_buf, - int columns) { +bool FaxGet1DLine(const uint8_t* src_buf, + int bitsize, + int* bitpos, + std::vector* dest_buf, + int columns) { bool color = true; int startpos = 0; while (1) { if (*bitpos >= bitsize) - return FALSE; + return false; int run_len = 0; while (1) { @@ -427,9 +427,9 @@ FX_BOOL FaxGet1DLine(const uint8_t* src_buf, if (run < 0) { while (*bitpos < bitsize) { if (NextBit(src_buf, bitpos)) - return TRUE; + return true; } - return FALSE; + return false; } run_len += run; if (run < 64) { @@ -445,7 +445,7 @@ FX_BOOL FaxGet1DLine(const uint8_t* src_buf, color = !color; } - return TRUE; + return true; } } // namespace @@ -464,7 +464,7 @@ class CCodec_FaxDecoder : public CCodec_ScanlineDecoder { ~CCodec_FaxDecoder() override; // CCodec_ScanlineDecoder - FX_BOOL v_Rewind() override; + bool v_Rewind() override; uint8_t* v_GetNextLine() override; uint32_t GetSrcOffset() override; @@ -502,10 +502,10 @@ CCodec_FaxDecoder::CCodec_FaxDecoder(const uint8_t* src_buf, CCodec_FaxDecoder::~CCodec_FaxDecoder() {} -FX_BOOL CCodec_FaxDecoder::v_Rewind() { +bool CCodec_FaxDecoder::v_Rewind() { FXSYS_memset(m_RefBuf.data(), 0xff, m_RefBuf.size()); m_bitpos = 0; - return TRUE; + return true; } uint8_t* CCodec_FaxDecoder::v_GetNextLine() { diff --git a/core/fxcodec/codec/fx_codec_flate.cpp b/core/fxcodec/codec/fx_codec_flate.cpp index 9b9ad041df..c5611cc27a 100644 --- a/core/fxcodec/codec/fx_codec_flate.cpp +++ b/core/fxcodec/codec/fx_codec_flate.cpp @@ -94,7 +94,7 @@ class CLZWDecoder { uint32_t& outlen, const uint8_t* input, uint32_t& size, - FX_BOOL bEarlyChange); + bool bEarlyChange); private: void AddCode(uint32_t prefix_code, uint8_t append_char); @@ -104,7 +104,7 @@ class CLZWDecoder { uint32_t m_OutPos; uint8_t* m_pOutput; const uint8_t* m_pInput; - FX_BOOL m_Early; + bool m_Early; uint32_t m_CodeArray[5021]; uint32_t m_nCodes; uint8_t m_DecodeStack[4000]; @@ -147,7 +147,7 @@ int CLZWDecoder::Decode(uint8_t* dest_buf, uint32_t& dest_size, const uint8_t* src_buf, uint32_t& src_size, - FX_BOOL bEarlyChange) { + bool bEarlyChange) { m_CodeLen = 9; m_InPos = 0; m_OutPos = 0; @@ -342,18 +342,18 @@ void PNG_PredictLine(uint8_t* pDestData, } } -FX_BOOL PNG_Predictor(uint8_t*& data_buf, - uint32_t& data_size, - int Colors, - int BitsPerComponent, - int Columns) { +bool PNG_Predictor(uint8_t*& data_buf, + uint32_t& data_size, + int Colors, + int BitsPerComponent, + int Columns) { const int BytesPerPixel = (Colors * BitsPerComponent + 7) / 8; const int row_size = (Colors * BitsPerComponent * Columns + 7) / 8; if (row_size <= 0) - return FALSE; + return false; const int row_count = (data_size + row_size) / (row_size + 1); if (row_count <= 0) - return FALSE; + return false; const int last_row_size = data_size % (row_size + 1); uint8_t* dest_buf = FX_Alloc2D(uint8_t, row_size, row_count); int byte_cnt = 0; @@ -433,7 +433,7 @@ FX_BOOL PNG_Predictor(uint8_t*& data_buf, data_buf = dest_buf; data_size = row_size * row_count - (last_row_size > 0 ? (row_size + 1 - last_row_size) : 0); - return TRUE; + return true; } void TIFF_PredictLine(uint8_t* dest_buf, @@ -476,14 +476,14 @@ void TIFF_PredictLine(uint8_t* dest_buf, } } -FX_BOOL TIFF_Predictor(uint8_t*& data_buf, - uint32_t& data_size, - int Colors, - int BitsPerComponent, - int Columns) { +bool TIFF_Predictor(uint8_t*& data_buf, + uint32_t& data_size, + int Colors, + int BitsPerComponent, + int Columns) { int row_size = (Colors * BitsPerComponent * Columns + 7) / 8; if (row_size == 0) - return FALSE; + return false; const int row_count = (data_size + row_size - 1) / row_size; const int last_row_size = data_size % row_size; for (int row = 0; row < row_count; row++) { @@ -493,7 +493,7 @@ FX_BOOL TIFF_Predictor(uint8_t*& data_buf, } TIFF_PredictLine(scan_line, row_size, BitsPerComponent, Colors, Columns); } - return TRUE; + return true; } void FlateUncompress(const uint8_t* src_buf, @@ -627,7 +627,7 @@ class CCodec_FlateScanlineDecoder : public CCodec_ScanlineDecoder { int Columns); // CCodec_ScanlineDecoder - FX_BOOL v_Rewind() override; + bool v_Rewind() override; uint8_t* v_GetNextLine() override; uint32_t GetSrcOffset() override; @@ -707,17 +707,17 @@ void CCodec_FlateScanlineDecoder::Create(const uint8_t* src_buf, } } } -FX_BOOL CCodec_FlateScanlineDecoder::v_Rewind() { +bool CCodec_FlateScanlineDecoder::v_Rewind() { if (m_pFlate) { FPDFAPI_FlateEnd(m_pFlate); } m_pFlate = FPDFAPI_FlateInit(my_alloc_func, my_free_func); if (!m_pFlate) { - return FALSE; + return false; } FPDFAPI_FlateInput(m_pFlate, m_SrcBuf, m_SrcSize); m_LeftOver = 0; - return TRUE; + return true; } uint8_t* CCodec_FlateScanlineDecoder::v_GetNextLine() { if (m_Predictor) { @@ -787,10 +787,10 @@ CCodec_ScanlineDecoder* CCodec_FlateModule::CreateDecoder( Colors, BitsPerComponent, Columns); return pDecoder; } -uint32_t CCodec_FlateModule::FlateOrLZWDecode(FX_BOOL bLZW, +uint32_t CCodec_FlateModule::FlateOrLZWDecode(bool bLZW, const uint8_t* src_buf, uint32_t src_size, - FX_BOOL bEarlyChange, + bool bEarlyChange, int predictor, int Colors, int BitsPerComponent, @@ -832,7 +832,7 @@ uint32_t CCodec_FlateModule::FlateOrLZWDecode(FX_BOOL bLZW, if (predictor_type == 0) { return offset; } - FX_BOOL ret = TRUE; + bool ret = true; if (predictor_type == 2) { ret = PNG_Predictor(dest_buf, dest_size, Colors, BitsPerComponent, Columns); } else if (predictor_type == 1) { diff --git a/core/fxcodec/codec/fx_codec_gif.cpp b/core/fxcodec/codec/fx_codec_gif.cpp index 8a8d2dcdf5..9d67652f86 100644 --- a/core/fxcodec/codec/fx_codec_gif.cpp +++ b/core/fxcodec/codec/fx_codec_gif.cpp @@ -49,19 +49,19 @@ static void gif_read_scanline(gif_decompress_struct_p gif_ptr, CCodec_GifModule* pModule = (CCodec_GifModule*)p->parent_ptr; pModule->ReadScanlineCallback(p->child_ptr, row_num, row_buf); } -static FX_BOOL gif_get_record_position(gif_decompress_struct_p gif_ptr, - uint32_t cur_pos, - int32_t left, - int32_t top, - int32_t width, - int32_t height, - 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) { +static bool gif_get_record_position(gif_decompress_struct_p gif_ptr, + uint32_t cur_pos, + int32_t left, + int32_t top, + int32_t width, + int32_t height, + int32_t pal_num, + void* pal_ptr, + int32_t delay_time, + bool user_input, + int32_t trans_index, + int32_t disposal_method, + bool interlace) { FXGIF_Context* p = (FXGIF_Context*)gif_ptr->context_ptr; CCodec_GifModule* pModule = (CCodec_GifModule*)p->parent_ptr; return pModule->InputRecordPositionBufCallback( diff --git a/core/fxcodec/codec/fx_codec_icc.cpp b/core/fxcodec/codec/fx_codec_icc.cpp index f0ea6bb43c..085452223d 100644 --- a/core/fxcodec/codec/fx_codec_icc.cpp +++ b/core/fxcodec/codec/fx_codec_icc.cpp @@ -18,45 +18,43 @@ struct CLcmsCmm { cmsHTRANSFORM m_hTransform; int m_nSrcComponents; int m_nDstComponents; - FX_BOOL m_bLab; + bool m_bLab; }; -FX_BOOL CheckComponents(cmsColorSpaceSignature cs, - int nComponents, - FX_BOOL bDst) { +bool CheckComponents(cmsColorSpaceSignature cs, int nComponents, bool bDst) { if (nComponents <= 0 || nComponents > 15) { - return FALSE; + return false; } switch (cs) { case cmsSigLabData: if (nComponents < 3) { - return FALSE; + return false; } break; case cmsSigGrayData: if (bDst && nComponents != 1) { - return FALSE; + return false; } if (!bDst && nComponents > 2) { - return FALSE; + return false; } break; case cmsSigRgbData: if (bDst && nComponents != 3) { - return FALSE; + return false; } break; case cmsSigCmykData: if (bDst && nComponents != 4) { - return FALSE; + return false; } break; default: if (nComponents != 3) { - return FALSE; + return false; } break; } - return TRUE; + return true; } uint32_t GetCSComponents(cmsColorSpaceSignature cs) { @@ -108,13 +106,13 @@ void* IccLib_CreateTransform(const unsigned char* pSrcProfileData, return nullptr; } int srcFormat; - FX_BOOL bLab = FALSE; + bool bLab = false; cmsColorSpaceSignature srcCS = cmsGetColorSpace(srcProfile); nSrcComponents = GetCSComponents(srcCS); if (srcCS == cmsSigLabData) { srcFormat = COLORSPACE_SH(PT_Lab) | CHANNELS_SH(nSrcComponents) | BYTES_SH(0); - bLab = TRUE; + bLab = true; } else { srcFormat = COLORSPACE_SH(PT_ANY) | CHANNELS_SH(nSrcComponents) | BYTES_SH(1); @@ -123,7 +121,7 @@ void* IccLib_CreateTransform(const unsigned char* pSrcProfileData, } } cmsColorSpaceSignature dstCS = cmsGetColorSpace(dstProfile); - if (!CheckComponents(dstCS, nDstComponents, TRUE)) { + if (!CheckComponents(dstCS, nDstComponents, true)) { cmsCloseProfile(srcProfile); cmsCloseProfile(dstProfile); return nullptr; diff --git a/core/fxcodec/codec/fx_codec_jpeg.cpp b/core/fxcodec/codec/fx_codec_jpeg.cpp index 49b0aca3b8..775ebfb9c6 100644 --- a/core/fxcodec/codec/fx_codec_jpeg.cpp +++ b/core/fxcodec/codec/fx_codec_jpeg.cpp @@ -126,7 +126,7 @@ static bool JpegLoadInfo(const uint8_t* src_buf, jpeg_destroy_decompress(&cinfo); return false; } - int ret = jpeg_read_header(&cinfo, TRUE); + int ret = jpeg_read_header(&cinfo, true); if (ret != JPEG_HEADER_OK) { jpeg_destroy_decompress(&cinfo); return false; @@ -146,19 +146,19 @@ class CCodec_JpegDecoder : public CCodec_ScanlineDecoder { CCodec_JpegDecoder(); ~CCodec_JpegDecoder() override; - FX_BOOL Create(const uint8_t* src_buf, - uint32_t src_size, - int width, - int height, - int nComps, - FX_BOOL ColorTransform); + bool Create(const uint8_t* src_buf, + uint32_t src_size, + int width, + int height, + int nComps, + bool ColorTransform); // CCodec_ScanlineDecoder - FX_BOOL v_Rewind() override; + bool v_Rewind() override; uint8_t* v_GetNextLine() override; uint32_t GetSrcOffset() override; - FX_BOOL InitDecode(); + bool InitDecode(); jmp_buf m_JmpBuf; struct jpeg_decompress_struct cinfo; @@ -168,9 +168,9 @@ class CCodec_JpegDecoder : public CCodec_ScanlineDecoder { uint32_t m_SrcSize; uint8_t* m_pScanlineBuf; - FX_BOOL m_bInited; - FX_BOOL m_bStarted; - FX_BOOL m_bJpegTransform; + bool m_bInited; + bool m_bStarted; + bool m_bJpegTransform; protected: uint32_t m_nDefaultScaleDenom; @@ -178,8 +178,8 @@ class CCodec_JpegDecoder : public CCodec_ScanlineDecoder { CCodec_JpegDecoder::CCodec_JpegDecoder() { m_pScanlineBuf = nullptr; - m_bStarted = FALSE; - m_bInited = FALSE; + m_bStarted = false; + m_bInited = false; FXSYS_memset(&cinfo, 0, sizeof(cinfo)); FXSYS_memset(&jerr, 0, sizeof(jerr)); FXSYS_memset(&src, 0, sizeof(src)); @@ -192,30 +192,30 @@ CCodec_JpegDecoder::~CCodec_JpegDecoder() { jpeg_destroy_decompress(&cinfo); } -FX_BOOL CCodec_JpegDecoder::InitDecode() { +bool CCodec_JpegDecoder::InitDecode() { cinfo.err = &jerr; cinfo.client_data = &m_JmpBuf; if (setjmp(m_JmpBuf) == -1) - return FALSE; + return false; jpeg_create_decompress(&cinfo); - m_bInited = TRUE; + m_bInited = true; cinfo.src = &src; src.bytes_in_buffer = m_SrcSize; src.next_input_byte = m_SrcBuf; if (setjmp(m_JmpBuf) == -1) { jpeg_destroy_decompress(&cinfo); - m_bInited = FALSE; - return FALSE; + m_bInited = false; + return false; } cinfo.image_width = m_OrigWidth; cinfo.image_height = m_OrigHeight; - int ret = jpeg_read_header(&cinfo, TRUE); + int ret = jpeg_read_header(&cinfo, true); if (ret != JPEG_HEADER_OK) - return FALSE; + return false; if (cinfo.saw_Adobe_marker) - m_bJpegTransform = TRUE; + m_bJpegTransform = true; if (cinfo.num_components == 3 && !m_bJpegTransform) cinfo.out_color_space = cinfo.jpeg_color_space; @@ -225,15 +225,15 @@ FX_BOOL CCodec_JpegDecoder::InitDecode() { m_OutputWidth = m_OrigWidth; m_OutputHeight = m_OrigHeight; m_nDefaultScaleDenom = cinfo.scale_denom; - return TRUE; + return true; } -FX_BOOL CCodec_JpegDecoder::Create(const uint8_t* src_buf, - uint32_t src_size, - int width, - int height, - int nComps, - FX_BOOL ColorTransform) { +bool CCodec_JpegDecoder::Create(const uint8_t* src_buf, + uint32_t src_size, + int width, + int height, + int nComps, + bool ColorTransform) { JpegScanSOI(&src_buf, &src_size); m_SrcBuf = src_buf; m_SrcSize = src_size; @@ -256,13 +256,13 @@ FX_BOOL CCodec_JpegDecoder::Create(const uint8_t* src_buf, m_OutputWidth = m_OrigWidth = width; m_OutputHeight = m_OrigHeight = height; if (!InitDecode()) - return FALSE; + return false; if (cinfo.num_components < nComps) - return FALSE; + return false; if ((int)cinfo.image_width < width) - return FALSE; + return false; m_Pitch = (static_cast(cinfo.image_width) * cinfo.num_components + 3) / @@ -270,33 +270,33 @@ FX_BOOL CCodec_JpegDecoder::Create(const uint8_t* src_buf, m_pScanlineBuf = FX_Alloc(uint8_t, m_Pitch); m_nComps = cinfo.num_components; m_bpc = 8; - m_bStarted = FALSE; - return TRUE; + m_bStarted = false; + return true; } -FX_BOOL CCodec_JpegDecoder::v_Rewind() { +bool CCodec_JpegDecoder::v_Rewind() { if (m_bStarted) { jpeg_destroy_decompress(&cinfo); if (!InitDecode()) { - return FALSE; + return false; } } if (setjmp(m_JmpBuf) == -1) { - return FALSE; + return false; } cinfo.scale_denom = m_nDefaultScaleDenom; m_OutputWidth = m_OrigWidth; m_OutputHeight = m_OrigHeight; if (!jpeg_start_decompress(&cinfo)) { jpeg_destroy_decompress(&cinfo); - return FALSE; + return false; } if ((int)cinfo.output_width > m_OrigWidth) { - ASSERT(FALSE); - return FALSE; + ASSERT(false); + return false; } - m_bStarted = TRUE; - return TRUE; + m_bStarted = true; + return true; } uint8_t* CCodec_JpegDecoder::v_GetNextLine() { @@ -311,13 +311,12 @@ uint32_t CCodec_JpegDecoder::GetSrcOffset() { return (uint32_t)(m_SrcSize - src.bytes_in_buffer); } -CCodec_ScanlineDecoder* CCodec_JpegModule::CreateDecoder( - const uint8_t* src_buf, - uint32_t src_size, - int width, - int height, - int nComps, - FX_BOOL ColorTransform) { +CCodec_ScanlineDecoder* CCodec_JpegModule::CreateDecoder(const uint8_t* src_buf, + uint32_t src_size, + int width, + int height, + int nComps, + bool ColorTransform) { if (!src_buf || src_size == 0) return nullptr; @@ -449,18 +448,18 @@ int CCodec_JpegModule::ReadHeader(FXJPEG_Context* ctx, return 0; } -FX_BOOL CCodec_JpegModule::StartScanline(FXJPEG_Context* ctx, int down_scale) { +bool CCodec_JpegModule::StartScanline(FXJPEG_Context* ctx, int down_scale) { if (setjmp(ctx->m_JumpMark) == -1) - return FALSE; + return false; ctx->m_Info.scale_denom = down_scale; return !!jpeg_start_decompress(&ctx->m_Info); } -FX_BOOL CCodec_JpegModule::ReadScanline(FXJPEG_Context* ctx, - unsigned char* dest_buf) { +bool CCodec_JpegModule::ReadScanline(FXJPEG_Context* ctx, + unsigned char* dest_buf) { if (setjmp(ctx->m_JumpMark) == -1) - return FALSE; + return false; int nlines = jpeg_read_scanlines(&ctx->m_Info, &dest_buf, 1); return nlines == 1; diff --git a/core/fxcodec/codec/fx_codec_jpx_opj.cpp b/core/fxcodec/codec/fx_codec_jpx_opj.cpp index 85446c1d9b..bb46da4d26 100644 --- a/core/fxcodec/codec/fx_codec_jpx_opj.cpp +++ b/core/fxcodec/codec/fx_codec_jpx_opj.cpp @@ -691,7 +691,7 @@ class CJPX_Decoder { public: explicit CJPX_Decoder(CPDF_ColorSpace* cs); ~CJPX_Decoder(); - FX_BOOL Init(const unsigned char* src_data, uint32_t src_size); + bool Init(const unsigned char* src_data, uint32_t src_size); void GetInfo(uint32_t* width, uint32_t* height, uint32_t* components); bool Decode(uint8_t* dest_buf, int pitch, @@ -721,11 +721,11 @@ CJPX_Decoder::~CJPX_Decoder() { } } -FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, uint32_t src_size) { +bool CJPX_Decoder::Init(const unsigned char* src_data, uint32_t src_size) { static const unsigned char szJP2Header[] = { 0x00, 0x00, 0x00, 0x0c, 0x6a, 0x50, 0x20, 0x20, 0x0d, 0x0a, 0x87, 0x0a}; if (!src_data || src_size < sizeof(szJP2Header)) - return FALSE; + return false; image = nullptr; m_SrcData = src_data; @@ -734,7 +734,7 @@ FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, uint32_t src_size) { l_stream = fx_opj_stream_create_memory_stream(&srcData, OPJ_J2K_STREAM_CHUNK_SIZE, 1); if (!l_stream) { - return FALSE; + return false; } opj_dparameters_t parameters; opj_set_default_decoder_parameters(¶meters); @@ -747,7 +747,7 @@ FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, uint32_t src_size) { l_codec = opj_create_decompress(OPJ_CODEC_J2K); } if (!l_codec) { - return FALSE; + return false; } if (m_ColorSpace && m_ColorSpace->GetFamily() == PDFCS_INDEXED) parameters.flags |= OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG; @@ -755,11 +755,11 @@ FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, uint32_t src_size) { opj_set_warning_handler(l_codec, fx_warning_callback, 00); opj_set_error_handler(l_codec, fx_error_callback, 00); if (!opj_setup_decoder(l_codec, ¶meters)) { - return FALSE; + return false; } if (!opj_read_header(l_stream, l_codec, &image)) { image = nullptr; - return FALSE; + return false; } image->pdfium_use_colorspace = !!m_ColorSpace; @@ -768,18 +768,18 @@ FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, uint32_t src_size) { parameters.DA_x1, parameters.DA_y1)) { opj_image_destroy(image); image = nullptr; - return FALSE; + return false; } if (!(opj_decode(l_codec, l_stream, image) && opj_end_decompress(l_codec, l_stream))) { opj_image_destroy(image); image = nullptr; - return FALSE; + return false; } } else { if (!opj_get_decoded_tile(l_codec, l_stream, image, parameters.tile_index)) { - return FALSE; + return false; } } opj_stream_destroy(l_stream); @@ -799,9 +799,9 @@ FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, uint32_t src_size) { image->icc_profile_len = 0; } if (!image) { - return FALSE; + return false; } - return TRUE; + return true; } void CJPX_Decoder::GetInfo(uint32_t* width, diff --git a/core/fxcodec/codec/fx_codec_png.cpp b/core/fxcodec/codec/fx_codec_png.cpp index 8630887a70..0b55a97dbe 100644 --- a/core/fxcodec/codec/fx_codec_png.cpp +++ b/core/fxcodec/codec/fx_codec_png.cpp @@ -240,17 +240,17 @@ void CCodec_PngModule::Finish(FXPNG_Context* ctx) { } } -FX_BOOL CCodec_PngModule::Input(FXPNG_Context* ctx, - const uint8_t* src_buf, - uint32_t src_size, - CFX_DIBAttribute* pAttribute) { +bool CCodec_PngModule::Input(FXPNG_Context* ctx, + const uint8_t* src_buf, + uint32_t src_size, + CFX_DIBAttribute* pAttribute) { if (setjmp(png_jmpbuf(ctx->png_ptr))) { if (pAttribute && 0 == FXSYS_strcmp(m_szLastError, "Read Header Callback Error")) { _png_load_bmp_attribute(ctx->png_ptr, ctx->info_ptr, pAttribute); } - return FALSE; + return false; } png_process_data(ctx->png_ptr, ctx->info_ptr, (uint8_t*)src_buf, src_size); - return TRUE; + return true; } diff --git a/core/fxcodec/codec/fx_codec_progress.cpp b/core/fxcodec/codec/fx_codec_progress.cpp index 4de62baad2..7d8a3203e9 100644 --- a/core/fxcodec/codec/fx_codec_progress.cpp +++ b/core/fxcodec/codec/fx_codec_progress.cpp @@ -47,7 +47,7 @@ void CCodec_ProgressiveDecoder::CFXCODEC_WeightTable::Calc(int dest_len, int src_len, int src_min, int src_max, - FX_BOOL bInterpol) { + bool bInterpol) { double scale, base; scale = (FX_FLOAT)src_len / (FX_FLOAT)dest_len; if (dest_len < 0) { @@ -146,7 +146,7 @@ CCodec_ProgressiveDecoder::CFXCODEC_HorzTable::~CFXCODEC_HorzTable() {} void CCodec_ProgressiveDecoder::CFXCODEC_HorzTable::Calc(int dest_len, int src_len, - FX_BOOL bInterpol) { + bool bInterpol) { double scale = (double)dest_len / (double)src_len; m_ItemSize = sizeof(int) * 4; int size = dest_len * m_ItemSize + 4; @@ -282,7 +282,7 @@ CCodec_ProgressiveDecoder::CCodec_ProgressiveDecoder( m_TransMethod = -1; m_SrcRow = 0; m_SrcFormat = FXCodec_Invalid; - m_bInterpol = TRUE; + m_bInterpol = true; m_FrameNumber = 0; m_FrameCur = 0; m_SrcPaletteNumber = 0; @@ -291,7 +291,7 @@ CCodec_ProgressiveDecoder::CCodec_ProgressiveDecoder( m_pGifPalette = nullptr; m_GifTransIndex = -1; m_GifFrameRect = FX_RECT(0, 0, 0, 0); - m_BmpIsTopBottom = FALSE; + m_BmpIsTopBottom = false; } CCodec_ProgressiveDecoder::~CCodec_ProgressiveDecoder() { @@ -311,12 +311,11 @@ CCodec_ProgressiveDecoder::~CCodec_ProgressiveDecoder() { FX_Free(m_pSrcPalette); } -FX_BOOL CCodec_ProgressiveDecoder::JpegReadMoreData( - CCodec_JpegModule* pJpegModule, - FXCODEC_STATUS& err_status) { +bool CCodec_ProgressiveDecoder::JpegReadMoreData(CCodec_JpegModule* pJpegModule, + FXCODEC_STATUS& err_status) { uint32_t dwSize = (uint32_t)m_pFile->GetSize(); if (dwSize <= m_offSet) { - return FALSE; + return false; } dwSize = dwSize - m_offSet; uint32_t dwAvail = pJpegModule->GetAvailInput(m_pJpegContext, nullptr); @@ -329,7 +328,7 @@ FX_BOOL CCodec_ProgressiveDecoder::JpegReadMoreData( m_pSrcBuf = FX_Realloc(uint8_t, m_pSrcBuf, m_SrcSize); if (!m_pSrcBuf) { err_status = FXCODEC_STATUS_ERR_MEMORY; - return FALSE; + return false; } } else { uint32_t dwConsume = m_SrcSize - dwAvail; @@ -342,20 +341,20 @@ FX_BOOL CCodec_ProgressiveDecoder::JpegReadMoreData( } if (!m_pFile->ReadBlock(m_pSrcBuf + dwAvail, m_offSet, dwSize)) { err_status = FXCODEC_STATUS_ERR_READ; - return FALSE; + return false; } m_offSet += dwSize; pJpegModule->Input(m_pJpegContext, m_pSrcBuf, dwSize + dwAvail); - return TRUE; + return true; } -FX_BOOL CCodec_ProgressiveDecoder::PngReadHeaderFunc(void* pModule, - int width, - int height, - int bpc, - int pass, - int* color_type, - double* gamma) { +bool CCodec_ProgressiveDecoder::PngReadHeaderFunc(void* pModule, + int width, + int height, + int bpc, + int pass, + int* color_type, + double* gamma) { CCodec_ProgressiveDecoder* pCodec = (CCodec_ProgressiveDecoder*)pModule; if (!pCodec->m_pDeviceBitmap) { pCodec->m_SrcWidth = width; @@ -381,14 +380,14 @@ FX_BOOL CCodec_ProgressiveDecoder::PngReadHeaderFunc(void* pModule, break; } pCodec->m_clipBox = FX_RECT(0, 0, width, height); - return FALSE; + return false; } FXDIB_Format format = pCodec->m_pDeviceBitmap->GetFormat(); switch (format) { case FXDIB_1bppMask: case FXDIB_1bppRgb: - ASSERT(FALSE); - return FALSE; + ASSERT(false); + return false; case FXDIB_8bppMask: case FXDIB_8bppRgb: *color_type = 0; @@ -401,21 +400,21 @@ FX_BOOL CCodec_ProgressiveDecoder::PngReadHeaderFunc(void* pModule, *color_type = 6; break; default: - ASSERT(FALSE); - return FALSE; + ASSERT(false); + return false; } *gamma = kPngGamma; - return TRUE; + return true; } -FX_BOOL CCodec_ProgressiveDecoder::PngAskScanlineBufFunc(void* pModule, - int line, - uint8_t*& src_buf) { +bool CCodec_ProgressiveDecoder::PngAskScanlineBufFunc(void* pModule, + int line, + uint8_t*& src_buf) { CCodec_ProgressiveDecoder* pCodec = (CCodec_ProgressiveDecoder*)pModule; CFX_DIBitmap* pDIBitmap = pCodec->m_pDeviceBitmap; if (!pDIBitmap) { ASSERT(false); - return FALSE; + return false; } if (line >= pCodec->m_clipBox.top && line < pCodec->m_clipBox.bottom) { double scale_y = @@ -440,12 +439,12 @@ FX_BOOL CCodec_ProgressiveDecoder::PngAskScanlineBufFunc(void* pModule, switch (pDIBitmap->GetFormat()) { case FXDIB_1bppMask: case FXDIB_1bppRgb: - ASSERT(FALSE); - return FALSE; + ASSERT(false); + return false; case FXDIB_8bppMask: case FXDIB_8bppRgb: { if (pDIBitmap->GetPalette()) { - return FALSE; + return false; } uint32_t des_g = 0; des_g += pPixelWeights->m_Weights[0] * src_scan[src_col]; @@ -476,11 +475,11 @@ FX_BOOL CCodec_ProgressiveDecoder::PngAskScanlineBufFunc(void* pModule, *pDes = *p; } break; default: - return FALSE; + return false; } } } - return TRUE; + return true; } void CCodec_ProgressiveDecoder::PngOneOneMapResampleHorz( @@ -500,7 +499,7 @@ void CCodec_ProgressiveDecoder::PngOneOneMapResampleHorz( switch (pDeviceBitmap->GetFormat()) { case FXDIB_1bppMask: case FXDIB_1bppRgb: - ASSERT(FALSE); + ASSERT(false); return; case FXDIB_8bppMask: case FXDIB_8bppRgb: { @@ -585,11 +584,11 @@ void CCodec_ProgressiveDecoder::PngFillScanlineBufCompletedFunc(void* pModule, } } -FX_BOOL CCodec_ProgressiveDecoder::GifReadMoreData(CCodec_GifModule* pGifModule, - FXCODEC_STATUS& err_status) { +bool CCodec_ProgressiveDecoder::GifReadMoreData(CCodec_GifModule* pGifModule, + FXCODEC_STATUS& err_status) { uint32_t dwSize = (uint32_t)m_pFile->GetSize(); if (dwSize <= m_offSet) { - return FALSE; + return false; } dwSize = dwSize - m_offSet; uint32_t dwAvail = pGifModule->GetAvailInput(m_pGifContext, nullptr); @@ -602,7 +601,7 @@ FX_BOOL CCodec_ProgressiveDecoder::GifReadMoreData(CCodec_GifModule* pGifModule, m_pSrcBuf = FX_Realloc(uint8_t, m_pSrcBuf, m_SrcSize); if (!m_pSrcBuf) { err_status = FXCODEC_STATUS_ERR_MEMORY; - return FALSE; + return false; } } else { uint32_t dwConsume = m_SrcSize - dwAvail; @@ -615,11 +614,11 @@ FX_BOOL CCodec_ProgressiveDecoder::GifReadMoreData(CCodec_GifModule* pGifModule, } if (!m_pFile->ReadBlock(m_pSrcBuf + dwAvail, m_offSet, dwSize)) { err_status = FXCODEC_STATUS_ERR_READ; - return FALSE; + return false; } m_offSet += dwSize; pGifModule->Input(m_pGifContext, m_pSrcBuf, dwSize + dwAvail); - return TRUE; + return true; } void CCodec_ProgressiveDecoder::GifRecordCurrentPositionCallback( @@ -638,23 +637,23 @@ uint8_t* CCodec_ProgressiveDecoder::GifAskLocalPaletteBufCallback( return FX_Alloc(uint8_t, pal_size); } -FX_BOOL CCodec_ProgressiveDecoder::GifInputRecordPositionBufCallback( +bool CCodec_ProgressiveDecoder::GifInputRecordPositionBufCallback( 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, + bool user_input, int32_t trans_index, int32_t disposal_method, - FX_BOOL interlace) { + bool interlace) { CCodec_ProgressiveDecoder* pCodec = (CCodec_ProgressiveDecoder*)pModule; pCodec->m_offSet = rcd_pos; FXCODEC_STATUS error_status = FXCODEC_STATUS_ERROR; if (!pCodec->GifReadMoreData(pCodec->m_pCodecMgr->GetGifModule(), error_status)) { - return FALSE; + return false; } uint8_t* pPalette = nullptr; if (pal_num != 0 && pal_ptr) { @@ -669,7 +668,7 @@ FX_BOOL CCodec_ProgressiveDecoder::GifInputRecordPositionBufCallback( pCodec->m_pSrcPalette = FX_Realloc(FX_ARGB, pCodec->m_pSrcPalette, pal_num); } if (!pCodec->m_pSrcPalette) - return FALSE; + return false; pCodec->m_SrcPaletteNumber = pal_num; for (int i = 0; i < pal_num; i++) { @@ -725,7 +724,7 @@ FX_BOOL CCodec_ProgressiveDecoder::GifInputRecordPositionBufCallback( } } } - return TRUE; + return true; } void CCodec_ProgressiveDecoder::GifReadScanlineCallback(void* pModule, @@ -875,11 +874,11 @@ void CCodec_ProgressiveDecoder::GifDoubleLineResampleVert( } } -FX_BOOL CCodec_ProgressiveDecoder::BmpReadMoreData(CCodec_BmpModule* pBmpModule, - FXCODEC_STATUS& err_status) { +bool CCodec_ProgressiveDecoder::BmpReadMoreData(CCodec_BmpModule* pBmpModule, + FXCODEC_STATUS& err_status) { uint32_t dwSize = (uint32_t)m_pFile->GetSize(); if (dwSize <= m_offSet) - return FALSE; + return false; dwSize = dwSize - m_offSet; uint32_t dwAvail = pBmpModule->GetAvailInput(m_pBmpContext, nullptr); @@ -892,7 +891,7 @@ FX_BOOL CCodec_ProgressiveDecoder::BmpReadMoreData(CCodec_BmpModule* pBmpModule, m_pSrcBuf = FX_Realloc(uint8_t, m_pSrcBuf, m_SrcSize); if (!m_pSrcBuf) { err_status = FXCODEC_STATUS_ERR_MEMORY; - return FALSE; + return false; } } else { uint32_t dwConsume = m_SrcSize - dwAvail; @@ -905,14 +904,14 @@ FX_BOOL CCodec_ProgressiveDecoder::BmpReadMoreData(CCodec_BmpModule* pBmpModule, } if (!m_pFile->ReadBlock(m_pSrcBuf + dwAvail, m_offSet, dwSize)) { err_status = FXCODEC_STATUS_ERR_READ; - return FALSE; + return false; } m_offSet += dwSize; pBmpModule->Input(m_pBmpContext, m_pSrcBuf, dwSize + dwAvail); - return TRUE; + return true; } -FX_BOOL CCodec_ProgressiveDecoder::BmpInputImagePositionBufCallback( +bool CCodec_ProgressiveDecoder::BmpInputImagePositionBufCallback( void* pModule, uint32_t rcd_pos) { CCodec_ProgressiveDecoder* pCodec = (CCodec_ProgressiveDecoder*)pModule; @@ -1039,9 +1038,8 @@ void CCodec_ProgressiveDecoder::ResampleVertBT(CFX_DIBitmap* pDeviceBitmap, } } -FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( - FXCODEC_IMAGE_TYPE imageType, - CFX_DIBAttribute* pAttribute) { +bool CCodec_ProgressiveDecoder::DetectImageType(FXCODEC_IMAGE_TYPE imageType, + CFX_DIBAttribute* pAttribute) { m_offSet = 0; uint32_t size = (uint32_t)m_pFile->GetSize(); if (size > FXCODEC_BLOCK_SIZE) { @@ -1056,7 +1054,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( CCodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule(); if (!pBmpModule) { m_status = FXCODEC_STATUS_ERR_MEMORY; - return FALSE; + return false; } pBmpModule->InputImagePositionBufCallback = BmpInputImagePositionBufCallback; @@ -1064,12 +1062,12 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( m_pBmpContext = pBmpModule->Start((void*)this); if (!m_pBmpContext) { m_status = FXCODEC_STATUS_ERR_MEMORY; - return FALSE; + return false; } - FX_BOOL bResult = m_pFile->ReadBlock(m_pSrcBuf, 0, size); + bool bResult = m_pFile->ReadBlock(m_pSrcBuf, 0, size); if (!bResult) { m_status = FXCODEC_STATUS_ERR_READ; - return FALSE; + return false; } m_offSet += size; pBmpModule->Input(m_pBmpContext, m_pSrcBuf, size); @@ -1081,7 +1079,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( FXCODEC_STATUS error_status = FXCODEC_STATUS_ERR_FORMAT; if (!BmpReadMoreData(pBmpModule, error_status)) { m_status = error_status; - return FALSE; + return false; } readResult = pBmpModule->ReadHeader( m_pBmpContext, &m_SrcWidth, &m_SrcHeight, &m_BmpIsTopBottom, @@ -1098,30 +1096,30 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( } else { m_pSrcPalette = nullptr; } - return TRUE; + return true; } if (m_pBmpContext) { pBmpModule->Finish(m_pBmpContext); m_pBmpContext = nullptr; } m_status = FXCODEC_STATUS_ERR_FORMAT; - return FALSE; + return false; } case FXCODEC_IMAGE_JPG: { CCodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule(); if (!pJpegModule) { m_status = FXCODEC_STATUS_ERR_MEMORY; - return FALSE; + return false; } m_pJpegContext = pJpegModule->Start(); if (!m_pJpegContext) { m_status = FXCODEC_STATUS_ERR_MEMORY; - return FALSE; + return false; } - FX_BOOL bResult = m_pFile->ReadBlock(m_pSrcBuf, 0, size); + bool bResult = m_pFile->ReadBlock(m_pSrcBuf, 0, size); if (!bResult) { m_status = FXCODEC_STATUS_ERR_READ; - return FALSE; + return false; } m_offSet += size; pJpegModule->Input(m_pJpegContext, m_pSrcBuf, size); @@ -1132,7 +1130,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( FXCODEC_STATUS error_status = FXCODEC_STATUS_ERR_FORMAT; if (!JpegReadMoreData(pJpegModule, error_status)) { m_status = error_status; - return FALSE; + return false; } readResult = pJpegModule->ReadHeader(m_pJpegContext, &m_SrcWidth, &m_SrcHeight, @@ -1141,20 +1139,20 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( if (!readResult) { m_SrcBPC = 8; m_clipBox = FX_RECT(0, 0, m_SrcWidth, m_SrcHeight); - return TRUE; + return true; } if (m_pJpegContext) { pJpegModule->Finish(m_pJpegContext); m_pJpegContext = nullptr; } m_status = FXCODEC_STATUS_ERR_FORMAT; - return FALSE; + return false; } case FXCODEC_IMAGE_PNG: { CCodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule(); if (!pPngModule) { m_status = FXCODEC_STATUS_ERR_MEMORY; - return FALSE; + return false; } pPngModule->ReadHeaderCallback = CCodec_ProgressiveDecoder::PngReadHeaderFunc; @@ -1165,12 +1163,12 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( m_pPngContext = pPngModule->Start((void*)this); if (!m_pPngContext) { m_status = FXCODEC_STATUS_ERR_MEMORY; - return FALSE; + return false; } - FX_BOOL bResult = m_pFile->ReadBlock(m_pSrcBuf, 0, size); + bool bResult = m_pFile->ReadBlock(m_pSrcBuf, 0, size); if (!bResult) { m_status = FXCODEC_STATUS_ERR_READ; - return FALSE; + return false; } m_offSet += size; bResult = pPngModule->Input(m_pPngContext, m_pSrcBuf, size, pAttribute); @@ -1184,7 +1182,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( } m_pPngContext = nullptr; m_status = FXCODEC_STATUS_ERR_FORMAT; - return FALSE; + return false; } if (m_pSrcBuf && input_size > m_SrcSize) { FX_Free(m_pSrcBuf); @@ -1195,7 +1193,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( bResult = m_pFile->ReadBlock(m_pSrcBuf, m_offSet, input_size); if (!bResult) { m_status = FXCODEC_STATUS_ERR_READ; - return FALSE; + return false; } m_offSet += input_size; bResult = @@ -1208,15 +1206,15 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( } if (m_SrcPassNumber == 0) { m_status = FXCODEC_STATUS_ERR_FORMAT; - return FALSE; + return false; } - return TRUE; + return true; } case FXCODEC_IMAGE_GIF: { CCodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule(); if (!pGifModule) { m_status = FXCODEC_STATUS_ERR_MEMORY; - return FALSE; + return false; } pGifModule->RecordCurrentPositionCallback = CCodec_ProgressiveDecoder::GifRecordCurrentPositionCallback; @@ -1229,12 +1227,12 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( m_pGifContext = pGifModule->Start((void*)this); if (!m_pGifContext) { m_status = FXCODEC_STATUS_ERR_MEMORY; - return FALSE; + return false; } - FX_BOOL bResult = m_pFile->ReadBlock(m_pSrcBuf, 0, size); + bool bResult = m_pFile->ReadBlock(m_pSrcBuf, 0, size); if (!bResult) { m_status = FXCODEC_STATUS_ERR_READ; - return FALSE; + return false; } m_offSet += size; pGifModule->Input(m_pGifContext, m_pSrcBuf, size); @@ -1246,7 +1244,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( FXCODEC_STATUS error_status = FXCODEC_STATUS_ERR_FORMAT; if (!GifReadMoreData(pGifModule, error_status)) { m_status = error_status; - return FALSE; + return false; } readResult = pGifModule->ReadHeader( m_pGifContext, &m_SrcWidth, &m_SrcHeight, &m_GifPltNumber, @@ -1255,43 +1253,43 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( if (readResult == 1) { m_SrcBPC = 8; m_clipBox = FX_RECT(0, 0, m_SrcWidth, m_SrcHeight); - return TRUE; + return true; } if (m_pGifContext) { pGifModule->Finish(m_pGifContext); m_pGifContext = nullptr; } m_status = FXCODEC_STATUS_ERR_FORMAT; - return FALSE; + return false; } case FXCODEC_IMAGE_TIF: { CCodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule(); if (!pTiffModule) { m_status = FXCODEC_STATUS_ERR_FORMAT; - return FALSE; + return false; } m_pTiffContext = pTiffModule->CreateDecoder(m_pFile); if (!m_pTiffContext) { m_status = FXCODEC_STATUS_ERR_FORMAT; - return FALSE; + return false; } int32_t dummy_bpc; - FX_BOOL ret = pTiffModule->LoadFrameInfo(m_pTiffContext, 0, &m_SrcWidth, - &m_SrcHeight, &m_SrcComponents, - &dummy_bpc, pAttribute); + bool ret = pTiffModule->LoadFrameInfo(m_pTiffContext, 0, &m_SrcWidth, + &m_SrcHeight, &m_SrcComponents, + &dummy_bpc, pAttribute); m_SrcComponents = 4; m_clipBox = FX_RECT(0, 0, m_SrcWidth, m_SrcHeight); if (!ret) { pTiffModule->DestroyDecoder(m_pTiffContext); m_pTiffContext = nullptr; m_status = FXCODEC_STATUS_ERR_FORMAT; - return FALSE; + return false; } - return TRUE; + return true; } default: m_status = FXCODEC_STATUS_ERR_FORMAT; - return FALSE; + return false; } } @@ -1880,7 +1878,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap, int size_x, int size_y, int32_t frames, - FX_BOOL bInterpol) { + bool bInterpol) { if (m_status != FXCODEC_STATUS_DECODE_READY) return FXCODEC_STATUS_ERROR; @@ -1935,7 +1933,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap, CCodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule(); int down_scale = 1; GetDownScale(down_scale); - FX_BOOL bStart = pJpegModule->StartScanline(m_pJpegContext, down_scale); + bool bStart = pJpegModule->StartScanline(m_pJpegContext, down_scale); while (!bStart) { FXCODEC_STATUS error_status = FXCODEC_STATUS_ERROR; if (!JpegReadMoreData(pJpegModule, error_status)) { @@ -2088,8 +2086,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { case FXCODEC_IMAGE_JPG: { CCodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule(); while (true) { - FX_BOOL readRes = - pJpegModule->ReadScanline(m_pJpegContext, m_pDecodeBuf); + bool readRes = pJpegModule->ReadScanline(m_pJpegContext, m_pDecodeBuf); while (!readRes) { FXCODEC_STATUS error_status = FXCODEC_STATUS_DECODE_FINISH; if (!JpegReadMoreData(pJpegModule, error_status)) { @@ -2140,7 +2137,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { FXSYS_memset(m_pSrcBuf, 0, input_size); m_SrcSize = input_size; } - FX_BOOL bResult = m_pFile->ReadBlock(m_pSrcBuf, m_offSet, input_size); + bool bResult = m_pFile->ReadBlock(m_pSrcBuf, m_offSet, input_size); if (!bResult) { m_pDeviceBitmap = nullptr; m_pFile = nullptr; @@ -2225,7 +2222,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { }; case FXCODEC_IMAGE_TIF: { CCodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule(); - FX_BOOL ret = FALSE; + bool ret = false; if (m_pDeviceBitmap->GetBPP() == 32 && m_pDeviceBitmap->GetWidth() == m_SrcWidth && m_SrcWidth == m_sizeX && m_pDeviceBitmap->GetHeight() == m_SrcHeight && diff --git a/core/fxcodec/fx_codec.h b/core/fxcodec/fx_codec.h index 0fb39413e1..faf74d0902 100644 --- a/core/fxcodec/fx_codec.h +++ b/core/fxcodec/fx_codec.h @@ -117,7 +117,7 @@ void AdobeCMYK_to_sRGB1(uint8_t c, uint8_t& R, uint8_t& G, uint8_t& B); -FX_BOOL MD5ComputeID(const void* buf, uint32_t dwSize, uint8_t ID[16]); +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, diff --git a/core/fxcodec/jbig2/JBig2_BitStream.cpp b/core/fxcodec/jbig2/JBig2_BitStream.cpp index b5dfe92cda..dc4beabc4b 100644 --- a/core/fxcodec/jbig2/JBig2_BitStream.cpp +++ b/core/fxcodec/jbig2/JBig2_BitStream.cpp @@ -73,7 +73,7 @@ int32_t CJBig2_BitStream::read1Bit(uint32_t* dwResult) { return 0; } -int32_t CJBig2_BitStream::read1Bit(FX_BOOL* bResult) { +int32_t CJBig2_BitStream::read1Bit(bool* bResult) { if (!IsInBound()) return -1; diff --git a/core/fxcodec/jbig2/JBig2_BitStream.h b/core/fxcodec/jbig2/JBig2_BitStream.h index 24e8faaf5b..aeb2eba693 100644 --- a/core/fxcodec/jbig2/JBig2_BitStream.h +++ b/core/fxcodec/jbig2/JBig2_BitStream.h @@ -20,7 +20,7 @@ class CJBig2_BitStream { int32_t readNBits(uint32_t nBits, uint32_t* dwResult); int32_t readNBits(uint32_t nBits, int32_t* nResult); int32_t read1Bit(uint32_t* dwResult); - int32_t read1Bit(FX_BOOL* bResult); + int32_t read1Bit(bool* bResult); int32_t read1Byte(uint8_t* cResult); int32_t readInteger(uint32_t* dwResult); int32_t readShortInteger(uint16_t* wResult); diff --git a/core/fxcodec/jbig2/JBig2_Context.cpp b/core/fxcodec/jbig2/JBig2_Context.cpp index c0e40e325d..febd00b463 100644 --- a/core/fxcodec/jbig2/JBig2_Context.cpp +++ b/core/fxcodec/jbig2/JBig2_Context.cpp @@ -377,8 +377,8 @@ int32_t CJBig2_Context::ProcessingParseSegmentData(CJBig2_Segment* pSegment, pPageInfo->m_bIsStriped = !!(wTemp & 0x8000); pPageInfo->m_wMaxStripeSize = wTemp & 0x7fff; bool bMaxHeight = (pPageInfo->m_dwHeight == 0xffffffff); - if (bMaxHeight && pPageInfo->m_bIsStriped != TRUE) - pPageInfo->m_bIsStriped = TRUE; + if (bMaxHeight && pPageInfo->m_bIsStriped != true) + pPageInfo->m_bIsStriped = true; if (!m_bBufSpecified) { uint32_t height = @@ -582,7 +582,7 @@ int32_t CJBig2_Context::parseSymbolDict(CJBig2_Segment* pSegment, CJBig2_CacheKey key = CJBig2_CacheKey(pSegment->m_dwObjNum, pSegment->m_dwDataOffset); - FX_BOOL cache_hit = false; + bool cache_hit = false; pSegment->m_nResultType = JBIG2_SYMBOL_DICT_POINTER; if (m_bIsGlobal && key.first != 0) { for (auto it = m_pSymbolDictCache->begin(); it != m_pSymbolDictCache->end(); diff --git a/core/fxcodec/jbig2/JBig2_GrdProc.h b/core/fxcodec/jbig2/JBig2_GrdProc.h index 3b334b113c..a82aecbf12 100644 --- a/core/fxcodec/jbig2/JBig2_GrdProc.h +++ b/core/fxcodec/jbig2/JBig2_GrdProc.h @@ -34,12 +34,12 @@ class CJBig2_GRDProc { FXCODEC_STATUS Continue_decode(IFX_Pause* pPause); FX_RECT GetReplaceRect() const { return m_ReplaceRect; } - FX_BOOL MMR; + bool MMR; uint32_t GBW; uint32_t GBH; uint8_t GBTEMPLATE; - FX_BOOL TPGDON; - FX_BOOL USESKIP; + bool TPGDON; + bool USESKIP; CJBig2_Image* SKIP; int8_t GBAT[8]; diff --git a/core/fxcodec/jbig2/JBig2_GrrdProc.h b/core/fxcodec/jbig2/JBig2_GrrdProc.h index 1ba0d6add0..bdb49d7e91 100644 --- a/core/fxcodec/jbig2/JBig2_GrrdProc.h +++ b/core/fxcodec/jbig2/JBig2_GrrdProc.h @@ -36,7 +36,7 @@ class CJBig2_GRRDProc { CJBig2_Image* GRREFERENCE; int32_t GRREFERENCEDX; int32_t GRREFERENCEDY; - FX_BOOL TPGRON; + bool TPGRON; int8_t GRAT[4]; }; diff --git a/core/fxcodec/jbig2/JBig2_GsidProc.h b/core/fxcodec/jbig2/JBig2_GsidProc.h index c440ddb2b9..3d5dc2dd4a 100644 --- a/core/fxcodec/jbig2/JBig2_GsidProc.h +++ b/core/fxcodec/jbig2/JBig2_GsidProc.h @@ -24,8 +24,8 @@ class CJBig2_GSIDProc { uint32_t* decode_MMR(CJBig2_BitStream* pStream, IFX_Pause* pPause); public: - FX_BOOL GSMMR; - FX_BOOL GSUSESKIP; + bool GSMMR; + bool GSUSESKIP; uint8_t GSBPP; uint32_t GSW; uint32_t GSH; diff --git a/core/fxcodec/jbig2/JBig2_HtrdProc.h b/core/fxcodec/jbig2/JBig2_HtrdProc.h index 0ff79dcf29..9a9a5c59c4 100644 --- a/core/fxcodec/jbig2/JBig2_HtrdProc.h +++ b/core/fxcodec/jbig2/JBig2_HtrdProc.h @@ -26,13 +26,13 @@ class CJBig2_HTRDProc { public: uint32_t HBW; uint32_t HBH; - FX_BOOL HMMR; + bool HMMR; uint8_t HTEMPLATE; uint32_t HNUMPATS; CJBig2_Image** HPATS; - FX_BOOL HDEFPIXEL; + bool HDEFPIXEL; JBig2ComposeOp HCOMBOP; - FX_BOOL HENABLESKIP; + bool HENABLESKIP; uint32_t HGW; uint32_t HGH; int32_t HGX; diff --git a/core/fxcodec/jbig2/JBig2_Image.cpp b/core/fxcodec/jbig2/JBig2_Image.cpp index f20a1e8a2f..8f935ceb1f 100644 --- a/core/fxcodec/jbig2/JBig2_Image.cpp +++ b/core/fxcodec/jbig2/JBig2_Image.cpp @@ -119,28 +119,28 @@ void CJBig2_Image::copyLine(int32_t hTo, int32_t hFrom) { m_nStride); } } -void CJBig2_Image::fill(FX_BOOL v) { +void CJBig2_Image::fill(bool v) { if (!m_pData) { return; } JBIG2_memset(m_pData, v ? 0xff : 0, m_nStride * m_nHeight); } -FX_BOOL CJBig2_Image::composeTo(CJBig2_Image* pDst, - int32_t x, - int32_t y, - JBig2ComposeOp op) { +bool CJBig2_Image::composeTo(CJBig2_Image* pDst, + int32_t x, + int32_t y, + JBig2ComposeOp op) { if (!m_pData) { - return FALSE; + return false; } return composeTo_opt2(pDst, x, y, op); } -FX_BOOL CJBig2_Image::composeTo(CJBig2_Image* pDst, - int32_t x, - int32_t y, - JBig2ComposeOp op, - const FX_RECT* pSrcRect) { +bool CJBig2_Image::composeTo(CJBig2_Image* pDst, + int32_t x, + int32_t y, + JBig2ComposeOp op, + const FX_RECT* pSrcRect) { if (!m_pData) - return FALSE; + return false; if (!pSrcRect || *pSrcRect == FX_RECT(0, 0, m_nWidth, m_nHeight)) return composeTo_opt2(pDst, x, y, op); @@ -148,22 +148,22 @@ FX_BOOL CJBig2_Image::composeTo(CJBig2_Image* pDst, return composeTo_opt2(pDst, x, y, op, pSrcRect); } -FX_BOOL CJBig2_Image::composeFrom(int32_t x, - int32_t y, - CJBig2_Image* pSrc, - JBig2ComposeOp op) { +bool CJBig2_Image::composeFrom(int32_t x, + int32_t y, + CJBig2_Image* pSrc, + JBig2ComposeOp op) { if (!m_pData) { - return FALSE; + return false; } return pSrc->composeTo(this, x, y, op); } -FX_BOOL CJBig2_Image::composeFrom(int32_t x, - int32_t y, - CJBig2_Image* pSrc, - JBig2ComposeOp op, - const FX_RECT* pSrcRect) { +bool CJBig2_Image::composeFrom(int32_t x, + int32_t y, + CJBig2_Image* pSrc, + JBig2ComposeOp op, + const FX_RECT* pSrcRect) { if (!m_pData) { - return FALSE; + return false; } return pSrc->composeTo(this, x, y, op, pSrcRect); } @@ -229,7 +229,7 @@ CJBig2_Image* CJBig2_Image::subImage(int32_t x, return pImage; } -void CJBig2_Image::expand(int32_t h, FX_BOOL v) { +void CJBig2_Image::expand(int32_t h, bool v) { if (!m_pData || h <= m_nHeight || h > kMaxImageBytes / m_nStride) return; @@ -246,10 +246,10 @@ void CJBig2_Image::expand(int32_t h, FX_BOOL v) { m_nHeight = h; } -FX_BOOL CJBig2_Image::composeTo_opt2(CJBig2_Image* pDst, - int32_t x, - int32_t y, - JBig2ComposeOp op) { +bool CJBig2_Image::composeTo_opt2(CJBig2_Image* pDst, + int32_t x, + int32_t y, + JBig2ComposeOp op) { int32_t xs0 = 0, ys0 = 0, xs1 = 0, ys1 = 0, xd0 = 0, yd0 = 0, xd1 = 0, yd1 = 0, xx = 0, yy = 0, w = 0, h = 0, middleDwords = 0, lineLeft = 0; @@ -257,10 +257,10 @@ FX_BOOL CJBig2_Image::composeTo_opt2(CJBig2_Image* pDst, tmp1 = 0, tmp2 = 0, maskL = 0, maskR = 0, maskM = 0; if (!m_pData) - return FALSE; + return false; if (x < -1048576 || x > 1048576 || y < -1048576 || y > 1048576) - return FALSE; + return false; if (y < 0) { ys0 = -y; @@ -674,17 +674,17 @@ FX_BOOL CJBig2_Image::composeTo_opt2(CJBig2_Image* pDst, } return 1; } -FX_BOOL CJBig2_Image::composeTo_opt2(CJBig2_Image* pDst, - int32_t x, - int32_t y, - JBig2ComposeOp op, - const FX_RECT* pSrcRect) { +bool CJBig2_Image::composeTo_opt2(CJBig2_Image* pDst, + int32_t x, + int32_t y, + JBig2ComposeOp op, + const FX_RECT* pSrcRect) { if (!m_pData) { - return FALSE; + return false; } // TODO(weili): Check whether the range check is correct. Should x>=1048576? if (x < -1048576 || x > 1048576 || y < -1048576 || y > 1048576) { - return FALSE; + return false; } int32_t sw = pSrcRect->Width(); int32_t sh = pSrcRect->Height(); diff --git a/core/fxcodec/jbig2/JBig2_Image.h b/core/fxcodec/jbig2/JBig2_Image.h index 695420d76c..54529ef868 100644 --- a/core/fxcodec/jbig2/JBig2_Image.h +++ b/core/fxcodec/jbig2/JBig2_Image.h @@ -34,40 +34,34 @@ class CJBig2_Image { int32_t setPixel(int32_t x, int32_t y, int bVal); void copyLine(int32_t hTo, int32_t hFrom); - void fill(FX_BOOL v); - - FX_BOOL composeTo(CJBig2_Image* pDst, - int32_t x, - int32_t y, - JBig2ComposeOp op); - FX_BOOL composeTo(CJBig2_Image* pDst, - int32_t x, - int32_t y, - JBig2ComposeOp op, - const FX_RECT* pSrcRect); - - FX_BOOL composeTo_opt2(CJBig2_Image* pDst, - int32_t x, - int32_t y, - JBig2ComposeOp op); - FX_BOOL composeTo_opt2(CJBig2_Image* pDst, - int32_t x, - int32_t y, - JBig2ComposeOp op, - const FX_RECT* pSrcRect); - - FX_BOOL composeFrom(int32_t x, + void fill(bool v); + + bool composeTo(CJBig2_Image* pDst, int32_t x, int32_t y, JBig2ComposeOp op); + bool composeTo(CJBig2_Image* pDst, + int32_t x, + int32_t y, + JBig2ComposeOp op, + const FX_RECT* pSrcRect); + + bool composeTo_opt2(CJBig2_Image* pDst, + int32_t x, int32_t y, - CJBig2_Image* pSrc, JBig2ComposeOp op); - FX_BOOL composeFrom(int32_t x, + bool composeTo_opt2(CJBig2_Image* pDst, + int32_t x, int32_t y, - CJBig2_Image* pSrc, JBig2ComposeOp op, const FX_RECT* pSrcRect); + bool composeFrom(int32_t x, int32_t y, CJBig2_Image* pSrc, JBig2ComposeOp op); + bool composeFrom(int32_t x, + int32_t y, + CJBig2_Image* pSrc, + JBig2ComposeOp op, + const FX_RECT* pSrcRect); + CJBig2_Image* subImage(int32_t x, int32_t y, int32_t w, int32_t h); - void expand(int32_t h, FX_BOOL v); + void expand(int32_t h, bool v); uint8_t* m_pData; diff --git a/core/fxcodec/jbig2/JBig2_Page.h b/core/fxcodec/jbig2/JBig2_Page.h index 131d6c8ba7..064b9b3545 100644 --- a/core/fxcodec/jbig2/JBig2_Page.h +++ b/core/fxcodec/jbig2/JBig2_Page.h @@ -15,7 +15,7 @@ struct JBig2PageInfo { uint32_t m_dwResolutionX; uint32_t m_dwResolutionY; uint8_t m_cFlags; - FX_BOOL m_bIsStriped; + bool m_bIsStriped; uint16_t m_wMaxStripeSize; }; diff --git a/core/fxcodec/jbig2/JBig2_PddProc.h b/core/fxcodec/jbig2/JBig2_PddProc.h index 93b2d350c1..578f603122 100644 --- a/core/fxcodec/jbig2/JBig2_PddProc.h +++ b/core/fxcodec/jbig2/JBig2_PddProc.h @@ -24,7 +24,7 @@ class CJBig2_PDDProc { CJBig2_PatternDict* decode_MMR(CJBig2_BitStream* pStream, IFX_Pause* pPause); public: - FX_BOOL HDMMR; + bool HDMMR; uint8_t HDPW; uint8_t HDPH; uint32_t GRAYMAX; diff --git a/core/fxcodec/jbig2/JBig2_SddProc.cpp b/core/fxcodec/jbig2/JBig2_SddProc.cpp index f6afb13497..7e9ace2046 100644 --- a/core/fxcodec/jbig2/JBig2_SddProc.cpp +++ b/core/fxcodec/jbig2/JBig2_SddProc.cpp @@ -30,9 +30,9 @@ CJBig2_SymbolDict* CJBig2_SDDProc::decode_Arith( int32_t DW; CJBig2_Image* BS; uint32_t I, J, REFAGGNINST; - FX_BOOL* EXFLAGS; + bool* EXFLAGS; uint32_t EXINDEX; - FX_BOOL CUREXFLAG; + bool CUREXFLAG; uint32_t EXRUNLENGTH; uint32_t nTmp; uint32_t SBNUMSYMS; @@ -235,7 +235,7 @@ CJBig2_SymbolDict* CJBig2_SDDProc::decode_Arith( } EXINDEX = 0; CUREXFLAG = 0; - EXFLAGS = FX_Alloc(FX_BOOL, SDNUMINSYMS + SDNUMNEWSYMS); + EXFLAGS = FX_Alloc(bool, SDNUMINSYMS + SDNUMNEWSYMS); num_ex_syms = 0; while (EXINDEX < SDNUMINSYMS + SDNUMNEWSYMS) { IAEX->decode(pArithDecoder, (int*)&EXRUNLENGTH); @@ -299,9 +299,9 @@ CJBig2_SymbolDict* CJBig2_SDDProc::decode_Huffman( int32_t DW; CJBig2_Image *BS, *BHC; uint32_t I, J, REFAGGNINST; - FX_BOOL* EXFLAGS; + bool* EXFLAGS; uint32_t EXINDEX; - FX_BOOL CUREXFLAG; + bool CUREXFLAG; uint32_t EXRUNLENGTH; int32_t nVal, nBits; uint32_t nTmp; @@ -564,7 +564,7 @@ CJBig2_SymbolDict* CJBig2_SDDProc::decode_Huffman( CUREXFLAG = 0; pTable.reset(new CJBig2_HuffmanTable(HuffmanTable_B1, HuffmanTable_B1_Size, HuffmanTable_HTOOB_B1)); - EXFLAGS = FX_Alloc(FX_BOOL, SDNUMINSYMS + SDNUMNEWSYMS); + EXFLAGS = FX_Alloc(bool, SDNUMINSYMS + SDNUMNEWSYMS); num_ex_syms = 0; while (EXINDEX < SDNUMINSYMS + SDNUMNEWSYMS) { if (pHuffmanDecoder->decodeAValue(pTable.get(), (int*)&EXRUNLENGTH) != 0) { diff --git a/core/fxcodec/jbig2/JBig2_SddProc.h b/core/fxcodec/jbig2/JBig2_SddProc.h index fa799cb83f..4df0cb4146 100644 --- a/core/fxcodec/jbig2/JBig2_SddProc.h +++ b/core/fxcodec/jbig2/JBig2_SddProc.h @@ -30,8 +30,8 @@ class CJBig2_SDDProc { IFX_Pause* pPause); public: - FX_BOOL SDHUFF; - FX_BOOL SDREFAGG; + bool SDHUFF; + bool SDREFAGG; uint32_t SDNUMINSYMS; CJBig2_Image** SDINSYMS; uint32_t SDNUMNEWSYMS; diff --git a/core/fxcodec/jbig2/JBig2_TrdProc.cpp b/core/fxcodec/jbig2/JBig2_TrdProc.cpp index f3dd6be2b3..ccd8ebf98d 100644 --- a/core/fxcodec/jbig2/JBig2_TrdProc.cpp +++ b/core/fxcodec/jbig2/JBig2_TrdProc.cpp @@ -89,7 +89,7 @@ CJBig2_Image* CJBig2_TRDProc::decode_Huffman(CJBig2_BitStream* pStream, break; } } - FX_BOOL RI = 0; + bool RI = 0; if (SBREFINE != 0 && pStream->read1Bit(&RI) != 0) { return nullptr; } diff --git a/core/fxcodec/jbig2/JBig2_TrdProc.h b/core/fxcodec/jbig2/JBig2_TrdProc.h index 9429a6a738..be50ec152f 100644 --- a/core/fxcodec/jbig2/JBig2_TrdProc.h +++ b/core/fxcodec/jbig2/JBig2_TrdProc.h @@ -47,8 +47,8 @@ class CJBig2_TRDProc { JBig2ArithCtx* grContext, JBig2IntDecoderState* pIDS); - FX_BOOL SBHUFF; - FX_BOOL SBREFINE; + bool SBHUFF; + bool SBREFINE; uint32_t SBW; uint32_t SBH; uint32_t SBNUMINSTANCES; @@ -59,10 +59,10 @@ class CJBig2_TRDProc { uint8_t SBSYMCODELEN; CJBig2_Image** SBSYMS; - FX_BOOL SBDEFPIXEL; + bool SBDEFPIXEL; JBig2ComposeOp SBCOMBOP; - FX_BOOL TRANSPOSED; + bool TRANSPOSED; JBig2Corner REFCORNER; int8_t SBDSOFFSET; diff --git a/core/fxcodec/lbmp/fx_bmp.cpp b/core/fxcodec/lbmp/fx_bmp.cpp index b7f20666d8..9105c6ed9c 100644 --- a/core/fxcodec/lbmp/fx_bmp.cpp +++ b/core/fxcodec/lbmp/fx_bmp.cpp @@ -105,7 +105,7 @@ int32_t bmp_read_header(bmp_decompress_struct_p bmp_ptr) { bmp_ptr->bitCounts = GetWord_LSBFirst((uint8_t*)&bmp_core_header_ptr->bcBitCount); bmp_ptr->compress_flag = BMP_RGB; - bmp_ptr->imgTB_flag = FALSE; + bmp_ptr->imgTB_flag = false; } break; case kBmpInfoHeaderSize: { BmpInfoHeaderPtr bmp_info_header_ptr = nullptr; @@ -130,7 +130,7 @@ int32_t bmp_read_header(bmp_decompress_struct_p bmp_ptr) { (uint8_t*)&bmp_info_header_ptr->biYPelsPerMeter); if (bmp_ptr->height < 0) { bmp_ptr->height = -bmp_ptr->height; - bmp_ptr->imgTB_flag = TRUE; + bmp_ptr->imgTB_flag = true; } } break; default: { @@ -160,7 +160,7 @@ int32_t bmp_read_header(bmp_decompress_struct_p bmp_ptr) { (uint8_t*)&bmp_info_header_ptr->biYPelsPerMeter); if (bmp_ptr->height < 0) { bmp_ptr->height = -bmp_ptr->height; - bmp_ptr->imgTB_flag = TRUE; + bmp_ptr->imgTB_flag = true; } if (bmp_ptr->compress_flag == BMP_RGB && biPlanes == 1 && bmp_ptr->color_used == 0) { @@ -390,7 +390,7 @@ int32_t bmp_decode_rle8(bmp_decompress_struct_p bmp_ptr) { uint8_t* first_byte_ptr = nullptr; uint8_t* second_byte_ptr = nullptr; bmp_ptr->col_num = 0; - while (TRUE) { + while (true) { uint32_t skip_size_org = bmp_ptr->skip_size; if (!bmp_read_data(bmp_ptr, &first_byte_ptr, 1)) return 2; @@ -492,7 +492,7 @@ int32_t bmp_decode_rle4(bmp_decompress_struct_p bmp_ptr) { uint8_t* first_byte_ptr = nullptr; uint8_t* second_byte_ptr = nullptr; bmp_ptr->col_num = 0; - while (TRUE) { + while (true) { uint32_t skip_size_org = bmp_ptr->skip_size; if (!bmp_read_data(bmp_ptr, &first_byte_ptr, 1)) return 2; @@ -896,9 +896,9 @@ static void bmp_encode_rle4(bmp_compress_struct_p bmp_ptr, dst_buf[dst_pos++] = RLE_EOI; dst_size = dst_pos; } -FX_BOOL bmp_encode_image(bmp_compress_struct_p bmp_ptr, - uint8_t*& dst_buf, - uint32_t& dst_size) { +bool bmp_encode_image(bmp_compress_struct_p bmp_ptr, + uint8_t*& dst_buf, + uint32_t& dst_size) { uint32_t head_size = sizeof(BmpFileHeader) + sizeof(BmpInfoHeader); uint32_t pal_size = sizeof(uint32_t) * bmp_ptr->pal_num; if (bmp_ptr->info_header.biClrUsed > 0 && @@ -908,7 +908,7 @@ FX_BOOL bmp_encode_image(bmp_compress_struct_p bmp_ptr, dst_size = head_size + sizeof(uint32_t) * bmp_ptr->pal_num; dst_buf = FX_TryAlloc(uint8_t, dst_size); if (!dst_buf) - return FALSE; + return false; FXSYS_memset(dst_buf, 0, dst_size); bmp_ptr->file_header.bfOffBits = head_size; @@ -935,5 +935,5 @@ FX_BOOL bmp_encode_image(bmp_compress_struct_p bmp_ptr, } bmp_ptr->file_header.bfSize = dst_size; WriteFileHeader(&bmp_ptr->file_header, dst_buf); - return TRUE; + return true; } diff --git a/core/fxcodec/lbmp/fx_bmp.h b/core/fxcodec/lbmp/fx_bmp.h index dfaf2859ef..27a0f19970 100644 --- a/core/fxcodec/lbmp/fx_bmp.h +++ b/core/fxcodec/lbmp/fx_bmp.h @@ -84,7 +84,7 @@ struct tag_bmp_decompress_struct { uint8_t* out_row_buffer; uint16_t bitCounts; uint32_t color_used; - FX_BOOL imgTB_flag; + bool imgTB_flag; int32_t pal_num; int32_t pal_type; uint32_t* pal_ptr; @@ -99,8 +99,8 @@ struct tag_bmp_decompress_struct { uint32_t mask_green; uint32_t mask_blue; - FX_BOOL (*bmp_get_data_position_fn)(bmp_decompress_struct_p bmp_ptr, - uint32_t cur_pos); + bool (*bmp_get_data_position_fn)(bmp_decompress_struct_p bmp_ptr, + uint32_t cur_pos); void (*bmp_get_row_fn)(bmp_decompress_struct_p bmp_ptr, int32_t row_num, uint8_t* row_buf); @@ -137,7 +137,7 @@ struct tag_bmp_compress_struct { uint32_t src_row; uint8_t src_bpp; uint32_t src_width; - FX_BOOL src_free; + bool src_free; uint32_t* pal_ptr; uint16_t pal_num; uint8_t bit_type; @@ -145,9 +145,9 @@ struct tag_bmp_compress_struct { bmp_compress_struct_p bmp_create_compress(); void bmp_destroy_compress(bmp_compress_struct_p bmp_ptr); -FX_BOOL bmp_encode_image(bmp_compress_struct_p bmp_ptr, - uint8_t*& dst_buf, - uint32_t& dst_size); +bool bmp_encode_image(bmp_compress_struct_p bmp_ptr, + uint8_t*& dst_buf, + uint32_t& dst_size); uint16_t GetWord_LSBFirst(uint8_t* p); void SetWord_LSBFirst(uint8_t* p, uint16_t v); diff --git a/core/fxcodec/lgif/fx_gif.cpp b/core/fxcodec/lgif/fx_gif.cpp index 08b008ddb4..b996ba9796 100644 --- a/core/fxcodec/lgif/fx_gif.cpp +++ b/core/fxcodec/lgif/fx_gif.cpp @@ -58,7 +58,7 @@ void CGifLZWDecoder::ClearTable() { } void CGifLZWDecoder::DecodeString(uint16_t code) { stack_size = 0; - while (TRUE) { + while (true) { ASSERT(code <= code_next); if (code < code_clear || code > code_next) { break; @@ -163,9 +163,7 @@ int32_t CGifLZWDecoder::Decode(uint8_t* des_buf, uint32_t& des_size) { } return 0; } -static FX_BOOL gif_grow_buf(uint8_t*& dst_buf, - uint32_t& dst_len, - uint32_t size) { +static bool gif_grow_buf(uint8_t*& dst_buf, uint32_t& dst_len, uint32_t size) { if (dst_len < size) { uint32_t len_org = dst_len; while (dst_buf && dst_len < size) { @@ -180,7 +178,7 @@ static FX_BOOL gif_grow_buf(uint8_t*& dst_buf, FXSYS_memset(dst_buf + len_org, 0, dst_len - len_org); return !!dst_buf; } - return TRUE; + return true; } static inline void gif_cut_index(uint8_t& val, uint32_t index, @@ -318,14 +316,14 @@ void CGifLZWEncoder::EncodeString(uint32_t index, index_bit_cur++; } } -FX_BOOL CGifLZWEncoder::Encode(const uint8_t* src_buf, - uint32_t src_len, - uint8_t*& dst_buf, - uint32_t& dst_len, - uint32_t& offset) { +bool CGifLZWEncoder::Encode(const uint8_t* src_buf, + uint32_t src_len, + uint8_t*& dst_buf, + uint32_t& dst_len, + uint32_t& offset) { uint8_t suffix; if (setjmp(jmp)) { - return FALSE; + return false; } while (src_bit_num < src_len) { if (!LookUpInTable(src_buf, src_offset, src_bit_offset)) { @@ -347,11 +345,11 @@ FX_BOOL CGifLZWEncoder::Encode(const uint8_t* src_buf, src_offset = 0; src_bit_offset = 0; src_bit_num = 0; - return TRUE; + return true; } -FX_BOOL CGifLZWEncoder::LookUpInTable(const uint8_t* buf, - uint32_t& offset, - uint8_t& out_bit_offset) { +bool CGifLZWEncoder::LookUpInTable(const uint8_t* buf, + uint32_t& offset, + uint8_t& out_bit_offset) { for (uint16_t i = table_cur; i < index_num; i++) { if (code_table[i].prefix == code_table[index_num].prefix && code_table[i].suffix == code_table[index_num].suffix) { @@ -359,11 +357,11 @@ FX_BOOL CGifLZWEncoder::LookUpInTable(const uint8_t* buf, code_table[index_num].suffix = gif_cut_buf(buf, offset, src_bit_cut, out_bit_offset, src_bit_num); table_cur = i; - return TRUE; + return true; } } table_cur = code_end + 1; - return FALSE; + return false; } void CGifLZWEncoder::Finish(uint8_t*& dst_buf, uint32_t& dst_len, @@ -554,7 +552,7 @@ int32_t gif_get_frame(gif_decompress_struct_p gif_ptr) { return 0; int32_t ret = 1; - while (TRUE) { + while (true) { switch (gif_ptr->decode_status) { case GIF_D_STATUS_TAIL: return 1; @@ -859,14 +857,14 @@ int32_t gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) { : 0; gif_ptr->avail_in = 0; if (!gif_img_gce_ptr) { - FX_BOOL bRes = gif_ptr->gif_get_record_position_fn( + bool bRes = gif_ptr->gif_get_record_position_fn( gif_ptr, gif_image_ptr->image_data_pos, gif_image_ptr->image_info_ptr->left, gif_image_ptr->image_info_ptr->top, gif_image_ptr->image_info_ptr->width, gif_image_ptr->image_info_ptr->height, loc_pal_num, gif_image_ptr->local_pal_ptr, 0, 0, -1, 0, - (FX_BOOL)((GifLF*)&gif_image_ptr->image_info_ptr->local_flag) + (bool)((GifLF*)&gif_image_ptr->image_info_ptr->local_flag) ->interlace); if (!bRes) { FX_Free(gif_image_ptr->image_row_buf); @@ -875,7 +873,7 @@ int32_t gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) { return 0; } } else { - FX_BOOL bRes = gif_ptr->gif_get_record_position_fn( + bool bRes = gif_ptr->gif_get_record_position_fn( gif_ptr, gif_image_ptr->image_data_pos, gif_image_ptr->image_info_ptr->left, gif_image_ptr->image_info_ptr->top, @@ -883,14 +881,13 @@ int32_t gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) { gif_image_ptr->image_info_ptr->height, loc_pal_num, gif_image_ptr->local_pal_ptr, (int32_t)gif_image_ptr->image_gce_ptr->delay_time, - (FX_BOOL)((GifCEF*)&gif_image_ptr->image_gce_ptr->gce_flag) - ->user_input, + (bool)((GifCEF*)&gif_image_ptr->image_gce_ptr->gce_flag)->user_input, ((GifCEF*)&gif_image_ptr->image_gce_ptr->gce_flag)->transparency ? (int32_t)gif_image_ptr->image_gce_ptr->trans_index : -1, (int32_t)((GifCEF*)&gif_image_ptr->image_gce_ptr->gce_flag) ->disposal_method, - (FX_BOOL)((GifLF*)&gif_image_ptr->image_info_ptr->local_flag) + (bool)((GifLF*)&gif_image_ptr->image_info_ptr->local_flag) ->interlace); if (!bRes) { FX_Free(gif_image_ptr->image_row_buf); @@ -1039,16 +1036,16 @@ uint32_t gif_get_avail_input(gif_decompress_struct_p gif_ptr, int32_t gif_get_frame_num(gif_decompress_struct_p gif_ptr) { return gif_ptr->img_ptr_arr_ptr->GetSize(); } -static FX_BOOL gif_write_header(gif_compress_struct_p gif_ptr, - uint8_t*& dst_buf, - uint32_t& dst_len) { +static bool gif_write_header(gif_compress_struct_p gif_ptr, + uint8_t*& dst_buf, + uint32_t& dst_len) { if (gif_ptr->cur_offset) { - return TRUE; + return true; } dst_len = sizeof(GifHeader) + sizeof(GifLSD) + sizeof(GifGF); dst_buf = FX_TryAlloc(uint8_t, dst_len); if (!dst_buf) - return FALSE; + return false; FXSYS_memset(dst_buf, 0, dst_len); FXSYS_memcpy(dst_buf, gif_ptr->header_ptr, sizeof(GifHeader)); @@ -1063,12 +1060,12 @@ static FX_BOOL gif_write_header(gif_compress_struct_p gif_ptr, if (gif_ptr->global_pal) { uint16_t size = sizeof(GifPalette) * gif_ptr->gpal_num; if (!gif_grow_buf(dst_buf, dst_len, gif_ptr->cur_offset + size)) { - return FALSE; + return false; } FXSYS_memcpy(&dst_buf[gif_ptr->cur_offset], gif_ptr->global_pal, size); gif_ptr->cur_offset += size; } - return TRUE; + return true; } void interlace_buf(const uint8_t* buf, uint32_t pitch, uint32_t height) { CFX_ArrayTemplate pass[4]; @@ -1115,11 +1112,11 @@ static void gif_write_block_data(const uint8_t* src_buf, FXSYS_memcpy(&dst_buf[dst_offset], &src_buf[src_offset], src_len); dst_offset += src_len; } -static FX_BOOL gif_write_data(gif_compress_struct_p gif_ptr, - uint8_t*& dst_buf, - uint32_t& dst_len) { +static bool gif_write_data(gif_compress_struct_p gif_ptr, + uint8_t*& dst_buf, + uint32_t& dst_len) { if (!gif_grow_buf(dst_buf, dst_len, gif_ptr->cur_offset + GIF_DATA_BLOCK)) { - return FALSE; + return false; } if (FXSYS_memcmp(gif_ptr->header_ptr->version, "89a", 3) == 0) { dst_buf[gif_ptr->cur_offset++] = GIF_SIG_EXTENSION; @@ -1153,7 +1150,7 @@ static FX_BOOL gif_write_data(gif_compress_struct_p gif_ptr, if (gif_ptr->local_pal) { uint32_t pal_size = sizeof(GifPalette) * gif_ptr->lpal_num; if (!gif_grow_buf(dst_buf, dst_len, pal_size + gif_ptr->cur_offset)) { - return FALSE; + return false; } FXSYS_memcpy(&dst_buf[gif_ptr->cur_offset], gif_ptr->local_pal, pal_size); gif_ptr->cur_offset += pal_size; @@ -1175,7 +1172,7 @@ static FX_BOOL gif_write_data(gif_compress_struct_p gif_ptr, &gif_ptr->src_buf[i * gif_ptr->src_pitch], gif_ptr->src_width * (code_bit + 1), dst_buf, dst_len, gif_ptr->cur_offset)) { - return FALSE; + return false; } } gif_ptr->img_encoder_ptr->Finish(dst_buf, dst_len, gif_ptr->cur_offset); @@ -1220,22 +1217,22 @@ static FX_BOOL gif_write_data(gif_compress_struct_p gif_ptr, dst_buf[gif_ptr->cur_offset++] = 0; } dst_buf[gif_ptr->cur_offset++] = GIF_SIG_TRAILER; - return TRUE; + return true; } -FX_BOOL gif_encode(gif_compress_struct_p gif_ptr, - uint8_t*& dst_buf, - uint32_t& dst_len) { +bool gif_encode(gif_compress_struct_p gif_ptr, + uint8_t*& dst_buf, + uint32_t& dst_len) { if (!gif_write_header(gif_ptr, dst_buf, dst_len)) { - return FALSE; + return false; } uint32_t cur_offset = gif_ptr->cur_offset; - FX_BOOL res = TRUE; + bool res = true; if (gif_ptr->frames) { gif_ptr->cur_offset--; } if (!gif_write_data(gif_ptr, dst_buf, dst_len)) { gif_ptr->cur_offset = cur_offset; - res = FALSE; + res = false; } dst_len = gif_ptr->cur_offset; dst_buf[dst_len - 1] = GIF_SIG_TRAILER; diff --git a/core/fxcodec/lgif/fx_gif.h b/core/fxcodec/lgif/fx_gif.h index 2a40995bbe..eb5f85a187 100644 --- a/core/fxcodec/lgif/fx_gif.h +++ b/core/fxcodec/lgif/fx_gif.h @@ -168,18 +168,16 @@ class CGifLZWEncoder { const uint8_t* src_buf, uint8_t*& dst_buf, uint32_t& offset); - FX_BOOL Encode(const uint8_t* src_buf, - uint32_t src_len, - uint8_t*& dst_buf, - uint32_t& dst_len, - uint32_t& offset); + bool Encode(const uint8_t* src_buf, + uint32_t src_len, + uint8_t*& dst_buf, + uint32_t& dst_len, + uint32_t& offset); void Finish(uint8_t*& dst_buf, uint32_t& dst_len, uint32_t& offset); private: void ClearTable(); - FX_BOOL LookUpInTable(const uint8_t* buf, - uint32_t& offset, - uint8_t& bit_offset); + bool LookUpInTable(const uint8_t* buf, uint32_t& offset, uint8_t& bit_offset); void EncodeString(uint32_t index, uint8_t*& dst_buf, uint32_t& dst_len, @@ -237,12 +235,19 @@ struct tag_gif_decompress_struct { void (*gif_get_row_fn)(gif_decompress_struct_p gif_ptr, int32_t row_num, uint8_t* row_buf); - FX_BOOL (*gif_get_record_position_fn)(gif_decompress_struct_p gif_ptr, - uint32_t cur_pos, - int32_t left, int32_t top, int32_t width, int32_t height, - 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); + bool (*gif_get_record_position_fn)(gif_decompress_struct_p gif_ptr, + uint32_t cur_pos, + int32_t left, + int32_t top, + int32_t width, + int32_t height, + int32_t pal_num, + void* pal_ptr, + int32_t delay_time, + bool user_input, + int32_t trans_index, + int32_t disposal_method, + bool interlace); CFX_ByteString* cmt_data_ptr; GifGCE* gce_ptr; CFX_ArrayTemplate* pt_ptr_arr_ptr; @@ -300,8 +305,8 @@ void gif_input_buffer(gif_decompress_struct_p gif_ptr, uint32_t gif_get_avail_input(gif_decompress_struct_p gif_ptr, uint8_t** avail_buf_ptr); void interlace_buf(const uint8_t* buf, uint32_t width, uint32_t height); -FX_BOOL gif_encode(gif_compress_struct_p gif_ptr, - uint8_t*& dst_buf, - uint32_t& dst_len); +bool gif_encode(gif_compress_struct_p gif_ptr, + uint8_t*& dst_buf, + uint32_t& dst_len); #endif // CORE_FXCODEC_LGIF_FX_GIF_H_ -- cgit v1.2.3