Created
October 2, 2015 07:25
-
-
Save jusabatier/2935204d4d8a2a77b4a9 to your computer and use it in GitHub Desktop.
Patches for libecwj2-3.3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -r 486075d14769 -r d53918598fbf libecwj2-3.3/Source/C/NCSEcw/NCSJP2/NCSJP2File.cpp | |
--- libecwj2-3.3/Source/C/NCSEcw/NCSJP2/NCSJP2File.cpp Wed Sep 30 11:55:26 2009 +0100 | |
+++ libecwj2-3.3/Source/C/NCSEcw/NCSJP2/NCSJP2File.cpp Wed Sep 30 12:20:09 2009 +0100 | |
@@ -137,7 +137,7 @@ | |
m_bCodestreamOnly = false; | |
m_eCompressionOrder = CNCSJPCProgressionOrderType::RPCL; | |
- m_nDecompressionLayers = CNCSJPCBuffer::MAXUINT16; | |
+ m_nDecompressionLayers = CNCSJPCBuffer::NCS_MAXUINT16; | |
m_nNextLine = 0; | |
//Default geodata usage - was JP2_GEODATA_USE_WLD_GML_PCS | |
diff -r 486075d14769 -r d53918598fbf libecwj2-3.3/Source/C/NCSEcw/NCSJP2/NCSJPCBuffer.cpp | |
--- libecwj2-3.3/Source/C/NCSEcw/NCSJP2/NCSJPCBuffer.cpp Wed Sep 30 11:55:26 2009 +0100 | |
+++ libecwj2-3.3/Source/C/NCSEcw/NCSJP2/NCSJPCBuffer.cpp Wed Sep 30 12:20:09 2009 +0100 | |
@@ -26,19 +26,19 @@ | |
//void * memcpy_amd(void *dest, const void *src, size_t n); | |
-const UINT32 CNCSJPCBuffer::MAXUINT8 = (unsigned)0xff; | |
-const UINT32 CNCSJPCBuffer::MAXUINT16 = (unsigned)0xffff; | |
-const UINT32 CNCSJPCBuffer::MAXUINT32 = (unsigned)0xffffffff; | |
-const UINT32 CNCSJPCBuffer::MINUINT8 = 0; | |
-const UINT32 CNCSJPCBuffer::MINUINT16 = 0; | |
-const UINT32 CNCSJPCBuffer::MINUINT32 = 0; | |
+const UINT32 CNCSJPCBuffer::NCS_MAXUINT8 = (unsigned)0xff; | |
+const UINT32 CNCSJPCBuffer::NCS_MAXUINT16 = (unsigned)0xffff; | |
+const UINT32 CNCSJPCBuffer::NCS_MAXUINT32 = (unsigned)0xffffffff; | |
+const UINT32 CNCSJPCBuffer::NCS_MINUINT8 = 0; | |
+const UINT32 CNCSJPCBuffer::NCS_MINUINT16 = 0; | |
+const UINT32 CNCSJPCBuffer::NCS_MINUINT32 = 0; | |
-const UINT32 CNCSJPCBuffer::MAXINT8 = 0x7f; | |
-const UINT32 CNCSJPCBuffer::MAXINT16 = 0x7fff; | |
-const UINT32 CNCSJPCBuffer::MAXINT32 = 0x7fffffff; | |
-const INT32 CNCSJPCBuffer::MININT8 = (-1 * (signed)CNCSJPCBuffer::MAXINT8 - 1); | |
-const INT32 CNCSJPCBuffer::MININT16 = (-1 * (signed)CNCSJPCBuffer::MAXINT16 - 1); | |
-const INT32 CNCSJPCBuffer::MININT32 = (-1 * (signed)CNCSJPCBuffer::MAXINT32 - 1); | |
+const UINT32 CNCSJPCBuffer::NCS_MAXINT8 = 0x7f; | |
+const UINT32 CNCSJPCBuffer::NCS_MAXINT16 = 0x7fff; | |
+const UINT32 CNCSJPCBuffer::NCS_MAXINT32 = 0x7fffffff; | |
+const INT32 CNCSJPCBuffer::NCS_MININT8 = (-1 * (signed)CNCSJPCBuffer::NCS_MAXINT8 - 1); | |
+const INT32 CNCSJPCBuffer::NCS_MININT16 = (-1 * (signed)CNCSJPCBuffer::NCS_MAXINT16 - 1); | |
+const INT32 CNCSJPCBuffer::NCS_MININT32 = (-1 * (signed)CNCSJPCBuffer::NCS_MAXINT32 - 1); | |
const UINT32 CNCSJPCBuffer::AT_OWNER = (1 << 0); | |
const UINT32 CNCSJPCBuffer::AT_CHILD = (1 << 1); | |
@@ -308,27 +308,27 @@ | |
switch(m_eType) { | |
case CNCSJPCBuffer::BT_INT16: | |
// Optimise some common cases | |
- if(nMin == MINUINT8 && nMax == MAXUINT8) { | |
+ if(nMin == NCS_MINUINT8 && nMax == NCS_MAXUINT8) { | |
// UINT8 range | |
for(x = 0; x < nWidth; x++) { | |
INT16 v = ((INT16*)m_pBuffer)[x]; | |
if(v & 0xff00) { // Top bit is sign bit, so this tests for both >nMax & <nMin in one | |
- if(v > (INT16)MAXUINT8) { | |
- ((INT16*)m_pBuffer)[x] = MAXUINT8; | |
- } else if(v < (INT16)MINUINT8) { | |
- ((INT16*)m_pBuffer)[x] = MINUINT8; | |
+ if(v > (INT16)NCS_MAXUINT8) { | |
+ ((INT16*)m_pBuffer)[x] = NCS_MAXUINT8; | |
+ } else if(v < (INT16)NCS_MINUINT8) { | |
+ ((INT16*)m_pBuffer)[x] = NCS_MINUINT8; | |
} | |
} | |
} | |
- } else if(nMin == MININT8 && nMax == MAXINT8) { | |
+ } else if(nMin == NCS_MININT8 && nMax == NCS_MAXINT8) { | |
// INT8 range | |
for(x = 0; x < nWidth; x++) { | |
INT16 v = ((INT16*)m_pBuffer)[x]; | |
if(v & 0xff80) { // Top bit is sign bit, so this tests for both >nMax & <nMin in one | |
- if(v > (INT16)MAXINT8) { | |
- ((INT16*)m_pBuffer)[x] = MAXINT8; | |
- } else if(v < (INT16)MININT8) { | |
- ((INT16*)m_pBuffer)[x] = MININT8; | |
+ if(v > (INT16)NCS_MAXINT8) { | |
+ ((INT16*)m_pBuffer)[x] = NCS_MAXINT8; | |
+ } else if(v < (INT16)NCS_MININT8) { | |
+ ((INT16*)m_pBuffer)[x] = NCS_MININT8; | |
} | |
} | |
} | |
@@ -345,27 +345,27 @@ | |
break; | |
case CNCSJPCBuffer::BT_INT32: | |
// Optimise some common cases | |
- if(nMin == MINUINT16 && nMax == MAXUINT16) { | |
+ if(nMin == NCS_MINUINT16 && nMax == NCS_MAXUINT16) { | |
// UINT16 range | |
for(x = 0; x < nWidth; x++) { | |
INT32 v = ((INT32*)m_pBuffer)[x]; | |
if(v & 0xffff0000) { // Top bit is sign bit, so this tests for both >nMax & <nMin in one | |
- if(v > (INT32)MAXUINT16) { | |
- ((INT32*)m_pBuffer)[x] = MAXUINT16; | |
- } else if(v < (INT32)MINUINT16) { | |
- ((INT32*)m_pBuffer)[x] = MINUINT16; | |
+ if(v > (INT32)NCS_MAXUINT16) { | |
+ ((INT32*)m_pBuffer)[x] = NCS_MAXUINT16; | |
+ } else if(v < (INT32)NCS_MINUINT16) { | |
+ ((INT32*)m_pBuffer)[x] = NCS_MINUINT16; | |
} | |
} | |
} | |
- } else if(nMin == MININT16 && nMax == MAXINT16) { | |
+ } else if(nMin == NCS_MININT16 && nMax == NCS_MAXINT16) { | |
// INT16 range | |
for(x = 0; x < nWidth; x++) { | |
INT32 v = ((INT32*)m_pBuffer)[x]; | |
if(v & 0xffff8000) { // Top bit is sign bit, so this tests for both >nMax & <nMin in one | |
- if(v > (INT32)MAXINT16) { | |
- ((INT32*)m_pBuffer)[x] = MAXINT16; | |
- } else if(v < (INT32)MININT16) { | |
- ((INT32*)m_pBuffer)[x] = MININT16; | |
+ if(v > (INT32)NCS_MAXINT16) { | |
+ ((INT32*)m_pBuffer)[x] = NCS_MAXINT16; | |
+ } else if(v < (INT32)NCS_MININT16) { | |
+ ((INT32*)m_pBuffer)[x] = NCS_MININT16; | |
} | |
} | |
} | |
@@ -403,13 +403,13 @@ | |
return(Clip(NCSCeil(fMin), NCSFloor(fMax))); | |
break; | |
case CNCSJPCBuffer::BT_IEEE4: | |
- if(fMin == MINUINT8 && fMax == MAXUINT8) { | |
+ if(fMin == NCS_MINUINT8 && fMax == NCS_MAXUINT8) { | |
for(x = 0; x < nWidth; x++) { | |
IEEE4 v = ((IEEE4*)m_pBuffer)[x]; | |
- if(v > MAXUINT8) { | |
- ((IEEE4*)m_pBuffer)[x] = MAXUINT8; | |
- } else if(v < MINUINT8) { | |
- ((IEEE4*)m_pBuffer)[x] = MINUINT8; | |
+ if(v > NCS_MAXUINT8) { | |
+ ((IEEE4*)m_pBuffer)[x] = NCS_MAXUINT8; | |
+ } else if(v < NCS_MINUINT8) { | |
+ ((IEEE4*)m_pBuffer)[x] = NCS_MINUINT8; | |
} | |
} | |
} else { | |
diff -r 486075d14769 -r d53918598fbf libecwj2-3.3/Source/C/NCSEcw/NCSJP2/NCSJPCPLTMarker.cpp | |
--- libecwj2-3.3/Source/C/NCSEcw/NCSJP2/NCSJPCPLTMarker.cpp Wed Sep 30 11:55:26 2009 +0100 | |
+++ libecwj2-3.3/Source/C/NCSEcw/NCSJP2/NCSJPCPLTMarker.cpp Wed Sep 30 12:20:09 2009 +0100 | |
@@ -173,7 +173,7 @@ | |
nPrevHeaderLength = TMP.m_nHeaderLength; | |
TMP.m_nHeaderLength += (UINT32)nTotalHeaderLength; | |
} | |
- if(nTotalHeaderLength > CNCSJPCBuffer::MAXUINT32) { | |
+ if(nTotalHeaderLength > CNCSJPCBuffer::NCS_MAXUINT32) { | |
// Too big to store cumulated length in the PacketLength struct, so | |
// set it back to false and reparse the entire PLT | |
m_bCumulativeLengths = false; | |
@@ -202,7 +202,7 @@ | |
nPrevHeaderLength = TMP.m_nHeaderLength; | |
TMP.m_nHeaderLength += nTotalHeaderLength; | |
} | |
- if(nTotalHeaderLength > CNCSJPCBuffer::MAXUINT32) { | |
+ if(nTotalHeaderLength > CNCSJPCBuffer::NCS_MAXUINT32) { | |
// Too big to store cumulated length in the PacketLength struct, so | |
// set it back to false and reparse the entire PLT | |
m_bCumulativeLengths = false; | |
diff -r 486075d14769 -r d53918598fbf libecwj2-3.3/Source/C/NCSEcw/NCSJP2/NCSJPCT1Coder.cpp | |
--- libecwj2-3.3/Source/C/NCSEcw/NCSJP2/NCSJPCT1Coder.cpp Wed Sep 30 11:55:26 2009 +0100 | |
+++ libecwj2-3.3/Source/C/NCSEcw/NCSJP2/NCSJPCT1Coder.cpp Wed Sep 30 12:20:09 2009 +0100 | |
@@ -917,7 +917,7 @@ | |
int passno=0; | |
int passtype; | |
- INT32 nMax = CNCSJPCBuffer::MININT32; | |
+ INT32 nMax = CNCSJPCBuffer::NCS_MININT32; | |
UINT32 nWidth = pDecBuf->GetWidth(); | |
UINT32 nHeight = pDecBuf->GetHeight(); | |
@@ -956,7 +956,7 @@ | |
UINT32 nSubWidth = nWidth / 8; | |
__m128 mm7 = _mm_set1_ps(fRatio); | |
- __m128i mm4 = _mm_set1_epi16((short)CNCSJPCBuffer::MININT16); | |
+ __m128i mm4 = _mm_set1_epi16((short)CNCSJPCBuffer::NCS_MININT16); | |
for(UINT32 y = 0; y < nHeight; y++) { | |
INT16 *pSrc = (INT16*)pDecBuf->GetPtr() + y * nDecStep; | |
@@ -1008,7 +1008,7 @@ | |
UINT32 nSubWidth = nWidth / 4; | |
__m128 mm7 = _mm_set1_ps(fRatio); | |
- __m64 mm4 = _mm_set1_pi16((short)CNCSJPCBuffer::MININT16); | |
+ __m64 mm4 = _mm_set1_pi16((short)CNCSJPCBuffer::NCS_MININT16); | |
for(UINT32 y = 0; y < nHeight; y++) { | |
INT16 *pSrc = (INT16*)pDecBuf->GetPtr() + y * nDecStep; | |
diff -r 486075d14769 -r d53918598fbf libecwj2-3.3/Source/include/NCSJPCBuffer.h | |
--- libecwj2-3.3/Source/include/NCSJPCBuffer.h Wed Sep 30 11:55:26 2009 +0100 | |
+++ libecwj2-3.3/Source/include/NCSJPCBuffer.h Wed Sep 30 12:20:09 2009 +0100 | |
@@ -48,30 +48,30 @@ | |
class NCSJPC_EXPORT_ALL CNCSJPCBuffer: public CNCSJPCRect { | |
public: | |
/** Maximum UINT8 value */ | |
- static const UINT32 MAXUINT8; | |
+ static const UINT32 NCS_MAXUINT8; | |
/** Maximum UINT16 value */ | |
- static const UINT32 MAXUINT16; | |
+ static const UINT32 NCS_MAXUINT16; | |
/** Maximum UINT32 value */ | |
- static const UINT32 MAXUINT32; | |
+ static const UINT32 NCS_MAXUINT32; | |
/** Minimum UINT8 value */ | |
- static const UINT32 MINUINT8; | |
+ static const UINT32 NCS_MINUINT8; | |
/** Minimum UINT16 value */ | |
- static const UINT32 MINUINT16; | |
+ static const UINT32 NCS_MINUINT16; | |
/** Minimum UINT32 value */ | |
- static const UINT32 MINUINT32; | |
+ static const UINT32 NCS_MINUINT32; | |
/** Maximum INT8 value */ | |
- static const UINT32 MAXINT8; | |
+ static const UINT32 NCS_MAXINT8; | |
/** Maximum INT16 value */ | |
- static const UINT32 MAXINT16; | |
+ static const UINT32 NCS_MAXINT16; | |
/** Maximum INT32 value */ | |
- static const UINT32 MAXINT32; | |
+ static const UINT32 NCS_MAXINT32; | |
/** Minimum INT8 value */ | |
- static const INT32 MININT8; | |
+ static const INT32 NCS_MININT8; | |
/** Minimum INT16 value */ | |
- static const INT32 MININT16; | |
+ static const INT32 NCS_MININT16; | |
/** Minimum INT32 value */ | |
- static const INT32 MININT32; | |
+ static const INT32 NCS_MININT32; | |
/** | |
* SystemInfo class - Some basic system capabilities we care about. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- Source/C/NCSUtil/malloc.c.ori 2010-02-02 00:09:24.000000000 +0100 | |
+++ Source/C/NCSUtil/malloc.c 2010-02-02 00:17:13.000000000 +0100 | |
@@ -390,7 +390,12 @@ | |
#else /* SOLARIS */ | |
#ifdef LINUX | |
- return(sysconf(_SC_PHYS_PAGES) * sysconf(_SC_PAGESIZE)); | |
+ long nPages = sysconf(_SC_PHYS_PAGES); | |
+ long nPageSize = sysconf(_SC_PAGESIZE); | |
+ if (nPages > INT_MAX / nPageSize) | |
+ return INT_MAX; | |
+ else | |
+ return (INT32)(nPages * nPageSize); | |
#elif defined MACOSX | |
return(128*1024*1024); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -Nur libecwj2-3.3-orig/Source/C/NCSUtil/NCSPrefsXML.cpp libecwj2-3.3-wcharfix/Source/C/NCSUtil/NCSPrefsXML.cpp | |
--- libecwj2-3.3-orig/Source/C/NCSUtil/NCSPrefsXML.cpp 2006-07-03 03:15:12.000000000 +0200 | |
+++ libecwj2-3.3-wcharfix/Source/C/NCSUtil/NCSPrefsXML.cpp 2012-09-12 21:51:19.477487746 +0200 | |
@@ -32,7 +32,11 @@ | |
} else { | |
char *pHomeDir = getenv("HOME"); | |
if( pHomeDir ) { | |
+#ifdef NCS_BUILD_UNICODE | |
+ sUserPrefsFile.Format( NCS_T("%s%ls"), pHomeDir, NCS_T("/.erm/ncsuserprefs.xml") ); | |
+#else | |
sUserPrefsFile.Format( NCS_T("%s%s"), pHomeDir, NCS_T("/.erm/ncsuserprefs.xml") ); | |
+#endif | |
} else { | |
sUserPrefsFile = NCS_T("/etc/erm/ncsuserprefs.xml"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment