Skip to content

Commit

Permalink
graphics/libmng: upgrade from 1.0.10 to 2.0.3
Browse files Browse the repository at this point in the history
Despite the seemingly large version jump, the sole change is
the compatibility with lcms-2.x.

I'm now also adding fixes for some compiler-warnings raised
by the modern clang. These suggest, certain parts of the code
aren't even really excercised.

Neither API nor ABI are changing, so no shared library
version-bump.
  • Loading branch information
Mikhail Teterin authored and Mikhail Teterin committed Jan 12, 2024
1 parent 7212522 commit daa103d
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 36 deletions.
15 changes: 5 additions & 10 deletions graphics/libmng/Makefile
@@ -1,26 +1,21 @@
PORTNAME= libmng
PORTVERSION= 1.0.10
PORTREVISION= 5
PORTVERSION= 2.0.3
CATEGORIES= graphics
MASTER_SITES= SF/${PORTNAME}/${PORTNAME}-devel/${PORTVERSION} \
http://www.libmng.com/download/

MAINTAINER= mi@aldan.algebra.com
COMMENT= Multiple-image Network Graphics (MNG) reference library
WWW= https://www.libmng.com/
WWW= https://sourceforge.net/projects/libmng/

LIB_DEPENDS= liblcms.so:graphics/lcms

OPTIONS_DEFINE= MNG_OPTIMIZE
MNG_OPTIMIZE_DESC= Use vendor's new optimization flags
LIB_DEPENDS= liblcms2.so:graphics/lcms2

MAKEFILE= ${FILESDIR}/Makefile.bsd

USES= jpeg uidfix
USES= jpeg uidfix tar:xz
USE_LDCONFIG= yes

MNG_OPTIMIZE_MAKE_ARGS= WITH_MNG_OPTIMIZE=true
MNG_OPTIMIZE_MAKE_ARGS_OFF= WITH_MNG_OPTIMIZE=off
MAKE_ARGS+= WITH_MNG_OPTIMIZE=true

post-install:
cd ${WRKSRC}/doc/man && ${INSTALL_MAN} libmng.3 ${STAGEDIR}${PREFIX}/man/man3 \
Expand Down
5 changes: 3 additions & 2 deletions graphics/libmng/distinfo
@@ -1,2 +1,3 @@
SHA256 (libmng-1.0.10.tar.gz) = 03a79dac9b9316d37227057614a248a946f997c4d1a3437fb569e9a63897f911
SIZE (libmng-1.0.10.tar.gz) = 1093337
TIMESTAMP = 1704254831
SHA256 (libmng-2.0.3.tar.xz) = 4a462fdd48d4bc82c1d7a21106c8a18b62f8cc0042454323058e6da0dbb57dd3
SIZE (libmng-2.0.3.tar.xz) = 951808
4 changes: 2 additions & 2 deletions graphics/libmng/files/Makefile.bsd
@@ -1,5 +1,5 @@
LIB= mng
LDADD= -lm -L${LIBDIR} -lz -llcms -ljpeg
LDADD= -lm -L${LIBDIR} -lz -llcms2 -ljpeg

MK_PROFILE= no
SHLIB_MAJOR?= 1
Expand All @@ -8,7 +8,7 @@ SHLIB_MINOR?= 0
SRCS!= ${MAKE} -f ${.CURDIR}/makefiles/makefile.unix -V SOURCES

CFLAGS+= -I${INCDIR}
.if ${WITH_MNG_OPTIMIZE} == "true"
.if ${WITH_MNG_OPTIMIZE} == "truex"
.for f in CHUNKINITFREE OBJCLEANUP CHUNKASSIGN CHUNKREADER
CFLAGS+= -DMNG_OPTIMIZE_$f
.endfor
Expand Down
9 changes: 9 additions & 0 deletions graphics/libmng/files/patch-chunk_descr.c
@@ -0,0 +1,9 @@
--- libmng_chunk_descr.c 2012-07-29 15:26:34.000000000 -0400
+++ libmng_chunk_descr.c 2024-01-08 14:32:15.916979000 -0500
@@ -2751,5 +2751,5 @@
mng_get_chunkheader (MNG_UINT_sRGB, &chunk_srgb);
/* pretend it's an sRGB chunk then ! */
- iRetcode = mng_read_general (pData, &chunk_srgb, 1, (mng_ptr)"0", &pDummy);
+ iRetcode = mng_read_general (pData, &chunk_srgb, 1, (mng_ptr)"0", (void **)&pDummy);
if (iRetcode) /* on error bail out */
return iRetcode;
19 changes: 0 additions & 19 deletions graphics/libmng/files/patch-conf

