Skip site navigation (1)Skip section navigation (2)
Date:      Tue,  4 May 2010 15:22:46 +0800 (CST)
From:      Sunpoet Po-Chuan Hsieh <sunpoet@sunpoet.net>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        dinoex@FreeBSD.org
Subject:   ports/146290: [PATCH] graphics/jasper: introduce UUID patch
Message-ID:  <20100504072246.0D28F2AEC5A0@sunpoet.net>
Resent-Message-ID: <201005040730.o447U2kH057889@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         146290
>Category:       ports
>Synopsis:       [PATCH] graphics/jasper: introduce UUID patch
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue May 04 07:30:02 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator:     Sunpoet Po-Chuan Hsieh
>Release:        FreeBSD 8.0-STABLE amd64
>Organization:
SUNPOET.net
>Environment:
System: FreeBSD bonjour.sunpoet.net 8.0-STABLE FreeBSD 8.0-STABLE #0: Fri Mar 19 09:16:38 CST 2010
>Description:
Change:
- Introduce UUID patch, which is required by GDAL

Added file(s):
- files/extra-patch-uuid

Port maintainer (dinoex@FreeBSD.org) is cc'd.

Generated with FreeBSD Port Tools 0.99

>How-To-Repeat:

>From GDAL's configure log

without UUID patch:
checking for jp2_encode_uuid in -ljasper... no
configure: hacked JasPer version not found, GeoJP2 disabled.

with UUID patch:
checking for jp2_encode_uuid in -ljasper... yes
configure: hacked JasPer version found (JasPer UUID), GeoJP2 enabled.

>Fix:

--- jasper-1.900.1_9.patch begins here ---
diff -ruN --exclude=CVS /usr/ports/graphics/jasper/Makefile /usr/ports/sunpoet/jasper/Makefile
--- /usr/ports/graphics/jasper/Makefile	2010-02-06 10:46:17.000000000 +0800
+++ /usr/ports/sunpoet/jasper/Makefile	2010-05-04 15:17:56.000000000 +0800
@@ -32,7 +32,8 @@
 	ftp://ftp.imagemagick.org/pub/%SUBDIR%/ \
 	${MASTER_SITE_RINGSERVER:S,%SUBDIR%,graphics/&,}
 
-OPTIONS=	OPENGL	"OpenGL support" off
+OPTIONS=	OPENGL	"OpenGL support" off \
+		UUID	"UUID support (required by GDAL)" off
 
 .include <bsd.port.pre.mk>
 
@@ -45,6 +46,10 @@
 PLIST_SUB+=	OPENGL="@comment "
 .endif
 
+.if defined(WITH_UUID)
+EXTRA_PATCHES+=	${FILESDIR}/extra-patch-uuid
+.endif
+
 .if !defined(NO_INSTALL_MANPAGES)
 MAN1=		imgcmp.1 imginfo.1 jasper.1 jiv.1
 .endif
