Skip to content

Commit

Permalink
graphics/libecwj2: patches to compile in C++17 mode
Browse files Browse the repository at this point in the history
  • Loading branch information
glebius committed Jul 7, 2023
1 parent cab5056 commit 51ba503
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 2 deletions.
3 changes: 1 addition & 2 deletions graphics/libecwj2/Makefile
@@ -1,6 +1,6 @@
PORTNAME= libecwj2
PORTVERSION= 3.3
PORTREVISION= 3
PORTREVISION= 4
CATEGORIES= graphics
MASTER_SITES= http://glebi.us/tmp/403/
DISTFILES= ecw_jpeg_2000_sdk_3_3_source.zip
Expand All @@ -17,7 +17,6 @@ LICENSE_TEXT= Registration required to download sources,\
LICENSE_PERMS= auto-accept

USES= gmake libtool zip
USE_CXXSTD= c++11
USE_LDCONFIG= yes
GNU_CONFIGURE= yes
INSTALL_TARGET= install-strip
Expand Down
36 changes: 36 additions & 0 deletions graphics/libecwj2/files/patch-unique_ptr
@@ -0,0 +1,36 @@
--- Source/include/NCSJPCNode.h.orig 2023-06-26 20:16:29.710073000 -0700
+++ Source/include/NCSJPCNode.h 2023-06-27 06:42:55.697501000 -0700
@@ -136,17 +136,7 @@
CNCSError GetError(ContextID nCtx);

protected:
- class ContextAutoPtr: public std::auto_ptr<Context> {
- public:
- ContextAutoPtr() {};
- ContextAutoPtr(Context *s): std::auto_ptr<Context>(s) {};
- ContextAutoPtr(const ContextAutoPtr &s) {
- ContextAutoPtr P(s.get());
- *this = P;
- };
- ~ContextAutoPtr() {};
- };
- std::map<ContextID, ContextAutoPtr> *m_pContext;/*std::auto_ptr<Context>*/
+ std::map<ContextID, std::unique_ptr<Context>> *m_pContext;

/**
* Get the context for the given ContextID
--- Source/C/NCSEcw/NCSJP2/NCSJPCNode.cpp.orig 2023-06-26 20:32:03.064056000 -0700
+++ Source/C/NCSEcw/NCSJP2/NCSJPCNode.cpp 2023-06-26 20:59:13.970978000 -0700
@@ -209,10 +209,9 @@
void CNCSJPCNode::SetContext(ContextID nCtx, Context *pCtx)
{
if(!m_pContext) {
- m_pContext = new std::map<ContextID, ContextAutoPtr>;
+ m_pContext = new std::map<ContextID, std::unique_ptr<Context>>;
}
- ContextAutoPtr P(pCtx);
- (*m_pContext)[nCtx] = P;
+ (*m_pContext)[nCtx] = std::unique_ptr<Context>(pCtx);
};

CNCSJPCNode::Context::Context()
76 changes: 76 additions & 0 deletions graphics/libecwj2/files/patch-unregister
@@ -0,0 +1,76 @@
--- Source/C/NCSEcw/NCSJP2/NCSJP2FileView.cpp.orig 2023-06-26 20:13:13.572938000 -0700
+++ Source/C/NCSEcw/NCSJP2/NCSJP2FileView.cpp 2023-06-26 20:13:28.835768000 -0700
@@ -2863,9 +2863,9 @@
IEEE4 *NCS_RESTRICT pB = ppInputLines[2];

for(i = 0; i < nInOutSizeX; i++) {
- register IEEE4 fRed = *(pR++);
- register IEEE4 fGreen = *(pG++);
- register IEEE4 fBlue = *(pB++);
+ IEEE4 fRed = *(pR++);
+ IEEE4 fGreen = *(pG++);
+ IEEE4 fBlue = *(pB++);

*(pY++) = ((0.299f * fRed) + (0.587f * fGreen) + (0.114f * fBlue));
*(pU++) = ((-0.1687f * fRed) + (-0.3313f * fGreen) + (0.5f * fBlue));
@@ -2877,9 +2877,9 @@
UINT8 *NCS_RESTRICT pB = (UINT8*)ppInputLines[2];

for(i = 0; i < nInOutSizeX; i++) {
- register IEEE4 fRed = *(pR++);
- register IEEE4 fGreen = *(pG++);
- register IEEE4 fBlue = *(pB++);
+ IEEE4 fRed = *(pR++);
+ IEEE4 fGreen = *(pG++);
+ IEEE4 fBlue = *(pB++);

*(pY++) = ((0.299f * fRed) + (0.587f * fGreen) + (0.114f * fBlue));
*(pU++) = ((-0.1687f * fRed) + (-0.3313f * fGreen) + (0.5f * fBlue));
--- Source/C/NCSEcw/NCSEcw/NCSHuffmanCoder.cpp.orig 2023-06-26 20:29:32.610922000 -0700
+++ Source/C/NCSEcw/NCSEcw/NCSHuffmanCoder.cpp 2023-06-26 20:29:50.210010000 -0700
@@ -275,7 +275,7 @@
UINT32 nRawLength)
{
UINT8 *pOutput = pPacked;
- register UINT32 nWordCount = nRawLength / 2;
+ UINT32 nWordCount = nRawLength / 2;

m_pTree = new CTree();
m_pTree->Pack(&pOutput, pUnPacked, nWordCount);
@@ -311,9 +311,9 @@
INT16 *pUnPacked,
UINT32 nRawLength)
{
- register UINT32 nWordCount = nRawLength / 2;
- register INT16 *pOutput = (INT16*)pUnPacked;
- register UINT32 nBitsUsed = 0;
+ UINT32 nWordCount = nRawLength / 2;
+ INT16 *pOutput = (INT16*)pUnPacked;
+ UINT32 nBitsUsed = 0;

m_pTree = new CTree(&pPacked);

@@ -330,8 +330,8 @@
}

if(pNode->m_Symbol.bZeroRun) {
- register UINT16 nZero;
- register UINT16 nZeroRun = pNode->m_Symbol.nValue;
+ UINT16 nZero;
+ UINT16 nZeroRun = pNode->m_Symbol.nValue;

if( nZeroRun >= nWordCount ) {
nZero = (UINT16)nWordCount + 1;
@@ -378,9 +378,9 @@
extern "C" NCSHuffmanSymbol *unpack_huffman_symbol(UINT8 **ppPacked,
NCSHuffmanState *pState)
{
- register UINT32 nBitsUsed = pState->nBitsUsed;
- register CNCSHuffmanCoder::CCodeNode *pNode = ((CNCSHuffmanCoder::CTree*)pState->pTree)->m_pRoot;
- register UINT8 *pEncoded = *ppPacked;
+ UINT32 nBitsUsed = pState->nBitsUsed;
+ CNCSHuffmanCoder::CCodeNode *pNode = ((CNCSHuffmanCoder::CTree*)pState->pTree)->m_pRoot;
+ UINT8 *pEncoded = *ppPacked;

while (pNode->m_Children.m_P.m_p0Child != 0) {
pNode = pNode->m_Children.m_Children[(pEncoded[nBitsUsed >> 3] >> (nBitsUsed & 0x7)) & 0x1];

0 comments on commit 51ba503

Please sign in to comment.