Merge to XFA: Replace FX_NEW with new, remote tests from fxcodec
authorLei Zhang <thestig@chromium.org>
Wed, 6 May 2015 22:09:06 +0000 (15:09 -0700)
committerLei Zhang <thestig@chromium.org>
Wed, 6 May 2015 22:09:06 +0000 (15:09 -0700)
Review URL: https://codereview.chromium.org/1084303002

(cherry picked from commit cfc1a654ef3e8b65bc447815d35932c185bf1422)

R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/1125363002

core/src/fxcodec/codec/fx_codec.cpp
core/src/fxcodec/codec/fx_codec_fax.cpp
core/src/fxcodec/codec/fx_codec_flate.cpp
core/src/fxcodec/codec/fx_codec_icc.cpp
core/src/fxcodec/codec/fx_codec_jbig.cpp
core/src/fxcodec/codec/fx_codec_jpeg.cpp
core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
core/src/fxcodec/codec/fx_codec_progress.cpp
core/src/fxcodec/codec/fx_codec_tiff.cpp
core/src/fxcodec/lgif/fx_gif.cpp

index b2f70c7..36dff5e 100644 (file)
@@ -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;\r
-    m_pGifModule = FX_NEW CCodec_GifModule;\r
-    m_pBmpModule = FX_NEW CCodec_BmpModule;\r
-    m_pTiffModule = FX_NEW CCodec_TiffModule;\r
-    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()\r
-{\r
-    FXSYS_memset32(this, 0, sizeof(CFX_DIBAttribute));\r
-    m_nXDPI = -1;\r
-    m_nYDPI = -1;\r
-    m_fAspectRatio = -1.0f;\r
-    m_pExif = FX_NEW CFX_DIBAttributeExif;\r
-}\r
-CFX_DIBAttribute::~CFX_DIBAttribute()\r
-{\r
-    if (m_pExif) {\r
-        delete m_pExif;\r
-    }\r
-}\r
-CFX_DIBAttributeExif::CFX_DIBAttributeExif()\r
-{\r
-    m_pExifData = NULL;\r
-    m_dwExifDataLen = 0;\r
-}\r
-CFX_DIBAttributeExif::~CFX_DIBAttributeExif()\r
-{\r
-    clear();\r
-}\r
-void CFX_DIBAttributeExif::clear()\r
-{\r
-    if (m_pExifData) {\r
-        FX_Free(m_pExifData);\r
-    }\r
-    m_pExifData = NULL;\r
-    FX_DWORD key = 0;\r
-    FX_LPBYTE buf = NULL;\r
-    FX_POSITION pos = NULL;\r
-    pos = m_TagHead.GetStartPosition();\r
-    while (pos) {\r
-        m_TagHead.GetNextAssoc(pos, key, buf);\r
-        if (buf) {\r
-            FX_Free(buf);\r
-        }\r
-    }\r
-    m_TagHead.RemoveAll();\r
-    pos = m_TagVal.GetStartPosition();\r
-    while (pos) {\r
-        m_TagVal.GetNextAssoc(pos, key, buf);\r
-        if (buf) {\r
-            FX_Free(buf);\r
-        }\r
-    }\r
-    m_TagVal.RemoveAll();\r
-}\r
-static FX_WORD _Read2BytesL(FX_LPBYTE data)\r
-{\r
-    ASSERT(data);\r
-    return data[0] | (data[1] << 8);\r
-}\r
-static FX_WORD _Read2BytesB(FX_LPBYTE data)\r
-{\r
-    ASSERT(data);\r
-    return data[1] | (data[0] << 8);\r
-}\r
-static FX_DWORD _Read4BytesL(FX_LPBYTE data)\r
-{\r
-    return _Read2BytesL(data) | (_Read2BytesL(data + 2) << 16);\r
-}\r
-static FX_DWORD _Read4BytesB(FX_LPBYTE data)\r
-{\r
-    return _Read2BytesB(data + 2) | (_Read2BytesB(data) << 16);\r
-}\r
-typedef FX_WORD (*_Read2Bytes) (FX_LPBYTE data);\r
-typedef FX_DWORD (*_Read4Bytes) (FX_LPBYTE data);\r
-typedef void (*_Write2Bytes) (FX_LPBYTE data, FX_WORD val);\r
-typedef void (*_Write4Bytes) (FX_LPBYTE data, FX_DWORD val);\r
-FX_LPBYTE CFX_DIBAttributeExif::ParseExifIFH(FX_LPBYTE data, FX_DWORD len, _Read2Bytes* pReadWord, _Read4Bytes* pReadDword)\r
-{\r
-    if (len > 8) {\r
-        FX_BOOL tag = FALSE;\r
-        if (FXSYS_memcmp32(data, "\x49\x49\x2a\x00", 4) == 0) {\r
-            if (pReadWord) {\r
-                *pReadWord = _Read2BytesL;\r
-            }\r
-            if (pReadDword) {\r
-                *pReadDword = _Read4BytesL;\r
-            }\r
-            tag = TRUE;\r
-        } else if (FXSYS_memcmp32(data, "\x4d\x4d\x00\x2a", 4) == 0) {\r
-            if (pReadWord) {\r
-                *pReadWord = _Read2BytesB;\r
-            }\r
-            if (pReadDword) {\r
-                *pReadDword = _Read4BytesB;\r
-            }\r
-            tag = TRUE;\r
-        }\r
-        if (tag) {\r
-            data += 4;\r
-            if (pReadDword) {\r
-                data += (*pReadDword)(data) - 4;\r
-            } else {\r
-                data += 4;\r
-            }\r
-        }\r
-    }\r
-    return data;\r
-}\r
-FX_BOOL CFX_DIBAttributeExif::ParseExifIFD(CFX_MapPtrTemplate<FX_DWORD, FX_LPBYTE>* pMap, FX_LPBYTE data, FX_DWORD len)\r
-{\r
-    if (pMap && data) {\r
-        if (len > 8) {\r
-            FX_WORD wTagNum = m_readWord(data);\r
-            data += 2;\r
-            FX_DWORD wTag;\r
-            FX_LPBYTE buf;\r
-            while (wTagNum--) {\r
-                wTag = m_readWord(data);\r
-                data += 2;\r
-                if (!pMap->Lookup(wTag, buf)) {\r
-                    buf = FX_Alloc(FX_BYTE, 10);\r
-                    if (buf == NULL) {\r
-                        return FALSE;\r
-                    }\r
-                    FXSYS_memcpy32(buf, data, 10);\r
-                    pMap->SetAt(wTag, buf);\r
-                }\r
-                data += 10;\r
-            }\r
-            FX_DWORD dwIFDOffset;\r
-            dwIFDOffset = m_readDword(data);\r
-            while (dwIFDOffset && dwIFDOffset < len) {\r
-                data = m_pExifData + dwIFDOffset;\r
-                wTagNum = m_readWord(data);\r
-                data += 2;\r
-                while (wTagNum--) {\r
-                    wTag = m_readWord(data);\r
-                    data += 2;\r
-                    if (!pMap->Lookup(wTag, buf)) {\r
-                        buf = FX_Alloc(FX_BYTE, 10);\r
-                        if (buf == NULL) {\r
-                            return FALSE;\r
-                        }\r
-                        FXSYS_memcpy32(buf, data, 10);\r
-                        pMap->SetAt(wTag, buf);\r
-                    }\r
-                    data += 10;\r
-                }\r
-                dwIFDOffset = m_readDword(data);\r
-            }\r
-            return TRUE;\r
-        }\r
-    }\r
-    return FALSE;\r
-}\r
-enum FX_ExifDataType {\r
-    FX_UnsignedByte = 1,\r
-    FX_AscString,\r
-    FX_UnsignedShort,\r
-    FX_UnsignedLong,\r
-    FX_UnsignedRation,\r
-    FX_SignedByte,\r
-    FX_Undefined,\r
-    FX_SignedShort,\r
-    FX_SignedLong,\r
-    FX_SignedRation,\r
-    FX_SignedFloat,\r
-    FX_DoubleFloat\r
-};\r
-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)\r
-{\r
-    if (pHead && data && pVal) {\r
-        if (len > 8) {\r
-            FX_LPBYTE old_data = data;\r
-            data = ParseExifIFH(data, len, &m_readWord, &m_readDword);\r
-            if (data == old_data) {\r
-                return FALSE;\r
-            }\r
-            if (pHead->GetCount() == 0) {\r
-                if (!ParseExifIFD(pHead, data, len)) {\r
-                    return FALSE;\r
-                }\r
-            }\r
-            FX_DWORD dwModuleNum;\r
-            FX_WORD type;\r
-            FX_DWORD dwSize;\r
-            FX_DWORD tag;\r
-            FX_LPBYTE head;\r
-            FX_POSITION pos = pHead->GetStartPosition();\r
-            while (pos) {\r
-                pHead->GetNextAssoc(pos, tag, head);\r
-                FX_LPBYTE val = NULL, buf = NULL, temp = NULL;\r
-                int i;\r
-                if (head) {\r
-                    type = m_readWord(head);\r
-                    head += 2;\r
-                    dwModuleNum = m_readDword(head);\r
-                    head += 4;\r
-                    switch (type) {\r
-                        case FX_UnsignedByte:\r
-                        case FX_AscString:\r
-                        case FX_SignedByte:\r
-                        case FX_Undefined:\r
-                            dwSize = dwModuleNum;\r
-                            val = FX_Alloc(FX_BYTE, dwSize);\r
-                            if (val == NULL) {\r
-                                return FALSE;\r
-                            }\r
-                            if (dwSize > 4) {\r
-                                FXSYS_memcpy32(val, old_data + m_readDword(head), dwSize);\r
-                            } else {\r
-                                FXSYS_memcpy32(val, head, dwSize);\r
-                            }\r
-                            break;\r
-                        case FX_UnsignedShort:\r
-                        case FX_SignedShort:\r
-                            dwSize = dwModuleNum << 1;\r
-                            val = FX_Alloc(FX_BYTE, dwSize);\r
-                            if (val == NULL) {\r
-                                return FALSE;\r
-                            }\r
-                            if (dwSize > 4) {\r
-                                FXSYS_memcpy32(val, old_data + m_readDword(head), dwSize);\r
-                            } else {\r
-                                FXSYS_memcpy32(val, head, dwSize);\r
-                            }\r
-                            buf = val;\r
-                            for(i = 0; i < (int)dwModuleNum; i ++) {\r
-                                *(FX_WORD*)buf = m_readWord(buf);\r
-                                buf += 2;\r
-                            }\r
-                            break;\r
-                        case FX_UnsignedLong:\r
-                        case FX_SignedLong:\r
-                        case FX_SignedFloat:\r
-                            dwSize = dwModuleNum << 2;\r
-                            val = FX_Alloc(FX_BYTE, dwSize);\r
-                            if (val == NULL) {\r
-                                return FALSE;\r
-                            }\r
-                            if (dwSize > 4) {\r
-                                FXSYS_memcpy32(val, old_data + m_readDword(head), dwSize);\r
-                            } else {\r
-                                FXSYS_memcpy32(val, head, dwSize);\r
-                            }\r
-                            buf = val;\r
-                            for(i = 0; i < (int)dwModuleNum; i ++) {\r
-                                *(FX_DWORD*)buf = m_readDword(buf);\r
-                                buf += 4;\r
-                            }\r
-                            break;\r
-                        case FX_UnsignedRation:\r
-                        case FX_SignedRation: {\r
-                                dwSize = dwModuleNum << 3;\r
-                                buf = FX_Alloc(FX_BYTE, dwSize);\r
-                                if (buf == NULL) {\r
-                                    return FALSE;\r
-                                }\r
-                                if (dwSize > 4) {\r
-                                    FXSYS_memcpy32(buf, old_data + m_readDword(head), dwSize);\r
-                                } else {\r
-                                    FXSYS_memcpy32(buf, head, dwSize);\r
-                                }\r
-                                temp = buf;\r
-                                val = FX_Alloc(FX_BYTE, dwSize / 2);\r
-                                if (val == NULL) {\r
-                                    FX_Free(buf);\r
-                                    return FALSE;\r
-                                }\r
-                                for(i = 0; i < (int)dwModuleNum; i ++) {\r
-                                    *(FX_DWORD*)temp = m_readDword(temp);\r
-                                    *(FX_DWORD*)(temp + 4) = m_readDword(temp + 4);\r
-                                    FX_DWORD* lNumerator = (FX_DWORD*)temp;\r
-                                    FX_DWORD* lNenominator = (FX_DWORD*)(temp + 4);\r
-                                    *(FX_FLOAT*)(val + i * 4) = (FX_FLOAT)(*lNumerator) / (FX_FLOAT)(*lNenominator);\r
-                                    temp += 8;\r
-                                }\r
-                                FX_Free(buf);\r
-                            }\r
-                            break;\r
-                        case FX_DoubleFloat:\r
-                            dwSize = dwModuleNum << 3;\r
-                            val = FX_Alloc(FX_BYTE, dwSize);\r
-                            if (val == NULL) {\r
-                                return FALSE;\r
-                            }\r
-                            if (dwSize > 4) {\r
-                                FXSYS_memcpy32(val, old_data + m_readDword(head), dwSize);\r
-                            } else {\r
-                                FXSYS_memcpy32(val, head, dwSize);\r
-                            }\r
-                            buf = val;\r
-                            for(i = 0; i < (int)dwModuleNum; i ++) {\r
-                                *(FX_DWORD*)buf = m_readDword(buf);\r
-                                *(FX_DWORD*)(buf + 4) = m_readDword(buf + 4);\r
-                                buf += 8;\r
-                            }\r
-                            break;\r
-                        default:\r
-                            return FALSE;\r
-                    }\r
-                }\r
-                pVal->SetAt(tag, val);\r
-            }\r
-            return TRUE;\r
-        }\r
-    }\r
-    return FALSE;\r
-}\r
-#define FXEXIF_INFOCONVERT(T) {T* src = (T*)ptr;       T* dst = (T*)val;       *dst = *src;}\r
-FX_BOOL CFX_DIBAttributeExif::GetInfo( FX_WORD tag, FX_LPVOID val )\r
-{\r
-    if (m_TagVal.GetCount() == 0) {\r
-        if (!ParseExif(&m_TagHead, m_pExifData, m_dwExifDataLen, &m_TagVal)) {\r
-            return FALSE;\r
-        }\r
-    }\r
-    FX_LPBYTE ptr = NULL;\r
-    if (m_TagVal.Lookup(tag, ptr)) {\r
-        switch (tag) {\r
-            case EXIFTAG_USHORT_RESUNIT:\r
-                FXEXIF_INFOCONVERT(FX_WORD);\r
-                {\r
-                    FX_WORD* ptr = (FX_WORD*)val;\r
-                    *ptr -= 1;\r
-                }\r
-                break;\r
-            case EXIFTAG_FLOAT_DPIX:\r
-            case EXIFTAG_FLOAT_DPIY:\r
-                FXEXIF_INFOCONVERT(FX_FLOAT);\r
-                break;\r
-            case EXIFTAG_USHORT_ORIENTATION:\r
-                FXEXIF_INFOCONVERT(FX_WORD);\r
-                break;\r
-            default: {\r
-                    FX_LPBYTE* dst = (FX_LPBYTE*)val;\r
-                    *dst = ptr;\r
-                }\r
-        }\r
-    }\r
-    return TRUE;\r
-}\r
+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;
index c6ab791..667b713 100644 (file)
@@ -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;
 }
index afdb835..3e1aa36 100644 (file)
@@ -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;
index 1a4fce6..a984fec 100644 (file)
@@ -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);
index 173f7a7..278d9cb 100644 (file)
@@ -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)
 {
index 95770ea..99c54e7 100644 (file)
@@ -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;
index 0f0d2e5..3b0490f 100644 (file)
@@ -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;
index 542ac68..0a51a9d 100644 (file)
@@ -2110,12 +2110,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause)
                     }\r
                     return m_status = FXCODEC_STATUS_DECODE_FINISH;\r
                 } else {\r
-                    CFX_DIBitmap* pDIBitmap = FX_NEW CFX_DIBitmap;\r
-                    if(pDIBitmap == NULL) {\r
-                        m_pDeviceBitmap = NULL;\r
-                        m_pFile = NULL;\r
-                        return m_status = FXCODEC_STATUS_ERR_MEMORY;\r
-                    }\r
+                    CFX_DIBitmap* pDIBitmap = new CFX_DIBitmap;\r
                     pDIBitmap->Create(m_SrcWidth, m_SrcHeight, FXDIB_Argb);\r
                     if(pDIBitmap->GetBuffer() == NULL) {\r
                         delete pDIBitmap;\r
@@ -2146,39 +2141,19 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause)
                     CFX_DIBitmap* pFormatBitmap = NULL;\r
                     switch(m_pDeviceBitmap->GetFormat()) {\r
                         case FXDIB_8bppRgb:\r
-                            pFormatBitmap = FX_NEW CFX_DIBitmap;\r
-                            if(pFormatBitmap == NULL) {\r
-                                m_pDeviceBitmap = NULL;\r
-                                m_pFile = NULL;\r
-                                return m_status = FXCODEC_STATUS_ERR_MEMORY;\r
-                            }\r
+                            pFormatBitmap = new CFX_DIBitmap;\r
                             pFormatBitmap->Create(pClipBitmap->GetWidth(), pClipBitmap->GetHeight(), FXDIB_8bppRgb);\r
                             break;\r
                         case FXDIB_8bppMask:\r
-                            pFormatBitmap = FX_NEW CFX_DIBitmap;\r
-                            if(pFormatBitmap == NULL) {\r
-                                m_pDeviceBitmap = NULL;\r
-                                m_pFile = NULL;\r
-                                return m_status = FXCODEC_STATUS_ERR_MEMORY;\r
-                            }\r
+                            pFormatBitmap = new CFX_DIBitmap;\r
                             pFormatBitmap->Create(pClipBitmap->GetWidth(), pClipBitmap->GetHeight(), FXDIB_8bppMask);\r
                             break;\r
                         case FXDIB_Rgb:\r
-                            pFormatBitmap = FX_NEW CFX_DIBitmap;\r
-                            if(pFormatBitmap == NULL) {\r
-                                m_pDeviceBitmap = NULL;\r
-                                m_pFile = NULL;\r
-                                return m_status = FXCODEC_STATUS_ERR_MEMORY;\r
-                            }\r
+                            pFormatBitmap = new CFX_DIBitmap;\r
                             pFormatBitmap->Create(pClipBitmap->GetWidth(), pClipBitmap->GetHeight(), FXDIB_Rgb);\r
                             break;\r
                         case FXDIB_Rgb32:\r
-                            pFormatBitmap = FX_NEW CFX_DIBitmap;\r
-                            if(pFormatBitmap == NULL) {\r
-                                m_pDeviceBitmap = NULL;\r
-                                m_pFile = NULL;\r
-                                return m_status = FXCODEC_STATUS_ERR_MEMORY;\r
-                            }\r
+                            pFormatBitmap = new CFX_DIBitmap;\r
                             pFormatBitmap->Create(pClipBitmap->GetWidth(), pClipBitmap->GetHeight(), FXDIB_Rgb32);\r
                             break;\r
                         case FXDIB_Argb:\r
@@ -2259,5 +2234,5 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause)
 }\r
 ICodec_ProgressiveDecoder* CCodec_ModuleMgr::CreateProgressiveDecoder()\r
 {\r
-    return FX_NEW CCodec_ProgressiveDecoder(this);\r
+    return new CCodec_ProgressiveDecoder(this);\r
 }\r
index b514445..fee2c78 100644 (file)
@@ -492,10 +492,7 @@ FX_BOOL CCodec_TiffContext::Decode(CFX_DIBitmap* pDIBitmap)
 }\r
 FX_LPVOID CCodec_TiffModule::CreateDecoder(IFX_FileRead* file_ptr)\r
 {\r
-    CCodec_TiffContext* pDecoder = FX_NEW CCodec_TiffContext;\r
-    if (pDecoder == NULL) {\r
-        return NULL;\r
-    }\r
+    CCodec_TiffContext* pDecoder = new CCodec_TiffContext;\r
     if (!pDecoder->InitDecoder(file_ptr)) {\r
         delete pDecoder;\r
         return NULL;\r
index 8f5794e..08c1803 100644 (file)
@@ -342,27 +342,12 @@ gif_decompress_struct_p _gif_create_decompress()
     }\r
     FXSYS_memset32(gif_ptr, 0, sizeof(gif_decompress_struct));\r
     gif_ptr->decode_status = GIF_D_STATUS_SIG;\r
-    gif_ptr->img_ptr_arr_ptr = FX_NEW CFX_ArrayTemplate<GifImage*>;\r
-    if(gif_ptr->img_ptr_arr_ptr == NULL) {\r
-        FX_Free(gif_ptr);\r
-        return NULL;\r
-    }\r
+    gif_ptr->img_ptr_arr_ptr = new CFX_ArrayTemplate<GifImage*>;\r
 #ifdef GIF_SUPPORT_COMMENT_EXTENSION\r
-    gif_ptr->cmt_data_ptr = FX_NEW CFX_ByteString;\r
-    if(gif_ptr->cmt_data_ptr == NULL) {\r
-        delete gif_ptr->img_ptr_arr_ptr;\r
-        FX_Free(gif_ptr);\r
-        return NULL;\r
-    }\r
+    gif_ptr->cmt_data_ptr = new CFX_ByteString;\r
 #endif\r
 #ifdef GIF_SUPPORT_PLAIN_TEXT_EXTENSION\r
-    gif_ptr->pt_ptr_arr_ptr = FX_NEW CFX_ArrayTemplate<GifPlainText*>;\r
-    if(gif_ptr->pt_ptr_arr_ptr == NULL) {\r
-        delete(gif_ptr->cmt_data_ptr);\r
-        delete gif_ptr->img_ptr_arr_ptr;\r
-        FX_Free(gif_ptr);\r
-        return NULL;\r
-    }\r
+    gif_ptr->pt_ptr_arr_ptr = new CFX_ArrayTemplate<GifPlainText*>;\r
 #endif\r
     return gif_ptr;\r
 }\r