This file was deleted.

13 changes: 13 additions & 0 deletions graphics/libmng/files/patch-filter.c
@@ -0,0 +1,13 @@
--- libmng_filter.c 2012-07-29 15:26:34.000000000 -0400
+++ libmng_filter.c 2024-01-08 14:25:01.379756000 -0500
@@ -207,7 +207,7 @@
iC = (mng_uint32)*pPriorx_prev;
iP = iA + iB - iC;
- iPa = abs (iP - iA);
- iPb = abs (iP - iB);
- iPc = abs (iP - iC);
+ iPa = iP > iA ? iP - iA : iA - iP;
+ iPb = iP > iB ? iP - iB : iB - iP;
+ iPc = iP > iC ? iP - iC : iC - iP;

if ((iPa <= iPb) && (iPa <= iPc))
128 changes: 128 additions & 0 deletions graphics/libmng/files/patch-pixels.c
@@ -0,0 +1,128 @@
This changes the behaviour to what appears to be the original intent...

-mi

--- libmng_pixels.c 2012-07-29 15:26:34.000000000 -0400
+++ libmng_pixels.c 2024-01-08 14:21:18.664893000 -0500
@@ -14669,5 +14669,5 @@

*pDstline = (mng_uint8)(iW >> 8);
- *(pDstline+1) = (mng_uint8)(iW && 0xFF);
+ *(pDstline+1) = (mng_uint8)(iW & 0xFF);

pSrcline++;
@@ -14787,5 +14787,5 @@

*pDstline = (mng_uint8)(iW >> 8);
- *(pDstline+1) = (mng_uint8)(iW && 0xFF);
+ *(pDstline+1) = (mng_uint8)(iW & 0xFF);

pSrcline++;
@@ -14908,5 +14908,5 @@
*(pDstline+2) = iB;
*(pDstline+4) = iB;
- iB = (mng_uint8)(iW && 0xFF);
+ iB = (mng_uint8)(iW & 0xFF);
*(pDstline+1) = iB;
*(pDstline+3) = iB;
@@ -15042,5 +15042,5 @@
*(pDstline+2) = iB;
*(pDstline+4) = iB;
- iB = (mng_uint8)(iW && 0xFF);
+ iB = (mng_uint8)(iW & 0xFF);
*(pDstline+1) = iB;
*(pDstline+3) = iB;
@@ -15126,7 +15126,7 @@

*pDstline = (mng_uint8)(iW >> 8);
- *(pDstline+1) = (mng_uint8)(iW && 0xFF);
+ *(pDstline+1) = (mng_uint8)(iW & 0xFF);
*(pDstline+2) = (mng_uint8)(iA >> 8);
- *(pDstline+3) = (mng_uint8)(iA && 0xFF);
+ *(pDstline+3) = (mng_uint8)(iA & 0xFF);

pSrcline += 2;
@@ -15210,10 +15210,10 @@
*(pDstline+2) = iB;
*(pDstline+4) = iB;
- iB = (mng_uint8)(iW && 0xFF);
+ iB = (mng_uint8)(iW & 0xFF);
*(pDstline+1) = iB;
*(pDstline+3) = iB;
*(pDstline+5) = iB;
*(pDstline+6) = (mng_uint8)(iA >> 8);
- *(pDstline+7) = (mng_uint8)(iA && 0xFF);
+ *(pDstline+7) = (mng_uint8)(iA & 0xFF);

pSrcline += 2;
@@ -15297,9 +15297,9 @@

*pDstline = (mng_uint8)(iR >> 8);
- *(pDstline+1) = (mng_uint8)(iR && 0xFF);
+ *(pDstline+1) = (mng_uint8)(iR & 0xFF);
*(pDstline+2) = (mng_uint8)(iG >> 8);
- *(pDstline+3) = (mng_uint8)(iG && 0xFF);
+ *(pDstline+3) = (mng_uint8)(iG & 0xFF);
*(pDstline+4) = (mng_uint8)(iB >> 8);
- *(pDstline+5) = (mng_uint8)(iB && 0xFF);
+ *(pDstline+5) = (mng_uint8)(iB & 0xFF);

