Add openjpeg package.

This commit is contained in:
Alexpux
2013-12-27 14:04:50 +04:00
parent 7bda03ad9f
commit d2b8b3f30e
7 changed files with 273 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
# Maintainer: Alexey Pavlov <alexpux@gmail.com>
_realname=openjpeg
_mingw_suff=mingw-w64-${CARCH}
pkgname="${_mingw_suff}-${_realname}"
pkgver=1.5.1
pkgrel=1
pkgdesc="An open source JPEG 2000 codec (mingw-w64)"
arch=('any')
url="http://www.openjpeg.org"
license=("BSD")
depends=("${_mingw_suff}-crt" "${_mingw_suff}-lcms2" "${_mingw_suff}-libtiff" "${_mingw_suff}-libpng" "${_mingw_suff}-zlib")
makedepends=("${_mingw_suff}-gcc" "${_mingw_suff}-pkg-config")
options=('staticlibs' 'strip')
source=("http://openjpeg.googlecode.com/files/openjpeg-${pkgver}.tar.gz"
"cdecl.patch"
"openjpeg-1.5.1_tiff-pkgconfig.patch"
"openjpeg-1.5-r2029.patch"
"openjpeg-1.5-r2031.patch"
"openjpeg-1.5-r2032.patch"
"openjpeg-1.5-r2033.patch")
md5sums=('b5f74cec2688fb918331bb014061be6f'
'673edf457f9b4f3fdc9a083e1857a76a'
'b1129bbd396b37fc54e7ac93e049d8ab'
'3f7235e2e18f3a9953778d6e9d25cb81'
'4154f1f9fcc3c8a706d3741cda24295f'
'e2dabc34959eacc5f8122aa521ece4e1'
'ff9e5cdb269571563e075ccf88e1e1eb')
prepare() {
cd "$srcdir/openjpeg-$pkgver"
rm -r thirdparty
patch -Np1 -i "$srcdir"/cdecl.patch
patch -Np1 -i "$srcdir"/openjpeg-1.5.1_tiff-pkgconfig.patch
patch -Np0 -i "$srcdir"/openjpeg-1.5-r2029.patch
patch -Np0 -i "$srcdir"/openjpeg-1.5-r2031.patch
patch -Np0 -i "$srcdir"/openjpeg-1.5-r2032.patch
patch -Np0 -i "$srcdir"/openjpeg-1.5-r2033.patch
autoreconf -i
}
build() {
mkdir -p $srcdir/build-${MINGW_CHOST} && cd $srcdir/build-${MINGW_CHOST}
../${_realname}-${pkgver}/configure \
--prefix=${MINGW_PREFIX} \
--build=${MINGW_CHOST} \
--host=${MINGW_CHOST} \
--disable-doc \
--enable-jpwl
make
}
package() {
cd "$srcdir/build-${MINGW_CHOST}"
make DESTDIR="$pkgdir" install
rm -r "${pkgdir}${MINGW_PREFIX}"/share
#rm "$pkgdir"/usr/${_arch}/bin/*.exe
}

View File