@@ -443,11 +428,7 @@ gif_compress_struct_p _gif_create_compress()
         return NULL;\r
     }\r
     FXSYS_memset32(gif_ptr, 0, sizeof(gif_compress_struct));\r
-    gif_ptr->img_encoder_ptr = FX_NEW CGifLZWEncoder;\r
-    if (gif_ptr->img_encoder_ptr == NULL) {\r
-        FX_Free(gif_ptr);\r
-        return NULL;\r
-    }\r
+    gif_ptr->img_encoder_ptr = new CGifLZWEncoder;\r
     gif_ptr->header_ptr = (GifHeader*)FX_Alloc(FX_BYTE, sizeof(GifHeader));\r
     if (gif_ptr->header_ptr == NULL) {\r
         delete(gif_ptr->img_encoder_ptr);\r
@@ -800,7 +781,7 @@ FX_INT32 _gif_decode_extension(gif_decompress_struct_p gif_ptr)
                 _gif_takeover_gce_ptr(gif_ptr, &gif_pt_ptr->gce_ptr);\r
                 gif_pt_ptr->pte_ptr = (GifPTE*)FX_Alloc(FX_BYTE, sizeof(GifPTE));\r
                 GIF_PTR_NOT_NULL(gif_pt_ptr->pte_ptr, gif_ptr);\r
-                gif_pt_ptr->string_ptr = FX_NEW CFX_ByteString;\r
+                gif_pt_ptr->string_ptr = new CFX_ByteString;\r
                 GIF_PTR_NOT_NULL(gif_pt_ptr->string_ptr, gif_ptr);\r
                 gif_pt_ptr->pte_ptr->block_size = gif_pte_ptr->block_size;\r
                 gif_pt_ptr->pte_ptr->grid_left = _GetWord_LSBFirst((FX_LPBYTE)&gif_pte_ptr->grid_left);\r
@@ -1036,7 +1017,7 @@ FX_INT32 _gif_load_frame(gif_decompress_struct_p gif_ptr, FX_INT32 frame_num)
             }\r
         }\r
         if(gif_ptr->img_decoder_ptr == NULL) {\r
-            gif_ptr->img_decoder_ptr = FX_NEW CGifLZWDecoder(gif_ptr->err_ptr);\r
+            gif_ptr->img_decoder_ptr = new CGifLZWDecoder(gif_ptr->err_ptr);\r
             GIF_PTR_NOT_NULL(gif_ptr->img_decoder_ptr, gif_ptr);\r
         }\r
         gif_ptr->img_decoder_ptr->InitTable(gif_image_ptr->image_code_size);\r