aboutsummaryrefslogtreecommitdiff
path: root/graphics/openjpeg
diff options
context:
space:
mode:
authorDirk Meyer <dinoex@FreeBSD.org>2009-03-21 12:04:30 +0000
committerDirk Meyer <dinoex@FreeBSD.org>2009-03-21 12:04:30 +0000
commit06f759a55e4c34e6dbf61bc7b6e26e84a41da88e (patch)
treedc1a3a85a3b45741b7e400c13e73f6611eea1a27 /graphics/openjpeg
parent3391e7cb9700412dbca28ea43e8c92b09e56eb55 (diff)
downloadports-06f759a55e4c34e6dbf61bc7b6e26e84a41da88e.tar.gz
ports-06f759a55e4c34e6dbf61bc7b6e26e84a41da88e.zip
Notes
Diffstat (limited to 'graphics/openjpeg')
-rw-r--r--graphics/openjpeg/Makefile13
-rw-r--r--graphics/openjpeg/distinfo6
-rw-r--r--graphics/openjpeg/files/patch-Makefile11
-rw-r--r--graphics/openjpeg/files/patch-jpwl-Makefile35
-rw-r--r--graphics/openjpeg/files/patch-jpwl.c149
-rw-r--r--graphics/openjpeg/files/patch-jpwl.h11
-rw-r--r--graphics/openjpeg/files/patch-jpwl_Makefile27
-rw-r--r--graphics/openjpeg/files/patch-jpwl_lib.c29
-rw-r--r--graphics/openjpeg/files/patch-opj_malloc.h18
9 files changed, 257 insertions, 42 deletions
diff --git a/graphics/openjpeg/Makefile b/graphics/openjpeg/Makefile
index 600a63605ab5..ccebb6b9b94b 100644
--- a/graphics/openjpeg/Makefile
+++ b/graphics/openjpeg/Makefile
@@ -6,8 +6,7 @@
#
PORTNAME= openjpeg
-PORTVERSION= 1.2
-PORTREVISION= 1
+PORTVERSION= 1.3
CATEGORIES= graphics
MASTER_SITES= http://www.openjpeg.org/ \
${MASTER_SITE_LOCAL}
@@ -21,7 +20,7 @@ LIB_DEPENDS= tiff.4:${PORTSDIR}/graphics/tiff
USE_GMAKE= yes
USE_LDCONFIG= yes
-WRKSRC= ${WRKDIR}/trunk
+WRKSRC= ${WRKDIR}/OpenJPEG_v1_3
JPWL_BINS= JPWL_image_to_j2k JPWL_j2k_to_image
M2J_BINS= extract_j2k_from_mj2 frames_to_mj2 mj2_to_frames wrap_j2k_in_mj2
@@ -35,14 +34,14 @@ PLIST_FILES= include/openjpeg.h \
SHLIB_VER= 2
do-install:
- ${INSTALL_DATA} ${WRKSRC}/libopenjpeg/openjpeg.h ${PREFIX}/include
- ${INSTALL_DATA} ${WRKSRC}/libopenjpeg.a ${PREFIX}/lib
- ${INSTALL_DATA} ${WRKSRC}/libopenjpeg-2.1.2.0.so \
+ ${INSTALL_DATA} ${WRKSRC}/libopenjpeg/openjpeg.h ${PREFIX}/include/
+ ${INSTALL_DATA} ${WRKSRC}/libopenjpeg.a ${PREFIX}/lib/
+ ${INSTALL_DATA} ${WRKSRC}/libopenjpeg-2.1.3.0.so \
${PREFIX}/lib/libopenjpeg.so.${SHLIB_VER}
cd ${PREFIX}/lib && \
${LN} -sf libopenjpeg.so.${SHLIB_VER} libopenjpeg.so
.for file in ${M2J_BINS:S|^|mj2/|} ${JPWL_BINS:S|^|jpwl/|}
- ${INSTALL_PROGRAM} ${WRKSRC}/${file} ${PREFIX}/bin
+ ${INSTALL_PROGRAM} ${WRKSRC}/${file} ${PREFIX}/bin/
.endfor
.include <bsd.port.mk>
diff --git a/graphics/openjpeg/distinfo b/graphics/openjpeg/distinfo
index 4deec532751f..1dc44f2dbdfa 100644
--- a/graphics/openjpeg/distinfo
+++ b/graphics/openjpeg/distinfo
@@ -1,3 +1,3 @@
-MD5 (openjpeg_v1_2.tar.gz) = 4973c564c96683a921a7f6759906da4e
-SHA256 (openjpeg_v1_2.tar.gz) = 20294c8aefc15b455abfc8ab73747ac5345a1cbf6f7035dd36ef690d2188e2c4
-SIZE (openjpeg_v1_2.tar.gz) = 929866
+MD5 (openjpeg_v1_3.tar.gz) = f9a3ccfa91ac34b589e9bf7577ce8ff9
+SHA256 (openjpeg_v1_3.tar.gz) = 3bca2e1e040f9dcbbcb1e0627f17a76eeb95e153bf663d082070c044a21202bd
+SIZE (openjpeg_v1_3.tar.gz) = 1004678
diff --git a/graphics/openjpeg/files/patch-Makefile b/graphics/openjpeg/files/patch-Makefile
index b7aafb366c36..8b64092bddb6 100644
--- a/graphics/openjpeg/files/patch-Makefile
+++ b/graphics/openjpeg/files/patch-Makefile
@@ -1,5 +1,5 @@
---- Makefile.orig 2007-06-04 09:27:25.000000000 -0400
-+++ Makefile 2007-07-18 06:51:33.000000000 -0400
+--- Makefile.orig 2007-12-21 11:39:41.000000000 +0100
++++ Makefile 2009-03-21 11:51:26.000000000 +0100
@@ -8,17 +8,16 @@
INCLUDE = -Ilibopenjpeg
@@ -16,12 +16,12 @@
# Converts cr/lf to just lf
DOS2UNIX = dos2unix
--COMPILERFLAGS = -O3 -fPIC
-+COMPILERFLAGS := $(CFLAGS) -fPIC
+-COMPILERFLAGS = -Wall -O3 -ffast-math -std=c99 -fPIC
++COMPILERFLAGS := $(CFLAGS) -Wall -std=c99 -fPIC
LIBRARIES = -lstdc++
MODULES = $(SRCS:.c=.o)
-@@ -33,7 +32,12 @@
+@@ -33,7 +32,13 @@
default: all
@@ -29,6 +29,7 @@
+all: OpenJPEG subdirs
+
+subdirs:
++ set -e; \
+ for dir in $(SUBDIRS); do \
+ $(MAKE) -C $$dir; \
+ done
diff --git a/graphics/openjpeg/files/patch-jpwl-Makefile b/graphics/openjpeg/files/patch-jpwl-Makefile
new file mode 100644
index 000000000000..e4c1230dcab4
--- /dev/null
+++ b/graphics/openjpeg/files/patch-jpwl-Makefile
@@ -0,0 +1,35 @@
+--- jpwl/Makefile.orig 2007-11-05 14:05:07.000000000 +0100
++++ jpwl/Makefile 2009-03-21 11:54:55.000000000 +0100
+@@ -9,10 +9,7 @@
+ INCLUDE = -Ilibopenjpeg_JPWL
+
+ # General configuration variables:
+-CC = gcc
+-AR = ar
+
+-PREFIX = /usr
+ INSTALL_LIBDIR = $(PREFIX)/lib
+ INSTALL_INCLUDE = $(PREFIX)/include
+
+@@ -23,7 +20,7 @@
+ LIBRARIES = -lstdc++
+
+ MODULES = $(SRCS:.c=.o)
+-CFLAGS = $(COMPILERFLAGS) $(INCLUDE) -DUSE_JPWL
++CFLAGS += $(COMPILERFLAGS) $(INCLUDE) -DUSE_JPWL
+
+ TARGET = openjpeg_JPWL
+ STATICLIB = lib$(TARGET).a
+@@ -60,10 +57,10 @@
+ $(CC) -s -shared -Wl,-soname,$(LIBNAME) -o $@ $(MODULES) $(LIBRARIES)
+
+ JPWL_j2k_to_image: ../codec/j2k_to_image.c
+- gcc $(CFLAGS) ../codec/convert.c ../codec/j2k_to_image.c -o JPWL_j2k_to_image -I ../libopenjpeg/ -L . -lopenjpeg_JPWL -lm -ltiff
++ gcc $(CFLAGS) ../codec/convert.c ../codec/j2k_to_image.c ../codec/index.c -o JPWL_j2k_to_image -I ../libopenjpeg/ -L . -L$(LOCALBASE)/lib -lopenjpeg_JPWL -lm -ltiff
+
+ JPWL_image_to_j2k: ../codec/image_to_j2k.c
+- gcc $(CFLAGS) ../codec/convert.c ../codec/image_to_j2k.c -o JPWL_image_to_j2k -I ../libopenjpeg/ -L . -lopenjpeg_JPWL -lm -ltiff
++ gcc $(CFLAGS) ../codec/convert.c ../codec/image_to_j2k.c ../codec/index.c -o JPWL_image_to_j2k -I ../libopenjpeg/ -L . -L$(LOCALBASE)/lib -lopenjpeg_JPWL -lm -ltiff
+
+ install: OpenJPEG
+ install -d '$(DESTDIR)$(INSTALL_LIBDIR)' '$(DESTDIR)$(INSTALL_INCLUDE)'
diff --git a/graphics/openjpeg/files/patch-jpwl.c b/graphics/openjpeg/files/patch-jpwl.c
new file mode 100644
index 000000000000..d316c3c8de50
--- /dev/null
+++ b/graphics/openjpeg/files/patch-jpwl.c
@@ -0,0 +1,149 @@
+--- jpwl/jpwl.c.orig 2007-11-29 15:38:26.000000000 +0100
++++ jpwl/jpwl.c 2009-03-21 12:36:53.000000000 +0100
+@@ -122,19 +122,19 @@
+ switch (jwmarker[mm].id) {
+
+ case J2K_MS_EPB:
+- free(jwmarker[mm].epbmark);
++ opj_aligned_free(jwmarker[mm].u.epbmark);
+ break;
+
+ case J2K_MS_EPC:
+- free(jwmarker[mm].epcmark);
++ opj_aligned_free(jwmarker[mm].u.epcmark);
+ break;
+
+ case J2K_MS_ESD:
+- free(jwmarker[mm].esdmark);
++ opj_aligned_free(jwmarker[mm].u.esdmark);
+ break;
+
+ case J2K_MS_RED:
+- free(jwmarker[mm].redmark);
++ opj_aligned_free(jwmarker[mm].u.redmark);
+ break;
+
+ default:
+@@ -213,7 +213,7 @@
+ /* Add this marker to the 'insertanda' list */
+ if (epc_mark) {
+ jwmarker[jwmarker_num].id = J2K_MS_EPC; /* its type */
+- jwmarker[jwmarker_num].epcmark = epc_mark; /* the EPC */
++ jwmarker[jwmarker_num].u.epcmark = epc_mark; /* the EPC */
+ jwmarker[jwmarker_num].pos = soc_pos + socsiz_len; /* after SIZ */
+ jwmarker[jwmarker_num].dpos = (double) jwmarker[jwmarker_num].pos + 0.1; /* not so first */
+ jwmarker[jwmarker_num].len = epc_mark->Lepc; /* its length */
+@@ -258,7 +258,7 @@
+ /* Add this marker to the 'insertanda' list */
+ if (jwmarker_num < JPWL_MAX_NO_MARKERS) {
+ jwmarker[jwmarker_num].id = J2K_MS_ESD; /* its type */
+- jwmarker[jwmarker_num].esdmark = esd_mark; /* the EPB */
++ jwmarker[jwmarker_num].u.esdmark = esd_mark; /* the EPB */
+ jwmarker[jwmarker_num].pos = soc_pos + socsiz_len; /* we choose to place it after SIZ */
+ jwmarker[jwmarker_num].dpos = (double) jwmarker[jwmarker_num].pos + 0.2; /* not first at all! */
+ jwmarker[jwmarker_num].len = esd_mark->Lesd; /* its length */
+@@ -352,7 +352,7 @@
+ /* Add this marker to the 'insertanda' list */
+ if (jwmarker_num < JPWL_MAX_NO_MARKERS) {
+ jwmarker[jwmarker_num].id = J2K_MS_ESD; /* its type */
+- jwmarker[jwmarker_num].esdmark = esd_mark; /* the EPB */
++ jwmarker[jwmarker_num].u.esdmark = esd_mark; /* the EPB */
+ /****** jwmarker[jwmarker_num].pos = j2k->cstr_info->tile[tileno].start_pos + sot_len + 2; */ /* after SOT */
+ jwmarker[jwmarker_num].pos = j2k->cstr_info->tile[tileno].tp[tpno].tp_start_pos + sot_len + 2; /* after SOT */
+ jwmarker[jwmarker_num].dpos = (double) jwmarker[jwmarker_num].pos + 0.2; /* not first at all! */
+@@ -430,7 +430,7 @@
+ /* Add this marker to the 'insertanda' list */
+ if (jwmarker_num < JPWL_MAX_NO_MARKERS) {
+ jwmarker[jwmarker_num].id = J2K_MS_EPB; /* its type */
+- jwmarker[jwmarker_num].epbmark = epb_mark; /* the EPB */
++ jwmarker[jwmarker_num].u.epbmark = epb_mark; /* the EPB */
+ jwmarker[jwmarker_num].pos = soc_pos + socsiz_len; /* after SIZ */
+ jwmarker[jwmarker_num].dpos = (double) jwmarker[jwmarker_num].pos; /* first first first! */
+ jwmarker[jwmarker_num].len = epb_mark->Lepb; /* its length */
+@@ -528,7 +528,7 @@
+ /* Add this marker to the 'insertanda' list */
+ if (jwmarker_num < JPWL_MAX_NO_MARKERS) {
+ jwmarker[jwmarker_num].id = J2K_MS_EPB; /* its type */
+- jwmarker[jwmarker_num].epbmark = epb_mark; /* the EPB */
++ jwmarker[jwmarker_num].u.epbmark = epb_mark; /* the EPB */
+ /****** jwmarker[jwmarker_num].pos = j2k->cstr_info->tile[tileno].start_pos + sot_len + 2; */ /* after SOT */
+ jwmarker[jwmarker_num].pos = j2k->cstr_info->tile[tileno].tp[tpno].tp_start_pos + sot_len + 2; /* after SOT */
+ jwmarker[jwmarker_num].dpos = (double) jwmarker[jwmarker_num].pos; /* first first first! */
+@@ -758,15 +758,15 @@
+ switch (jwmarker[mm].id) {
+
+ case J2K_MS_EPB:
+- jpwl_epb_write(j2k, jwmarker[mm].epbmark, jpwl_buf);
++ jpwl_epb_write(j2k, jwmarker[mm].u.epbmark, jpwl_buf);
+ break;
+
+ case J2K_MS_EPC:
+- jpwl_epc_write(j2k, jwmarker[mm].epcmark, jpwl_buf);
++ jpwl_epc_write(j2k, jwmarker[mm].u.epcmark, jpwl_buf);
+ break;
+
+ case J2K_MS_ESD:
+- jpwl_esd_write(j2k, jwmarker[mm].esdmark, jpwl_buf);
++ jpwl_esd_write(j2k, jwmarker[mm].u.esdmark, jpwl_buf);
+ break;
+
+ case J2K_MS_RED:
+@@ -812,11 +812,11 @@
+ unsigned short int mycrc = 0x0000;
+
+ /* fix and fill the DL field */
+- jwmarker[mm].epcmark->DL = new_size;
+- orig_buf[epc_pos + 6] = (unsigned char) (jwmarker[mm].epcmark->DL >> 24);
+- orig_buf[epc_pos + 7] = (unsigned char) (jwmarker[mm].epcmark->DL >> 16);
+- orig_buf[epc_pos + 8] = (unsigned char) (jwmarker[mm].epcmark->DL >> 8);
+- orig_buf[epc_pos + 9] = (unsigned char) (jwmarker[mm].epcmark->DL >> 0);
++ jwmarker[mm].u.epcmark->DL = new_size;
++ orig_buf[epc_pos + 6] = (unsigned char) (jwmarker[mm].u.epcmark->DL >> 24);
++ orig_buf[epc_pos + 7] = (unsigned char) (jwmarker[mm].u.epcmark->DL >> 16);
++ orig_buf[epc_pos + 8] = (unsigned char) (jwmarker[mm].u.epcmark->DL >> 8);
++ orig_buf[epc_pos + 9] = (unsigned char) (jwmarker[mm].u.epcmark->DL >> 0);
+
+ /* compute the CRC field (excluding itself) */
+ for (pp = 0; pp < 4; pp++)
+@@ -825,9 +825,9 @@
+ jpwl_updateCRC16(&mycrc, orig_buf[epc_pos + pp]);
+
+ /* fix and fill the CRC */
+- jwmarker[mm].epcmark->Pcrc = mycrc;
+- orig_buf[epc_pos + 4] = (unsigned char) (jwmarker[mm].epcmark->Pcrc >> 8);
+- orig_buf[epc_pos + 5] = (unsigned char) (jwmarker[mm].epcmark->Pcrc >> 0);
++ jwmarker[mm].u.epcmark->Pcrc = mycrc;
++ orig_buf[epc_pos + 4] = (unsigned char) (jwmarker[mm].u.epcmark->Pcrc >> 8);
++ orig_buf[epc_pos + 5] = (unsigned char) (jwmarker[mm].u.epcmark->Pcrc >> 0);
+
+ }
+ }
+@@ -842,7 +842,7 @@
+ /* remember that they are now in a new position (dpos) */
+ int esd_pos = (int) jwmarker[mm].dpos;
+
+- jpwl_esd_fill(j2k, jwmarker[mm].esdmark, &orig_buf[esd_pos]);
++ jpwl_esd_fill(j2k, jwmarker[mm].u.esdmark, &orig_buf[esd_pos]);
+
+ }
+
+@@ -867,16 +867,16 @@
+ accum_len = 0;
+ for (nn = mm; (nn < jwmarker_num) && (jwmarker[nn].id == J2K_MS_EPB) &&
+ (jwmarker[nn].pos == jwmarker[mm].pos); nn++)
+- accum_len += jwmarker[nn].epbmark->Lepb + 2;
++ accum_len += jwmarker[nn].u.epbmark->Lepb + 2;
+
+ /* fill the current (first) EPB with post-data starting from the computed position */
+- jpwl_epb_fill(j2k, jwmarker[mm].epbmark, &orig_buf[(int) jwmarker[mm].dpos],
++ jpwl_epb_fill(j2k, jwmarker[mm].u.epbmark, &orig_buf[(int) jwmarker[mm].dpos],
+ &orig_buf[(int) jwmarker[mm].dpos + accum_len]);
+
+ /* fill the remaining EPBs in the header with post-data starting from the last position */
+ for (nn = mm + 1; (nn < jwmarker_num) && (jwmarker[nn].id == J2K_MS_EPB) &&
+ (jwmarker[nn].pos == jwmarker[mm].pos); nn++)
+- jpwl_epb_fill(j2k, jwmarker[nn].epbmark, &orig_buf[(int) jwmarker[nn].dpos], NULL);
++ jpwl_epb_fill(j2k, jwmarker[nn].u.epbmark, &orig_buf[(int) jwmarker[nn].dpos], NULL);
+
+ /* skip all the processed EPBs */
+ mm = nn - 1;
diff --git a/graphics/openjpeg/files/patch-jpwl.h b/graphics/openjpeg/files/patch-jpwl.h
new file mode 100644
index 000000000000..2c9b44df5fcd
--- /dev/null
+++ b/graphics/openjpeg/files/patch-jpwl.h
@@ -0,0 +1,11 @@
+--- jpwl/jpwl.h.orig 2007-11-05 14:05:07.000000000 +0100
++++ jpwl/jpwl.h 2009-03-21 12:21:21.000000000 +0100
+@@ -188,7 +188,7 @@
+ jpwl_esd_ms_t *esdmark;
+ /** pointer to RED marker */
+ jpwl_red_ms_t *redmark;
+- };
++ } u;
+ /** position where the marker should go, in the pre-JPWL codestream */
+ unsigned long int pos;
+ /** same as before, only written as a double, so we can sort it better */
diff --git a/graphics/openjpeg/files/patch-jpwl_Makefile b/graphics/openjpeg/files/patch-jpwl_Makefile
deleted file mode 100644
index 979d2c6890af..000000000000
--- a/graphics/openjpeg/files/patch-jpwl_Makefile
+++ /dev/null
@@ -1,27 +0,0 @@
---- jpwl/Makefile.orig 2007-02-23 13:24:49.000000000 -0500
-+++ jpwl/Makefile 2007-07-18 07:13:51.000000000 -0400
-@@ -1,10 +1,7 @@
- # Makefile for the main JPWL OpenJPEG codecs: JPWL_ j2k_to_image and JPWL_image_to_j2k
-
- # General configuration variables:
--CC = gcc
--AR = ar
--
--CFLAGS = -O3 -DUSE_JPWL # -g -p -pg -DUSE_JPWL
-+CFLAGS += -DUSE_JPWL # -g -p -pg -DUSE_JPWL
-
- OPJ_SRCS = ../libopenjpeg/bio.c ../libopenjpeg/cio.c ../libopenjpeg/dwt.c ../libopenjpeg/event.c ../libopenjpeg/image.c ../libopenjpeg/j2k.c ../libopenjpeg/j2k_lib.c ../libopenjpeg/jp2.c ../libopenjpeg/jpt.c ../libopenjpeg/mct.c ../libopenjpeg/mqc.c ../libopenjpeg/openjpeg.c ../libopenjpeg/pi.c ../libopenjpeg/raw.c ../libopenjpeg/t1.c ../libopenjpeg/t2.c ../libopenjpeg/tcd.c ../libopenjpeg/tgt.c
- JPWL_SRCS = crc.c jpwl.c jpwl_lib.c rs.c
-@@ -23,10 +20,10 @@
- $(AR) r $@ $(MODULES)
-
- JPWL_j2k_to_image: ../codec/j2k_to_image.c $(STATICLIB)
-- gcc $(CFLAGS) ../codec/convert.c ../codec/j2k_to_image.c -o JPWL_j2k_to_image -I ../libopenjpeg/ -L . -lopenjpeg_JPWL -lm -lstdc++
-+ $(CC) $(CFLAGS) ../codec/convert.c ../codec/j2k_to_image.c -o JPWL_j2k_to_image -I ../libopenjpeg/ -ltiff -L$(LOCALBASE)/lib -L . -lopenjpeg_JPWL -lm -lstdc++
-
- JPWL_image_to_j2k: ../codec/image_to_j2k.c $(STATICLIB)
-- gcc $(CFLAGS) ../codec/convert.c ../codec/image_to_j2k.c -o JPWL_image_to_j2k -I ../libopenjpeg/ -L . -lopenjpeg_JPWL -lm -lstdc++
-+ $(CC) $(CFLAGS) ../codec/convert.c ../codec/image_to_j2k.c -o JPWL_image_to_j2k -I ../libopenjpeg/ -ltiff -L$(LOCALBASE)/lib -L . -lopenjpeg_JPWL -lm -lstdc++
-
- clean:
- rm -f JPWL_j2k_to_image JPWL_image_to_j2k *.o *.a
diff --git a/graphics/openjpeg/files/patch-jpwl_lib.c b/graphics/openjpeg/files/patch-jpwl_lib.c
new file mode 100644
index 000000000000..0292d8079770
--- /dev/null
+++ b/graphics/openjpeg/files/patch-jpwl_lib.c
@@ -0,0 +1,29 @@
+--- jpwl/jpwl_lib.c.orig 2007-11-29 15:38:26.000000000 +0100
++++ jpwl/jpwl_lib.c 2009-03-21 12:39:09.000000000 +0100
+@@ -166,7 +166,7 @@
+ /* Add this marker to the 'insertanda' list */
+ if (*jwmarker_num < JPWL_MAX_NO_MARKERS) {
+ jwmarker[*jwmarker_num].id = J2K_MS_EPB; /* its type */
+- jwmarker[*jwmarker_num].epbmark = epb_mark; /* the EPB */
++ jwmarker[*jwmarker_num].u.epbmark = epb_mark; /* the EPB */
+ jwmarker[*jwmarker_num].pos = (int) place_pos; /* after SOT */
+ jwmarker[*jwmarker_num].dpos = place_pos + 0.0000001 * (double)(*idx); /* not very first! */
+ jwmarker[*jwmarker_num].len = epb_mark->Lepb; /* its length */
+@@ -335,7 +335,7 @@
+ jpwl_epc_ms_t *epc = NULL;
+
+ /* Alloc space */
+- if (!(epc = (jpwl_epc_ms_t *) malloc((size_t) 1 * sizeof (jpwl_epc_ms_t)))) {
++ if (!(epc = (jpwl_epc_ms_t *) opj_aligned_malloc((size_t) 1 * sizeof (jpwl_epc_ms_t)))) {
+ opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not allocate room for EPC MS\n");
+ return NULL;
+ };
+@@ -1196,7 +1196,7 @@
+ jpwl_esd_ms_t *esd = NULL;
+
+ /* Alloc space */
+- if (!(esd = (jpwl_esd_ms_t *) malloc((size_t) 1 * sizeof (jpwl_esd_ms_t)))) {
++ if (!(esd = (jpwl_esd_ms_t *) opj_aligned_malloc((size_t) 1 * sizeof (jpwl_esd_ms_t)))) {
+ opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not allocate room for ESD MS\n");
+ return NULL;
+ };
diff --git a/graphics/openjpeg/files/patch-opj_malloc.h b/graphics/openjpeg/files/patch-opj_malloc.h
new file mode 100644
index 000000000000..6fc47351b7a4
--- /dev/null
+++ b/graphics/openjpeg/files/patch-opj_malloc.h
@@ -0,0 +1,18 @@
+--- libopenjpeg/opj_malloc.h.orig 2007-12-21 11:19:01.000000000 +0100
++++ libopenjpeg/opj_malloc.h 2009-03-21 12:02:37.000000000 +0100
+@@ -76,8 +76,15 @@
+ #if defined(__sun)
+ #define HAVE_MEMALIGN
+ #elif defined(__GNUC__)
++ #if defined(__FreeBSD__)
++ #include <stdlib.h>
++ #include <osreldate.h>
++ #if __FreeBSD_versioni >= 700000
++ #endif
++ #else
+ #define HAVE_MEMALIGN
+ #include <malloc.h>
++ #endif
+ /* Linux x86_64 and OSX always align allocations to 16 bytes */
+ #elif !defined(__amd64__) && !defined(__APPLE__)
+ /* FIXME: Yes, this is a big assumption */