@@ -0,0 +1,12 @@
diff -ru openjpeg-1.5.1/libopenjpeg/openjpeg.h patched/libopenjpeg/openjpeg.h
--- openjpeg-1.5.1/libopenjpeg/openjpeg.h 2012-09-13 09:58:39.000000000 +0200
+++ patched/libopenjpeg/openjpeg.h 2013-06-15 11:23:32.370015134 +0200
@@ -44,7 +44,7 @@
#define OPJ_API
#define OPJ_CALLCONV
#else
-#define OPJ_CALLCONV __stdcall
+#define OPJ_CALLCONV __cdecl
/*
The following ifdef block is the standard way of creating macros which make exporting
from a DLL simpler. All files within this DLL are compiled with the OPJ_EXPORTS

View File

@@ -0,0 +1,77 @@
Index: libopenjpeg/jp2.c
===================================================================
--- libopenjpeg/jp2.c (revision 2028)
+++ libopenjpeg/jp2.c (revision 2029)
@@ -173,6 +173,10 @@
else if (box->length == 0) {
box->length = cio_numbytesleft(cio) + 8;
}
+ if (box->length < 0) {
+ opj_event_msg(cinfo, EVT_ERROR, "Integer overflow in box->length\n");
+ return OPJ_FALSE; // TODO: actually check jp2_read_boxhdr's return value
+ }
return OPJ_TRUE;
}
@@ -654,6 +658,7 @@
opj_event_msg(cinfo, EVT_ERROR, "Expected JP2H Marker\n");
return OPJ_FALSE;
}
+ if (box.length <= 8) return OPJ_FALSE;
cio_skip(cio, box.length - 8);
if(cio->bp >= cio->end) return OPJ_FALSE;
@@ -679,6 +684,7 @@
{
if( !jp2_read_colr(jp2, cio, &box, color))
{
+ if (box.length <= 8) return OPJ_FALSE;
cio_seek(cio, box.init_pos + 8);
cio_skip(cio, box.length - 8);
}
@@ -689,6 +695,7 @@
{
if( !jp2_read_cdef(jp2, cio, &box, color))
{
+ if (box.length <= 8) return OPJ_FALSE;
cio_seek(cio, box.init_pos + 8);
cio_skip(cio, box.length - 8);
}
@@ -699,6 +706,7 @@
{
if( !jp2_read_pclr(jp2, cio, &box, color))
{
+ if (box.length <= 8) return OPJ_FALSE;
cio_seek(cio, box.init_pos + 8);
cio_skip(cio, box.length - 8);
}
@@ -709,12 +717,14 @@
{
if( !jp2_read_cmap(jp2, cio, &box, color))
{
+ if (box.length <= 8) return OPJ_FALSE;
cio_seek(cio, box.init_pos + 8);
cio_skip(cio, box.length - 8);
}
if( jp2_read_boxhdr(cinfo, cio, &box) == OPJ_FALSE ) return OPJ_FALSE;
continue;
}
+ if (box.length <= 8) return OPJ_FALSE;
cio_seek(cio, box.init_pos + 8);
cio_skip(cio, box.length - 8);
if( jp2_read_boxhdr(cinfo, cio, &box) == OPJ_FALSE ) return OPJ_FALSE;
@@ -910,12 +920,14 @@
}
do {
if(JP2_JP2C != box.type) {
+ if (box.length <= 8) return OPJ_FALSE;
cio_skip(cio, box.length - 8);
if( jp2_read_boxhdr(cinfo, cio, &box) == OPJ_FALSE ) return OPJ_FALSE;
}
} while(JP2_JP2C != box.type);
*j2k_codestream_offset = cio_tell(cio);
+ if (box.length <= 8) return OPJ_FALSE;
*j2k_codestream_length = box.length - 8;
return OPJ_TRUE;

View File

@@ -0,0 +1,24 @@
Index: libopenjpeg/jpwl/Makefile.am
===================================================================
--- libopenjpeg/jpwl/Makefile.am (revision 2030)
+++ libopenjpeg/jpwl/Makefile.am (revision 2031)
@@ -18,7 +18,6 @@
../pi.c \
../raw.c \
../t1.c \
-../t1_generate_luts.c \
../t2.c \
../tcd.c \
../tgt.c \
Index: libopenjpeg/Makefile.am
===================================================================
--- libopenjpeg/Makefile.am (revision 2030)
+++ libopenjpeg/Makefile.am (revision 2031)
@@ -35,7 +35,6 @@
pi.c \
raw.c \
t1.c \
-t1_generate_luts.c \
t2.c \
tcd.c \
tgt.c \

View File

@@ -0,0 +1,30 @@
Index: libopenjpeg/j2k.c
===================================================================
--- libopenjpeg/j2k.c (revision 2031)
+++ libopenjpeg/j2k.c (revision 2032)
@@ -468,6 +468,12 @@
}
#endif /* USE_JPWL */
+ /* prevent division by zero */
+ if (!(cp->tdx * cp->tdy)) {
+ opj_event_msg(j2k->cinfo, EVT_ERROR, "JPWL: invalid tile size (tdx: %d, tdy: %d)\n", cp->tdx, cp->tdy);
+ return;
+ }
+
image->comps = (opj_image_comp_t*) opj_calloc(image->numcomps, sizeof(opj_image_comp_t));
for (i = 0; i < image->numcomps; i++) {
int tmp, w, h;
@@ -506,6 +512,12 @@
}
#endif /* USE_JPWL */
+ /* prevent division by zero */
+ if (!(image->comps[i].dx * image->comps[i].dy)) {
+ opj_event_msg(j2k->cinfo, EVT_ERROR, "JPWL: invalid component size (dx: %d, dy: %d)\n", image->comps[i].dx, image->comps[i].dy);
+ return;
+ }
+
/* TODO: unused ? */
w = int_ceildiv(image->x1 - image->x0, image->comps[i].dx);
h = int_ceildiv(image->y1 - image->y0, image->comps[i].dy);

