From bb17868d736f698d5217c30d52c5bbfed62c5936 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 9 Jun 2015 11:30:25 -0700 Subject: Use stdint.h types throughout PDFium. It's redundant nowadays to provide our own equivalents, now that this is done for us by the system header. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1177483002 --- core/src/fxcodec/codec/codec_int.h | 24 ++--- core/src/fxcodec/codec/fx_codec.cpp | 20 ++--- core/src/fxcodec/codec/fx_codec_fax.cpp | 48 +++++----- core/src/fxcodec/codec/fx_codec_flate.cpp | 134 ++++++++++++++-------------- core/src/fxcodec/codec/fx_codec_icc.cpp | 44 ++++----- core/src/fxcodec/codec/fx_codec_jbig.cpp | 4 +- core/src/fxcodec/codec/fx_codec_jpeg.cpp | 24 ++--- core/src/fxcodec/codec/fx_codec_jpx_opj.cpp | 8 +- 8 files changed, 153 insertions(+), 153 deletions(-) (limited to 'core/src/fxcodec/codec') diff --git a/core/src/fxcodec/codec/codec_int.h b/core/src/fxcodec/codec/codec_int.h index 2b693e88b6..d39a1fd18a 100644 --- a/core/src/fxcodec/codec/codec_int.h +++ b/core/src/fxcodec/codec/codec_int.h @@ -17,9 +17,9 @@ class CCodec_BasicModule : public ICodec_BasicModule { public: - virtual FX_BOOL RunLengthEncode(const FX_BYTE* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_buf, + virtual FX_BOOL RunLengthEncode(const uint8_t* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_buf, FX_DWORD& dest_size); - virtual FX_BOOL A85Encode(const FX_BYTE* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_buf, + virtual FX_BOOL A85Encode(const uint8_t* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_buf, FX_DWORD& dest_size); virtual ICodec_ScanlineDecoder* CreateRunLengthDecoder(FX_LPCBYTE src_buf, FX_DWORD src_size, int width, int height, int nComps, int bpc); @@ -27,7 +27,7 @@ public: struct CCodec_ImageDataCache { int m_Width, m_Height; int m_nCachedLines; - FX_BYTE m_Data; + uint8_t m_Data; }; class CCodec_ScanlineDecoder : public ICodec_ScanlineDecoder { @@ -126,10 +126,10 @@ class CCodec_FlateModule : public ICodec_FlateModule public: virtual ICodec_ScanlineDecoder* CreateDecoder(FX_LPCBYTE src_buf, FX_DWORD src_size, int width, int height, int nComps, int bpc, int predictor, int Colors, int BitsPerComponent, int Columns); - virtual FX_DWORD FlateOrLZWDecode(FX_BOOL bLZW, const FX_BYTE* src_buf, FX_DWORD src_size, FX_BOOL bEarlyChange, + virtual FX_DWORD FlateOrLZWDecode(FX_BOOL bLZW, const uint8_t* src_buf, FX_DWORD src_size, FX_BOOL bEarlyChange, int predictor, int Colors, int BitsPerComponent, int Columns, FX_DWORD estimated_size, FX_LPBYTE& dest_buf, FX_DWORD& dest_size); - virtual FX_BOOL Encode(const FX_BYTE* src_buf, FX_DWORD src_size, + virtual FX_BOOL Encode(const uint8_t* src_buf, FX_DWORD src_size, int predictor, int Colors, int BitsPerComponent, int Columns, FX_LPBYTE& dest_buf, FX_DWORD& dest_size); virtual FX_BOOL Encode(FX_LPCBYTE src_buf, FX_DWORD src_size, FX_LPBYTE& dest_buf, FX_DWORD& dest_size); @@ -171,10 +171,10 @@ public: FX_DWORD dwPrfIntent = Icc_INTENT_ABSOLUTE_COLORIMETRIC, FX_DWORD dwPrfFlag = Icc_FLAGS_SOFTPROOFING ); - virtual FX_LPVOID CreateTransform_sRGB(FX_LPCBYTE pProfileData, FX_DWORD dwProfileSize, FX_INT32& nComponents, FX_INT32 intent = 0, + virtual FX_LPVOID CreateTransform_sRGB(FX_LPCBYTE pProfileData, FX_DWORD dwProfileSize, int32_t& nComponents, int32_t intent = 0, FX_DWORD dwSrcFormat = Icc_FORMAT_DEFAULT); - virtual FX_LPVOID CreateTransform_CMYK(FX_LPCBYTE pSrcProfileData, FX_DWORD dwSrcProfileSize, FX_INT32& nSrcComponents, - FX_LPCBYTE pDstProfileData, FX_DWORD dwDstProfileSize, FX_INT32 intent = 0, + virtual FX_LPVOID CreateTransform_CMYK(FX_LPCBYTE pSrcProfileData, FX_DWORD dwSrcProfileSize, int32_t& nSrcComponents, + FX_LPCBYTE pDstProfileData, FX_DWORD dwDstProfileSize, int32_t intent = 0, FX_DWORD dwSrcFormat = Icc_FORMAT_DEFAULT, FX_DWORD dwDstFormat = Icc_FORMAT_DEFAULT ); @@ -210,14 +210,14 @@ class CPDF_Jbig2Interface : public CJBig2_Module public: virtual void *JBig2_Malloc(FX_DWORD dwSize) { - return FX_Alloc(FX_BYTE, dwSize); + return FX_Alloc(uint8_t, dwSize); } virtual void *JBig2_Malloc2(FX_DWORD num, FX_DWORD dwSize) { if (dwSize && num >= UINT_MAX / dwSize) { return NULL; } - return FX_Alloc(FX_BYTE, num * dwSize); + return FX_Alloc(uint8_t, num * dwSize); } virtual void *JBig2_Malloc3(FX_DWORD num, FX_DWORD dwSize, FX_DWORD dwSize2) { @@ -228,11 +228,11 @@ public: if (size && num >= UINT_MAX / size) { return NULL; } - return FX_Alloc(FX_BYTE, num * size); + return FX_Alloc(uint8_t, num * size); } virtual void *JBig2_Realloc(FX_LPVOID pMem, FX_DWORD dwSize) { - return FX_Realloc(FX_BYTE, pMem, dwSize); + return FX_Realloc(uint8_t, pMem, dwSize); } virtual void JBig2_Free(FX_LPVOID pMem) { diff --git a/core/src/fxcodec/codec/fx_codec.cpp b/core/src/fxcodec/codec/fx_codec.cpp index c325cccdd4..ee3ef8ce9d 100644 --- a/core/src/fxcodec/codec/fx_codec.cpp +++ b/core/src/fxcodec/codec/fx_codec.cpp @@ -119,7 +119,7 @@ void CCodec_ScanlineDecoder::DownScale(int dest_width, int dest_height) FX_Free(m_pDataCache); m_pDataCache = NULL; } - m_pDataCache = (CCodec_ImageDataCache*)FX_TryAlloc(FX_BYTE, sizeof(CCodec_ImageDataCache) + m_Pitch * m_OutputHeight); + m_pDataCache = (CCodec_ImageDataCache*)FX_TryAlloc(uint8_t, sizeof(CCodec_ImageDataCache) + m_Pitch * m_OutputHeight); if (m_pDataCache == NULL) { return; } @@ -127,7 +127,7 @@ void CCodec_ScanlineDecoder::DownScale(int dest_width, int dest_height) m_pDataCache->m_Width = m_OutputWidth; m_pDataCache->m_nCachedLines = 0; } -FX_BOOL CCodec_BasicModule::RunLengthEncode(const FX_BYTE* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_buf, +FX_BOOL CCodec_BasicModule::RunLengthEncode(const uint8_t* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_buf, FX_DWORD& dest_size) { return FALSE; @@ -236,7 +236,7 @@ extern "C" double FXstrtod(const char* nptr, char** endptr) } return is_negative ? -ret : ret; } -FX_BOOL CCodec_BasicModule::A85Encode(const FX_BYTE* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_buf, +FX_BOOL CCodec_BasicModule::A85Encode(const uint8_t* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_buf, FX_DWORD& dest_size) { return FALSE; @@ -265,7 +265,7 @@ public: protected: FX_BOOL CheckDestSize(); void GetNextOperator(); - void UpdateOperator(FX_BYTE used_bytes); + void UpdateOperator(uint8_t used_bytes); FX_LPBYTE m_pScanline; FX_LPCBYTE m_pSrcBuf; @@ -273,7 +273,7 @@ protected: FX_DWORD m_dwLineBytes; FX_DWORD m_SrcOffset; FX_BOOL m_bEOD; - FX_BYTE m_Operator; + uint8_t m_Operator; }; CCodec_RLScanlineDecoder::CCodec_RLScanlineDecoder() : m_pScanline(NULL) @@ -332,7 +332,7 @@ FX_BOOL CCodec_RLScanlineDecoder::Create(FX_LPCBYTE src_buf, FX_DWORD src_size, m_DownScale = 1; m_Pitch = (width * nComps * bpc + 31) / 32 * 4; m_dwLineBytes = (width * nComps * bpc + 7) / 8; - m_pScanline = FX_Alloc(FX_BYTE, m_Pitch); + m_pScanline = FX_Alloc(uint8_t, m_Pitch); return CheckDestSize(); } FX_BOOL CCodec_RLScanlineDecoder::v_Rewind() @@ -368,7 +368,7 @@ FX_LPBYTE CCodec_RLScanlineDecoder::v_GetNextLine() } FXSYS_memcpy32(m_pScanline + col_pos, m_pSrcBuf + m_SrcOffset, copy_len); col_pos += copy_len; - UpdateOperator((FX_BYTE)copy_len); + UpdateOperator((uint8_t)copy_len); } else if (m_Operator > 128) { int fill = 0; if (m_SrcOffset - 1 < m_SrcSize - 1) { @@ -381,7 +381,7 @@ FX_LPBYTE CCodec_RLScanlineDecoder::v_GetNextLine() } FXSYS_memset8(m_pScanline + col_pos, fill, duplicate_len); col_pos += duplicate_len; - UpdateOperator((FX_BYTE)duplicate_len); + UpdateOperator((uint8_t)duplicate_len); } else { m_bEOD = TRUE; break; @@ -398,7 +398,7 @@ void CCodec_RLScanlineDecoder::GetNextOperator() m_Operator = m_pSrcBuf[m_SrcOffset]; m_SrcOffset ++; } -void CCodec_RLScanlineDecoder::UpdateOperator(FX_BYTE used_bytes) +void CCodec_RLScanlineDecoder::UpdateOperator(uint8_t used_bytes) { if (used_bytes == 0) { return; @@ -417,7 +417,7 @@ void CCodec_RLScanlineDecoder::UpdateOperator(FX_BYTE used_bytes) } return; } - FX_BYTE count = 257 - m_Operator; + uint8_t count = 257 - m_Operator; FXSYS_assert((FX_DWORD)count >= used_bytes); if (used_bytes == count) { m_SrcOffset ++; diff --git a/core/src/fxcodec/codec/fx_codec_fax.cpp b/core/src/fxcodec/codec/fx_codec_fax.cpp index dc2ee2aacd..869751e05b 100644 --- a/core/src/fxcodec/codec/fx_codec_fax.cpp +++ b/core/src/fxcodec/codec/fx_codec_fax.cpp @@ -6,7 +6,7 @@ #include "../../../include/fxcodec/fx_codec.h" #include "codec_int.h" -const FX_BYTE OneLeadPos[256] = { +const uint8_t OneLeadPos[256] = { 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -24,7 +24,7 @@ const FX_BYTE OneLeadPos[256] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; -const FX_BYTE ZeroLeadPos[256] = { +const uint8_t ZeroLeadPos[256] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -43,14 +43,14 @@ const FX_BYTE ZeroLeadPos[256] = { 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 7, 8, }; -int _FindBit(const FX_BYTE* data_buf, int max_pos, int start_pos, int bit) +int _FindBit(const uint8_t* data_buf, int max_pos, int start_pos, int bit) { if (start_pos >= max_pos) { return max_pos; } FX_LPCBYTE leading_pos = bit ? OneLeadPos : ZeroLeadPos; if (start_pos % 8) { - FX_BYTE data = data_buf[start_pos / 8]; + uint8_t data = data_buf[start_pos / 8]; if (bit) { data &= 0xff >> (start_pos % 8); } else { @@ -61,7 +61,7 @@ int _FindBit(const FX_BYTE* data_buf, int max_pos, int start_pos, int bit) } start_pos += 7; } - FX_BYTE skip = bit ? 0x00 : 0xff; + uint8_t skip = bit ? 0x00 : 0xff; int byte_pos = start_pos / 8; int max_byte = (max_pos + 7) / 8; while (byte_pos < max_byte) { @@ -79,12 +79,12 @@ int _FindBit(const FX_BYTE* data_buf, int max_pos, int start_pos, int bit) } return pos; } -void _FaxG4FindB1B2(const FX_BYTE* ref_buf, int columns, int a0, FX_BOOL a0color, int& b1, int& b2) +void _FaxG4FindB1B2(const uint8_t* ref_buf, int columns, int a0, FX_BOOL a0color, int& b1, int& b2) { if (a0color) { a0color = 1; } - FX_BYTE first_bit = (a0 < 0) ? 1 : ((ref_buf[a0 / 8] & (1 << (7 - a0 % 8))) != 0); + uint8_t first_bit = (a0 < 0) ? 1 : ((ref_buf[a0 / 8] & (1 << (7 - a0 % 8))) != 0); b1 = _FindBit(ref_buf, columns, a0 + 1, !first_bit); if (b1 >= columns) { b1 = b2 = columns; @@ -136,7 +136,7 @@ void _FaxFillBits(FX_LPBYTE dest_buf, int columns, int startpos, int endpos) #define NEXTBIT src_buf[bitpos/8] & (1 << (7-bitpos%8)); bitpos ++; #define ADDBIT(code, bit) code = code << 1; if (bit) code ++; #define GETBIT(bitpos) src_buf[bitpos/8] & (1 << (7-bitpos%8)) -static const FX_BYTE FaxBlackRunIns[] = { +static const uint8_t FaxBlackRunIns[] = { 0, 2, 0x02, 3, 0, @@ -256,7 +256,7 @@ static const FX_BYTE FaxBlackRunIns[] = { 0x77, 1216 % 256, 1216 / 256, 0xff }; -static const FX_BYTE FaxWhiteRunIns[] = { +static const uint8_t FaxWhiteRunIns[] = { 0, 0, 0, @@ -375,12 +375,12 @@ static const FX_BYTE FaxWhiteRunIns[] = { 0x1f, 2560 % 256, 2560 / 256, 0xff, }; -int _FaxGetRun(FX_LPCBYTE ins_array, const FX_BYTE* src_buf, int& bitpos, int bitsize) +int _FaxGetRun(FX_LPCBYTE ins_array, const uint8_t* src_buf, int& bitpos, int bitsize) { FX_DWORD code = 0; int ins_off = 0; while (1) { - FX_BYTE ins = ins_array[ins_off++]; + uint8_t ins = ins_array[ins_off++]; if (ins == 0xff) { return -1; } @@ -400,7 +400,7 @@ int _FaxGetRun(FX_LPCBYTE ins_array, const FX_BYTE* src_buf, int& bitpos, int bi } } } -FX_BOOL _FaxG4GetRow(const FX_BYTE* src_buf, int bitsize, int& bitpos, FX_LPBYTE dest_buf, const FX_BYTE* ref_buf, int columns) +FX_BOOL _FaxG4GetRow(const uint8_t* src_buf, int bitsize, int& bitpos, FX_LPBYTE dest_buf, const uint8_t* ref_buf, int columns) { int a0 = -1, a0color = 1; while (1) { @@ -522,7 +522,7 @@ FX_BOOL _FaxG4GetRow(const FX_BYTE* src_buf, int bitsize, int& bitpos, FX_LPBYTE a0color = !a0color; } } -FX_BOOL _FaxSkipEOL(const FX_BYTE* src_buf, int bitsize, int& bitpos) +FX_BOOL _FaxSkipEOL(const uint8_t* src_buf, int bitsize, int& bitpos) { int startbit = bitpos; while (bitpos < bitsize) { @@ -536,7 +536,7 @@ FX_BOOL _FaxSkipEOL(const FX_BYTE* src_buf, int bitsize, int& bitpos) } return FALSE; } -FX_BOOL _FaxGet1DLine(const FX_BYTE* src_buf, int bitsize, int& bitpos, FX_LPBYTE dest_buf, int columns) +FX_BOOL _FaxGet1DLine(const uint8_t* src_buf, int bitsize, int& bitpos, FX_LPBYTE dest_buf, int columns) { int color = TRUE; int startpos = 0; @@ -621,8 +621,8 @@ FX_BOOL CCodec_FaxDecoder::Create(FX_LPCBYTE src_buf, FX_DWORD src_size, int wid m_Pitch = (m_OrigWidth + 31) / 32 * 4; m_OutputWidth = m_OrigWidth; m_OutputHeight = m_OrigHeight; - m_pScanlineBuf = FX_Alloc(FX_BYTE, m_Pitch); - m_pRefBuf = FX_Alloc(FX_BYTE, m_Pitch); + m_pScanlineBuf = FX_Alloc(uint8_t, m_Pitch); + m_pRefBuf = FX_Alloc(uint8_t, m_Pitch); m_pSrcBuf = src_buf; m_SrcSize = src_size; m_nComps = 1; @@ -698,7 +698,7 @@ extern "C" { if (pitch == 0) { pitch = (width + 7) / 8; } - FX_LPBYTE ref_buf = FX_Alloc(FX_BYTE, pitch); + FX_LPBYTE ref_buf = FX_Alloc(uint8_t, pitch); FXSYS_memset8(ref_buf, 0xff, pitch); int bitpos = *pbitpos; for (int iRow = 0; iRow < height; iRow ++) { @@ -711,7 +711,7 @@ extern "C" { *pbitpos = bitpos; } }; -static const FX_BYTE BlackRunTerminator[128] = { +static const uint8_t BlackRunTerminator[128] = { 0x37, 10, 0x02, 3, 0x03, 2, 0x02, 2, 0x03, 3, 0x03, 4, 0x02, 4, 0x03, 5, 0x05, 6, 0x04, 6, 0x04, 7, 0x05, 7, 0x07, 7, 0x04, 8, 0x07, 8, 0x18, 9, 0x17, 10, 0x18, 10, 0x08, 10, 0x67, 11, 0x68, 11, 0x6c, 11, 0x37, 11, 0x28, 11, @@ -721,14 +721,14 @@ static const FX_BYTE BlackRunTerminator[128] = { 0x64, 12, 0x65, 12, 0x52, 12, 0x53, 12, 0x24, 12, 0x37, 12, 0x38, 12, 0x27, 12, 0x28, 12, 0x58, 12, 0x59, 12, 0x2b, 12, 0x2c, 12, 0x5a, 12, 0x66, 12, 0x67, 12, }; -static const FX_BYTE BlackRunMarkup[80] = { +static const uint8_t BlackRunMarkup[80] = { 0x0f, 10, 0xc8, 12, 0xc9, 12, 0x5b, 12, 0x33, 12, 0x34, 12, 0x35, 12, 0x6c, 13, 0x6d, 13, 0x4a, 13, 0x4b, 13, 0x4c, 13, 0x4d, 13, 0x72, 13, 0x73, 13, 0x74, 13, 0x75, 13, 0x76, 13, 0x77, 13, 0x52, 13, 0x53, 13, 0x54, 13, 0x55, 13, 0x5a, 13, 0x5b, 13, 0x64, 13, 0x65, 13, 0x08, 11, 0x0c, 11, 0x0d, 11, 0x12, 12, 0x13, 12, 0x14, 12, 0x15, 12, 0x16, 12, 0x17, 12, 0x1c, 12, 0x1d, 12, 0x1e, 12, 0x1f, 12, }; -static const FX_BYTE WhiteRunTerminator[128] = { +static const uint8_t WhiteRunTerminator[128] = { 0x35, 8, 0x07, 6, 0x07, 4, @@ -794,7 +794,7 @@ static const FX_BYTE WhiteRunTerminator[128] = { 0x33, 8, 0x34, 8, }; -static const FX_BYTE WhiteRunMarkup[80] = { +static const uint8_t WhiteRunMarkup[80] = { 0x1b, 5, 0x12, 5, 0x17, 6, @@ -935,9 +935,9 @@ CCodec_FaxEncoder::CCodec_FaxEncoder(FX_LPCBYTE src_buf, int width, int height, m_Cols = width; m_Rows = height; m_Pitch = pitch; - m_pRefLine = FX_Alloc(FX_BYTE, m_Pitch); + m_pRefLine = FX_Alloc(uint8_t, m_Pitch); FXSYS_memset8(m_pRefLine, 0xff, m_Pitch); - m_pLineBuf = FX_Alloc2D(FX_BYTE, m_Pitch, 8); + m_pLineBuf = FX_Alloc2D(uint8_t, m_Pitch, 8); m_DestBuf.EstimateSize(0, 10240); } CCodec_FaxEncoder::~CCodec_FaxEncoder() @@ -952,7 +952,7 @@ CCodec_FaxEncoder::~CCodec_FaxEncoder() void CCodec_FaxEncoder::Encode(FX_LPBYTE& dest_buf, FX_DWORD& dest_size) { int dest_bitpos = 0; - FX_BYTE last_byte = 0; + uint8_t last_byte = 0; for (int i = 0; i < m_Rows; i ++) { FX_LPCBYTE scan_line = m_pSrcBuf + i * m_Pitch; FXSYS_memset32(m_pLineBuf, 0, m_Pitch * 8); diff --git a/core/src/fxcodec/codec/fx_codec_flate.cpp b/core/src/fxcodec/codec/fx_codec_flate.cpp index 7a19e8b855..9997a570d6 100644 --- a/core/src/fxcodec/codec/fx_codec_flate.cpp +++ b/core/src/fxcodec/codec/fx_codec_flate.cpp @@ -13,7 +13,7 @@ extern "C" { static void* my_alloc_func (void* opaque, unsigned int items, unsigned int size) { - return FX_Alloc2D(FX_BYTE, items, size); + return FX_Alloc2D(uint8_t, items, size); } static void my_free_func (void* opaque, void* address) { @@ -79,22 +79,22 @@ extern "C" class CLZWDecoder { public: - FX_BOOL Decode(FX_LPBYTE output, FX_DWORD& outlen, const FX_BYTE* input, FX_DWORD& size, FX_BOOL bEarlyChange); + FX_BOOL Decode(FX_LPBYTE output, FX_DWORD& outlen, const uint8_t* input, FX_DWORD& size, FX_BOOL bEarlyChange); private: FX_DWORD m_InPos; FX_DWORD m_OutPos; FX_LPBYTE m_pOutput; - const FX_BYTE* m_pInput; + const uint8_t* m_pInput; FX_BOOL m_Early; - void AddCode(FX_DWORD prefix_code, FX_BYTE append_char); + void AddCode(FX_DWORD prefix_code, uint8_t append_char); FX_DWORD m_CodeArray[5021]; FX_DWORD m_nCodes; - FX_BYTE m_DecodeStack[4000]; + uint8_t m_DecodeStack[4000]; FX_DWORD m_StackLen; void DecodeString(FX_DWORD code); int m_CodeLen; }; -void CLZWDecoder::AddCode(FX_DWORD prefix_code, FX_BYTE append_char) +void CLZWDecoder::AddCode(FX_DWORD prefix_code, uint8_t append_char) { if (m_nCodes + m_Early == 4094) { return; @@ -119,15 +119,15 @@ void CLZWDecoder::DecodeString(FX_DWORD code) if (m_StackLen >= sizeof(m_DecodeStack)) { return; } - m_DecodeStack[m_StackLen++] = (FX_BYTE)data; + m_DecodeStack[m_StackLen++] = (uint8_t)data; code = data >> 16; } if (m_StackLen >= sizeof(m_DecodeStack)) { return; } - m_DecodeStack[m_StackLen++] = (FX_BYTE)code; + m_DecodeStack[m_StackLen++] = (uint8_t)code; } -int CLZWDecoder::Decode(FX_LPBYTE dest_buf, FX_DWORD& dest_size, const FX_BYTE* src_buf, FX_DWORD& src_size, FX_BOOL bEarlyChange) +int CLZWDecoder::Decode(FX_LPBYTE dest_buf, FX_DWORD& dest_size, const uint8_t* src_buf, FX_DWORD& src_size, FX_BOOL bEarlyChange) { m_CodeLen = 9; m_InPos = 0; @@ -137,7 +137,7 @@ int CLZWDecoder::Decode(FX_LPBYTE dest_buf, FX_DWORD& dest_size, const FX_BYTE* m_Early = bEarlyChange ? 1 : 0; m_nCodes = 0; FX_DWORD old_code = (FX_DWORD) - 1; - FX_BYTE last_char; + uint8_t last_char; while (1) { if (m_InPos + m_CodeLen > src_size * 8) { break; @@ -164,10 +164,10 @@ int CLZWDecoder::Decode(FX_LPBYTE dest_buf, FX_DWORD& dest_size, const FX_BYTE* return -5; } if (m_pOutput) { - m_pOutput[m_OutPos] = (FX_BYTE)code; + m_pOutput[m_OutPos] = (uint8_t)code; } m_OutPos ++; - last_char = (FX_BYTE)code; + last_char = (uint8_t)code; if (old_code != (FX_DWORD) - 1) { AddCode(old_code, last_char); } @@ -217,19 +217,19 @@ int CLZWDecoder::Decode(FX_LPBYTE dest_buf, FX_DWORD& dest_size, const FX_BYTE* src_size = (m_InPos + 7) / 8; return 0; } -static FX_BYTE PaethPredictor(int a, int b, int c) +static uint8_t PaethPredictor(int a, int b, int c) { int p = a + b - c; int pa = FXSYS_abs(p - a); int pb = FXSYS_abs(p - b); int pc = FXSYS_abs(p - c); if (pa <= pb && pa <= pc) { - return (FX_BYTE)a; + return (uint8_t)a; } if (pb <= pc) { - return (FX_BYTE)b; + return (uint8_t)b; } - return (FX_BYTE)c; + return (uint8_t)c; } static FX_BOOL PNG_PredictorEncode(FX_LPBYTE& data_buf, FX_DWORD& data_size, int predictor, int Colors, @@ -241,7 +241,7 @@ static FX_BOOL PNG_PredictorEncode(FX_LPBYTE& data_buf, FX_DWORD& data_size, return FALSE; const int row_count = (data_size + row_size - 1) / row_size; const int last_row_size = data_size % row_size; - FX_LPBYTE dest_buf = FX_Alloc2D(FX_BYTE, row_size + 1, row_count); + FX_LPBYTE dest_buf = FX_Alloc2D(uint8_t, row_size + 1, row_count); int byte_cnt = 0; FX_LPBYTE pSrcData = data_buf; FX_LPBYTE pDestData = dest_buf; @@ -262,7 +262,7 @@ static FX_BOOL PNG_PredictorEncode(FX_LPBYTE& data_buf, FX_DWORD& data_size, switch (predictor) { case 11: { pDestData[0] = 1; - FX_BYTE left = 0; + uint8_t left = 0; if (byte >= BytesPerPixel) { left = pSrcData[byte - BytesPerPixel]; } @@ -271,7 +271,7 @@ static FX_BOOL PNG_PredictorEncode(FX_LPBYTE& data_buf, FX_DWORD& data_size, break; case 12: { pDestData[0] = 2; - FX_BYTE up = 0; + uint8_t up = 0; if (row) { up = pSrcData[byte - row_size]; } @@ -280,11 +280,11 @@ static FX_BOOL PNG_PredictorEncode(FX_LPBYTE& data_buf, FX_DWORD& data_size, break; case 13: { pDestData[0] = 3; - FX_BYTE left = 0; + uint8_t left = 0; if (byte >= BytesPerPixel) { left = pSrcData[byte - BytesPerPixel]; } - FX_BYTE up = 0; + uint8_t up = 0; if (row) { up = pSrcData[byte - row_size]; } @@ -293,15 +293,15 @@ static FX_BOOL PNG_PredictorEncode(FX_LPBYTE& data_buf, FX_DWORD& data_size, break; case 14: { pDestData[0] = 4; - FX_BYTE left = 0; + uint8_t left = 0; if (byte >= BytesPerPixel) { left = pSrcData[byte - BytesPerPixel]; } - FX_BYTE up = 0; + uint8_t up = 0; if (row) { up = pSrcData[byte - row_size]; } - FX_BYTE upper_left = 0; + uint8_t upper_left = 0; if (byte >= BytesPerPixel && row) { upper_left = pSrcData[byte - row_size - BytesPerPixel]; } @@ -328,16 +328,16 @@ static void PNG_PredictLine(FX_LPBYTE pDestData, FX_LPCBYTE pSrcData, FX_LPCBYTE { int row_size = (nPixels * bpc * nColors + 7) / 8; int BytesPerPixel = (bpc * nColors + 7) / 8; - FX_BYTE tag = pSrcData[0]; + uint8_t tag = pSrcData[0]; if (tag == 0) { FXSYS_memmove32(pDestData, pSrcData + 1, row_size); return; } for (int byte = 0; byte < row_size; byte ++) { - FX_BYTE raw_byte = pSrcData[byte + 1]; + uint8_t raw_byte = pSrcData[byte + 1]; switch (tag) { case 1: { - FX_BYTE left = 0; + uint8_t left = 0; if (byte >= BytesPerPixel) { left = pDestData[byte - BytesPerPixel]; } @@ -345,7 +345,7 @@ static void PNG_PredictLine(FX_LPBYTE pDestData, FX_LPCBYTE pSrcData, FX_LPCBYTE break; } case 2: { - FX_BYTE up = 0; + uint8_t up = 0; if (pLastLine) { up = pLastLine[byte]; } @@ -353,11 +353,11 @@ static void PNG_PredictLine(FX_LPBYTE pDestData, FX_LPCBYTE pSrcData, FX_LPCBYTE break; } case 3: { - FX_BYTE left = 0; + uint8_t left = 0; if (byte >= BytesPerPixel) { left = pDestData[byte - BytesPerPixel]; } - FX_BYTE up = 0; + uint8_t up = 0; if (pLastLine) { up = pLastLine[byte]; } @@ -365,15 +365,15 @@ static void PNG_PredictLine(FX_LPBYTE pDestData, FX_LPCBYTE pSrcData, FX_LPCBYTE break; } case 4: { - FX_BYTE left = 0; + uint8_t left = 0; if (byte >= BytesPerPixel) { left = pDestData[byte - BytesPerPixel]; } - FX_BYTE up = 0; + uint8_t up = 0; if (pLastLine) { up = pLastLine[byte]; } - FX_BYTE upper_left = 0; + uint8_t upper_left = 0; if (byte >= BytesPerPixel && pLastLine) { upper_left = pLastLine[byte - BytesPerPixel]; } @@ -395,12 +395,12 @@ static FX_BOOL PNG_Predictor(FX_LPBYTE& data_buf, FX_DWORD& data_size, return FALSE; const int row_count = (data_size + row_size) / (row_size + 1); const int last_row_size = data_size % (row_size + 1); - FX_LPBYTE dest_buf = FX_Alloc2D(FX_BYTE, row_size, row_count); + FX_LPBYTE dest_buf = FX_Alloc2D(uint8_t, row_size, row_count); int byte_cnt = 0; FX_LPBYTE pSrcData = data_buf; FX_LPBYTE pDestData = dest_buf; for (int row = 0; row < row_count; row ++) { - FX_BYTE tag = pSrcData[0]; + uint8_t tag = pSrcData[0]; byte_cnt++; if (tag == 0) { int move_size = row_size; @@ -414,10 +414,10 @@ static FX_BOOL PNG_Predictor(FX_LPBYTE& data_buf, FX_DWORD& data_size, continue; } for (int byte = 0; byte < row_size && byte_cnt < (int)data_size; byte ++) { - FX_BYTE raw_byte = pSrcData[byte + 1]; + uint8_t raw_byte = pSrcData[byte + 1]; switch (tag) { case 1: { - FX_BYTE left = 0; + uint8_t left = 0; if (byte >= BytesPerPixel) { left = pDestData[byte - BytesPerPixel]; } @@ -425,7 +425,7 @@ static FX_BOOL PNG_Predictor(FX_LPBYTE& data_buf, FX_DWORD& data_size, break; } case 2: { - FX_BYTE up = 0; + uint8_t up = 0; if (row) { up = pDestData[byte - row_size]; } @@ -433,11 +433,11 @@ static FX_BOOL PNG_Predictor(FX_LPBYTE& data_buf, FX_DWORD& data_size, break; } case 3: { - FX_BYTE left = 0; + uint8_t left = 0; if (byte >= BytesPerPixel) { left = pDestData[byte - BytesPerPixel]; } - FX_BYTE up = 0; + uint8_t up = 0; if (row) { up = pDestData[byte - row_size]; } @@ -445,15 +445,15 @@ static FX_BOOL PNG_Predictor(FX_LPBYTE& data_buf, FX_DWORD& data_size, break; } case 4: { - FX_BYTE left = 0; + uint8_t left = 0; if (byte >= BytesPerPixel) { left = pDestData[byte - BytesPerPixel]; } - FX_BYTE up = 0; + uint8_t up = 0; if (row) { up = pDestData[byte - row_size]; } - FX_BYTE upper_left = 0; + uint8_t upper_left = 0; if (byte >= BytesPerPixel && row) { upper_left = pDestData[byte - row_size - BytesPerPixel]; } @@ -478,7 +478,7 @@ static void TIFF_PredictorEncodeLine(FX_LPBYTE dest_buf, int row_size, int BitsP { int BytesPerPixel = BitsPerComponent * Colors / 8; if (BitsPerComponent < 8) { - FX_BYTE mask = 0x01; + uint8_t mask = 0x01; if (BitsPerComponent == 2) { mask = 0x03; } else if (BitsPerComponent == 4) { @@ -490,8 +490,8 @@ static void TIFF_PredictorEncodeLine(FX_LPBYTE dest_buf, int row_size, int BitsP int index = i / 8; int col_pre = (col == 0) ? (8 - BitsPerComponent) : (col - BitsPerComponent); int index_pre = (col == 0) ? (index - 1) : index; - FX_BYTE cur = (dest_buf[index] >> (8 - col - BitsPerComponent)) & mask; - FX_BYTE left = (dest_buf[index_pre] >> (8 - col_pre - BitsPerComponent)) & mask; + uint8_t cur = (dest_buf[index] >> (8 - col - BitsPerComponent)) & mask; + uint8_t left = (dest_buf[index_pre] >> (8 - col_pre - BitsPerComponent)) & mask; cur -= left; cur &= mask; cur <<= (8 - col - BitsPerComponent); @@ -507,7 +507,7 @@ static void TIFF_PredictorEncodeLine(FX_LPBYTE dest_buf, int row_size, int BitsP FX_WORD pixel = (dest_buf[i] << 8) | dest_buf[i + 1]; pixel -= (dest_buf[i - BytesPerPixel] << 8) | dest_buf[i - BytesPerPixel + 1]; dest_buf[i] = pixel >> 8; - dest_buf[i + 1] = (FX_BYTE)pixel; + dest_buf[i + 1] = (uint8_t)pixel; } } } @@ -553,7 +553,7 @@ static void TIFF_PredictLine(FX_LPBYTE dest_buf, int row_size, int BitsPerCompon FX_WORD pixel = (dest_buf[i - BytesPerPixel] << 8) | dest_buf[i - BytesPerPixel + 1]; pixel += (dest_buf[i] << 8) | dest_buf[i + 1]; dest_buf[i] = pixel >> 8; - dest_buf[i + 1] = (FX_BYTE)pixel; + dest_buf[i + 1] = (uint8_t)pixel; } } else { for (int i = BytesPerPixel; i < row_size; i ++) { @@ -641,7 +641,7 @@ void CCodec_FlateScanlineDecoder::Create(FX_LPCBYTE src_buf, FX_DWORD src_size, m_bpc = bpc; m_bColorTransformed = FALSE; m_Pitch = (width * nComps * bpc + 7) / 8; - m_pScanline = FX_Alloc(FX_BYTE, m_Pitch); + m_pScanline = FX_Alloc(uint8_t, m_Pitch); m_Predictor = 0; if (predictor) { if (predictor >= 10) { @@ -659,9 +659,9 @@ void CCodec_FlateScanlineDecoder::Create(FX_LPCBYTE src_buf, FX_DWORD src_size, m_BitsPerComponent = BitsPerComponent; m_Columns = Columns; m_PredictPitch = (m_BitsPerComponent * m_Colors * m_Columns + 7) / 8; - m_pLastLine = FX_Alloc(FX_BYTE, m_PredictPitch); - m_pPredictRaw = FX_Alloc(FX_BYTE, m_PredictPitch + 1); - m_pPredictBuffer = FX_Alloc(FX_BYTE, m_PredictPitch); + m_pLastLine = FX_Alloc(uint8_t, m_PredictPitch); + m_pPredictRaw = FX_Alloc(uint8_t, m_PredictPitch + 1); + m_pPredictBuffer = FX_Alloc(uint8_t, m_PredictPitch); } } } @@ -737,7 +737,7 @@ static void FlateUncompress(FX_LPCBYTE src_buf, FX_DWORD src_size, FX_DWORD orig FX_DWORD last_buf_size = buf_size; void* context = nullptr; - FX_LPBYTE guess_buf = FX_Alloc(FX_BYTE, guess_size + 1); + FX_LPBYTE guess_buf = FX_Alloc(uint8_t, guess_size + 1); FX_LPBYTE cur_buf = guess_buf; guess_buf[guess_size] = '\0'; context = FPDFAPI_FlateInit(my_alloc_func, my_free_func); @@ -746,10 +746,10 @@ static void FlateUncompress(FX_LPCBYTE src_buf, FX_DWORD src_size, FX_DWORD orig FPDFAPI_FlateInput(context, src_buf, src_size); if (useOldImpl) { while (1) { - FX_INT32 ret = FPDFAPI_FlateOutput(context, cur_buf, buf_size); + int32_t ret = FPDFAPI_FlateOutput(context, cur_buf, buf_size); if (ret != Z_OK) break; - FX_INT32 avail_buf_size = FPDFAPI_FlateGetAvailOut(context); + int32_t avail_buf_size = FPDFAPI_FlateGetAvailOut(context); if (avail_buf_size != 0) break; @@ -758,7 +758,7 @@ static void FlateUncompress(FX_LPCBYTE src_buf, FX_DWORD src_size, FX_DWORD orig guess_size += alloc_step; if (guess_size < old_size || guess_size + 1 < guess_size) goto fail; - guess_buf = FX_Realloc(FX_BYTE, guess_buf, guess_size + 1); + guess_buf = FX_Realloc(uint8_t, guess_buf, guess_size + 1); if (!guess_buf) goto fail; guess_buf[guess_size] = '\0'; @@ -768,7 +768,7 @@ static void FlateUncompress(FX_LPCBYTE src_buf, FX_DWORD src_size, FX_DWORD orig dest_size = FPDFAPI_FlateGetTotalOut(context); offset = FPDFAPI_FlateGetTotalIn(context); if (guess_size / 2 > dest_size) { - guess_buf = FX_Realloc(FX_BYTE, guess_buf, dest_size + 1); + guess_buf = FX_Realloc(uint8_t, guess_buf, dest_size + 1); if (!guess_buf) goto fail; guess_size = dest_size; @@ -778,8 +778,8 @@ static void FlateUncompress(FX_LPCBYTE src_buf, FX_DWORD src_size, FX_DWORD orig } else { CFX_ArrayTemplate result_tmp_bufs; while (1) { - FX_INT32 ret = FPDFAPI_FlateOutput(context, cur_buf, buf_size); - FX_INT32 avail_buf_size = FPDFAPI_FlateGetAvailOut(context); + int32_t ret = FPDFAPI_FlateOutput(context, cur_buf, buf_size); + int32_t avail_buf_size = FPDFAPI_FlateGetAvailOut(context); if (ret != Z_OK) { last_buf_size = buf_size - avail_buf_size; result_tmp_bufs.Add(cur_buf); @@ -793,7 +793,7 @@ static void FlateUncompress(FX_LPCBYTE src_buf, FX_DWORD src_size, FX_DWORD orig // |avail_buf_size| == 0 case. result_tmp_bufs.Add(cur_buf); - cur_buf = FX_Alloc(FX_BYTE, buf_size + 1); + cur_buf = FX_Alloc(uint8_t, buf_size + 1); cur_buf[buf_size] = '\0'; } dest_size = FPDFAPI_FlateGetTotalOut(context); @@ -801,9 +801,9 @@ static void FlateUncompress(FX_LPCBYTE src_buf, FX_DWORD src_size, FX_DWORD orig if (result_tmp_bufs.GetSize() == 1) { dest_buf = result_tmp_bufs[0]; } else { - FX_LPBYTE result_buf = FX_Alloc(FX_BYTE, dest_size); + FX_LPBYTE result_buf = FX_Alloc(uint8_t, dest_size); FX_DWORD result_pos = 0; - for (FX_INT32 i = 0; i < result_tmp_bufs.GetSize(); i++) { + for (int32_t i = 0; i < result_tmp_bufs.GetSize(); i++) { FX_LPBYTE tmp_buf = result_tmp_bufs[i]; FX_DWORD tmp_buf_size = buf_size; if (i == result_tmp_bufs.GetSize() - 1) { @@ -832,7 +832,7 @@ ICodec_ScanlineDecoder* CCodec_FlateModule::CreateDecoder(FX_LPCBYTE src_buf, FX pDecoder->Create(src_buf, src_size, width, height, nComps, bpc, predictor, Colors, BitsPerComponent, Columns); return pDecoder; } -FX_DWORD CCodec_FlateModule::FlateOrLZWDecode(FX_BOOL bLZW, const FX_BYTE* src_buf, FX_DWORD src_size, FX_BOOL bEarlyChange, +FX_DWORD CCodec_FlateModule::FlateOrLZWDecode(FX_BOOL bLZW, const uint8_t* src_buf, FX_DWORD src_size, FX_BOOL bEarlyChange, int predictor, int Colors, int BitsPerComponent, int Columns, FX_DWORD estimated_size, FX_LPBYTE& dest_buf, FX_DWORD& dest_size) { @@ -859,7 +859,7 @@ FX_DWORD CCodec_FlateModule::FlateOrLZWDecode(FX_BOOL bLZW, const FX_BYTE* src_b } { nonstd::unique_ptr decoder(new CLZWDecoder); - dest_buf = FX_Alloc( FX_BYTE, dest_size + 1); + dest_buf = FX_Alloc( uint8_t, dest_size + 1); dest_buf[dest_size] = '\0'; decoder->Decode(dest_buf, dest_size, src_buf, offset, bEarlyChange); } @@ -879,7 +879,7 @@ FX_DWORD CCodec_FlateModule::FlateOrLZWDecode(FX_BOOL bLZW, const FX_BYTE* src_b } return ret ? offset : -1; } -FX_BOOL CCodec_FlateModule::Encode(const FX_BYTE* src_buf, FX_DWORD src_size, +FX_BOOL CCodec_FlateModule::Encode(const uint8_t* src_buf, FX_DWORD src_size, int predictor, int Colors, int BitsPerComponent, int Columns, FX_LPBYTE& dest_buf, FX_DWORD& dest_size) { @@ -887,7 +887,7 @@ FX_BOOL CCodec_FlateModule::Encode(const FX_BYTE* src_buf, FX_DWORD src_size, return Encode(src_buf, src_size, dest_buf, dest_size); } FX_LPBYTE pSrcBuf = NULL; - pSrcBuf = FX_Alloc(FX_BYTE, src_size); + pSrcBuf = FX_Alloc(uint8_t, src_size); FXSYS_memcpy32(pSrcBuf, src_buf, src_size); FX_BOOL ret = TRUE; if (predictor == 2) { @@ -905,7 +905,7 @@ FX_BOOL CCodec_FlateModule::Encode(const FX_BYTE* src_buf, FX_DWORD src_size, FX_BOOL CCodec_FlateModule::Encode(FX_LPCBYTE src_buf, FX_DWORD src_size, FX_LPBYTE& dest_buf, FX_DWORD& dest_size) { dest_size = src_size + src_size / 1000 + 12; - dest_buf = FX_Alloc( FX_BYTE, dest_size); + dest_buf = FX_Alloc( uint8_t, dest_size); unsigned long temp_size = dest_size; FPDFAPI_FlateCompress(dest_buf, &temp_size, src_buf, src_size); dest_size = (FX_DWORD)temp_size; diff --git a/core/src/fxcodec/codec/fx_codec_icc.cpp b/core/src/fxcodec/codec/fx_codec_icc.cpp index 26b4c1adfc..cde5d4c1bd 100644 --- a/core/src/fxcodec/codec/fx_codec_icc.cpp +++ b/core/src/fxcodec/codec/fx_codec_icc.cpp @@ -13,7 +13,7 @@ const FX_DWORD N_COMPONENT_RGB = 3; const FX_DWORD N_COMPONENT_CMYK = 4; const FX_DWORD N_COMPONENT_DEFAULT = 3; -FX_BOOL MD5ComputeID( FX_LPCVOID buf, FX_DWORD dwSize, FX_BYTE ID[16] ) +FX_BOOL MD5ComputeID( FX_LPCVOID buf, FX_DWORD dwSize, uint8_t ID[16] ) { return cmsMD5computeIDExt(buf, dwSize, ID); } @@ -65,7 +65,7 @@ FX_BOOL CheckComponents(cmsColorSpaceSignature cs, int nComponents, FX_BOOL bDst } return TRUE; } -FX_INT32 GetCSComponents(cmsColorSpaceSignature cs) +int32_t GetCSComponents(cmsColorSpaceSignature cs) { FX_DWORD components; switch (cs) { @@ -87,8 +87,8 @@ FX_INT32 GetCSComponents(cmsColorSpaceSignature cs) } return components; } -void* IccLib_CreateTransform(const unsigned char* pSrcProfileData, FX_DWORD dwSrcProfileSize, FX_INT32& nSrcComponents, - const unsigned char* pDstProfileData, FX_DWORD dwDstProfileSize, FX_INT32 nDstComponents, +void* IccLib_CreateTransform(const unsigned char* pSrcProfileData, FX_DWORD dwSrcProfileSize, int32_t& nSrcComponents, + const unsigned char* pDstProfileData, FX_DWORD dwDstProfileSize, int32_t nDstComponents, int intent, FX_DWORD dwSrcFormat = Icc_FORMAT_DEFAULT, FX_DWORD dwDstFormat = Icc_FORMAT_DEFAULT) { cmsHPROFILE srcProfile = NULL; @@ -157,7 +157,7 @@ void* IccLib_CreateTransform(const unsigned char* pSrcProfileData, FX_DWORD dwSr cmsCloseProfile(dstProfile); return pCmm; } -void* IccLib_CreateTransform_sRGB(const unsigned char* pProfileData, FX_DWORD dwProfileSize, FX_INT32& nComponents, FX_INT32 intent, FX_DWORD dwSrcFormat) +void* IccLib_CreateTransform_sRGB(const unsigned char* pProfileData, FX_DWORD dwProfileSize, int32_t& nComponents, int32_t intent, FX_DWORD dwSrcFormat) { return IccLib_CreateTransform(pProfileData, dwProfileSize, nComponents, NULL, 0, 3, intent, dwSrcFormat); } @@ -175,7 +175,7 @@ void IccLib_Translate(void* pTransform, FX_DWORD nSrcComponents, FX_FLOAT* pSrcV return; } CLcmsCmm* p = (CLcmsCmm*)pTransform; - FX_BYTE output[4]; + uint8_t output[4]; if (p->m_bLab) { CFX_FixedBufGrow inputs(nSrcComponents); double* input = inputs; @@ -184,8 +184,8 @@ void IccLib_Translate(void* pTransform, FX_DWORD nSrcComponents, FX_FLOAT* pSrcV } cmsDoTransform(p->m_hTransform, input, output, 1); } else { - CFX_FixedBufGrow inputs(nSrcComponents); - FX_BYTE* input = inputs; + CFX_FixedBufGrow inputs(nSrcComponents); + uint8_t* input = inputs; for (FX_DWORD i = 0; i < nSrcComponents; i ++) { if (pSrcValues[i] > 1.0f) { input[i] = 255; @@ -214,7 +214,7 @@ void IccLib_Translate(void* pTransform, FX_DWORD nSrcComponents, FX_FLOAT* pSrcV break; } } -void IccLib_TranslateImage(void* pTransform, unsigned char* pDest, const unsigned char* pSrc, FX_INT32 pixels) +void IccLib_TranslateImage(void* pTransform, unsigned char* pDest, const unsigned char* pSrc, int32_t pixels) { cmsDoTransform(((CLcmsCmm*)pTransform)->m_hTransform, (void*)pSrc, pDest, pixels); } @@ -284,7 +284,7 @@ ICodec_IccModule::IccCS CCodec_IccModule::GetProfileCS(IFX_FileRead* pFile) } ICodec_IccModule::IccCS cs; FX_DWORD dwSize = (FX_DWORD)pFile->GetSize(); - FX_LPBYTE pBuf = FX_Alloc(FX_BYTE, dwSize); + FX_LPBYTE pBuf = FX_Alloc(uint8_t, dwSize); pFile->ReadBlock(pBuf, 0, dwSize); cs = GetProfileCS(pBuf, dwSize); FX_Free(pBuf); @@ -406,7 +406,7 @@ FX_LPVOID CCodec_IccModule::CreateProfile(ICodec_IccModule::IccParam* pIccParam, CFX_ByteStringKey key; CFX_ByteString text; key << pIccParam->ColorSpace << (pIccParam->dwProfileType | ic << 8); - FX_BYTE ID[16]; + uint8_t ID[16]; switch (pIccParam->dwProfileType) { case Icc_PARAMTYPE_NONE: return NULL; @@ -526,12 +526,12 @@ CCodec_IccModule::~CCodec_IccModule() } } } -void* CCodec_IccModule::CreateTransform_sRGB(FX_LPCBYTE pProfileData, FX_DWORD dwProfileSize, FX_INT32& nComponents, FX_INT32 intent, FX_DWORD dwSrcFormat) +void* CCodec_IccModule::CreateTransform_sRGB(FX_LPCBYTE pProfileData, FX_DWORD dwProfileSize, int32_t& nComponents, int32_t intent, FX_DWORD dwSrcFormat) { return IccLib_CreateTransform_sRGB(pProfileData, dwProfileSize, nComponents, intent, dwSrcFormat); } -void* CCodec_IccModule::CreateTransform_CMYK(FX_LPCBYTE pSrcProfileData, FX_DWORD dwSrcProfileSize, FX_INT32& nSrcComponents, - FX_LPCBYTE pDstProfileData, FX_DWORD dwDstProfileSize, FX_INT32 intent, +void* CCodec_IccModule::CreateTransform_CMYK(FX_LPCBYTE pSrcProfileData, FX_DWORD dwSrcProfileSize, int32_t& nSrcComponents, + FX_LPCBYTE pDstProfileData, FX_DWORD dwDstProfileSize, int32_t intent, FX_DWORD dwSrcFormat , FX_DWORD dwDstFormat) { return IccLib_CreateTransform(pSrcProfileData, dwSrcProfileSize, nSrcComponents, @@ -545,11 +545,11 @@ void CCodec_IccModule::Translate(void* pTransform, FX_FLOAT* pSrcValues, FX_FLOA { IccLib_Translate(pTransform, m_nComponents, pSrcValues, pDestValues); } -void CCodec_IccModule::TranslateScanline(void* pTransform, FX_LPBYTE pDest, FX_LPCBYTE pSrc, FX_INT32 pixels) +void CCodec_IccModule::TranslateScanline(void* pTransform, FX_LPBYTE pDest, FX_LPCBYTE pSrc, int32_t pixels) { IccLib_TranslateImage(pTransform, pDest, pSrc, pixels); } -const FX_BYTE g_CMYKSamples[81 * 81 * 3] = { +const uint8_t g_CMYKSamples[81 * 81 * 3] = { 255, 255, 255, 225, 226, 228, 199, 200, 202, 173, 174, 178, 147, 149, 152, 123, 125, 128, 99, 99, 102, 69, 70, 71, 34, 30, 31, 255, 253, 229, 226, 224, 203, 200, 199, 182, 173, 173, 158, 149, 148, 135, 125, 124, 113, 99, 99, 90, 70, 69, 63, 33, 29, 24, 255, 251, 204, 228, 223, 182, 201, 198, 163, 174, 172, 142, 150, 147, 122, 125, 123, 101, 99, 98, 80, 70, 68, 54, 32, 28, 16, @@ -1280,7 +1280,7 @@ const FX_BYTE g_CMYKSamples[81 * 81 * 3] = { 53, 53, 66, 47, 44, 57, 40, 36, 48, 32, 27, 39, 22, 18, 30, 9, 4, 18, 0, 0, 3, 0, 0, 0, 0, 0, 0, 54, 53, 57, 48, 45, 49, 41, 37, 41, 33, 28, 32, 22, 19, 23, 11, 6, 10, 1, 0, 0, 0, 0, 0, 0, 0, 0, }; -void AdobeCMYK_to_sRGB1(FX_BYTE c, FX_BYTE m, FX_BYTE y, FX_BYTE k, FX_BYTE& R, FX_BYTE& G, FX_BYTE& B) +void AdobeCMYK_to_sRGB1(uint8_t c, uint8_t m, uint8_t y, uint8_t k, uint8_t& R, uint8_t& G, uint8_t& B) { int fix_c = c << 8; int fix_m = m << 8; @@ -1357,11 +1357,11 @@ void AdobeCMYK_to_sRGB1(FX_BYTE c, FX_BYTE m, FX_BYTE y, FX_BYTE k, FX_BYTE& R, } void AdobeCMYK_to_sRGB(FX_FLOAT c, FX_FLOAT m, FX_FLOAT y, FX_FLOAT k, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B) { - FX_BYTE c1 = FXSYS_round(c * 255); - FX_BYTE m1 = FXSYS_round(m * 255); - FX_BYTE y1 = FXSYS_round(y * 255); - FX_BYTE k1 = FXSYS_round(k * 255); - FX_BYTE r, g, b; + uint8_t c1 = FXSYS_round(c * 255); + uint8_t m1 = FXSYS_round(m * 255); + uint8_t y1 = FXSYS_round(y * 255); + uint8_t k1 = FXSYS_round(k * 255); + uint8_t r, g, b; AdobeCMYK_to_sRGB1(c1, m1, y1, k1, r, g, b); R = 1.0f * r / 255; G = 1.0f * g / 255; diff --git a/core/src/fxcodec/codec/fx_codec_jbig.cpp b/core/src/fxcodec/codec/fx_codec_jbig.cpp index 8fcd9f4711..622448d659 100644 --- a/core/src/fxcodec/codec/fx_codec_jbig.cpp +++ b/core/src/fxcodec/codec/fx_codec_jbig.cpp @@ -52,7 +52,7 @@ FX_BOOL CCodec_Jbig2Module::Decode(IFX_FileRead* file_ptr, CJBig2_Context* pContext = NULL; CJBig2_Image* dest_image = NULL; FX_DWORD src_size = (FX_DWORD)file_ptr->GetSize(); - FX_LPBYTE src_buf = FX_Alloc(FX_BYTE, src_size); + FX_LPBYTE src_buf = FX_Alloc(uint8_t, src_size); int ret = 0; if(!file_ptr->ReadBlock(src_buf, 0, src_size)) { goto failed; @@ -129,7 +129,7 @@ FXCODEC_STATUS CCodec_Jbig2Module::StartDecode(void* pJbig2Context, IFX_FileRead m_pJbig2Context->m_bFileReader = TRUE; m_pJbig2Context->m_dest_image = NULL; m_pJbig2Context->m_src_size = (FX_DWORD)file_ptr->GetSize(); - m_pJbig2Context->m_src_buf = FX_Alloc(FX_BYTE, m_pJbig2Context->m_src_size); + m_pJbig2Context->m_src_buf = FX_Alloc(uint8_t, m_pJbig2Context->m_src_size); int ret = 0; if(!file_ptr->ReadBlock((void*)m_pJbig2Context->m_src_buf, 0, m_pJbig2Context->m_src_size)) { goto failed; diff --git a/core/src/fxcodec/codec/fx_codec_jpeg.cpp b/core/src/fxcodec/codec/fx_codec_jpeg.cpp index 9dcc87bcdf..111cbcf245 100644 --- a/core/src/fxcodec/codec/fx_codec_jpeg.cpp +++ b/core/src/fxcodec/codec/fx_codec_jpeg.cpp @@ -12,7 +12,7 @@ #include "codec_int.h" extern "C" { - static void _JpegScanSOI(const FX_BYTE*& src_buf, FX_DWORD& src_size) + static void _JpegScanSOI(const uint8_t*& src_buf, FX_DWORD& src_size) { if (src_size == 0) { return; @@ -88,15 +88,15 @@ static FX_BOOL _JpegEmbedIccProfile(j_compress_ptr cinfo, FX_LPCBYTE icc_buf_ptr return FALSE; } FX_DWORD icc_data_length = JPEG_OVERHEAD_LEN + (icc_segment_num > 1 ? icc_segment_size : icc_length); - FX_LPBYTE icc_data = FX_Alloc(FX_BYTE, icc_data_length); + FX_LPBYTE icc_data = FX_Alloc(uint8_t, icc_data_length); FXSYS_memcpy32(icc_data, "\x49\x43\x43\x5f\x50\x52\x4f\x46\x49\x4c\x45\x00", 12); - icc_data[13] = (FX_BYTE)icc_segment_num; - for (FX_BYTE i = 0; i < (icc_segment_num - 1); i++) { + icc_data[13] = (uint8_t)icc_segment_num; + for (uint8_t i = 0; i < (icc_segment_num - 1); i++) { icc_data[12] = i + 1; FXSYS_memcpy32(icc_data + JPEG_OVERHEAD_LEN, icc_buf_ptr + i * icc_segment_size, icc_segment_size); jpeg_write_marker(cinfo, JPEG_MARKER_ICC, icc_data, icc_data_length); } - icc_data[12] = (FX_BYTE)icc_segment_num; + icc_data[12] = (uint8_t)icc_segment_num; FX_DWORD icc_size = (icc_segment_num - 1) * icc_segment_size; FXSYS_memcpy32(icc_data + JPEG_OVERHEAD_LEN, icc_buf_ptr + icc_size, icc_length - icc_size); jpeg_write_marker(cinfo, JPEG_MARKER_ICC, icc_data, JPEG_OVERHEAD_LEN + icc_length - icc_size); @@ -144,11 +144,11 @@ static void _JpegEncode(const CFX_DIBSource* pSource, FX_LPBYTE& dest_buf, FX_ST dest_buf = nullptr; } else { dest_buf_length = safe_buf_len.ValueOrDie(); - dest_buf = FX_TryAlloc(FX_BYTE, dest_buf_length); + dest_buf = FX_TryAlloc(uint8_t, dest_buf_length); const int MIN_TRY_BUF_LEN = 1024; while (!dest_buf && dest_buf_length > MIN_TRY_BUF_LEN) { dest_buf_length >>= 1; - dest_buf = FX_TryAlloc(FX_BYTE, dest_buf_length); + dest_buf = FX_TryAlloc(uint8_t, dest_buf_length); } } if (!dest_buf) { @@ -173,7 +173,7 @@ static void _JpegEncode(const CFX_DIBSource* pSource, FX_LPBYTE& dest_buf, FX_ST } FX_LPBYTE line_buf = NULL; if (nComponents > 1) { - line_buf = FX_Alloc2D(FX_BYTE, width, nComponents); + line_buf = FX_Alloc2D(uint8_t, width, nComponents); } jpeg_set_defaults(&cinfo); if(quality != 75) { @@ -207,7 +207,7 @@ static void _JpegEncode(const CFX_DIBSource* pSource, FX_LPBYTE& dest_buf, FX_ST row = cinfo.next_scanline; jpeg_write_scanlines(&cinfo, row_pointer, 1); if (cinfo.next_scanline == row) { - dest_buf = FX_Realloc(FX_BYTE, dest_buf, dest_buf_length + JPEG_BLOCK_SIZE); + dest_buf = FX_Realloc(uint8_t, dest_buf, dest_buf_length + JPEG_BLOCK_SIZE); dest.next_output_byte = dest_buf + dest_buf_length - dest.free_in_buffer; dest_buf_length += JPEG_BLOCK_SIZE; dest.free_in_buffer += JPEG_BLOCK_SIZE; @@ -404,7 +404,7 @@ FX_BOOL CCodec_JpegDecoder::Create(FX_LPCBYTE src_buf, FX_DWORD src_size, int wi return FALSE; } m_Pitch = (cinfo.image_width * cinfo.num_components + 3) / 4 * 4; - m_pScanlineBuf = FX_Alloc(FX_BYTE, m_Pitch); + m_pScanlineBuf = FX_Alloc(uint8_t, m_Pitch); m_nComps = cinfo.num_components; m_bpc = 8; m_bColorTransformed = FALSE; @@ -412,7 +412,7 @@ FX_BOOL CCodec_JpegDecoder::Create(FX_LPCBYTE src_buf, FX_DWORD src_size, int wi return TRUE; } extern "C" { - FX_INT32 FX_GetDownsampleRatio(FX_INT32 originWidth, FX_INT32 originHeight, FX_INT32 downsampleWidth, FX_INT32 downsampleHeight) + int32_t FX_GetDownsampleRatio(int32_t originWidth, int32_t originHeight, int32_t downsampleWidth, int32_t downsampleHeight) { int iratio_w = originWidth / downsampleWidth; int iratio_h = originHeight / downsampleHeight; @@ -564,7 +564,7 @@ void* CCodec_JpegModule::Start() if (m_pExtProvider) { return m_pExtProvider->Start(); } - FXJPEG_Context* p = (FXJPEG_Context*)FX_Alloc(FX_BYTE, sizeof(FXJPEG_Context)); + FXJPEG_Context* p = (FXJPEG_Context*)FX_Alloc(uint8_t, sizeof(FXJPEG_Context)); p->m_AllocFunc = jpeg_alloc_func; p->m_FreeFunc = jpeg_free_func; p->m_ErrMgr.error_exit = _error_fatal1; diff --git a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp index 1a1616c0a1..01faf67a30 100644 --- a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp +++ b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp @@ -714,7 +714,7 @@ FX_BOOL CJPX_Decoder::Decode(FX_LPBYTE dest_buf, int pitch, FX_BOOL bTranslateCo return FALSE; } FXSYS_memset8(dest_buf, 0xff, image->y1 * pitch); - FX_BYTE** channel_bufs = FX_Alloc(FX_BYTE*, image->numcomps); + uint8_t** channel_bufs = FX_Alloc(uint8_t*, image->numcomps); FX_BOOL result = FALSE; int* adjust_comps = FX_Alloc(int, image->numcomps); for (i = 0; i < (int)image->numcomps; i ++) { @@ -742,7 +742,7 @@ FX_BOOL CJPX_Decoder::Decode(FX_LPBYTE dest_buf, int pitch, FX_BOOL bTranslateCo if (adjust_comps[channel] > 0) { *pPixel = 0; } else { - *pPixel = (FX_BYTE)(src << -adjust_comps[channel]); + *pPixel = (uint8_t)(src << -adjust_comps[channel]); } } } @@ -757,7 +757,7 @@ FX_BOOL CJPX_Decoder::Decode(FX_LPBYTE dest_buf, int pitch, FX_BOOL bTranslateCo src = image->comps[channel].data[row * wid + col]; src += image->comps[channel].sgnd ? 1 << (image->comps[channel].prec - 1) : 0; if (adjust_comps[channel] - 1 < 0) { - *pPixel = (FX_BYTE)((src >> adjust_comps[channel])); + *pPixel = (uint8_t)((src >> adjust_comps[channel])); } else { int tmpPixel = (src >> adjust_comps[channel]) + ((src >> (adjust_comps[channel] - 1)) % 2); if (tmpPixel > 255) { @@ -765,7 +765,7 @@ FX_BOOL CJPX_Decoder::Decode(FX_LPBYTE dest_buf, int pitch, FX_BOOL bTranslateCo } else if (tmpPixel < 0) { tmpPixel = 0; } - *pPixel = (FX_BYTE)tmpPixel; + *pPixel = (uint8_t)tmpPixel; } } } -- cgit v1.2.3