summaryrefslogtreecommitdiff
path: root/core/src/fxcodec/codec
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/fxcodec/codec')
-rw-r--r--core/src/fxcodec/codec/codec_int.h42
-rw-r--r--core/src/fxcodec/codec/fx_codec.cpp58
-rw-r--r--core/src/fxcodec/codec/fx_codec_fax.cpp86
-rw-r--r--core/src/fxcodec/codec/fx_codec_flate.cpp54
-rw-r--r--core/src/fxcodec/codec/fx_codec_icc.cpp30
-rw-r--r--core/src/fxcodec/codec/fx_codec_jbig.cpp24
-rw-r--r--core/src/fxcodec/codec/fx_codec_jpeg.cpp108
-rw-r--r--core/src/fxcodec/codec/fx_codec_jpx_opj.cpp44
8 files changed, 223 insertions, 223 deletions
diff --git a/core/src/fxcodec/codec/codec_int.h b/core/src/fxcodec/codec/codec_int.h
index 7668f84a20..dc64748e83 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 uint8_t* src_buf, FX_DWORD src_size, uint8_t*& dest_buf,
+ virtual bool RunLengthEncode(const uint8_t* src_buf, FX_DWORD src_size, uint8_t*& dest_buf,
FX_DWORD& dest_size);
- virtual FX_BOOL A85Encode(const uint8_t* src_buf, FX_DWORD src_size, uint8_t*& dest_buf,
+ virtual bool A85Encode(const uint8_t* src_buf, FX_DWORD src_size, uint8_t*& dest_buf,
FX_DWORD& dest_size);
virtual ICodec_ScanlineDecoder* CreateRunLengthDecoder(const uint8_t* src_buf, FX_DWORD src_size, int width, int height,
int nComps, int bpc);
@@ -46,7 +46,7 @@ public:
uint8_t* GetScanline(int line);
- FX_BOOL SkipToScanline(int line, IFX_Pause* pPause);
+ bool SkipToScanline(int line, IFX_Pause* pPause);
int GetWidth()
{
@@ -68,7 +68,7 @@ public:
return m_bpc;
}
- FX_BOOL IsColorTransformed()
+ bool IsColorTransformed()
{
return m_bColorTransformed;
}
@@ -98,11 +98,11 @@ protected:
int m_Pitch;
- FX_BOOL m_bColorTransformed;
+ bool m_bColorTransformed;
uint8_t* ReadNextLine();
- virtual FX_BOOL v_Rewind() = 0;
+ virtual bool v_Rewind() = 0;
virtual uint8_t* v_GetNextLine() = 0;
@@ -118,21 +118,21 @@ class CCodec_FaxModule : public ICodec_FaxModule
{
public:
virtual ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf, FX_DWORD src_size, int width, int height,
- int K, FX_BOOL EndOfLine, FX_BOOL EncodedByteAlign, FX_BOOL BlackIs1, int Columns, int Rows);
- FX_BOOL Encode(const uint8_t* src_buf, int width, int height, int pitch, uint8_t*& dest_buf, FX_DWORD& dest_size);
+ int K, bool EndOfLine, bool EncodedByteAlign, bool BlackIs1, int Columns, int Rows);
+ bool Encode(const uint8_t* src_buf, int width, int height, int pitch, uint8_t*& dest_buf, FX_DWORD& dest_size);
};
class CCodec_FlateModule : public ICodec_FlateModule
{
public:
virtual ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* 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 uint8_t* src_buf, FX_DWORD src_size, FX_BOOL bEarlyChange,
+ virtual FX_DWORD FlateOrLZWDecode(bool bLZW, const uint8_t* src_buf, FX_DWORD src_size, bool bEarlyChange,
int predictor, int Colors, int BitsPerComponent, int Columns,
FX_DWORD estimated_size, uint8_t*& dest_buf, FX_DWORD& dest_size);
- virtual FX_BOOL Encode(const uint8_t* src_buf, FX_DWORD src_size,
+ virtual bool Encode(const uint8_t* src_buf, FX_DWORD src_size,
int predictor, int Colors, int BitsPerComponent, int Columns,
uint8_t*& dest_buf, FX_DWORD& dest_size);
- virtual FX_BOOL Encode(const uint8_t* src_buf, FX_DWORD src_size, uint8_t*& dest_buf, FX_DWORD& dest_size);
+ virtual bool Encode(const uint8_t* src_buf, FX_DWORD src_size, uint8_t*& dest_buf, FX_DWORD& dest_size);
};
class CCodec_JpegModule : public ICodec_JpegModule
{
@@ -143,17 +143,17 @@ public:
m_pExtProvider = pJP;
}
ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf, FX_DWORD src_size,
- int width, int height, int nComps, FX_BOOL ColorTransform);
- FX_BOOL LoadInfo(const uint8_t* src_buf, FX_DWORD src_size, int& width, int& height,
- int& num_components, int& bits_per_components, FX_BOOL& color_transform,
+ int width, int height, int nComps, bool ColorTransform);
+ bool LoadInfo(const uint8_t* src_buf, FX_DWORD src_size, int& width, int& height,
+ int& num_components, int& bits_per_components, bool& color_transform,
uint8_t** icc_buf_ptr, FX_DWORD* icc_length);
- FX_BOOL Encode(const CFX_DIBSource* pSource, uint8_t*& dest_buf, FX_STRSIZE& dest_size, int quality, const uint8_t* icc_buf, FX_DWORD icc_length);
+ bool Encode(const CFX_DIBSource* pSource, uint8_t*& dest_buf, FX_STRSIZE& dest_size, int quality, const uint8_t* icc_buf, FX_DWORD icc_length);
virtual void* Start();
virtual void Finish(void* pContext);
virtual void Input(void* pContext, const uint8_t* src_buf, FX_DWORD src_size);
virtual int ReadHeader(void* pContext, int* width, int* height, int* nComps);
virtual int StartScanline(void* pContext, int down_scale);
- virtual FX_BOOL ReadScanline(void* pContext, uint8_t* dest_buf);
+ virtual bool ReadScanline(void* pContext, uint8_t* dest_buf);
virtual FX_DWORD GetAvailInput(void* pContext, uint8_t** avail_buf_ptr);
protected:
IFX_JpegProvider* m_pExtProvider;
@@ -199,10 +199,10 @@ class CCodec_JpxModule : public ICodec_JpxModule
{
public:
CCodec_JpxModule();
- void* CreateDecoder(const uint8_t* src_buf, FX_DWORD src_size, FX_BOOL useColorSpace = FALSE);
+ void* CreateDecoder(const uint8_t* src_buf, FX_DWORD src_size, bool useColorSpace = false);
void GetImageInfo(void* ctx, FX_DWORD& width, FX_DWORD& height,
FX_DWORD& codestream_nComps, FX_DWORD& output_nComps);
- FX_BOOL Decode(void* ctx, uint8_t* dest_data, int pitch, FX_BOOL bTranslateColor, uint8_t* offsets);
+ bool Decode(void* ctx, uint8_t* dest_data, int pitch, bool bTranslateColor, uint8_t* offsets);
void DestroyDecoder(void* ctx);
};
class CPDF_Jbig2Interface : public CJBig2_Module
@@ -253,7 +253,7 @@ public:
FX_DWORD m_global_size;
uint8_t* m_dest_buf;
FX_DWORD m_dest_pitch;
- FX_BOOL m_bFileReader;
+ bool m_bFileReader;
IFX_Pause* m_pPause;
CJBig2_Context* m_pContext;
CJBig2_Image* m_dest_image;
@@ -263,9 +263,9 @@ class CCodec_Jbig2Module : public ICodec_Jbig2Module
public:
CCodec_Jbig2Module() {};
~CCodec_Jbig2Module();
- FX_BOOL Decode(FX_DWORD width, FX_DWORD height, const uint8_t* src_buf, FX_DWORD src_size,
+ bool Decode(FX_DWORD width, FX_DWORD height, const uint8_t* src_buf, FX_DWORD src_size,
const uint8_t* global_data, FX_DWORD global_size, uint8_t* dest_buf, FX_DWORD dest_pitch);
- FX_BOOL Decode(IFX_FileRead* file_ptr,
+ bool Decode(IFX_FileRead* file_ptr,
FX_DWORD& width, FX_DWORD& height, FX_DWORD& pitch, uint8_t*& dest_buf);
void* CreateJbig2Context();
FXCODEC_STATUS StartDecode(void* pJbig2Context, FX_DWORD width, FX_DWORD height, const uint8_t* src_buf, FX_DWORD src_size,
diff --git a/core/src/fxcodec/codec/fx_codec.cpp b/core/src/fxcodec/codec/fx_codec.cpp
index 9bbcce105f..8edfde5319 100644
--- a/core/src/fxcodec/codec/fx_codec.cpp
+++ b/core/src/fxcodec/codec/fx_codec.cpp
@@ -49,13 +49,13 @@ uint8_t* CCodec_ScanlineDecoder::GetScanline(int line)
m_NextLine ++;
return m_pLastScanline;
}
-FX_BOOL CCodec_ScanlineDecoder::SkipToScanline(int line, IFX_Pause* pPause)
+bool CCodec_ScanlineDecoder::SkipToScanline(int line, IFX_Pause* pPause)
{
if (m_pDataCache && line < m_pDataCache->m_nCachedLines) {
- return FALSE;
+ return false;
}
if (m_NextLine == line || m_NextLine == line + 1) {
- return FALSE;
+ return false;
}
if (m_NextLine < 0 || m_NextLine > line) {
v_Rewind();
@@ -66,10 +66,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()
{
@@ -107,10 +107,10 @@ 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 uint8_t* src_buf, FX_DWORD src_size, uint8_t*& dest_buf,
+bool CCodec_BasicModule::RunLengthEncode(const uint8_t* src_buf, FX_DWORD src_size, uint8_t*& dest_buf,
FX_DWORD& dest_size)
{
- return FALSE;
+ return false;
}
extern "C" double FXstrtod(const char* nptr, char** endptr)
{
@@ -216,26 +216,26 @@ extern "C" double FXstrtod(const char* nptr, char** endptr)
}
return is_negative ? -ret : ret;
}
-FX_BOOL CCodec_BasicModule::A85Encode(const uint8_t* src_buf, FX_DWORD src_size, uint8_t*& dest_buf,
+bool CCodec_BasicModule::A85Encode(const uint8_t* src_buf, FX_DWORD src_size, uint8_t*& dest_buf,
FX_DWORD& dest_size)
{
- return FALSE;
+ return false;
}
class CCodec_RLScanlineDecoder : public CCodec_ScanlineDecoder
{
public:
CCodec_RLScanlineDecoder();
virtual ~CCodec_RLScanlineDecoder();
- FX_BOOL Create(const uint8_t* src_buf, FX_DWORD src_size, int width, int height, int nComps, int bpc);
+ bool Create(const uint8_t* src_buf, FX_DWORD src_size, int width, int height, int nComps, int bpc);
virtual void v_DownScale(int dest_width, int dest_height) {}
- virtual FX_BOOL v_Rewind();
+ virtual bool v_Rewind();
virtual uint8_t* v_GetNextLine();
virtual FX_DWORD GetSrcOffset()
{
return m_SrcOffset;
}
protected:
- FX_BOOL CheckDestSize();
+ bool CheckDestSize();
void GetNextOperator();
void UpdateOperator(uint8_t used_bytes);
@@ -244,7 +244,7 @@ protected:
FX_DWORD m_SrcSize;
FX_DWORD m_dwLineBytes;
FX_DWORD m_SrcOffset;
- FX_BOOL m_bEOD;
+ bool m_bEOD;
uint8_t m_Operator;
};
CCodec_RLScanlineDecoder::CCodec_RLScanlineDecoder()
@@ -253,7 +253,7 @@ CCodec_RLScanlineDecoder::CCodec_RLScanlineDecoder()
, m_SrcSize(0)
, m_dwLineBytes(0)
, m_SrcOffset(0)
- , m_bEOD(FALSE)
+ , m_bEOD(false)
, m_Operator(0)
{
}
@@ -263,7 +263,7 @@ CCodec_RLScanlineDecoder::~CCodec_RLScanlineDecoder()
FX_Free(m_pScanline);
}
}
-FX_BOOL CCodec_RLScanlineDecoder::CheckDestSize()
+bool CCodec_RLScanlineDecoder::CheckDestSize()
{
FX_DWORD i = 0;
FX_DWORD old_size = 0;
@@ -273,14 +273,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 {
@@ -288,11 +288,11 @@ FX_BOOL CCodec_RLScanlineDecoder::CheckDestSize()
}
}
if (((FX_DWORD)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, FX_DWORD src_size, int width, int height, int nComps, int bpc)
+bool CCodec_RLScanlineDecoder::Create(const uint8_t* src_buf, FX_DWORD src_size, int width, int height, int nComps, int bpc)
{
m_pSrcBuf = src_buf;
m_SrcSize = src_size;
@@ -300,20 +300,20 @@ FX_BOOL CCodec_RLScanlineDecoder::Create(const uint8_t* src_buf, FX_DWORD src_si
m_OutputHeight = m_OrigHeight = height;
m_nComps = nComps;
m_bpc = bpc;
- m_bColorTransformed = FALSE;
+ m_bColorTransformed = false;
m_DownScale = 1;
m_Pitch = (width * nComps * bpc + 31) / 32 * 4;
m_dwLineBytes = (width * nComps * bpc + 7) / 8;
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()
{
@@ -326,17 +326,17 @@ uint8_t* CCodec_RLScanlineDecoder::v_GetNextLine()
}
FXSYS_memset(m_pScanline, 0, m_Pitch);
FX_DWORD col_pos = 0;
- FX_BOOL eol = FALSE;
+ bool eol = false;
while (m_SrcOffset < m_SrcSize && !eol) {
if (m_Operator < 128) {
FX_DWORD 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;
@@ -349,13 +349,13 @@ uint8_t* CCodec_RLScanlineDecoder::v_GetNextLine()
FX_DWORD 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/src/fxcodec/codec/fx_codec_fax.cpp b/core/src/fxcodec/codec/fx_codec_fax.cpp
index d45600372f..3446d0a7b9 100644
--- a/core/src/fxcodec/codec/fx_codec_fax.cpp
+++ b/core/src/fxcodec/codec/fx_codec_fax.cpp
@@ -79,7 +79,7 @@ int _FindBit(const uint8_t* data_buf, int max_pos, int start_pos, int bit)
}
return pos;
}
-void _FaxG4FindB1B2(const uint8_t* ref_buf, int columns, int a0, FX_BOOL a0color, int& b1, int& b2)
+void _FaxG4FindB1B2(const uint8_t* ref_buf, int columns, int a0, bool a0color, int& b1, int& b2)
{
if (a0color) {
a0color = 1;
@@ -400,27 +400,27 @@ int _FaxGetRun(const uint8_t* ins_array, const uint8_t* src_buf, int& bitpos, in
}
}
}
-FX_BOOL _FaxG4GetRow(const uint8_t* src_buf, int bitsize, int& bitpos, uint8_t* dest_buf, const uint8_t* ref_buf, int columns)
+bool _FaxG4GetRow(const uint8_t* src_buf, int bitsize, int& bitpos, uint8_t* dest_buf, const uint8_t* ref_buf, int columns)
{
int a0 = -1, a0color = 1;
while (1) {
if (bitpos >= bitsize) {
- return FALSE;
+ return false;
}
int a1, a2, b1, b2;
_FaxG4FindB1B2(ref_buf, columns, a0, a0color, b1, b2);
- FX_BOOL bit = NEXTBIT;
+ bool bit = NEXTBIT;
int v_delta = 0;
if (bit) {
} else {
if (bitpos >= bitsize) {
- return FALSE;
+ return false;
}
- FX_BOOL bit1 = NEXTBIT;
+ bool bit1 = NEXTBIT;
if (bitpos >= bitsize) {
- return FALSE;
+ return false;
}
- FX_BOOL bit2 = NEXTBIT;
+ bool bit2 = NEXTBIT;
if (bit1 && bit2) {
v_delta = 1;
} else if (bit1) {
@@ -457,10 +457,10 @@ FX_BOOL _FaxG4GetRow(const uint8_t* src_buf, int bitsize, int& bitpos, uint8_t*
if (a0 < columns) {
continue;
}
- return TRUE;
+ return true;
} else {
if (bitpos >= bitsize) {
- return FALSE;
+ return false;
}
bit = NEXTBIT;
if (bit) {
@@ -468,26 +468,26 @@ FX_BOOL _FaxG4GetRow(const uint8_t* src_buf, int bitsize, int& bitpos, uint8_t*
_FaxFillBits(dest_buf, columns, a0, b2);
}
if (b2 >= columns) {
- return TRUE;
+ return true;
}
a0 = b2;
continue;
} else {
if (bitpos >= bitsize) {
- return FALSE;
+ return false;
}
- FX_BOOL bit1 = NEXTBIT;
+ bool bit1 = NEXTBIT;
if (bitpos >= bitsize) {
- return FALSE;
+ return false;
}
- FX_BOOL bit2 = NEXTBIT;
+ bool bit2 = NEXTBIT;
if (bit1 && bit2) {
v_delta = 2;
} else if (bit1) {
v_delta = -2;
} else if (bit2) {
if (bitpos >= bitsize) {
- return FALSE;
+ return false;
}
bit = NEXTBIT;
if (bit) {
@@ -497,7 +497,7 @@ FX_BOOL _FaxG4GetRow(const uint8_t* src_buf, int bitsize, int& bitpos, uint8_t*
}
} else {
if (bitpos >= bitsize) {
- return FALSE;
+ return false;
}
bit = NEXTBIT;
if (bit) {
@@ -505,7 +505,7 @@ FX_BOOL _FaxG4GetRow(const uint8_t* src_buf, int bitsize, int& bitpos, uint8_t*
continue;
} else {
bitpos += 5;
- return TRUE;
+ return true;
}
}
}
@@ -516,13 +516,13 @@ FX_BOOL _FaxG4GetRow(const uint8_t* src_buf, int bitsize, int& bitpos, uint8_t*
_FaxFillBits(dest_buf, columns, a0, a1);
}
if (a1 >= columns) {
- return TRUE;
+ return true;
}
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) {
@@ -531,18 +531,18 @@ FX_BOOL _FaxSkipEOL(const uint8_t* src_buf, int bitsize, int& bitpos)
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, uint8_t* dest_buf, int columns)
+bool _FaxGet1DLine(const uint8_t* src_buf, int bitsize, int& bitpos, uint8_t* dest_buf, int columns)
{
- int color = TRUE;
+ int color = true;
int startpos = 0;
while (1) {
if (bitpos >= bitsize) {
- return FALSE;
+ return false;
}
int run_len = 0;
while (1) {
@@ -551,10 +551,10 @@ FX_BOOL _FaxGet1DLine(const uint8_t* src_buf, int bitsize, int& bitpos, uint8_t*
while (bitpos < bitsize) {
int bit = NEXTBIT;
if (bit) {
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
run_len += run;
if (run < 64) {
@@ -570,17 +570,17 @@ FX_BOOL _FaxGet1DLine(const uint8_t* src_buf, int bitsize, int& bitpos, uint8_t*
}
color = !color;
}
- return TRUE;
+ return true;
}
class CCodec_FaxDecoder : public CCodec_ScanlineDecoder
{
public:
CCodec_FaxDecoder();
virtual ~CCodec_FaxDecoder();
- FX_BOOL Create(const uint8_t* src_buf, FX_DWORD src_size, int width, int height,
- int K, FX_BOOL EndOfLine, FX_BOOL EncodedByteAlign, FX_BOOL BlackIs1, int Columns, int Rows);
+ bool Create(const uint8_t* src_buf, FX_DWORD src_size, int width, int height,
+ int K, bool EndOfLine, bool EncodedByteAlign, bool BlackIs1, int Columns, int Rows);
virtual void v_DownScale(int dest_width, int dest_height) {}
- virtual FX_BOOL v_Rewind();
+ virtual bool v_Rewind();
virtual uint8_t* v_GetNextLine();
virtual FX_DWORD GetSrcOffset();
int m_Encoding, m_bEndOfLine, m_bByteAlign, m_bBlack;
@@ -604,8 +604,8 @@ CCodec_FaxDecoder::~CCodec_FaxDecoder()
FX_Free(m_pRefBuf);
}
}
-FX_BOOL CCodec_FaxDecoder::Create(const uint8_t* src_buf, FX_DWORD src_size, int width, int height,
- int K, FX_BOOL EndOfLine, FX_BOOL EncodedByteAlign, FX_BOOL BlackIs1, int Columns, int Rows)
+bool CCodec_FaxDecoder::Create(const uint8_t* src_buf, FX_DWORD src_size, int width, int height,
+ int K, bool EndOfLine, bool EncodedByteAlign, bool BlackIs1, int Columns, int Rows)
{
m_Encoding = K;
m_bEndOfLine = EndOfLine;
@@ -628,14 +628,14 @@ FX_BOOL CCodec_FaxDecoder::Create(const uint8_t* src_buf, FX_DWORD src_size, int
m_SrcSize = src_size;
m_nComps = 1;
m_bpc = 1;
- m_bColorTransformed = FALSE;
- return TRUE;
+ m_bColorTransformed = false;
+ return true;
}
-FX_BOOL CCodec_FaxDecoder::v_Rewind()
+bool CCodec_FaxDecoder::v_Rewind()
{
FXSYS_memset(m_pRefBuf, 0xff, m_Pitch);
bitpos = 0;
- return TRUE;
+ return true;
}
uint8_t* CCodec_FaxDecoder::v_GetNextLine()
{
@@ -651,7 +651,7 @@ uint8_t* CCodec_FaxDecoder::v_GetNextLine()
} else if (m_Encoding == 0) {
_FaxGet1DLine(m_pSrcBuf, bitsize, bitpos, m_pScanlineBuf, m_OrigWidth);
} else {
- FX_BOOL bNext1D = m_pSrcBuf[bitpos / 8] & (1 << (7 - bitpos % 8));
+ bool bNext1D = m_pSrcBuf[bitpos / 8] & (1 << (7 - bitpos % 8));
bitpos ++;
if (bNext1D) {
_FaxGet1DLine(m_pSrcBuf, bitsize, bitpos, m_pScanlineBuf, m_OrigWidth);
@@ -669,7 +669,7 @@ uint8_t* CCodec_FaxDecoder::v_GetNextLine()
while (m_bByteAlign && bitpos0 < bitpos1) {
int bit = m_pSrcBuf[bitpos0 / 8] & (1 << (7 - bitpos0 % 8));
if (bit != 0) {
- m_bByteAlign = FALSE;
+ m_bByteAlign = false;
} else {
bitpos0 ++;
}
@@ -846,7 +846,7 @@ static void _AddBitStream(uint8_t* dest_buf, int& dest_bitpos, int data, int bit
dest_bitpos ++;
}
}
-static void _FaxEncodeRun(uint8_t* dest_buf, int& dest_bitpos, int run, FX_BOOL bWhite)
+static void _FaxEncodeRun(uint8_t* dest_buf, int& dest_bitpos, int run, bool bWhite)
{
while (run >= 2560) {
_AddBitStream(dest_buf, dest_bitpos, 0x1f, 12);
@@ -972,14 +972,14 @@ void CCodec_FaxEncoder::Encode(uint8_t*& dest_buf, FX_DWORD& dest_size)
dest_size = m_DestBuf.GetSize();
m_DestBuf.DetachBuffer();
}
-FX_BOOL CCodec_FaxModule::Encode(const uint8_t* src_buf, int width, int height, int pitch, uint8_t*& dest_buf, FX_DWORD& dest_size)
+bool CCodec_FaxModule::Encode(const uint8_t* src_buf, int width, int height, int pitch, uint8_t*& dest_buf, FX_DWORD& dest_size)
{
CCodec_FaxEncoder encoder(src_buf, width, height, pitch);
encoder.Encode(dest_buf, dest_size);
- return TRUE;
+ return true;
}
ICodec_ScanlineDecoder* CCodec_FaxModule::CreateDecoder(const uint8_t* src_buf, FX_DWORD src_size, int width, int height,
- int K, FX_BOOL EndOfLine, FX_BOOL EncodedByteAlign, FX_BOOL BlackIs1, int Columns, int Rows)
+ int K, bool EndOfLine, bool EncodedByteAlign, bool BlackIs1, int Columns, int Rows)
{
CCodec_FaxDecoder* pDecoder = new CCodec_FaxDecoder;
pDecoder->Create(src_buf, src_size, width, height, K, EndOfLine, EncodedByteAlign, BlackIs1, Columns, Rows);
diff --git a/core/src/fxcodec/codec/fx_codec_flate.cpp b/core/src/fxcodec/codec/fx_codec_flate.cpp
index d129e36392..a61be75bbe 100644
--- a/core/src/fxcodec/codec/fx_codec_flate.cpp
+++ b/core/src/fxcodec/codec/fx_codec_flate.cpp
@@ -84,7 +84,7 @@ extern "C"
class CLZWDecoder
{
public:
- int Decode(uint8_t* output, FX_DWORD& outlen, const uint8_t* input, FX_DWORD& size, FX_BOOL bEarlyChange);
+ int Decode(uint8_t* output, FX_DWORD& outlen, const uint8_t* input, FX_DWORD& size, bool bEarlyChange);
private:
void AddCode(FX_DWORD prefix_code, uint8_t append_char);
@@ -94,7 +94,7 @@ private:
FX_DWORD m_OutPos;
uint8_t* m_pOutput;
const uint8_t* m_pInput;
- FX_BOOL m_Early;
+ bool m_Early;
FX_DWORD m_CodeArray[5021];
FX_DWORD m_nCodes;
uint8_t m_DecodeStack[4000];
@@ -134,7 +134,7 @@ void CLZWDecoder::DecodeString(FX_DWORD code)
}
m_DecodeStack[m_StackLen++] = (uint8_t)code;
}
-int CLZWDecoder::Decode(uint8_t* dest_buf, FX_DWORD& dest_size, const uint8_t* src_buf, FX_DWORD& src_size, FX_BOOL bEarlyChange)
+int CLZWDecoder::Decode(uint8_t* dest_buf, FX_DWORD& dest_size, const uint8_t* src_buf, FX_DWORD& src_size, bool bEarlyChange)
{
m_CodeLen = 9;
m_InPos = 0;
@@ -238,14 +238,14 @@ static uint8_t PaethPredictor(int a, int b, int c)
}
return (uint8_t)c;
}
-static FX_BOOL PNG_PredictorEncode(uint8_t*& data_buf, FX_DWORD& data_size,
+static bool PNG_PredictorEncode(uint8_t*& data_buf, FX_DWORD& data_size,
int predictor, 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 - 1) / row_size;
const int last_row_size = data_size % row_size;
uint8_t* dest_buf = FX_Alloc2D(uint8_t, row_size + 1, row_count);
@@ -328,7 +328,7 @@ static FX_BOOL PNG_PredictorEncode(uint8_t*& data_buf, FX_DWORD& data_size,
FX_Free(data_buf);
data_buf = dest_buf;
data_size = (row_size + 1) * row_count - (last_row_size > 0 ? (row_size - last_row_size) : 0);
- return TRUE;
+ return true;
}
static void PNG_PredictLine(uint8_t* pDestData, const uint8_t* pSrcData, const uint8_t* pLastLine,
int bpc, int nColors, int nPixels)
@@ -393,13 +393,13 @@ static void PNG_PredictLine(uint8_t* pDestData, const uint8_t* pSrcData, const u
}
}
}
-static FX_BOOL PNG_Predictor(uint8_t*& data_buf, FX_DWORD& data_size,
+static bool PNG_Predictor(uint8_t*& data_buf, FX_DWORD& 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);
const int last_row_size = data_size % (row_size + 1);
uint8_t* dest_buf = FX_Alloc2D(uint8_t, row_size, row_count);
@@ -479,7 +479,7 @@ static FX_BOOL PNG_Predictor(uint8_t*& data_buf, FX_DWORD& data_size,
FX_Free(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;
}
static void TIFF_PredictorEncodeLine(uint8_t* dest_buf, int row_size, int BitsPerComponent, int Colors, int Columns)
{
@@ -518,12 +518,12 @@ static void TIFF_PredictorEncodeLine(uint8_t* dest_buf, int row_size, int BitsPe
}
}
}
-static FX_BOOL TIFF_PredictorEncode(uint8_t*& data_buf, FX_DWORD& data_size,
+static bool TIFF_PredictorEncode(uint8_t*& data_buf, FX_DWORD& 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++) {
@@ -533,7 +533,7 @@ static FX_BOOL TIFF_PredictorEncode(uint8_t*& data_buf, FX_DWORD& data_size,
}
TIFF_PredictorEncodeLine(scan_line, row_size, BitsPerComponent, Colors, Columns);
}
- return TRUE;
+ return true;
}
static void TIFF_PredictLine(uint8_t* dest_buf, int row_size, int BitsPerComponent, int Colors, int Columns)
{
@@ -568,12 +568,12 @@ static void TIFF_PredictLine(uint8_t* dest_buf, int row_size, int BitsPerCompone
}
}
}
-static FX_BOOL TIFF_Predictor(uint8_t*& data_buf, FX_DWORD& data_size,
+static bool TIFF_Predictor(uint8_t*& data_buf, FX_DWORD& 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 ++) {
@@ -583,7 +583,7 @@ static FX_BOOL TIFF_Predictor(uint8_t*& data_buf, FX_DWORD& data_size,
}
TIFF_PredictLine(scan_line, row_size, BitsPerComponent, Colors, Columns);
}
- return TRUE;
+ return true;
}
class CCodec_FlateScanlineDecoder : public CCodec_ScanlineDecoder
{
@@ -597,7 +597,7 @@ public:
delete this;
}
virtual void v_DownScale(int dest_width, int dest_height) {}
- virtual FX_BOOL v_Rewind();
+ virtual bool v_Rewind();
virtual uint8_t* v_GetNextLine();
virtual FX_DWORD GetSrcOffset();
void* m_pFlate;
@@ -646,7 +646,7 @@ void CCodec_FlateScanlineDecoder::Create(const uint8_t* src_buf, FX_DWORD src_si
m_OutputHeight = m_OrigHeight = height;
m_nComps = nComps;
m_bpc = bpc;
- m_bColorTransformed = FALSE;
+ m_bColorTransformed = false;
m_Pitch = (width * nComps * bpc + 7) / 8;
m_pScanline = FX_Alloc(uint8_t, m_Pitch);
m_Predictor = 0;
@@ -672,18 +672,18 @@ void CCodec_FlateScanlineDecoder::Create(const uint8_t* src_buf, FX_DWORD src_si
}
}
}
-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 == NULL) {
- 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()
{
@@ -732,7 +732,7 @@ FX_DWORD CCodec_FlateScanlineDecoder::GetSrcOffset()
static void FlateUncompress(const uint8_t* src_buf, FX_DWORD src_size, FX_DWORD orig_size,
uint8_t*& dest_buf, FX_DWORD& dest_size, FX_DWORD& offset)
{
- const FX_BOOL useOldImpl = src_size < 10240;
+ const bool useOldImpl = src_size < 10240;
FX_DWORD guess_size = orig_size ? orig_size : src_size * 2;
FX_DWORD alloc_step = orig_size ? 10240 : (src_size < 10240 ? 10240 : src_size);
static const FX_DWORD kMaxInitialAllocSize = 10000000;
@@ -839,7 +839,7 @@ ICodec_ScanlineDecoder* CCodec_FlateModule::CreateDecoder(const uint8_t* src_buf
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 uint8_t* src_buf, FX_DWORD src_size, FX_BOOL bEarlyChange,
+FX_DWORD CCodec_FlateModule::FlateOrLZWDecode(bool bLZW, const uint8_t* src_buf, FX_DWORD src_size, bool bEarlyChange,
int predictor, int Colors, int BitsPerComponent, int Columns,
FX_DWORD estimated_size, uint8_t*& dest_buf, FX_DWORD& dest_size)
{
@@ -876,7 +876,7 @@ FX_DWORD CCodec_FlateModule::FlateOrLZWDecode(FX_BOOL bLZW, const uint8_t* src_b
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);
@@ -886,7 +886,7 @@ FX_DWORD CCodec_FlateModule::FlateOrLZWDecode(FX_BOOL bLZW, const uint8_t* src_b
}
return ret ? offset : -1;
}
-FX_BOOL CCodec_FlateModule::Encode(const uint8_t* src_buf, FX_DWORD src_size,
+bool CCodec_FlateModule::Encode(const uint8_t* src_buf, FX_DWORD src_size,
int predictor, int Colors, int BitsPerComponent, int Columns,
uint8_t*& dest_buf, FX_DWORD& dest_size)
{
@@ -896,7 +896,7 @@ FX_BOOL CCodec_FlateModule::Encode(const uint8_t* src_buf, FX_DWORD src_size,
uint8_t* pSrcBuf = NULL;
pSrcBuf = FX_Alloc(uint8_t, src_size);
FXSYS_memcpy(pSrcBuf, src_buf, src_size);
- FX_BOOL ret = TRUE;
+ bool ret = true;
if (predictor == 2) {
ret = TIFF_PredictorEncode(pSrcBuf, src_size, Colors, BitsPerComponent,
Columns);
@@ -909,12 +909,12 @@ FX_BOOL CCodec_FlateModule::Encode(const uint8_t* src_buf, FX_DWORD src_size,
FX_Free(pSrcBuf);
return ret;
}
-FX_BOOL CCodec_FlateModule::Encode(const uint8_t* src_buf, FX_DWORD src_size, uint8_t*& dest_buf, FX_DWORD& dest_size)
+bool CCodec_FlateModule::Encode(const uint8_t* src_buf, FX_DWORD src_size, uint8_t*& dest_buf, FX_DWORD& dest_size)
{
dest_size = src_size + src_size / 1000 + 12;
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;
- return TRUE;
+ return true;
}
diff --git a/core/src/fxcodec/codec/fx_codec_icc.cpp b/core/src/fxcodec/codec/fx_codec_icc.cpp
index 7507fe5d6d..0ccfe1fba6 100644
--- a/core/src/fxcodec/codec/fx_codec_icc.cpp
+++ b/core/src/fxcodec/codec/fx_codec_icc.cpp
@@ -14,7 +14,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( const void* buf, FX_DWORD dwSize, uint8_t ID[16] )
+bool MD5ComputeID( const void* buf, FX_DWORD dwSize, uint8_t ID[16] )
{
return cmsMD5computeIDExt(buf, dwSize, ID);
}
@@ -22,50 +22,50 @@ struct CLcmsCmm {
cmsHTRANSFORM m_hTransform;
int m_nSrcComponents;
int m_nDstComponents;
- FX_BOOL m_bLab;
+ bool m_bLab;
};
extern "C" {
int ourHandler(int ErrorCode, const char *ErrorText)
{
- return TRUE;
+ return true;
}
};
-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;
}
int32_t GetCSComponents(cmsColorSpaceSignature cs)
{
@@ -112,12 +112,12 @@ void* IccLib_CreateTransform(const unsigned char* pSrcProfileData, FX_DWORD dwSr
return NULL;
}
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);
if (srcCS == cmsSigRgbData && T_DOSWAP(dwSrcFormat)) {
@@ -125,7 +125,7 @@ void* IccLib_CreateTransform(const unsigned char* pSrcProfileData, FX_DWORD dwSr
}
}
cmsColorSpaceSignature dstCS = cmsGetColorSpace(dstProfile);
- if (!CheckComponents(dstCS, nDstComponents, TRUE)) {
+ if (!CheckComponents(dstCS, nDstComponents, true)) {
cmsCloseProfile(srcProfile);
cmsCloseProfile(dstProfile);
return NULL;
diff --git a/core/src/fxcodec/codec/fx_codec_jbig.cpp b/core/src/fxcodec/codec/fx_codec_jbig.cpp
index 51184306eb..c13a2f9526 100644
--- a/core/src/fxcodec/codec/fx_codec_jbig.cpp
+++ b/core/src/fxcodec/codec/fx_codec_jbig.cpp
@@ -26,28 +26,28 @@ void CCodec_Jbig2Module::DestroyJbig2Context(void* pJbig2Content)
}
pJbig2Content = NULL;
}
-FX_BOOL CCodec_Jbig2Module::Decode(FX_DWORD width, FX_DWORD height, const uint8_t* src_buf, FX_DWORD src_size,
+bool CCodec_Jbig2Module::Decode(FX_DWORD width, FX_DWORD height, const uint8_t* src_buf, FX_DWORD src_size,
const uint8_t* global_data, FX_DWORD global_size, uint8_t* dest_buf, FX_DWORD dest_pitch)
{
FXSYS_memset(dest_buf, 0, height * dest_pitch);
CJBig2_Context* pContext = CJBig2_Context::CreateContext(&m_Module,
(uint8_t*)global_data, global_size, (uint8_t*)src_buf, src_size, JBIG2_EMBED_STREAM, &m_SymbolDictCache);
if (pContext == NULL) {
- return FALSE;
+ return false;
}
int ret = pContext->getFirstPage(dest_buf, width, height, dest_pitch, NULL);
CJBig2_Context::DestroyContext(pContext);
if (ret != JBIG2_SUCCESS) {
- return FALSE;
+ return false;
}
int dword_size = height * dest_pitch / 4;
FX_DWORD* dword_buf = (FX_DWORD*)dest_buf;
for (int i = 0; i < dword_size; i ++) {
dword_buf[i] = ~dword_buf[i];
}
- return TRUE;
+ return true;
}
-FX_BOOL CCodec_Jbig2Module::Decode(IFX_FileRead* file_ptr,
+bool CCodec_Jbig2Module::Decode(IFX_FileRead* file_ptr,
FX_DWORD& width, FX_DWORD& height, FX_DWORD& pitch, uint8_t*& dest_buf)
{
CJBig2_Context* pContext = NULL;
@@ -71,15 +71,15 @@ FX_BOOL CCodec_Jbig2Module::Decode(IFX_FileRead* file_ptr,
height = (FX_DWORD)dest_image->m_nHeight;
pitch = (FX_DWORD)dest_image->m_nStride;
dest_buf = dest_image->m_pData;
- dest_image->m_bNeedFree = FALSE;
+ dest_image->m_bNeedFree = false;
delete dest_image;
FX_Free(src_buf);
- return TRUE;
+ return true;
failed:
if(src_buf) {
FX_Free(src_buf);
}
- return FALSE;
+ return false;
}
FXCODEC_STATUS CCodec_Jbig2Module::StartDecode(void* pJbig2Context, FX_DWORD width, FX_DWORD height, const uint8_t* src_buf, FX_DWORD src_size,
const uint8_t* global_data, FX_DWORD global_size, uint8_t* dest_buf, FX_DWORD dest_pitch, IFX_Pause* pPause)
@@ -97,7 +97,7 @@ FXCODEC_STATUS CCodec_Jbig2Module::StartDecode(void* pJbig2Context, FX_DWORD wid
m_pJbig2Context->m_dest_buf = dest_buf;
m_pJbig2Context->m_dest_pitch = dest_pitch;
m_pJbig2Context->m_pPause = pPause;
- m_pJbig2Context->m_bFileReader = FALSE;
+ m_pJbig2Context->m_bFileReader = false;
FXSYS_memset(dest_buf, 0, height * dest_pitch);
m_pJbig2Context->m_pContext = CJBig2_Context::CreateContext(&m_Module,
(uint8_t*)global_data, global_size, (uint8_t*)src_buf, src_size, JBIG2_EMBED_STREAM, &m_SymbolDictCache, pPause);
@@ -127,7 +127,7 @@ FXCODEC_STATUS CCodec_Jbig2Module::StartDecode(void* pJbig2Context, IFX_FileRead
return FXCODEC_STATUS_ERR_PARAMS;
}
CCodec_Jbig2Context* m_pJbig2Context = (CCodec_Jbig2Context*)pJbig2Context;
- m_pJbig2Context->m_bFileReader = TRUE;
+ 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(uint8_t, m_pJbig2Context->m_src_size);
@@ -145,7 +145,7 @@ FXCODEC_STATUS CCodec_Jbig2Module::StartDecode(void* pJbig2Context, IFX_FileRead
height = (FX_DWORD)m_pJbig2Context->m_dest_image->m_nHeight;
pitch = (FX_DWORD)m_pJbig2Context->m_dest_image->m_nStride;
dest_buf = m_pJbig2Context->m_dest_image->m_pData;
- m_pJbig2Context->m_dest_image->m_bNeedFree = FALSE;
+ m_pJbig2Context->m_dest_image->m_bNeedFree = false;
return FXCODEC_STATUS_DECODE_TOBECONTINUE;
}
CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext);
@@ -157,7 +157,7 @@ FXCODEC_STATUS CCodec_Jbig2Module::StartDecode(void* pJbig2Context, IFX_FileRead
height = (FX_DWORD)m_pJbig2Context->m_dest_image->m_nHeight;
pitch = (FX_DWORD)m_pJbig2Context->m_dest_image->m_nStride;
dest_buf = m_pJbig2Context->m_dest_image->m_pData;
- m_pJbig2Context->m_dest_image->m_bNeedFree = FALSE;
+ m_pJbig2Context->m_dest_image->m_bNeedFree = false;
delete m_pJbig2Context->m_dest_image;
FX_Free(m_pJbig2Context->m_src_buf);
return FXCODEC_STATUS_DECODE_FINISH;
diff --git a/core/src/fxcodec/codec/fx_codec_jpeg.cpp b/core/src/fxcodec/codec/fx_codec_jpeg.cpp
index 6839d31509..1ac2f03c04 100644
--- a/core/src/fxcodec/codec/fx_codec_jpeg.cpp
+++ b/core/src/fxcodec/codec/fx_codec_jpeg.cpp
@@ -78,15 +78,15 @@ extern "C" {
#define JPEG_MARKER_AUTHORTIME (JPEG_APP0 + 3)
#define JPEG_MARKER_MAXSIZE 0xFFFF
#define JPEG_OVERHEAD_LEN 14
-static FX_BOOL _JpegEmbedIccProfile(j_compress_ptr cinfo, const uint8_t* icc_buf_ptr, FX_DWORD icc_length)
+static bool _JpegEmbedIccProfile(j_compress_ptr cinfo, const uint8_t* icc_buf_ptr, FX_DWORD icc_length)
{
if(icc_buf_ptr == NULL || icc_length == 0) {
- return FALSE;
+ return false;
}
FX_DWORD icc_segment_size = (JPEG_MARKER_MAXSIZE - 2 - JPEG_OVERHEAD_LEN);
FX_DWORD icc_segment_num = (icc_length / icc_segment_size) + 1;
if (icc_segment_num > 255) {
- return FALSE;
+ return false;
}
FX_DWORD icc_data_length = JPEG_OVERHEAD_LEN + (icc_segment_num > 1 ? icc_segment_size : icc_length);
uint8_t* icc_data = FX_Alloc(uint8_t, icc_data_length);
@@ -102,7 +102,7 @@ static FX_BOOL _JpegEmbedIccProfile(j_compress_ptr cinfo, const uint8_t* icc_buf
FXSYS_memcpy(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);
FX_Free(icc_data);
- return TRUE;
+ return true;
}
extern "C" {
static void _dest_do_nothing(j_compress_ptr cinfo) {}
@@ -110,7 +110,7 @@ extern "C" {
extern "C" {
static boolean _dest_empty(j_compress_ptr cinfo)
{
- return FALSE;
+ return false;
}
};
#define JPEG_BLOCK_SIZE 1048576
@@ -178,9 +178,9 @@ static void _JpegEncode(const CFX_DIBSource* pSource, uint8_t*& dest_buf, FX_STR
}
jpeg_set_defaults(&cinfo);
if(quality != 75) {
- jpeg_set_quality(&cinfo, quality, TRUE);
+ jpeg_set_quality(&cinfo, quality, true);
}
- jpeg_start_compress(&cinfo, TRUE);
+ jpeg_start_compress(&cinfo, true);
_JpegEmbedIccProfile(&cinfo, icc_buf, icc_length);
JSAMPROW row_pointer[1];
JDIMENSION row;
@@ -221,8 +221,8 @@ static void _JpegEncode(const CFX_DIBSource* pSource, uint8_t*& dest_buf, FX_STR
}
dest_size = dest_buf_length - (FX_STRSIZE)dest.free_in_buffer;
}
-static FX_BOOL _JpegLoadInfo(const uint8_t* src_buf, FX_DWORD src_size, int& width, int& height,
- int& num_components, int& bits_per_components, FX_BOOL& color_transform,
+static bool _JpegLoadInfo(const uint8_t* src_buf, FX_DWORD src_size, int& width, int& height,
+ int& num_components, int& bits_per_components, bool& color_transform,
uint8_t** icc_buf_ptr, FX_DWORD* icc_length)
{
_JpegScanSOI(src_buf, src_size);
@@ -238,7 +238,7 @@ static FX_BOOL _JpegLoadInfo(const uint8_t* src_buf, FX_DWORD src_size, int& wid
jmp_buf mark;
cinfo.client_data = &mark;
if (setjmp(mark) == -1) {
- return FALSE;
+ return false;
}
jpeg_create_decompress(&cinfo);
struct jpeg_source_mgr src;
@@ -252,15 +252,15 @@ static FX_BOOL _JpegLoadInfo(const uint8_t* src_buf, FX_DWORD src_size, int& wid
cinfo.src = &src;
if (setjmp(mark) == -1) {
jpeg_destroy_decompress(&cinfo);
- return FALSE;
+ return false;
}
if(icc_buf_ptr && icc_length) {
jpeg_save_markers(&cinfo, JPEG_MARKER_ICC, JPEG_MARKER_MAXSIZE);
}
- 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;
+ return false;
}
width = cinfo.image_width;
height = cinfo.image_height;
@@ -274,21 +274,21 @@ static FX_BOOL _JpegLoadInfo(const uint8_t* src_buf, FX_DWORD src_size, int& wid
*icc_length = 0;
}
jpeg_destroy_decompress(&cinfo);
- return TRUE;
+ return true;
}
class CCodec_JpegDecoder : public CCodec_ScanlineDecoder
{
public:
CCodec_JpegDecoder();
~CCodec_JpegDecoder();
- FX_BOOL Create(const uint8_t* src_buf, FX_DWORD src_size, int width, int height, int nComps,
- FX_BOOL ColorTransform, IFX_JpegProvider* pJP);
+ bool Create(const uint8_t* src_buf, FX_DWORD src_size, int width, int height, int nComps,
+ bool ColorTransform, IFX_JpegProvider* pJP);
virtual void Destroy()
{
delete this;
}
virtual void v_DownScale(int dest_width, int dest_height);
- virtual FX_BOOL v_Rewind();
+ virtual bool v_Rewind();
virtual uint8_t* v_GetNextLine();
virtual FX_DWORD GetSrcOffset();
jmp_buf m_JmpBuf;
@@ -298,8 +298,8 @@ public:
const uint8_t* m_SrcBuf;
FX_DWORD m_SrcSize;
uint8_t* m_pScanlineBuf;
- FX_BOOL InitDecode();
- FX_BOOL m_bInited, m_bStarted, m_bJpegTransform;
+ bool InitDecode();
+ bool m_bInited, m_bStarted, m_bJpegTransform;
protected:
IFX_JpegProvider* m_pExtProvider;
void* m_pExtContext;
@@ -309,8 +309,8 @@ CCodec_JpegDecoder::CCodec_JpegDecoder()
{
m_pScanlineBuf = NULL;
m_DownScale = 1;
- m_bStarted = FALSE;
- m_bInited = FALSE;
+ m_bStarted = false;
+ m_bInited = false;
m_pExtProvider = NULL;
m_pExtContext = NULL;
FXSYS_memset(&cinfo, 0, sizeof(cinfo));
@@ -331,31 +331,31 @@ 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;
@@ -365,10 +365,10 @@ 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, FX_DWORD src_size, int width, int height,
- int nComps, FX_BOOL ColorTransform, IFX_JpegProvider* pJP)
+bool CCodec_JpegDecoder::Create(const uint8_t* src_buf, FX_DWORD src_size, int width, int height,
+ int nComps, bool ColorTransform, IFX_JpegProvider* pJP)
{
if (pJP) {
m_pExtProvider = pJP;
@@ -396,21 +396,21 @@ FX_BOOL CCodec_JpegDecoder::Create(const uint8_t* src_buf, FX_DWORD src_size, in
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 = (cinfo.image_width * cinfo.num_components + 3) / 4 * 4;
m_pScanlineBuf = FX_Alloc(uint8_t, m_Pitch);
m_nComps = cinfo.num_components;
m_bpc = 8;
- m_bColorTransformed = FALSE;
- m_bStarted = FALSE;
- return TRUE;
+ m_bColorTransformed = false;
+ m_bStarted = false;
+ return true;
}
extern "C" {
int32_t FX_GetDownsampleRatio(int32_t originWidth, int32_t originHeight, int32_t downsampleWidth, int32_t downsampleHeight)
@@ -445,7 +445,7 @@ void CCodec_JpegDecoder::v_DownScale(int dest_width, int dest_height)
m_NextLine = -1;
}
}
-FX_BOOL CCodec_JpegDecoder::v_Rewind()
+bool CCodec_JpegDecoder::v_Rewind()
{
if (m_pExtProvider) {
return m_pExtProvider->Rewind(m_pExtContext);
@@ -453,25 +453,25 @@ FX_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_DownScale;
m_OutputWidth = (m_OrigWidth + m_DownScale - 1) / m_DownScale;
m_OutputHeight = (m_OrigHeight + m_DownScale - 1) / m_DownScale;
if (!jpeg_start_decompress(&cinfo)) {
jpeg_destroy_decompress(&cinfo);
- return FALSE;
+ return false;
}
if ((int)cinfo.output_width > m_OrigWidth) {
- FXSYS_assert(FALSE);
- return FALSE;
+ FXSYS_assert(false);
+ return false;
}
- m_bStarted = TRUE;
- return TRUE;
+ m_bStarted = true;
+ return true;
}
uint8_t* CCodec_JpegDecoder::v_GetNextLine()
{
@@ -492,7 +492,7 @@ FX_DWORD CCodec_JpegDecoder::GetSrcOffset()
return (FX_DWORD)(m_SrcSize - src.bytes_in_buffer);
}
ICodec_ScanlineDecoder* CCodec_JpegModule::CreateDecoder(const uint8_t* src_buf, FX_DWORD src_size,
- int width, int height, int nComps, FX_BOOL ColorTransform)
+ int width, int height, int nComps, bool ColorTransform)
{
if (src_buf == NULL || src_size == 0) {
return NULL;
@@ -504,8 +504,8 @@ ICodec_ScanlineDecoder* CCodec_JpegModule::CreateDecoder(const uint8_t* src_buf,
}
return pDecoder;
}
-FX_BOOL CCodec_JpegModule::LoadInfo(const uint8_t* src_buf, FX_DWORD src_size, int& width, int& height,
- int& num_components, int& bits_per_components, FX_BOOL& color_transform,
+bool CCodec_JpegModule::LoadInfo(const uint8_t* src_buf, FX_DWORD src_size, int& width, int& height,
+ int& num_components, int& bits_per_components, bool& color_transform,
uint8_t** icc_buf_ptr, FX_DWORD* icc_length)
{
if (m_pExtProvider) {
@@ -515,17 +515,17 @@ FX_BOOL CCodec_JpegModule::LoadInfo(const uint8_t* src_buf, FX_DWORD src_size, i
}
return _JpegLoadInfo(src_buf, src_size, width, height, num_components, bits_per_components, color_transform, icc_buf_ptr, icc_length);
}
-FX_BOOL CCodec_JpegModule::Encode(const CFX_DIBSource* pSource, uint8_t*& dest_buf, FX_STRSIZE& dest_size, int quality, const uint8_t* icc_buf, FX_DWORD icc_length)
+bool CCodec_JpegModule::Encode(const CFX_DIBSource* pSource, uint8_t*& dest_buf, FX_STRSIZE& dest_size, int quality, const uint8_t* icc_buf, FX_DWORD icc_length)
{
if (m_pExtProvider) {
return m_pExtProvider->Encode(pSource, dest_buf, dest_size, quality, icc_buf, icc_length);
}
if(pSource->GetBPP() < 8 || pSource->GetPalette() != NULL) {
ASSERT(pSource->GetBPP() >= 8 && pSource->GetPalette() == NULL);
- return FALSE;
+ return false;
}
_JpegEncode(pSource, dest_buf, dest_size, quality, icc_buf, icc_length);
- return TRUE;
+ return true;
}
struct FXJPEG_Context {
jmp_buf m_JumpMark;
@@ -653,14 +653,14 @@ int CCodec_JpegModule::StartScanline(void* pContext, int down_scale)
p->m_Info.scale_denom = down_scale;
return jpeg_start_decompress(&p->m_Info);
}
-FX_BOOL CCodec_JpegModule::ReadScanline(void* pContext, unsigned char* dest_buf)
+bool CCodec_JpegModule::ReadScanline(void* pContext, unsigned char* dest_buf)
{
if (m_pExtProvider) {
return m_pExtProvider->ReadScanline(pContext, dest_buf);
}
FXJPEG_Context* p = (FXJPEG_Context*)pContext;
if (setjmp(p->m_JumpMark) == -1) {
- return FALSE;
+ return false;
}
int nlines = jpeg_read_scanlines(&p->m_Info, &dest_buf, 1);
return nlines == 1;
diff --git a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
index 2d395b0b4b..92af626f25 100644
--- a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
+++ b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
@@ -587,17 +587,17 @@ class CJPX_Decoder
public:
CJPX_Decoder();
~CJPX_Decoder();
- FX_BOOL Init(const unsigned char* src_data, int src_size);
+ bool Init(const unsigned char* src_data, int src_size);
void GetInfo(FX_DWORD& width, FX_DWORD& height, FX_DWORD& codestream_nComps, FX_DWORD& output_nComps);
- FX_BOOL Decode(uint8_t* dest_buf, int pitch, FX_BOOL bTranslateColor, uint8_t* offsets);
+ bool Decode(uint8_t* dest_buf, int pitch, bool bTranslateColor, uint8_t* offsets);
const uint8_t* m_SrcData;
int m_SrcSize;
opj_image_t *image;
opj_codec_t* l_codec;
opj_stream_t *l_stream;
- FX_BOOL m_useColorSpace;
+ bool m_useColorSpace;
};
-CJPX_Decoder::CJPX_Decoder(): image(NULL), l_codec(NULL), l_stream(NULL), m_useColorSpace(FALSE)
+CJPX_Decoder::CJPX_Decoder(): image(NULL), l_codec(NULL), l_stream(NULL), m_useColorSpace(false)
{
}
CJPX_Decoder::~CJPX_Decoder()
@@ -612,11 +612,11 @@ CJPX_Decoder::~CJPX_Decoder()
opj_image_destroy(image);
}
}
-FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, int src_size)
+bool CJPX_Decoder::Init(const unsigned char* src_data, int 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 = NULL;
m_SrcData = src_data;
@@ -624,7 +624,7 @@ FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, int src_size)
DecodeData srcData(const_cast<unsigned char*>(src_data), src_size);
l_stream = fx_opj_stream_create_memory_stream(&srcData, OPJ_J2K_STREAM_CHUNK_SIZE, 1);
if (l_stream == NULL) {
- return FALSE;
+ return false;
}
opj_dparameters_t parameters;
opj_set_default_decoder_parameters(&parameters);
@@ -637,33 +637,33 @@ FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, int src_size)
l_codec = opj_create_decompress(OPJ_CODEC_J2K);
}
if(!l_codec) {
- return FALSE;
+ return false;
}
opj_set_info_handler(l_codec, fx_info_callback, 00);
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, &parameters) ) {
- return FALSE;
+ return false;
}
if(! opj_read_header(l_stream, l_codec, &image)) {
image = NULL;
- return FALSE;
+ return false;
}
if (!parameters.nb_tile_to_decode) {
if (!opj_set_decode_area(l_codec, image, parameters.DA_x0,
parameters.DA_y0, parameters.DA_x1, parameters.DA_y1)) {
opj_image_destroy(image);
image = NULL;
- return FALSE;
+ return false;
}
if (!(opj_decode(l_codec, l_stream, image) && opj_end_decompress(l_codec, l_stream))) {
opj_image_destroy(image);
image = NULL;
- 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);
@@ -684,9 +684,9 @@ FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, int src_size)
image->icc_profile_len = 0;
}
if(!image) {
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
void CJPX_Decoder::GetInfo(FX_DWORD& width, FX_DWORD& height, FX_DWORD& codestream_nComps, FX_DWORD& output_nComps)
{
@@ -694,7 +694,7 @@ void CJPX_Decoder::GetInfo(FX_DWORD& width, FX_DWORD& height, FX_DWORD& codestre
height = (FX_DWORD)image->y1;
output_nComps = codestream_nComps = (FX_DWORD)image->numcomps;
}
-FX_BOOL CJPX_Decoder::Decode(uint8_t* dest_buf, int pitch, FX_BOOL bTranslateColor, uint8_t* offsets)
+bool CJPX_Decoder::Decode(uint8_t* dest_buf, int pitch, bool bTranslateColor, uint8_t* offsets)
{
int i, wid, hei, row, col, channel, src;
uint8_t* pChannel;
@@ -702,14 +702,14 @@ FX_BOOL CJPX_Decoder::Decode(uint8_t* dest_buf, int pitch, FX_BOOL bTranslateCol
uint8_t* pPixel;
if(image->comps[0].w != image->x1 || image->comps[0].h != image->y1) {
- return FALSE;
+ return false;
}
if(pitch < (int)(image->comps[0].w * 8 * image->numcomps + 31) >> 5 << 2) {
- return FALSE;
+ return false;
}
FXSYS_memset(dest_buf, 0xff, image->y1 * pitch);
uint8_t** channel_bufs = FX_Alloc(uint8_t*, image->numcomps);
- FX_BOOL result = FALSE;
+ bool result = false;
int* adjust_comps = FX_Alloc(int, image->numcomps);
for (i = 0; i < (int)image->numcomps; i ++) {
channel_bufs[i] = dest_buf + offsets[i];
@@ -765,7 +765,7 @@ FX_BOOL CJPX_Decoder::Decode(uint8_t* dest_buf, int pitch, FX_BOOL bTranslateCol
}
}
}
- result = TRUE;
+ result = true;
done:
FX_Free(channel_bufs);
@@ -778,7 +778,7 @@ void initialize_sign_lut();
CCodec_JpxModule::CCodec_JpxModule()
{
}
-void* CCodec_JpxModule::CreateDecoder(const uint8_t* src_buf, FX_DWORD src_size , FX_BOOL useColorSpace)
+void* CCodec_JpxModule::CreateDecoder(const uint8_t* src_buf, FX_DWORD src_size , bool useColorSpace)
{
CJPX_Decoder* pDecoder = new CJPX_Decoder;
pDecoder->m_useColorSpace = useColorSpace;
@@ -794,7 +794,7 @@ void CCodec_JpxModule::GetImageInfo(void* ctx, FX_DWORD& width, FX_DWORD& height
CJPX_Decoder* pDecoder = (CJPX_Decoder*)ctx;
pDecoder->GetInfo(width, height, codestream_nComps, output_nComps);
}
-FX_BOOL CCodec_JpxModule::Decode(void* ctx, uint8_t* dest_data, int pitch, FX_BOOL bTranslateColor, uint8_t* offsets)
+bool CCodec_JpxModule::Decode(void* ctx, uint8_t* dest_data, int pitch, bool bTranslateColor, uint8_t* offsets)
{
CJPX_Decoder* pDecoder = (CJPX_Decoder*)ctx;
return pDecoder->Decode(dest_data, pitch, bTranslateColor, offsets);