summaryrefslogtreecommitdiff
path: root/core/src/fxcodec
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/fxcodec')
-rw-r--r--core/src/fxcodec/codec/fx_codec_jpeg.cpp4
-rw-r--r--core/src/fxcodec/codec/fx_codec_jpx_opj.cpp10
-rw-r--r--core/src/fxcodec/jbig2/JBig2_HuffmanDecoder.cpp47
-rw-r--r--core/src/fxcodec/jbig2/JBig2_HuffmanDecoder.h4
-rw-r--r--core/src/fxcodec/jbig2/JBig2_HuffmanTable.cpp43
-rw-r--r--core/src/fxcodec/jbig2/JBig2_HuffmanTable.h6
6 files changed, 55 insertions, 59 deletions
diff --git a/core/src/fxcodec/codec/fx_codec_jpeg.cpp b/core/src/fxcodec/codec/fx_codec_jpeg.cpp
index efd83f88ae..4fdbb8ed29 100644
--- a/core/src/fxcodec/codec/fx_codec_jpeg.cpp
+++ b/core/src/fxcodec/codec/fx_codec_jpeg.cpp
@@ -193,7 +193,7 @@ static void _JpegEncode(const CFX_DIBSource* pSource,
if (nComponents > 1) {
uint8_t* dest_scan = line_buf;
if (nComponents == 3) {
- for (int i = 0; i < width; i++) {
+ for (FX_DWORD i = 0; i < width; i++) {
dest_scan[0] = src_scan[2];
dest_scan[1] = src_scan[1];
dest_scan[2] = src_scan[0];
@@ -201,7 +201,7 @@ static void _JpegEncode(const CFX_DIBSource* pSource,
src_scan += Bpp;
}
} else {
- for (int i = 0; i < pitch; i++) {
+ for (FX_DWORD i = 0; i < pitch; i++) {
*dest_scan++ = ~*src_scan++;
}
}
diff --git a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
index fdffcb66de..76d62f763b 100644
--- a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
+++ b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
@@ -616,7 +616,7 @@ class CJPX_Decoder {
public:
explicit CJPX_Decoder(bool use_colorspace);
~CJPX_Decoder();
- FX_BOOL Init(const unsigned char* src_data, int src_size);
+ FX_BOOL Init(const unsigned char* src_data, FX_DWORD src_size);
void GetInfo(FX_DWORD* width, FX_DWORD* height, FX_DWORD* components);
bool Decode(uint8_t* dest_buf,
int pitch,
@@ -624,7 +624,7 @@ class CJPX_Decoder {
private:
const uint8_t* m_SrcData;
- int m_SrcSize;
+ FX_DWORD m_SrcSize;
opj_image_t* image;
opj_codec_t* l_codec;
opj_stream_t* l_stream;
@@ -650,12 +650,12 @@ CJPX_Decoder::~CJPX_Decoder() {
}
}
-FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, int src_size) {
+FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, FX_DWORD 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)) {
+ if (!src_data || src_size < sizeof(szJP2Header))
return FALSE;
- }
+
image = NULL;
m_SrcData = src_data;
m_SrcSize = src_size;
diff --git a/core/src/fxcodec/jbig2/JBig2_HuffmanDecoder.cpp b/core/src/fxcodec/jbig2/JBig2_HuffmanDecoder.cpp
index 61a45bebae..cbbe6af70e 100644
--- a/core/src/fxcodec/jbig2/JBig2_HuffmanDecoder.cpp
+++ b/core/src/fxcodec/jbig2/JBig2_HuffmanDecoder.cpp
@@ -8,47 +8,44 @@
#include "JBig2_Define.h"
-CJBig2_HuffmanDecoder::CJBig2_HuffmanDecoder(CJBig2_BitStream* pStream) {
- m_pStream = pStream;
+CJBig2_HuffmanDecoder::CJBig2_HuffmanDecoder(CJBig2_BitStream* pStream)
+ : m_pStream(pStream) {
}
+
CJBig2_HuffmanDecoder::~CJBig2_HuffmanDecoder() {}
+
int CJBig2_HuffmanDecoder::decodeAValue(CJBig2_HuffmanTable* pTable,
int* nResult) {
- int i;
int nVal = 0;
int nBits = 0;
- FX_DWORD nTmp;
while (1) {
- if (m_pStream->read1Bit(&nTmp) == -1) {
+ FX_DWORD nTmp;
+ if (m_pStream->read1Bit(&nTmp) == -1)
return -1;
- }
+
nVal = (nVal << 1) | nTmp;
- nBits++;
- for (i = 0; i < pTable->NTEMP; i++) {
+ ++nBits;
+ for (FX_DWORD i = 0; i < pTable->NTEMP; ++i) {
if ((pTable->PREFLEN[i] == nBits) && (pTable->CODES[i] == nVal)) {
- if ((pTable->HTOOB == 1) && (i == pTable->NTEMP - 1)) {
+ if ((pTable->HTOOB == 1) && (i == pTable->NTEMP - 1))
return JBIG2_OOB;
- }
- if (m_pStream->readNBits(pTable->RANGELEN[i], &nTmp) == -1) {
+
+ if (m_pStream->readNBits(pTable->RANGELEN[i], &nTmp) == -1)
return -1;
- }
+
if (pTable->HTOOB) {
- if (i == pTable->NTEMP - 3) {
+ if (i == pTable->NTEMP - 3)
*nResult = pTable->RANGELOW[i] - nTmp;
- return 0;
- } else {
+ else
*nResult = pTable->RANGELOW[i] + nTmp;
- return 0;
- }
- } else {
- if (i == pTable->NTEMP - 2) {
- *nResult = pTable->RANGELOW[i] - nTmp;
- return 0;
- } else {
- *nResult = pTable->RANGELOW[i] + nTmp;
- return 0;
- }
+ return 0;
}
+
+ if (i == pTable->NTEMP - 2)
+ *nResult = pTable->RANGELOW[i] - nTmp;
+ else
+ *nResult = pTable->RANGELOW[i] + nTmp;
+ return 0;
}
}
}
diff --git a/core/src/fxcodec/jbig2/JBig2_HuffmanDecoder.h b/core/src/fxcodec/jbig2/JBig2_HuffmanDecoder.h
index c972aae074..e15e891060 100644
--- a/core/src/fxcodec/jbig2/JBig2_HuffmanDecoder.h
+++ b/core/src/fxcodec/jbig2/JBig2_HuffmanDecoder.h
@@ -10,13 +10,13 @@
#include "JBig2_HuffmanTable.h"
class CJBig2_HuffmanDecoder {
public:
- CJBig2_HuffmanDecoder(CJBig2_BitStream* pStream);
+ explicit CJBig2_HuffmanDecoder(CJBig2_BitStream* pStream);
~CJBig2_HuffmanDecoder();
int decodeAValue(CJBig2_HuffmanTable* pTable, int* nResult);
private:
- CJBig2_BitStream* m_pStream;
+ CJBig2_BitStream* const m_pStream;
};
#endif
diff --git a/core/src/fxcodec/jbig2/JBig2_HuffmanTable.cpp b/core/src/fxcodec/jbig2/JBig2_HuffmanTable.cpp
index a09d152052..4effbfadef 100644
--- a/core/src/fxcodec/jbig2/JBig2_HuffmanTable.cpp
+++ b/core/src/fxcodec/jbig2/JBig2_HuffmanTable.cpp
@@ -35,25 +35,22 @@ CJBig2_HuffmanTable::~CJBig2_HuffmanTable() {
void CJBig2_HuffmanTable::init() {
HTOOB = FALSE;
NTEMP = 0;
- CODES = NULL;
- PREFLEN = NULL;
- RANGELEN = NULL;
- RANGELOW = NULL;
+ CODES = nullptr;
+ PREFLEN = nullptr;
+ RANGELEN = nullptr;
+ RANGELOW = nullptr;
}
int CJBig2_HuffmanTable::parseFromStandardTable(const JBig2TableLine* pTable,
int nLines,
FX_BOOL bHTOOB) {
- int CURLEN, LENMAX, CURCODE, CURTEMP;
- int* LENCOUNT;
- int* FIRSTCODE;
HTOOB = bHTOOB;
NTEMP = nLines;
CODES = FX_Alloc(int, NTEMP);
PREFLEN = FX_Alloc(int, NTEMP);
RANGELEN = FX_Alloc(int, NTEMP);
RANGELOW = FX_Alloc(int, NTEMP);
- LENMAX = 0;
- for (int i = 0; i < NTEMP; i++) {
+ int LENMAX = 0;
+ for (FX_DWORD i = 0; i < NTEMP; ++i) {
PREFLEN[i] = pTable[i].PREFLEN;
RANGELEN[i] = pTable[i].RANDELEN;
RANGELOW[i] = pTable[i].RANGELOW;
@@ -61,19 +58,19 @@ int CJBig2_HuffmanTable::parseFromStandardTable(const JBig2TableLine* pTable,
LENMAX = PREFLEN[i];
}
}
- LENCOUNT = FX_Alloc(int, LENMAX + 1);
+ int* LENCOUNT = FX_Alloc(int, LENMAX + 1);
JBIG2_memset(LENCOUNT, 0, sizeof(int) * (LENMAX + 1));
- FIRSTCODE = FX_Alloc(int, LENMAX + 1);
- for (int i = 0; i < NTEMP; i++) {
- LENCOUNT[PREFLEN[i]]++;
- }
- CURLEN = 1;
+ int* FIRSTCODE = FX_Alloc(int, LENMAX + 1);
+ for (FX_DWORD i = 0; i < NTEMP; ++i)
+ ++LENCOUNT[PREFLEN[i]];
+
+ int CURLEN = 1;
FIRSTCODE[0] = 0;
LENCOUNT[0] = 0;
while (CURLEN <= LENMAX) {
FIRSTCODE[CURLEN] = (FIRSTCODE[CURLEN - 1] + LENCOUNT[CURLEN - 1]) << 1;
- CURCODE = FIRSTCODE[CURLEN];
- CURTEMP = 0;
+ int CURCODE = FIRSTCODE[CURLEN];
+ FX_DWORD CURTEMP = 0;
while (CURTEMP < NTEMP) {
if (PREFLEN[CURTEMP] == CURLEN) {
CODES[CURTEMP] = CURCODE;
@@ -109,6 +106,7 @@ int CJBig2_HuffmanTable::parseFromCodedBuffer(CJBig2_BitStream* pStream) {
pStream->readInteger(&HTHIGH) == -1 || HTLOW > HTHIGH) {
return FALSE;
}
+
FX_DWORD nSize = 16;
PREFLEN = FX_Alloc(int, nSize);
RANGELEN = FX_Alloc(int, nSize);
@@ -131,7 +129,7 @@ int CJBig2_HuffmanTable::parseFromCodedBuffer(CJBig2_BitStream* pStream) {
RANGELEN[NTEMP] = 32;
RANGELOW[NTEMP] = HTLOW - 1;
- NTEMP = NTEMP + 1;
+ ++NTEMP;
HT_CHECK_MEMORY_ADJUST
if (pStream->readNBits(HTPS, &PREFLEN[NTEMP]) == -1)
return FALSE;
@@ -143,18 +141,19 @@ int CJBig2_HuffmanTable::parseFromCodedBuffer(CJBig2_BitStream* pStream) {
HT_CHECK_MEMORY_ADJUST
if (pStream->readNBits(HTPS, &PREFLEN[NTEMP]) == -1)
return FALSE;
- NTEMP = NTEMP + 1;
+
+ ++NTEMP;
}
CODES = FX_Alloc(int, NTEMP);
int LENMAX = 0;
- for (int i = 0; i < NTEMP; i++) {
+ for (FX_DWORD i = 0; i < NTEMP; ++i) {
if (PREFLEN[i] > LENMAX) {
LENMAX = PREFLEN[i];
}
}
std::vector<int> LENCOUNT(LENMAX + 1);
- for (int i = 0; i < NTEMP; ++i)
+ for (FX_DWORD i = 0; i < NTEMP; ++i)
LENCOUNT[PREFLEN[i]]++;
LENCOUNT[0] = 0;
@@ -163,7 +162,7 @@ int CJBig2_HuffmanTable::parseFromCodedBuffer(CJBig2_BitStream* pStream) {
for (int i = 0; i <= LENMAX; ++i) {
FIRSTCODE[i] = (FIRSTCODE[i - 1] + LENCOUNT[i - 1]) << 1;
int CURCODE = FIRSTCODE[i];
- for (int j = 0; j < NTEMP; ++j) {
+ for (FX_DWORD j = 0; j < NTEMP; ++j) {
if (PREFLEN[j] == i)
CODES[j] = CURCODE++;
}
diff --git a/core/src/fxcodec/jbig2/JBig2_HuffmanTable.h b/core/src/fxcodec/jbig2/JBig2_HuffmanTable.h
index 7c843cf91b..fe8294dc7e 100644
--- a/core/src/fxcodec/jbig2/JBig2_HuffmanTable.h
+++ b/core/src/fxcodec/jbig2/JBig2_HuffmanTable.h
@@ -14,7 +14,7 @@ class CJBig2_HuffmanTable {
public:
CJBig2_HuffmanTable(const JBig2TableLine* pTable, int nLines, FX_BOOL bHTOOB);
- CJBig2_HuffmanTable(CJBig2_BitStream* pStream);
+ explicit CJBig2_HuffmanTable(CJBig2_BitStream* pStream);
~CJBig2_HuffmanTable();
@@ -24,13 +24,13 @@ class CJBig2_HuffmanTable {
int parseFromCodedBuffer(CJBig2_BitStream* pStream);
- FX_BOOL isOK() { return m_bOK; }
+ FX_BOOL isOK() const { return m_bOK; }
private:
void init();
FX_BOOL HTOOB;
- int NTEMP;
+ FX_DWORD NTEMP;
int* CODES;
int* PREFLEN;
int* RANGELEN;