pSrcline += 3;
@@ -15402,9 +15402,9 @@

*pDstline = (mng_uint8)(iRw >> 8);
- *(pDstline+1) = (mng_uint8)(iRw && 0xFF);
+ *(pDstline+1) = (mng_uint8)(iRw & 0xFF);
*(pDstline+2) = (mng_uint8)(iGw >> 8);
- *(pDstline+3) = (mng_uint8)(iGw && 0xFF);
+ *(pDstline+3) = (mng_uint8)(iGw & 0xFF);
*(pDstline+4) = (mng_uint8)(iBw >> 8);
- *(pDstline+5) = (mng_uint8)(iBw && 0xFF);
+ *(pDstline+5) = (mng_uint8)(iBw & 0xFF);

pSrcline += 3;
@@ -15539,9 +15539,9 @@
iB = ((mng_bitdepth_16)pData->fPromBitdepth) (pBuf->aPLTEentries [iN].iBlue);
*pDstline = (mng_uint8)(iR >> 8);
- *(pDstline+1) = (mng_uint8)(iR && 0xFF);
+ *(pDstline+1) = (mng_uint8)(iR & 0xFF);
*(pDstline+2) = (mng_uint8)(iG >> 8);
- *(pDstline+3) = (mng_uint8)(iG && 0xFF);
+ *(pDstline+3) = (mng_uint8)(iG & 0xFF);
*(pDstline+4) = (mng_uint8)(iB >> 8);
- *(pDstline+5) = (mng_uint8)(iB && 0xFF);
+ *(pDstline+5) = (mng_uint8)(iB & 0xFF);
}

@@ -15642,11 +15642,11 @@

*pDstline = (mng_uint8)(iR >> 8);
- *(pDstline+1) = (mng_uint8)(iR && 0xFF);
+ *(pDstline+1) = (mng_uint8)(iR & 0xFF);
*(pDstline+2) = (mng_uint8)(iG >> 8);
- *(pDstline+3) = (mng_uint8)(iG && 0xFF);
+ *(pDstline+3) = (mng_uint8)(iG & 0xFF);
*(pDstline+4) = (mng_uint8)(iB >> 8);
- *(pDstline+5) = (mng_uint8)(iB && 0xFF);
+ *(pDstline+5) = (mng_uint8)(iB & 0xFF);
*(pDstline+6) = (mng_uint8)(iA >> 8);
- *(pDstline+7) = (mng_uint8)(iA && 0xFF);
+ *(pDstline+7) = (mng_uint8)(iA & 0xFF);
}

@@ -15690,11 +15690,11 @@

*pDstline = (mng_uint8)(iR >> 8);
- *(pDstline+1) = (mng_uint8)(iR && 0xFF);
+ *(pDstline+1) = (mng_uint8)(iR & 0xFF);
*(pDstline+2) = (mng_uint8)(iG >> 8);
- *(pDstline+3) = (mng_uint8)(iG && 0xFF);
+ *(pDstline+3) = (mng_uint8)(iG & 0xFF);
*(pDstline+4) = (mng_uint8)(iB >> 8);
- *(pDstline+5) = (mng_uint8)(iB && 0xFF);
+ *(pDstline+5) = (mng_uint8)(iB & 0xFF);
*(pDstline+6) = (mng_uint8)(iA >> 8);
- *(pDstline+7) = (mng_uint8)(iA && 0xFF);
+ *(pDstline+7) = (mng_uint8)(iA & 0xFF);

pSrcline += 4;
3 changes: 0 additions & 3 deletions graphics/libmng/pkg-descr
Expand Up @@ -3,6 +3,3 @@ manipulations of Multiple-image Network Graphics (MNG) format image files. It
uses the zlib(3) compression library, and optionally the JPEG library by the
Independant JPEG Group (IJG) and/or lcms (little CMS), a color-management
library by Marti Maria Saguar.

Mikhail Teterin
mi@aldan.algebra.com

0 comments on commit daa103d

Please sign in to comment.