View File

@@ -0,0 +1,49 @@
Index: libopenjpeg/j2k.c
===================================================================
--- libopenjpeg/j2k.c (revision 2032)
+++ libopenjpeg/j2k.c (revision 2033)
@@ -835,6 +835,12 @@
len = cio_read(cio, 2); /* Lcoc */
compno = cio_read(cio, image->numcomps <= 256 ? 1 : 2); /* Ccoc */
+ if (compno >= image->numcomps) {
+ opj_event_msg(j2k->cinfo, EVT_ERROR,
+ "bad component number in COC (%d out of a maximum of %d)\n",
+ compno, image->numcomps);
+ return;
+ }
tcp->tccps[compno].csty = cio_read(cio, 1); /* Scoc */
j2k_read_cox(j2k, compno);
}
@@ -1016,9 +1022,16 @@
/* keep your private count of tiles */
backup_compno++;
- };
+ }
#endif /* USE_JPWL */
+ if ((compno < 0) || (compno >= numcomp)) {
+ opj_event_msg(j2k->cinfo, EVT_ERROR,
+ "bad component number in QCC (%d out of a maximum of %d)\n",
+ compno, j2k->image->numcomps);
+ return;
+ }
+
j2k_read_qcx(j2k, compno, len - 2 - (numcomp <= 256 ? 1 : 2));
}
@@ -1602,6 +1615,13 @@
};
#endif /* USE_JPWL */
+ if (compno >= numcomps) {
+ opj_event_msg(j2k->cinfo, EVT_ERROR,
+ "bad component number in RGN (%d out of a maximum of %d)\n",
+ compno, j2k->image->numcomps);
+ return;
+ }
+
tcp->tccps[compno].roishift = cio_read(cio, 1); /* SPrgn */
}

View File

@@ -0,0 +1,21 @@
--- a/configure.ac.orig 2013-12-27 13:10:18.762600000 +0400
+++ a/configure.ac 2013-12-27 13:33:42.390200000 +0400
@@ -267,17 +267,9 @@
AC_MSG_RESULT([${want_tiff}])
if test "x${want_tiff}" = "xyes" ; then
-
- OPJ_CHECK_LIB(
- [tiff.h],
- [tiff],
- [TIFFOpen],
+ PKG_CHECK_MODULES([TIFF], libtiff-4,
[have_libtiff="yes"],
[have_libtiff="no"])
-
- if test "x${have_libtiff}" = "xno" ; then
- AC_MSG_WARN([Can not find a usuable TIFF library. Make sure that CPPFLAGS and LDFLAGS are correctly set.])
- fi
fi
AC_MSG_CHECKING([whether TIFF is available])