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/fx_codec.cpp703
-rw-r--r--core/src/fxcodec/codec/fx_codec_fax.cpp5
-rw-r--r--core/src/fxcodec/codec/fx_codec_flate.cpp15
-rw-r--r--core/src/fxcodec/codec/fx_codec_icc.cpp16
-rw-r--r--core/src/fxcodec/codec/fx_codec_jbig.cpp2
-rw-r--r--core/src/fxcodec/codec/fx_codec_jpeg.cpp5
-rw-r--r--core/src/fxcodec/codec/fx_codec_jpx_opj.cpp5
-rw-r--r--core/src/fxcodec/codec/fx_codec_progress.cpp37
-rw-r--r--core/src/fxcodec/codec/fx_codec_tiff.cpp5
9 files changed, 367 insertions, 426 deletions
diff --git a/core/src/fxcodec/codec/fx_codec.cpp b/core/src/fxcodec/codec/fx_codec.cpp
index b2f70c73d1..36dff5e5b2 100644
--- a/core/src/fxcodec/codec/fx_codec.cpp
+++ b/core/src/fxcodec/codec/fx_codec.cpp
@@ -8,17 +8,17 @@
#include "codec_int.h"
CCodec_ModuleMgr::CCodec_ModuleMgr()
{
- m_pBasicModule = FX_NEW CCodec_BasicModule;
- m_pFaxModule = FX_NEW CCodec_FaxModule;
- m_pJpegModule = FX_NEW CCodec_JpegModule;
- m_pJpxModule = FX_NEW CCodec_JpxModule;
- m_pJbig2Module = FX_NEW CCodec_Jbig2Module;
- m_pIccModule = FX_NEW CCodec_IccModule;
- m_pPngModule = FX_NEW CCodec_PngModule;
- m_pGifModule = FX_NEW CCodec_GifModule;
- m_pBmpModule = FX_NEW CCodec_BmpModule;
- m_pTiffModule = FX_NEW CCodec_TiffModule;
- m_pFlateModule = FX_NEW CCodec_FlateModule;
+ m_pBasicModule = new CCodec_BasicModule;
+ m_pFaxModule = new CCodec_FaxModule;
+ m_pJpegModule = new CCodec_JpegModule;
+ m_pJpxModule = new CCodec_JpxModule;
+ m_pJbig2Module = new CCodec_Jbig2Module;
+ m_pIccModule = new CCodec_IccModule;
+ m_pPngModule = new CCodec_PngModule;
+ m_pGifModule = new CCodec_GifModule;
+ m_pBmpModule = new CCodec_BmpModule;
+ m_pTiffModule = new CCodec_TiffModule;
+ m_pFlateModule = new CCodec_FlateModule;
}
CCodec_ModuleMgr::~CCodec_ModuleMgr()
{
@@ -247,349 +247,349 @@ FX_BOOL CCodec_BasicModule::A85Encode(const FX_BYTE* src_buf, FX_DWORD src_size,
}
CCodec_ModuleMgr* CCodec_ModuleMgr::Create()
{
- return FX_NEW CCodec_ModuleMgr;
+ return new CCodec_ModuleMgr;
}
void CCodec_ModuleMgr::Destroy()
{
delete this;
}
-CFX_DIBAttribute::CFX_DIBAttribute()
-{
- FXSYS_memset32(this, 0, sizeof(CFX_DIBAttribute));
- m_nXDPI = -1;
- m_nYDPI = -1;
- m_fAspectRatio = -1.0f;
- m_pExif = FX_NEW CFX_DIBAttributeExif;
-}
-CFX_DIBAttribute::~CFX_DIBAttribute()
-{
- if (m_pExif) {
- delete m_pExif;
- }
-}
-CFX_DIBAttributeExif::CFX_DIBAttributeExif()
-{
- m_pExifData = NULL;
- m_dwExifDataLen = 0;
-}
-CFX_DIBAttributeExif::~CFX_DIBAttributeExif()
-{
- clear();
-}
-void CFX_DIBAttributeExif::clear()
-{
- if (m_pExifData) {
- FX_Free(m_pExifData);
- }
- m_pExifData = NULL;
- FX_DWORD key = 0;
- FX_LPBYTE buf = NULL;
- FX_POSITION pos = NULL;
- pos = m_TagHead.GetStartPosition();
- while (pos) {
- m_TagHead.GetNextAssoc(pos, key, buf);
- if (buf) {
- FX_Free(buf);
- }
- }
- m_TagHead.RemoveAll();
- pos = m_TagVal.GetStartPosition();
- while (pos) {
- m_TagVal.GetNextAssoc(pos, key, buf);
- if (buf) {
- FX_Free(buf);
- }
- }
- m_TagVal.RemoveAll();
-}
-static FX_WORD _Read2BytesL(FX_LPBYTE data)
-{
- ASSERT(data);
- return data[0] | (data[1] << 8);
-}
-static FX_WORD _Read2BytesB(FX_LPBYTE data)
-{
- ASSERT(data);
- return data[1] | (data[0] << 8);
-}
-static FX_DWORD _Read4BytesL(FX_LPBYTE data)
-{
- return _Read2BytesL(data) | (_Read2BytesL(data + 2) << 16);
-}
-static FX_DWORD _Read4BytesB(FX_LPBYTE data)
-{
- return _Read2BytesB(data + 2) | (_Read2BytesB(data) << 16);
-}
-typedef FX_WORD (*_Read2Bytes) (FX_LPBYTE data);
-typedef FX_DWORD (*_Read4Bytes) (FX_LPBYTE data);
-typedef void (*_Write2Bytes) (FX_LPBYTE data, FX_WORD val);
-typedef void (*_Write4Bytes) (FX_LPBYTE data, FX_DWORD val);
-FX_LPBYTE CFX_DIBAttributeExif::ParseExifIFH(FX_LPBYTE data, FX_DWORD len, _Read2Bytes* pReadWord, _Read4Bytes* pReadDword)
-{
- if (len > 8) {
- FX_BOOL tag = FALSE;
- if (FXSYS_memcmp32(data, "\x49\x49\x2a\x00", 4) == 0) {
- if (pReadWord) {
- *pReadWord = _Read2BytesL;
- }
- if (pReadDword) {
- *pReadDword = _Read4BytesL;
- }
- tag = TRUE;
- } else if (FXSYS_memcmp32(data, "\x4d\x4d\x00\x2a", 4) == 0) {
- if (pReadWord) {
- *pReadWord = _Read2BytesB;
- }
- if (pReadDword) {
- *pReadDword = _Read4BytesB;
- }
- tag = TRUE;
- }
- if (tag) {
- data += 4;
- if (pReadDword) {
- data += (*pReadDword)(data) - 4;
- } else {
- data += 4;
- }
- }
- }
- return data;
-}
-FX_BOOL CFX_DIBAttributeExif::ParseExifIFD(CFX_MapPtrTemplate<FX_DWORD, FX_LPBYTE>* pMap, FX_LPBYTE data, FX_DWORD len)
-{
- if (pMap && data) {
- if (len > 8) {
- FX_WORD wTagNum = m_readWord(data);
- data += 2;
- FX_DWORD wTag;
- FX_LPBYTE buf;
- while (wTagNum--) {
- wTag = m_readWord(data);
- data += 2;
- if (!pMap->Lookup(wTag, buf)) {
- buf = FX_Alloc(FX_BYTE, 10);
- if (buf == NULL) {
- return FALSE;
- }
- FXSYS_memcpy32(buf, data, 10);
- pMap->SetAt(wTag, buf);
- }
- data += 10;
- }
- FX_DWORD dwIFDOffset;
- dwIFDOffset = m_readDword(data);
- while (dwIFDOffset && dwIFDOffset < len) {
- data = m_pExifData + dwIFDOffset;
- wTagNum = m_readWord(data);
- data += 2;
- while (wTagNum--) {
- wTag = m_readWord(data);
- data += 2;
- if (!pMap->Lookup(wTag, buf)) {
- buf = FX_Alloc(FX_BYTE, 10);
- if (buf == NULL) {
- return FALSE;
- }
- FXSYS_memcpy32(buf, data, 10);
- pMap->SetAt(wTag, buf);
- }
- data += 10;
- }
- dwIFDOffset = m_readDword(data);
- }
- return TRUE;
- }
- }
- return FALSE;
-}
-enum FX_ExifDataType {
- FX_UnsignedByte = 1,
- FX_AscString,
- FX_UnsignedShort,
- FX_UnsignedLong,
- FX_UnsignedRation,
- FX_SignedByte,
- FX_Undefined,
- FX_SignedShort,
- FX_SignedLong,
- FX_SignedRation,
- FX_SignedFloat,
- FX_DoubleFloat
-};
-FX_BOOL CFX_DIBAttributeExif::ParseExif(CFX_MapPtrTemplate<FX_DWORD, FX_LPBYTE>* pHead, FX_LPBYTE data, FX_DWORD len, CFX_MapPtrTemplate<FX_DWORD, FX_LPBYTE>* pVal)
-{
- if (pHead && data && pVal) {
- if (len > 8) {
- FX_LPBYTE old_data = data;
- data = ParseExifIFH(data, len, &m_readWord, &m_readDword);
- if (data == old_data) {
- return FALSE;
- }
- if (pHead->GetCount() == 0) {
- if (!ParseExifIFD(pHead, data, len)) {
- return FALSE;
- }
- }
- FX_DWORD dwModuleNum;
- FX_WORD type;
- FX_DWORD dwSize;
- FX_DWORD tag;
- FX_LPBYTE head;
- FX_POSITION pos = pHead->GetStartPosition();
- while (pos) {
- pHead->GetNextAssoc(pos, tag, head);
- FX_LPBYTE val = NULL, buf = NULL, temp = NULL;
- int i;
- if (head) {
- type = m_readWord(head);
- head += 2;
- dwModuleNum = m_readDword(head);
- head += 4;
- switch (type) {
- case FX_UnsignedByte:
- case FX_AscString:
- case FX_SignedByte:
- case FX_Undefined:
- dwSize = dwModuleNum;
- val = FX_Alloc(FX_BYTE, dwSize);
- if (val == NULL) {
- return FALSE;
- }
- if (dwSize > 4) {
- FXSYS_memcpy32(val, old_data + m_readDword(head), dwSize);
- } else {
- FXSYS_memcpy32(val, head, dwSize);
- }
- break;
- case FX_UnsignedShort:
- case FX_SignedShort:
- dwSize = dwModuleNum << 1;
- val = FX_Alloc(FX_BYTE, dwSize);
- if (val == NULL) {
- return FALSE;
- }
- if (dwSize > 4) {
- FXSYS_memcpy32(val, old_data + m_readDword(head), dwSize);
- } else {
- FXSYS_memcpy32(val, head, dwSize);
- }
- buf = val;
- for(i = 0; i < (int)dwModuleNum; i ++) {
- *(FX_WORD*)buf = m_readWord(buf);
- buf += 2;
- }
- break;
- case FX_UnsignedLong:
- case FX_SignedLong:
- case FX_SignedFloat:
- dwSize = dwModuleNum << 2;
- val = FX_Alloc(FX_BYTE, dwSize);
- if (val == NULL) {
- return FALSE;
- }
- if (dwSize > 4) {
- FXSYS_memcpy32(val, old_data + m_readDword(head), dwSize);
- } else {
- FXSYS_memcpy32(val, head, dwSize);
- }
- buf = val;
- for(i = 0; i < (int)dwModuleNum; i ++) {
- *(FX_DWORD*)buf = m_readDword(buf);
- buf += 4;
- }
- break;
- case FX_UnsignedRation:
- case FX_SignedRation: {
- dwSize = dwModuleNum << 3;
- buf = FX_Alloc(FX_BYTE, dwSize);
- if (buf == NULL) {
- return FALSE;
- }
- if (dwSize > 4) {
- FXSYS_memcpy32(buf, old_data + m_readDword(head), dwSize);
- } else {
- FXSYS_memcpy32(buf, head, dwSize);
- }
- temp = buf;
- val = FX_Alloc(FX_BYTE, dwSize / 2);
- if (val == NULL) {
- FX_Free(buf);
- return FALSE;
- }
- for(i = 0; i < (int)dwModuleNum; i ++) {
- *(FX_DWORD*)temp = m_readDword(temp);
- *(FX_DWORD*)(temp + 4) = m_readDword(temp + 4);
- FX_DWORD* lNumerator = (FX_DWORD*)temp;
- FX_DWORD* lNenominator = (FX_DWORD*)(temp + 4);
- *(FX_FLOAT*)(val + i * 4) = (FX_FLOAT)(*lNumerator) / (FX_FLOAT)(*lNenominator);
- temp += 8;
- }
- FX_Free(buf);
- }
- break;
- case FX_DoubleFloat:
- dwSize = dwModuleNum << 3;
- val = FX_Alloc(FX_BYTE, dwSize);
- if (val == NULL) {
- return FALSE;
- }
- if (dwSize > 4) {
- FXSYS_memcpy32(val, old_data + m_readDword(head), dwSize);
- } else {
- FXSYS_memcpy32(val, head, dwSize);
- }
- buf = val;
- for(i = 0; i < (int)dwModuleNum; i ++) {
- *(FX_DWORD*)buf = m_readDword(buf);
- *(FX_DWORD*)(buf + 4) = m_readDword(buf + 4);
- buf += 8;
- }
- break;
- default:
- return FALSE;
- }
- }
- pVal->SetAt(tag, val);
- }
- return TRUE;
- }
- }
- return FALSE;
-}
-#define FXEXIF_INFOCONVERT(T) {T* src = (T*)ptr; T* dst = (T*)val; *dst = *src;}
-FX_BOOL CFX_DIBAttributeExif::GetInfo( FX_WORD tag, FX_LPVOID val )
-{
- if (m_TagVal.GetCount() == 0) {
- if (!ParseExif(&m_TagHead, m_pExifData, m_dwExifDataLen, &m_TagVal)) {
- return FALSE;
- }
- }
- FX_LPBYTE ptr = NULL;
- if (m_TagVal.Lookup(tag, ptr)) {
- switch (tag) {
- case EXIFTAG_USHORT_RESUNIT:
- FXEXIF_INFOCONVERT(FX_WORD);
- {
- FX_WORD* ptr = (FX_WORD*)val;
- *ptr -= 1;
- }
- break;
- case EXIFTAG_FLOAT_DPIX:
- case EXIFTAG_FLOAT_DPIY:
- FXEXIF_INFOCONVERT(FX_FLOAT);
- break;
- case EXIFTAG_USHORT_ORIENTATION:
- FXEXIF_INFOCONVERT(FX_WORD);
- break;
- default: {
- FX_LPBYTE* dst = (FX_LPBYTE*)val;
- *dst = ptr;
- }
- }
- }
- return TRUE;
-}
+CFX_DIBAttribute::CFX_DIBAttribute()
+{
+ FXSYS_memset32(this, 0, sizeof(CFX_DIBAttribute));
+ m_nXDPI = -1;
+ m_nYDPI = -1;
+ m_fAspectRatio = -1.0f;
+ m_pExif = new CFX_DIBAttributeExif;
+}
+CFX_DIBAttribute::~CFX_DIBAttribute()
+{
+ if (m_pExif) {
+ delete m_pExif;
+ }
+}
+CFX_DIBAttributeExif::CFX_DIBAttributeExif()
+{
+ m_pExifData = NULL;
+ m_dwExifDataLen = 0;
+}
+CFX_DIBAttributeExif::~CFX_DIBAttributeExif()
+{
+ clear();
+}
+void CFX_DIBAttributeExif::clear()
+{
+ if (m_pExifData) {
+ FX_Free(m_pExifData);
+ }
+ m_pExifData = NULL;
+ FX_DWORD key = 0;
+ FX_LPBYTE buf = NULL;
+ FX_POSITION pos = NULL;
+ pos = m_TagHead.GetStartPosition();
+ while (pos) {
+ m_TagHead.GetNextAssoc(pos, key, buf);
+ if (buf) {
+ FX_Free(buf);
+ }
+ }
+ m_TagHead.RemoveAll();
+ pos = m_TagVal.GetStartPosition();
+ while (pos) {
+ m_TagVal.GetNextAssoc(pos, key, buf);
+ if (buf) {
+ FX_Free(buf);
+ }
+ }
+ m_TagVal.RemoveAll();
+}
+static FX_WORD _Read2BytesL(FX_LPBYTE data)
+{
+ ASSERT(data);
+ return data[0] | (data[1] << 8);
+}
+static FX_WORD _Read2BytesB(FX_LPBYTE data)
+{
+ ASSERT(data);
+ return data[1] | (data[0] << 8);
+}
+static FX_DWORD _Read4BytesL(FX_LPBYTE data)
+{
+ return _Read2BytesL(data) | (_Read2BytesL(data + 2) << 16);
+}
+static FX_DWORD _Read4BytesB(FX_LPBYTE data)
+{
+ return _Read2BytesB(data + 2) | (_Read2BytesB(data) << 16);
+}
+typedef FX_WORD (*_Read2Bytes) (FX_LPBYTE data);
+typedef FX_DWORD (*_Read4Bytes) (FX_LPBYTE data);
+typedef void (*_Write2Bytes) (FX_LPBYTE data, FX_WORD val);
+typedef void (*_Write4Bytes) (FX_LPBYTE data, FX_DWORD val);
+FX_LPBYTE CFX_DIBAttributeExif::ParseExifIFH(FX_LPBYTE data, FX_DWORD len, _Read2Bytes* pReadWord, _Read4Bytes* pReadDword)
+{
+ if (len > 8) {
+ FX_BOOL tag = FALSE;
+ if (FXSYS_memcmp32(data, "\x49\x49\x2a\x00", 4) == 0) {
+ if (pReadWord) {
+ *pReadWord = _Read2BytesL;
+ }
+ if (pReadDword) {
+ *pReadDword = _Read4BytesL;
+ }
+ tag = TRUE;
+ } else if (FXSYS_memcmp32(data, "\x4d\x4d\x00\x2a", 4) == 0) {
+ if (pReadWord) {
+ *pReadWord = _Read2BytesB;
+ }
+ if (pReadDword) {
+ *pReadDword = _Read4BytesB;
+ }
+ tag = TRUE;
+ }
+ if (tag) {
+ data += 4;
+ if (pReadDword) {
+ data += (*pReadDword)(data) - 4;
+ } else {
+ data += 4;
+ }
+ }
+ }
+ return data;
+}
+FX_BOOL CFX_DIBAttributeExif::ParseExifIFD(CFX_MapPtrTemplate<FX_DWORD, FX_LPBYTE>* pMap, FX_LPBYTE data, FX_DWORD len)
+{
+ if (pMap && data) {
+ if (len > 8) {
+ FX_WORD wTagNum = m_readWord(data);
+ data += 2;
+ FX_DWORD wTag;
+ FX_LPBYTE buf;
+ while (wTagNum--) {
+ wTag = m_readWord(data);
+ data += 2;
+ if (!pMap->Lookup(wTag, buf)) {
+ buf = FX_Alloc(FX_BYTE, 10);
+ if (buf == NULL) {
+ return FALSE;
+ }
+ FXSYS_memcpy32(buf, data, 10);
+ pMap->SetAt(wTag, buf);
+ }
+ data += 10;
+ }
+ FX_DWORD dwIFDOffset;
+ dwIFDOffset = m_readDword(data);
+ while (dwIFDOffset && dwIFDOffset < len) {
+ data = m_pExifData + dwIFDOffset;
+ wTagNum = m_readWord(data);
+ data += 2;
+ while (wTagNum--) {
+ wTag = m_readWord(data);
+ data += 2;
+ if (!pMap->Lookup(wTag, buf)) {
+ buf = FX_Alloc(FX_BYTE, 10);
+ if (buf == NULL) {
+ return FALSE;
+ }
+ FXSYS_memcpy32(buf, data, 10);
+ pMap->SetAt(wTag, buf);
+ }
+ data += 10;
+ }
+ dwIFDOffset = m_readDword(data);
+ }
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+enum FX_ExifDataType {
+ FX_UnsignedByte = 1,
+ FX_AscString,
+ FX_UnsignedShort,
+ FX_UnsignedLong,
+ FX_UnsignedRation,
+ FX_SignedByte,
+ FX_Undefined,
+ FX_SignedShort,
+ FX_SignedLong,
+ FX_SignedRation,
+ FX_SignedFloat,
+ FX_DoubleFloat
+};
+FX_BOOL CFX_DIBAttributeExif::ParseExif(CFX_MapPtrTemplate<FX_DWORD, FX_LPBYTE>* pHead, FX_LPBYTE data, FX_DWORD len, CFX_MapPtrTemplate<FX_DWORD, FX_LPBYTE>* pVal)
+{
+ if (pHead && data && pVal) {
+ if (len > 8) {
+ FX_LPBYTE old_data = data;
+ data = ParseExifIFH(data, len, &m_readWord, &m_readDword);
+ if (data == old_data) {
+ return FALSE;
+ }
+ if (pHead->GetCount() == 0) {
+ if (!ParseExifIFD(pHead, data, len)) {
+ return FALSE;
+ }
+ }
+ FX_DWORD dwModuleNum;
+ FX_WORD type;
+ FX_DWORD dwSize;
+ FX_DWORD tag;
+ FX_LPBYTE head;
+ FX_POSITION pos = pHead->GetStartPosition();
+ while (pos) {
+ pHead->GetNextAssoc(pos, tag, head);
+ FX_LPBYTE val = NULL, buf = NULL, temp = NULL;
+ int i;
+ if (head) {
+ type = m_readWord(head);
+ head += 2;
+ dwModuleNum = m_readDword(head);
+ head += 4;
+ switch (type) {
+ case FX_UnsignedByte:
+ case FX_AscString:
+ case FX_SignedByte:
+ case FX_Undefined:
+ dwSize = dwModuleNum;
+ val = FX_Alloc(FX_BYTE, dwSize);
+ if (val == NULL) {
+ return FALSE;
+ }
+ if (dwSize > 4) {
+ FXSYS_memcpy32(val, old_data + m_readDword(head), dwSize);
+ } else {
+ FXSYS_memcpy32(val, head, dwSize);
+ }
+ break;
+ case FX_UnsignedShort:
+ case FX_SignedShort:
+ dwSize = dwModuleNum << 1;
+ val = FX_Alloc(FX_BYTE, dwSize);
+ if (val == NULL) {
+ return FALSE;
+ }
+ if (dwSize > 4) {
+ FXSYS_memcpy32(val, old_data + m_readDword(head), dwSize);
+ } else {
+ FXSYS_memcpy32(val, head, dwSize);
+ }
+ buf = val;
+ for(i = 0; i < (int)dwModuleNum; i ++) {
+ *(FX_WORD*)buf = m_readWord(buf);
+ buf += 2;
+ }
+ break;
+ case FX_UnsignedLong:
+ case FX_SignedLong:
+ case FX_SignedFloat:
+ dwSize = dwModuleNum << 2;
+ val = FX_Alloc(FX_BYTE, dwSize);
+ if (val == NULL) {
+ return FALSE;
+ }
+ if (dwSize > 4) {
+ FXSYS_memcpy32(val, old_data + m_readDword(head), dwSize);
+ } else {
+ FXSYS_memcpy32(val, head, dwSize);
+ }
+ buf = val;
+ for(i = 0; i < (int)dwModuleNum; i ++) {
+ *(FX_DWORD*)buf = m_readDword(buf);
+ buf += 4;
+ }
+ break;
+ case FX_UnsignedRation:
+ case FX_SignedRation: {
+ dwSize = dwModuleNum << 3;
+ buf = FX_Alloc(FX_BYTE, dwSize);
+ if (buf == NULL) {
+ return FALSE;
+ }
+ if (dwSize > 4) {
+ FXSYS_memcpy32(buf, old_data + m_readDword(head), dwSize);
+ } else {
+ FXSYS_memcpy32(buf, head, dwSize);
+ }
+ temp = buf;
+ val = FX_Alloc(FX_BYTE, dwSize / 2);
+ if (val == NULL) {
+ FX_Free(buf);
+ return FALSE;
+ }
+ for(i = 0; i < (int)dwModuleNum; i ++) {
+ *(FX_DWORD*)temp = m_readDword(temp);
+ *(FX_DWORD*)(temp + 4) = m_readDword(temp + 4);
+ FX_DWORD* lNumerator = (FX_DWORD*)temp;
+ FX_DWORD* lNenominator = (FX_DWORD*)(temp + 4);
+ *(FX_FLOAT*)(val + i * 4) = (FX_FLOAT)(*lNumerator) / (FX_FLOAT)(*lNenominator);
+ temp += 8;
+ }
+ FX_Free(buf);
+ }
+ break;
+ case FX_DoubleFloat:
+ dwSize = dwModuleNum << 3;
+ val = FX_Alloc(FX_BYTE, dwSize);
+ if (val == NULL) {
+ return FALSE;
+ }
+ if (dwSize > 4) {
+ FXSYS_memcpy32(val, old_data + m_readDword(head), dwSize);
+ } else {
+ FXSYS_memcpy32(val, head, dwSize);
+ }
+ buf = val;
+ for(i = 0; i < (int)dwModuleNum; i ++) {
+ *(FX_DWORD*)buf = m_readDword(buf);
+ *(FX_DWORD*)(buf + 4) = m_readDword(buf + 4);
+ buf += 8;
+ }
+ break;
+ default:
+ return FALSE;
+ }
+ }
+ pVal->SetAt(tag, val);
+ }
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+#define FXEXIF_INFOCONVERT(T) {T* src = (T*)ptr; T* dst = (T*)val; *dst = *src;}
+FX_BOOL CFX_DIBAttributeExif::GetInfo( FX_WORD tag, FX_LPVOID val )
+{
+ if (m_TagVal.GetCount() == 0) {
+ if (!ParseExif(&m_TagHead, m_pExifData, m_dwExifDataLen, &m_TagVal)) {
+ return FALSE;
+ }
+ }
+ FX_LPBYTE ptr = NULL;
+ if (m_TagVal.Lookup(tag, ptr)) {
+ switch (tag) {
+ case EXIFTAG_USHORT_RESUNIT:
+ FXEXIF_INFOCONVERT(FX_WORD);
+ {
+ FX_WORD* ptr = (FX_WORD*)val;
+ *ptr -= 1;
+ }
+ break;
+ case EXIFTAG_FLOAT_DPIX:
+ case EXIFTAG_FLOAT_DPIY:
+ FXEXIF_INFOCONVERT(FX_FLOAT);
+ break;
+ case EXIFTAG_USHORT_ORIENTATION:
+ FXEXIF_INFOCONVERT(FX_WORD);
+ break;
+ default: {
+ FX_LPBYTE* dst = (FX_LPBYTE*)val;
+ *dst = ptr;
+ }
+ }
+ }
+ return TRUE;
+}
class CCodec_RLScanlineDecoder : public CCodec_ScanlineDecoder
{
public:
@@ -774,10 +774,7 @@ void CCodec_RLScanlineDecoder::UpdateOperator(FX_BYTE used_bytes)
ICodec_ScanlineDecoder* CCodec_BasicModule::CreateRunLengthDecoder(FX_LPCBYTE src_buf, FX_DWORD src_size, int width, int height,
int nComps, int bpc)
{
- CCodec_RLScanlineDecoder* pRLScanlineDecoder = FX_NEW CCodec_RLScanlineDecoder;
- if (pRLScanlineDecoder == NULL) {
- return NULL;
- }
+ CCodec_RLScanlineDecoder* pRLScanlineDecoder = new CCodec_RLScanlineDecoder;
if (!pRLScanlineDecoder->Create(src_buf, src_size, width, height, nComps, bpc)) {
delete pRLScanlineDecoder;
return NULL;
diff --git a/core/src/fxcodec/codec/fx_codec_fax.cpp b/core/src/fxcodec/codec/fx_codec_fax.cpp
index c6ab791a0e..667b713df8 100644
--- a/core/src/fxcodec/codec/fx_codec_fax.cpp
+++ b/core/src/fxcodec/codec/fx_codec_fax.cpp
@@ -994,10 +994,7 @@ FX_BOOL CCodec_FaxModule::Encode(FX_LPCBYTE src_buf, int width, int height, int
ICodec_ScanlineDecoder* CCodec_FaxModule::CreateDecoder(FX_LPCBYTE 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)
{
- CCodec_FaxDecoder* pDecoder = FX_NEW CCodec_FaxDecoder;
- if (pDecoder == NULL) {
- return NULL;
- }
+ CCodec_FaxDecoder* pDecoder = new CCodec_FaxDecoder;
pDecoder->Create(src_buf, src_size, width, height, K, EndOfLine, EncodedByteAlign, BlackIs1, Columns, Rows);
return pDecoder;
}
diff --git a/core/src/fxcodec/codec/fx_codec_flate.cpp b/core/src/fxcodec/codec/fx_codec_flate.cpp
index afdb8354e6..3e1aa367c8 100644
--- a/core/src/fxcodec/codec/fx_codec_flate.cpp
+++ b/core/src/fxcodec/codec/fx_codec_flate.cpp
@@ -851,10 +851,7 @@ static void FlateUncompress(FX_LPCBYTE src_buf, FX_DWORD src_size, FX_DWORD orig
ICodec_ScanlineDecoder* CCodec_FlateModule::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)
{
- CCodec_FlateScanlineDecoder* pDecoder = FX_NEW CCodec_FlateScanlineDecoder;
- if (pDecoder == NULL) {
- return NULL;
- }
+ CCodec_FlateScanlineDecoder* pDecoder = new CCodec_FlateScanlineDecoder;
pDecoder->Create(src_buf, src_size, width, height, nComps, bpc, predictor, Colors, BitsPerComponent, Columns);
return pDecoder;
}
@@ -874,10 +871,7 @@ FX_DWORD CCodec_FlateModule::FlateOrLZWDecode(FX_BOOL bLZW, const FX_BYTE* src_b
}
}
if (bLZW) {
- pDecoder = FX_NEW CLZWDecoder;
- if (pDecoder == NULL) {
- return -1;
- }
+ pDecoder = new CLZWDecoder;
dest_size = (FX_DWORD) - 1;
offset = src_size;
int err = pDecoder->Decode(NULL, dest_size, src_buf, offset, bEarlyChange);
@@ -885,10 +879,7 @@ FX_DWORD CCodec_FlateModule::FlateOrLZWDecode(FX_BOOL bLZW, const FX_BYTE* src_b
if (err || dest_size == 0 || dest_size + 1 < dest_size) {
return (FX_DWORD) - 1;
}
- pDecoder = FX_NEW CLZWDecoder;
- if (pDecoder == NULL) {
- return -1;
- }
+ pDecoder = new CLZWDecoder;
dest_buf = FX_Alloc( FX_BYTE, dest_size + 1);
if (dest_buf == NULL) {
return -1;
diff --git a/core/src/fxcodec/codec/fx_codec_icc.cpp b/core/src/fxcodec/codec/fx_codec_icc.cpp
index 1a4fce63f2..a984fecc30 100644
--- a/core/src/fxcodec/codec/fx_codec_icc.cpp
+++ b/core/src/fxcodec/codec/fx_codec_icc.cpp
@@ -148,10 +148,7 @@ void* IccLib_CreateTransform(const unsigned char* pSrcProfileData, FX_DWORD dwSr
cmsCloseProfile(dstProfile);
return NULL;
}
- pCmm = FX_NEW CLcmsCmm;
- if (pCmm == NULL) {
- return NULL;
- }
+ pCmm = new CLcmsCmm;
pCmm->m_nSrcComponents = nSrcComponents;
pCmm->m_nDstComponents = nDstComponents;
pCmm->m_hTransform = hTransform;
@@ -438,10 +435,7 @@ FX_LPVOID CCodec_IccModule::CreateProfile(ICodec_IccModule::IccParam* pIccParam,
ASSERT(pTransformKey);
pTransformKey->AppendBlock(ProfileKey.GetBuffer(0), ProfileKey.GetLength());
if (!m_MapProfile.Lookup(ProfileKey, (FX_LPVOID&)pCache)) {
- pCache = FX_NEW CFX_IccProfileCache;
- if (pCache == NULL) {
- return NULL;
- }
+ pCache = new CFX_IccProfileCache;
switch (pIccParam->dwProfileType) {
case Icc_PARAMTYPE_BUFFER:
pCache->m_pProfile = cmsOpenProfileFromMem(pIccParam->pProfileData, pIccParam->dwProfileSize);
@@ -503,11 +497,7 @@ FX_LPVOID CCodec_IccModule::CreateTransform(ICodec_IccModule::IccParam* pInputPa
pCmm->m_nSrcComponents = T_CHANNELS(dwInputProfileType);
pCmm->m_nDstComponents = T_CHANNELS(dwOutputProfileType);
pCmm->m_bLab = T_COLORSPACE(pInputParam->dwFormat) == PT_Lab;
- pTransformCache = FX_NEW CFX_IccTransformCache(pCmm);
- if (pTransformCache == NULL) {
- FX_Free(pCmm);
- return NULL;
- }
+ pTransformCache = new CFX_IccTransformCache(pCmm);
if (pProofProfile) {
pTransformCache->m_pIccTransform = cmsCreateProofingTransform(pInputProfile, dwInputProfileType, pOutputProfile, dwOutputProfileType,
pProofProfile, dwIntent, dwPrfIntent, dwPrfFlag);
diff --git a/core/src/fxcodec/codec/fx_codec_jbig.cpp b/core/src/fxcodec/codec/fx_codec_jbig.cpp
index 173f7a7d36..278d9cbcf6 100644
--- a/core/src/fxcodec/codec/fx_codec_jbig.cpp
+++ b/core/src/fxcodec/codec/fx_codec_jbig.cpp
@@ -15,7 +15,7 @@ CCodec_Jbig2Module::~CCodec_Jbig2Module()
}
void* CCodec_Jbig2Module::CreateJbig2Context()
{
- return FX_NEW CCodec_Jbig2Context();
+ return new CCodec_Jbig2Context();
}
void CCodec_Jbig2Module::DestroyJbig2Context(void* pJbig2Content)
{
diff --git a/core/src/fxcodec/codec/fx_codec_jpeg.cpp b/core/src/fxcodec/codec/fx_codec_jpeg.cpp
index 95770ea26e..99c54e75cb 100644
--- a/core/src/fxcodec/codec/fx_codec_jpeg.cpp
+++ b/core/src/fxcodec/codec/fx_codec_jpeg.cpp
@@ -557,10 +557,7 @@ ICodec_ScanlineDecoder* CCodec_JpegModule::CreateDecoder(FX_LPCBYTE src_buf, FX_
if (src_buf == NULL || src_size == 0) {
return NULL;
}
- CCodec_JpegDecoder* pDecoder = FX_NEW CCodec_JpegDecoder;
- if (pDecoder == NULL) {
- return NULL;
- }
+ CCodec_JpegDecoder* pDecoder = new CCodec_JpegDecoder;
if (!pDecoder->Create(src_buf, src_size, width, height, nComps, ColorTransform, m_pExtProvider)) {
delete pDecoder;
return NULL;
diff --git a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
index 0f0d2e5e41..3b0490f3c6 100644
--- a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
+++ b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
@@ -801,10 +801,7 @@ CCodec_JpxModule::CCodec_JpxModule()
}
void* CCodec_JpxModule::CreateDecoder(FX_LPCBYTE src_buf, FX_DWORD src_size , FX_BOOL useColorSpace)
{
- CJPX_Decoder* pDecoder = FX_NEW CJPX_Decoder;
- if (pDecoder == NULL) {
- return NULL;
- }
+ CJPX_Decoder* pDecoder = new CJPX_Decoder;
pDecoder->m_useColorSpace = useColorSpace;
if (!pDecoder->Init(src_buf, src_size)) {
delete pDecoder;
diff --git a/core/src/fxcodec/codec/fx_codec_progress.cpp b/core/src/fxcodec/codec/fx_codec_progress.cpp
index 542ac681e6..0a51a9d437 100644
--- a/core/src/fxcodec/codec/fx_codec_progress.cpp
+++ b/core/src/fxcodec/codec/fx_codec_progress.cpp
@@ -2110,12 +2110,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause)
}
return m_status = FXCODEC_STATUS_DECODE_FINISH;
} else {
- CFX_DIBitmap* pDIBitmap = FX_NEW CFX_DIBitmap;
- if(pDIBitmap == NULL) {
- m_pDeviceBitmap = NULL;
- m_pFile = NULL;
- return m_status = FXCODEC_STATUS_ERR_MEMORY;
- }
+ CFX_DIBitmap* pDIBitmap = new CFX_DIBitmap;
pDIBitmap->Create(m_SrcWidth, m_SrcHeight, FXDIB_Argb);
if(pDIBitmap->GetBuffer() == NULL) {
delete pDIBitmap;
@@ -2146,39 +2141,19 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause)
CFX_DIBitmap* pFormatBitmap = NULL;
switch(m_pDeviceBitmap->GetFormat()) {
case FXDIB_8bppRgb:
- pFormatBitmap = FX_NEW CFX_DIBitmap;
- if(pFormatBitmap == NULL) {
- m_pDeviceBitmap = NULL;
- m_pFile = NULL;
- return m_status = FXCODEC_STATUS_ERR_MEMORY;
- }
+ pFormatBitmap = new CFX_DIBitmap;
pFormatBitmap->Create(pClipBitmap->GetWidth(), pClipBitmap->GetHeight(), FXDIB_8bppRgb);
break;
case FXDIB_8bppMask:
- pFormatBitmap = FX_NEW CFX_DIBitmap;
- if(pFormatBitmap == NULL) {
- m_pDeviceBitmap = NULL;
- m_pFile = NULL;
- return m_status = FXCODEC_STATUS_ERR_MEMORY;
- }
+ pFormatBitmap = new CFX_DIBitmap;
pFormatBitmap->Create(pClipBitmap->GetWidth(), pClipBitmap->GetHeight(), FXDIB_8bppMask);
break;
case FXDIB_Rgb:
- pFormatBitmap = FX_NEW CFX_DIBitmap;
- if(pFormatBitmap == NULL) {
- m_pDeviceBitmap = NULL;
- m_pFile = NULL;
- return m_status = FXCODEC_STATUS_ERR_MEMORY;
- }
+ pFormatBitmap = new CFX_DIBitmap;
pFormatBitmap->Create(pClipBitmap->GetWidth(), pClipBitmap->GetHeight(), FXDIB_Rgb);
break;
case FXDIB_Rgb32:
- pFormatBitmap = FX_NEW CFX_DIBitmap;
- if(pFormatBitmap == NULL) {
- m_pDeviceBitmap = NULL;
- m_pFile = NULL;
- return m_status = FXCODEC_STATUS_ERR_MEMORY;
- }
+ pFormatBitmap = new CFX_DIBitmap;
pFormatBitmap->Create(pClipBitmap->GetWidth(), pClipBitmap->GetHeight(), FXDIB_Rgb32);
break;
case FXDIB_Argb:
@@ -2259,5 +2234,5 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause)
}
ICodec_ProgressiveDecoder* CCodec_ModuleMgr::CreateProgressiveDecoder()
{
- return FX_NEW CCodec_ProgressiveDecoder(this);
+ return new CCodec_ProgressiveDecoder(this);
}
diff --git a/core/src/fxcodec/codec/fx_codec_tiff.cpp b/core/src/fxcodec/codec/fx_codec_tiff.cpp
index b51444592d..fee2c783c5 100644
--- a/core/src/fxcodec/codec/fx_codec_tiff.cpp
+++ b/core/src/fxcodec/codec/fx_codec_tiff.cpp
@@ -492,10 +492,7 @@ FX_BOOL CCodec_TiffContext::Decode(CFX_DIBitmap* pDIBitmap)
}
FX_LPVOID CCodec_TiffModule::CreateDecoder(IFX_FileRead* file_ptr)
{
- CCodec_TiffContext* pDecoder = FX_NEW CCodec_TiffContext;
- if (pDecoder == NULL) {
- return NULL;
- }
+ CCodec_TiffContext* pDecoder = new CCodec_TiffContext;
if (!pDecoder->InitDecoder(file_ptr)) {
delete pDecoder;
return NULL;