diff -ruN --exclude=CVS /usr/ports/graphics/jasper/files/extra-patch-uuid /usr/ports/sunpoet/jasper/files/extra-patch-uuid
--- /usr/ports/graphics/jasper/files/extra-patch-uuid	1970-01-01 08:00:00.000000000 +0800
+++ /usr/ports/sunpoet/jasper/files/extra-patch-uuid	2010-05-04 15:17:40.000000000 +0800
@@ -0,0 +1,242 @@
+#
+# Jasper with uuid patch, required by GDAL, can be downloaded from:
+# - http://download.osgeo.org/gdal/
+# - http://www.gdal.org/dl/
+# - ftp://ftp.remotesensing.org/gdal/
+#
+# Current version is jasper-1.900.1.uuid.tar.gz.
+#
+diff -ruN src/libjasper/jp2/jp2_cod.c.orig src/libjasper/jp2/jp2_cod.c
+--- src/libjasper/jp2/jp2_cod.c.orig	2007-01-20 05:43:05.000000000 +0800
++++ src/libjasper/jp2/jp2_cod.c	2007-03-06 21:49:58.000000000 +0800
+@@ -5,6 +5,11 @@
+  * All rights reserved.
+  */
+ 
++/*
++ * Modified by Andrey Kiselev <dron@ak4719.spb.edu> to properly handle UUID
++ * box.
++ */
++
+ /* __START_OF_JASPER_LICENSE__
+  * 
+  * JasPer License Version 2.0
+@@ -127,6 +132,9 @@
+ static int jp2_pclr_getdata(jp2_box_t *box, jas_stream_t *in);
+ static int jp2_pclr_putdata(jp2_box_t *box, jas_stream_t *out);
+ static void jp2_pclr_dumpdata(jp2_box_t *box, FILE *out);
++static void jp2_uuid_destroy(jp2_box_t *box);
++static int jp2_uuid_getdata(jp2_box_t *box, jas_stream_t *in);
++static int jp2_uuid_putdata(jp2_box_t *box, jas_stream_t *out);
+ 
+ /******************************************************************************\
+ * Local data.
+@@ -164,7 +172,7 @@
+ 	{JP2_BOX_XML, "XML", 0,
+ 	  {0, 0, 0, 0, 0}},
+ 	{JP2_BOX_UUID, "UUID", 0,
+-	  {0, 0, 0, 0, 0}},
++	  {0, jp2_uuid_destroy, jp2_uuid_getdata, jp2_uuid_putdata, 0}},
+ 	{JP2_BOX_UINF, "UINF", JP2_BOX_SUPER,
+ 	  {0, 0, 0, 0, 0}},
+ 	{JP2_BOX_ULST, "ULST", 0,
+@@ -271,7 +279,7 @@
+ 	} else {
+ 		box->datalen = box->len - JP2_BOX_HDRLEN(false);
+ 	}
+-	if (box->len != 0 && box->len < 8) {
++	if (box->len != 0 && box->len < JP2_BOX_HDRLEN(false)) {
+ 		goto error;
+ 	}
+ 
+@@ -876,6 +884,56 @@
+ 	}
+ }
+ 
++static void jp2_uuid_destroy(jp2_box_t *box)
++{
++	jp2_uuid_t *uuid = &box->data.uuid;
++	if (uuid->data)
++	{
++	    jas_free(uuid->data);
++	    uuid->data = NULL;
++	}
++}
++
++static int jp2_uuid_getdata(jp2_box_t *box, jas_stream_t *in)
++{
++	jp2_uuid_t *uuid = &box->data.uuid;
++	int i;
++	
++	for (i = 0; i < 16; i++)
++	{
++	    if (jp2_getuint8(in, &uuid->uuid[i]))
++		return -1;
++	}
++	
++	uuid->datalen = box->datalen - 16;
++	uuid->data = jas_malloc(uuid->datalen * sizeof(uint_fast8_t));
++	for (i = 0; i < uuid->datalen; i++)
++	{
++	    if (jp2_getuint8(in, &uuid->data[i]))
++		return -1;
++	}
++	return 0;
++}
++
++static int jp2_uuid_putdata(jp2_box_t *box, jas_stream_t *out)
++{
++	jp2_uuid_t *uuid = &box->data.uuid;
++	int i;
++	
++	for (i = 0; i < 16; i++)
++	{
++	    if (jp2_putuint8(out, uuid->uuid[i]))
++		return -1;
++	}
++	
++	for (i = 0; i < uuid->datalen; i++)
++	{
++	    if (jp2_putuint8(out, uuid->data[i]))
++		return -1;
++	}
++	return 0;
++}
++
+ static int jp2_getint(jas_stream_t *in, int s, int n, int_fast32_t *val)
+ {
+ 	int c;
+diff -ruN src/libjasper/jp2/jp2_cod.h.orig src/libjasper/jp2/jp2_cod.h
+--- src/libjasper/jp2/jp2_cod.h.orig	2007-01-20 05:43:05.000000000 +0800
++++ src/libjasper/jp2/jp2_cod.h	2007-03-06 21:49:58.000000000 +0800
+@@ -5,6 +5,11 @@
+  * All rights reserved.
+  */
+ 
++/*
++ * Modified by Andrey Kiselev <dron@ak4719.spb.edu> to properly handle UUID
++ * box.
++ */
++
+ /* __START_OF_JASPER_LICENSE__
+  * 
+  * JasPer License Version 2.0
+@@ -229,6 +234,12 @@
+ 	jp2_cmapent_t *ents;
+ } jp2_cmap_t;
+ 
++typedef struct {
++	uint_fast32_t datalen;
++	uint_fast8_t uuid[16];
++	uint_fast8_t *data;
++} jp2_uuid_t;
++
+ #define	JP2_CMAP_DIRECT		0
+ #define	JP2_CMAP_PALETTE	1
+ 
+@@ -257,6 +268,7 @@
+ 		jp2_pclr_t pclr;
+ 		jp2_cdef_t cdef;
+ 		jp2_cmap_t cmap;
++		jp2_uuid_t uuid;
+ 	} data;
+ 
+ } jp2_box_t;
+diff -ruN src/libjasper/jp2/jp2_enc.c.orig src/libjasper/jp2/jp2_enc.c
+--- src/libjasper/jp2/jp2_enc.c.orig	2007-01-20 05:43:05.000000000 +0800
++++ src/libjasper/jp2/jp2_enc.c	2007-03-06 21:49:58.000000000 +0800
+@@ -5,6 +5,11 @@
+  * All rights reserved.
+  */
+ 
++/*
++ * Modified by Andrey Kiselev <dron@ak4719.spb.edu> to properly handle UUID
++ * box.
++ */
++
+ /* __START_OF_JASPER_LICENSE__
+  * 
+  * JasPer License Version 2.0
+@@ -86,7 +91,7 @@
+ * Functions.
+ \******************************************************************************/
+ 
+-int jp2_encode(jas_image_t *image, jas_stream_t *out, char *optstr)
++int jp2_write_header(jas_image_t *image, jas_stream_t *out)
+ {
+ 	jp2_box_t *box;
+ 	jp2_ftyp_t *ftyp;
+@@ -97,8 +102,6 @@
+ 	long len;
+ 	uint_fast16_t cmptno;
+ 	jp2_colr_t *colr;
+-	char buf[4096];
+-	uint_fast32_t overhead;
+ 	jp2_cdefchan_t *cdefchanent;
+ 	jp2_cdef_t *cdef;
+ 	int i;
+@@ -326,6 +329,26 @@
+ 	jas_stream_close(tmpstream);
+ 	tmpstream = 0;
+ 
++	return 0;
++	abort();
++
++error:
++
++	if (box) {
++		jp2_box_destroy(box);
++	}
++	if (tmpstream) {
++		jas_stream_close(tmpstream);
++	}
++	return -1;
++}
++
++int jp2_write_codestream(jas_image_t *image, jas_stream_t *out, char *optstr)
++{
++	jp2_box_t *box;
++	char buf[4096];
++	uint_fast32_t overhead;
++
+ 	/*
+ 	 * Output the contiguous code stream box.
+ 	 */
+@@ -358,12 +381,34 @@
+ 	if (box) {
+ 		jp2_box_destroy(box);
+ 	}
+-	if (tmpstream) {
+-		jas_stream_close(tmpstream);
+-	}
+ 	return -1;
+ }
+ 
++int jp2_encode(jas_image_t *image, jas_stream_t *out, char *optstr)
++{
++	if (jp2_write_header(image, out) < 0)
++		return -1;
++	if (jp2_write_codestream(image, out, optstr) < 0)
++		return -1;
++
++	return 0;
++}
++
++int jp2_encode_uuid(jas_image_t *image, jas_stream_t *out,
++		    char *optstr, jp2_box_t *uuid)
++{
++	if (jp2_write_header(image, out) < 0)
++		return -1;
++	if (uuid) {
++		if (jp2_box_put(uuid, out))
++			return -1;
++	}
++	if (jp2_write_codestream(image, out, optstr) < 0)
++		return -1;
++
++	return 0;
++}
++
+ static uint_fast32_t jp2_gettypeasoc(int colorspace, int ctype)
+ {
+ 	int type;
--- jasper-1.900.1_9.patch ends here ---

>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100504072246.0D28F2AEC5A0>