shithub: jp2

Download patch

ref: 5323bf5d517d433e45291c1e78292e9cf3e1ac10
parent: 696171a9bfa8c9e26fe32288acc5b5bb3baf168a
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Tue Nov 24 06:37:36 EST 2020

strip more

--- a/jas_cm.c
+++ b/jas_cm.c
@@ -128,7 +128,7 @@
 static void jas_cmshapmatlut_init(jas_cmshapmatlut_t *lut);
 static int jas_cmshapmatlut_set(jas_cmshapmatlut_t *lut, const jas_icccurv_t *curv);
 
-static const jas_cmpxformops_t shapmat_ops = {jas_cmshapmat_destroy, jas_cmshapmat_apply, 0};
+static const jas_cmpxformops_t shapmat_ops = {jas_cmshapmat_destroy, jas_cmshapmat_apply};
 static jas_cmprof_t *jas_cmprof_createsycc(void);
 
 /******************************************************************************\
--- a/jas_debug.c
+++ b/jas_debug.c
@@ -109,44 +109,7 @@
 	va_list ap;
 
 	va_start(ap, fmt);
-	ret = vfprintf(stderr, fmt, ap);
+	ret = vfprint(2, fmt, ap);
 	va_end(ap);
 	return ret;
-}
-
-/* Dump memory to a stream. */
-int jas_memdump(FILE *out, const void *data, size_t len)
-{
-	size_t i;
-	size_t j;
-	const jas_uchar *dp = data;
-	for (i = 0; i < len; i += 16) {
-		fprintf(out, "%04zx:", i);
-		for (j = 0; j < 16; ++j) {
-			if (i + j < len) {
-				fprintf(out, " %02x", dp[i + j]);
-			}
-		}
-		fprintf(out, "\n");
-	}
-	return 0;
-}
-
-/******************************************************************************\
-* Code.
-\******************************************************************************/
-
-void jas_deprecated(const char *s)
-{
-	static const char message[] =
-	"WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!!\n"
-	"WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!!\n"
-	"WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!!\n"
-	"YOUR CODE IS RELYING ON DEPRECATED FUNCTIONALITY IN THE JASPER LIBRARY.\n"
-	"THIS FUNCTIONALITY WILL BE REMOVED IN THE NEAR FUTURE.\n"
-	"PLEASE FIX THIS PROBLEM BEFORE YOUR CODE STOPS WORKING!\n"
-	;
-	jas_eprintf("%s", message);
-	jas_eprintf("The specific problem is as follows:\n%s\n", s);
-	//abort();
 }
--- a/jas_icc.c
+++ b/jas_icc.c
@@ -65,7 +65,6 @@
 #include "jasper/jas_debug.h"
 #include "jasper/jas_cm.h"
 #include "jasper/jas_stream.h"
-#include "jasper/jas_string.h"
 
 #define	jas_iccputuint8(out, val)	jas_iccputuint(out, 1, val)
 #define	jas_iccputuint16(out, val)	jas_iccputuint(out, 2, val)
@@ -108,7 +107,6 @@
 //#ifdef JAS_ENABLE_ENCODER
 static int jas_icccurv_output(jas_iccattrval_t *attrval, jas_stream_t *out);
 //#endif
-static void jas_icccurv_dump(const jas_iccattrval_t *attrval, FILE *out);
 
 static void jas_icctxtdesc_destroy(jas_iccattrval_t *attrval);
 static int jas_icctxtdesc_copy(jas_iccattrval_t *attrval,
@@ -119,7 +117,6 @@
 //#ifdef JAS_ENABLE_ENCODER
 static int jas_icctxtdesc_output(jas_iccattrval_t *attrval, jas_stream_t *out);
 //#endif
-static void jas_icctxtdesc_dump(const jas_iccattrval_t *attrval, FILE *out);
 
 static void jas_icctxt_destroy(jas_iccattrval_t *attrval);
 static int jas_icctxt_copy(jas_iccattrval_t *attrval,
@@ -130,7 +127,6 @@
 //#ifdef JAS_ENABLE_ENCODER
 static int jas_icctxt_output(jas_iccattrval_t *attrval, jas_stream_t *out);
 //#endif
-static void jas_icctxt_dump(const jas_iccattrval_t *attrval, FILE *out);
 
 static int jas_iccxyz_input(jas_iccattrval_t *attrval, jas_stream_t *in,
   unsigned cnt);
@@ -138,7 +134,6 @@
 //#ifdef JAS_ENABLE_ENCODER
 static int jas_iccxyz_output(jas_iccattrval_t *attrval, jas_stream_t *out);
 //#endif
-static void jas_iccxyz_dump(const jas_iccattrval_t *attrval, FILE *out);
 
 static jas_iccattrtab_t *jas_iccattrtab_create(void);
 static void jas_iccattrtab_destroy(jas_iccattrtab_t *tab);
@@ -164,7 +159,6 @@
 //#ifdef JAS_ENABLE_ENCODER
 static int jas_icclut16_output(jas_iccattrval_t *attrval, jas_stream_t *out);
 //#endif
-static void jas_icclut16_dump(const jas_iccattrval_t *attrval, FILE *out);
 
 static void jas_icclut8_destroy(jas_iccattrval_t *attrval);
 static int jas_icclut8_copy(jas_iccattrval_t *attrval,
@@ -175,7 +169,6 @@
 //#ifdef JAS_ENABLE_ENCODER
 static int jas_icclut8_output(jas_iccattrval_t *attrval, jas_stream_t *out);
 //#endif /* JAS_ENABLE_ENCODER */
-static void jas_icclut8_dump(const jas_iccattrval_t *attrval, FILE *out);
 
 //#ifdef JAS_ENABLE_ENCODER
 static int jas_iccputtime(jas_stream_t *out, const jas_icctime_t *ctime);
@@ -197,7 +190,6 @@
 			jas_icccurv_output,
 //#endif
 			jas_icccurv_getsize,
-			jas_icccurv_dump,
 		},
 	},
 	{
@@ -210,7 +202,6 @@
 			jas_iccxyz_output,
 //#endif
 			jas_iccxyz_getsize,
-			jas_iccxyz_dump,
 		},
 	},
 	{
@@ -223,7 +214,6 @@
 			jas_icctxtdesc_output,
 //#endif
 			jas_icctxtdesc_getsize,
-			jas_icctxtdesc_dump,
 		},
 	},
 	{
@@ -236,7 +226,6 @@
 			jas_icctxt_output,
 //#endif
 			jas_icctxt_getsize,
-			jas_icctxt_dump,
 		},
 	},
 	{
@@ -249,7 +238,6 @@
 			jas_icclut8_output,
 //#endif
 			jas_icclut8_getsize,
-			jas_icclut8_dump,
 		},
 	},
 	{
@@ -261,7 +249,6 @@
 			jas_icclut16_output,
 //#endif
 			jas_icclut16_getsize,
-			jas_icclut16_dump,
 		},
 	},
 	{
@@ -274,7 +261,6 @@
 			0,
 //#endif
 			0,
-			0,
 		},
 	}
 };
@@ -329,11 +315,6 @@
 	jas_free(prof);
 }
 
-void jas_iccprof_dump(const jas_iccprof_t *prof, FILE *out)
-{
-	jas_iccattrtab_dump(prof->attrtab, out);
-}
-
 jas_iccprof_t *jas_iccprof_load(jas_stream_t *in)
 {
 	jas_iccprof_t *prof;
@@ -792,29 +773,6 @@
 	jas_free(tab);
 }
 
-void jas_iccattrtab_dump(const jas_iccattrtab_t *attrtab, FILE *out)
-{
-	char buf[16];
-	fprintf(out, "numattrs=%d\n", attrtab->numattrs);
-	fprintf(out, "---\n");
-	for (unsigned i = 0; i < attrtab->numattrs; ++i) {
-		const jas_iccattr_t *attr = &attrtab->attrs[i];
-		const jas_iccattrval_t *attrval = attr->val;
-		const jas_iccattrvalinfo_t *info = jas_iccattrvalinfo_lookup(attrval->type);
-		assert(info);
-		(void)info;
-		fprintf(out, "attrno=%d; attrname=\"%s\"(0x%08"PRIxFAST32"); attrtype=\"%s\"(0x%08"PRIxFAST32")\n",
-		  i,
-		  jas_iccsigtostr(attr->name, &buf[0]),
-		  attr->name,
-		  jas_iccsigtostr(attrval->type, &buf[8]),
-		  attrval->type
-		  );
-		jas_iccattrval_dump(attrval, out);
-		fprintf(out, "---\n");
-	}
-}
-
 static int jas_iccattrtab_resize(jas_iccattrtab_t *tab, unsigned maxents)
 {
 	jas_iccattr_t *newattrs;
@@ -951,17 +909,6 @@
 	}
 }
 
-void jas_iccattrval_dump(const jas_iccattrval_t *attrval, FILE *out)
-{
-	char buf[8];
-	jas_iccsigtostr(attrval->type, buf);
-	fprintf(out, "refcnt = %d; type = 0x%08"PRIxFAST32" %s\n", attrval->refcnt,
-	  attrval->type, jas_iccsigtostr(attrval->type, &buf[0]));
-	if (attrval->ops->dump) {
-		(*attrval->ops->dump)(attrval, out);
-	}
-}
-
 int jas_iccattrval_allowmodify(jas_iccattrval_t **attrvalx)
 {
 	jas_iccattrval_t *newattrval;
@@ -1033,12 +980,6 @@
 	return 12;
 }
 
-static void jas_iccxyz_dump(const jas_iccattrval_t *attrval, FILE *out)
-{
-	const jas_iccxyz_t *xyz = &attrval->data.xyz;
-	fprintf(out, "(%f, %f, %f)\n", xyz->x / 65536.0, xyz->y / 65536.0, xyz->z / 65536.0);
-}
-
 /******************************************************************************\
 * attribute table class
 \******************************************************************************/
@@ -1113,21 +1054,6 @@
 }
 //#endif /* JAS_ENABLE_ENCODER */
 
-static void jas_icccurv_dump(const jas_iccattrval_t *attrval, FILE *out)
-{
-	const jas_icccurv_t *curv = &attrval->data.curv;
-	fprintf(out, "number of entries = %"PRIuFAST32"\n", curv->numents);
-	if (curv->numents == 1) {
-		fprintf(out, "gamma = %f\n", curv->ents[0] / 256.0);
-	} else {
-		for (unsigned i = 0; i < curv->numents; ++i) {
-			if (i < 3 || i >= curv->numents - 3) {
-				fprintf(out, "entry[%d] = %f\n", i, curv->ents[i] / 65535.0);
-			}
-		}
-	}
-}
-
 /******************************************************************************\
 *
 \******************************************************************************/
@@ -1245,16 +1171,6 @@
 }
 //#endif /* JAS_ENABLE_ENCODER */
 
-static void jas_icctxtdesc_dump(const jas_iccattrval_t *attrval, FILE *out)
-{
-	const jas_icctxtdesc_t *txtdesc = &attrval->data.txtdesc;
-	fprintf(out, "ascii = \"%s\"\n", txtdesc->ascdata);
-	fprintf(out, "uclangcode = %"PRIuFAST32"; uclen = %"PRIuFAST32"\n",
-	  txtdesc->uclangcode, txtdesc->uclen);
-	fprintf(out, "sccode = %"PRIuFAST16"\n", txtdesc->sccode);
-	fprintf(out, "maclen = %d\n", txtdesc->maclen);
-}
-
 /******************************************************************************\
 *
 \******************************************************************************/
@@ -1273,7 +1189,7 @@
 {
 	jas_icctxt_t *txt = &attrval->data.txt;
 	const jas_icctxt_t *othtxt = &othattrval->data.txt;
-	if (!(txt->string = jas_strdup(othtxt->string)))
+	if (!(txt->string = strdup(othtxt->string)))
 		return -1;
 	return 0;
 }
@@ -1313,12 +1229,6 @@
 }
 //#endif /* JAS_ENABLE_ENCODER */
 
-static void jas_icctxt_dump(const jas_iccattrval_t *attrval, FILE *out)
-{
-	const jas_icctxt_t *txt = &attrval->data.txt;
-	fprintf(out, "string = \"%s\"\n", txt->string);
-}
-
 /******************************************************************************\
 *
 \******************************************************************************/
@@ -1473,21 +1383,6 @@
 }
 //#endif /* JAS_ENABLE_ENCODER */
 
-static void jas_icclut8_dump(const jas_iccattrval_t *attrval, FILE *out)
-{
-	const jas_icclut8_t *lut8 = &attrval->data.lut8;
-	fprintf(out, "numinchans=%d, numoutchans=%d, clutlen=%d\n",
-	  lut8->numinchans, lut8->numoutchans, lut8->clutlen);
-	for (unsigned i = 0; i < 3; ++i) {
-		for (unsigned j = 0; j < 3; ++j) {
-			fprintf(out, "e[%d][%d]=%f ", i, j, lut8->e[i][j] / 65536.0);
-		}
-		fprintf(out, "\n");
-	}
-	fprintf(out, "numintabents=%"PRIuFAST16", numouttabents=%"PRIuFAST16"\n",
-	  lut8->numintabents, lut8->numouttabents);
-}
-
 /******************************************************************************\
 *
 \******************************************************************************/
@@ -1637,21 +1532,6 @@
 	return -1;
 }
 //#endif /* JAS_ENABLE_ENCODER */
-
-static void jas_icclut16_dump(const jas_iccattrval_t *attrval, FILE *out)
-{
-	const jas_icclut16_t *lut16 = &attrval->data.lut16;
-	fprintf(out, "numinchans=%d, numoutchans=%d, clutlen=%d\n",
-	  lut16->numinchans, lut16->numoutchans, lut16->clutlen);
-	for (unsigned i = 0; i < 3; ++i) {
-		for (unsigned j = 0; j < 3; ++j) {
-			fprintf(out, "e[%d][%d]=%f ", i, j, lut16->e[i][j] / 65536.0);
-		}
-		fprintf(out, "\n");
-	}
-	fprintf(out, "numintabents=%"PRIuFAST16", numouttabents=%"PRIuFAST16"\n",
-	  lut16->numintabents, lut16->numouttabents);
-}
 
 /******************************************************************************\
 *
--- a/jas_image.c
+++ b/jas_image.c
@@ -74,7 +74,6 @@
 #include "jasper/jas_image.h"
 #include "jasper/jas_math.h"
 #include "jasper/jas_malloc.h"
-#include "jasper/jas_string.h"
 #include "jasper/jas_debug.h"
 
 /******************************************************************************\
@@ -91,8 +90,7 @@
 static void jas_image_cmpt_destroy(jas_image_cmpt_t *cmpt);
 static jas_image_cmpt_t *jas_image_cmpt_create(int_fast32_t tlx,
   int_fast32_t tly, int_fast32_t hstep, int_fast32_t vstep,
-  int_fast32_t width, int_fast32_t height, uint_fast16_t depth, bool sgnd,
-  bool inmem);
+  int_fast32_t width, int_fast32_t height, uint_fast16_t depth, bool sgnd);
 static void jas_image_setbbox(jas_image_t *image);
 static jas_image_cmpt_t *jas_image_cmpt_copy(jas_image_cmpt_t *cmpt);
 static int jas_image_growcmpts(jas_image_t *image, unsigned maxcmpts);
@@ -135,7 +133,6 @@
 
 	image->clrspc_ = clrspc;
 	image->maxcmpts_ = numcmpts;
-//	image->inmem_ = true;
 
 	/* Allocate memory for the per-component information. */
 	if (!(image->cmpts_ = jas_alloc2(image->maxcmpts_,
@@ -147,19 +144,6 @@
 		image->cmpts_[cmptno] = 0;
 	}
 
-#if 0
-	/* Compute the approximate raw size of the image. */
-	rawsize = 0;
-	for (cmptno = 0, cmptparm = cmptparms; cmptno < numcmpts; ++cmptno,
-	  ++cmptparm) {
-		rawsize += cmptparm->width * cmptparm->height *
-		  (cmptparm->prec + 7) / 8;
-	}
-	/* Decide whether to buffer the image data in memory, based on the
-	  raw size of the image. */
-	inmem = (rawsize < JAS_IMAGE_INMEMTHRESH);
-#endif
-
 	/* Create the individual image components. */
 	for (cmptno = 0, cmptparm = cmptparms; cmptno < numcmpts; ++cmptno,
 	  ++cmptparm) {
@@ -168,11 +152,10 @@
 			goto error;
 		}
 		rawsize /= 8;
-		const bool inmem = (rawsize < JAS_IMAGE_INMEMTHRESH);
 		if (!(image->cmpts_[cmptno] = jas_image_cmpt_create(cmptparm->tlx,
 		  cmptparm->tly, cmptparm->hstep, cmptparm->vstep,
 		  cmptparm->width, cmptparm->height, cmptparm->prec,
-		  cmptparm->sgnd, inmem))) {
+		  cmptparm->sgnd))) {
 			goto error;
 		}
 		++image->numcmpts_;
@@ -207,7 +190,6 @@
 	image->numcmpts_ = 0;
 	image->maxcmpts_ = 0;
 	image->cmpts_ = 0;
-//	image->inmem_ = true;
 	image->cmprof_ = 0;
 
 	return image;
@@ -277,13 +259,13 @@
 	if (!(newcmpt->stream_ = jas_stream_memopen(0, 0))) {
 		goto error;
 	}
-	if (jas_stream_seek(cmpt->stream_, 0, SEEK_SET)) {
+	if (jas_stream_seek(cmpt->stream_, 0, 0)) {
 		goto error;
 	}
 	if (jas_stream_copy(newcmpt->stream_, cmpt->stream_, -1)) {
 		goto error;
 	}
-	if (jas_stream_seek(newcmpt->stream_, 0, SEEK_SET)) {
+	if (jas_stream_seek(newcmpt->stream_, 0, 0)) {
 		goto error;
 	}
 	return newcmpt;
@@ -308,14 +290,13 @@
 
 static jas_image_cmpt_t *jas_image_cmpt_create(int_fast32_t tlx,
   int_fast32_t tly, int_fast32_t hstep, int_fast32_t vstep,
-  int_fast32_t width, int_fast32_t height, uint_fast16_t depth, bool sgnd,
-  bool inmem)
+  int_fast32_t width, int_fast32_t height, uint_fast16_t depth, bool sgnd)
 {
 	jas_image_cmpt_t *cmpt;
 	size_t size;
 
 	JAS_DBGLOG(100, (
-	  "jas_image_cmpt_create(%ld, %ld, %ld, %ld, %ld, %ld, %d, %d, %d)\n",
+	  "jas_image_cmpt_create(%ld, %ld, %ld, %ld, %ld, %ld, %d, %d)\n",
 	  JAS_CAST(long, tlx),
 	  JAS_CAST(long, tly),
 	  JAS_CAST(long, hstep),
@@ -324,7 +305,6 @@
 	  JAS_CAST(long, height),
 	  JAS_CAST(int, depth),
 	  sgnd,
-	  inmem
 	  ));
 
 	if (depth < 1U + sgnd) {
@@ -366,8 +346,7 @@
 	if (!jas_safe_size_mul3(cmpt->width_, cmpt->height_, cmpt->cps_, &size)) {
 		goto error;
 	}
-	cmpt->stream_ = (inmem) ? jas_stream_memopen2(0, size) :
-	  jas_stream_tmpfile();
+	cmpt->stream_ = jas_stream_memopen2(0, size);
 	if (!cmpt->stream_) {
 		goto error;
 	}
@@ -379,9 +358,9 @@
 		if (size - 1 > LONG_MAX) {
 			goto error;
 		}
-		if (jas_stream_seek(cmpt->stream_, size - 1, SEEK_SET) < 0 ||
+		if (jas_stream_seek(cmpt->stream_, size - 1, 0) < 0 ||
 		  jas_stream_putc(cmpt->stream_, 0) == EOF ||
-		  jas_stream_seek(cmpt->stream_, 0, SEEK_SET) < 0) {
+		  jas_stream_seek(cmpt->stream_, 0, 0) < 0) {
 			goto error;
 		}
 	}
@@ -520,8 +499,7 @@
 	const uint_least32_t drs = jas_matrix_rowstep(data);
 	for (i = 0; i < height; ++i, dr += drs) {
 		d = dr;
-		if (jas_stream_seek(stream, (cmpt_width * (y + i) + x)
-		  * cps, SEEK_SET) < 0) {
+		if (jas_stream_seek(stream, (cmpt_width * (y + i) + x) * cps, 0) < 0) {
 			return -1;
 		}
 
@@ -599,8 +577,7 @@
 	const uint_least32_t drs = jas_matrix_rowstep(data);
 	for (i = 0; i < height; ++i, dr += drs) {
 		const jas_seqent_t *d = dr;
-		if (jas_stream_seek(stream, (cmpt_width * (y + i) + x)
-		  * cps, SEEK_SET) < 0) {
+		if (jas_stream_seek(stream, (cmpt_width * (y + i) + x) * cps, 0) < 0) {
 			return -1;
 		}
 
@@ -668,14 +645,14 @@
 	}
 	fmtinfo = &jas_image_fmtinfos[jas_image_numfmts];
 	fmtinfo->id = id;
-	if (!(fmtinfo->name = jas_strdup(name))) {
+	if (!(fmtinfo->name = strdup(name))) {
 		return -1;
 	}
-	if (!(fmtinfo->ext = jas_strdup(ext))) {
+	if (!(fmtinfo->ext = strdup(ext))) {
 		jas_free(fmtinfo->name);
 		return -1;
 	}
-	if (!(fmtinfo->desc = jas_strdup(desc))) {
+	if (!(fmtinfo->desc = strdup(desc))) {
 		jas_free(fmtinfo->name);
 		jas_free(fmtinfo->ext);
 		return -1;
@@ -685,6 +662,37 @@
 	return 0;
 }
 
+int jas_image_addcmpt(jas_image_t *image, int cmptno,
+  const jas_image_cmptparm_t *cmptparm)
+{
+	jas_image_cmpt_t *newcmpt;
+	if (cmptno < 0) {
+		cmptno = image->numcmpts_;
+	}
+	assert(cmptno >= 0 && (unsigned)cmptno <= image->numcmpts_);
+	if (image->numcmpts_ >= image->maxcmpts_) {
+		if (jas_image_growcmpts(image, image->maxcmpts_ + 128)) {
+			return -1;
+		}
+	}
+	if (!(newcmpt = jas_image_cmpt_create(cmptparm->tlx,
+	  cmptparm->tly, cmptparm->hstep, cmptparm->vstep,
+	  cmptparm->width, cmptparm->height, cmptparm->prec,
+	  cmptparm->sgnd))) {
+		return -1;
+	}
+	if ((unsigned)cmptno < image->numcmpts_) {
+		memmove(&image->cmpts_[cmptno + 1], &image->cmpts_[cmptno],
+		  (image->numcmpts_ - (unsigned)cmptno) * sizeof(jas_image_cmpt_t *));
+	}
+	image->cmpts_[cmptno] = newcmpt;
+	++image->numcmpts_;
+
+	jas_image_setbbox(image);
+
+	return 0;
+}
+
 /* This is for future consideration for addition to the library API. */
 #if 0
 JAS_DLLEXPORT
@@ -816,37 +824,6 @@
 	jas_image_setbbox(image);
 }
 
-int jas_image_addcmpt(jas_image_t *image, int cmptno,
-  const jas_image_cmptparm_t *cmptparm)
-{
-	jas_image_cmpt_t *newcmpt;
-	if (cmptno < 0) {
-		cmptno = image->numcmpts_;
-	}
-	assert(cmptno >= 0 && (unsigned)cmptno <= image->numcmpts_);
-	if (image->numcmpts_ >= image->maxcmpts_) {
-		if (jas_image_growcmpts(image, image->maxcmpts_ + 128)) {
-			return -1;
-		}
-	}
-	if (!(newcmpt = jas_image_cmpt_create(cmptparm->tlx,
-	  cmptparm->tly, cmptparm->hstep, cmptparm->vstep,
-	  cmptparm->width, cmptparm->height, cmptparm->prec,
-	  cmptparm->sgnd, true))) {
-		return -1;
-	}
-	if ((unsigned)cmptno < image->numcmpts_) {
-		memmove(&image->cmpts_[cmptno + 1], &image->cmpts_[cmptno],
-		  (image->numcmpts_ - (unsigned)cmptno) * sizeof(jas_image_cmpt_t *));
-	}
-	image->cmpts_[cmptno] = newcmpt;
-	++image->numcmpts_;
-
-	jas_image_setbbox(image);
-
-	return 0;
-}
-
 const jas_image_fmtinfo_t *jas_image_lookupfmtbyid(int id)
 {
 	unsigned i;
@@ -968,34 +945,6 @@
 	return 0;
 }
 
-void jas_image_dump(jas_image_t *image, FILE *out)
-{
-	long buf[1024];
-	jas_image_cmpt_t *cmpt;
-	for (unsigned cmptno = 0; cmptno < image->numcmpts_; ++cmptno) {
-		cmpt = image->cmpts_[cmptno];
-		fprintf(out, "prec=%d, sgnd=%d, cmpttype=%"PRIiFAST32"\n", cmpt->prec_,
-		  cmpt->sgnd_, cmpt->type_);
-		const unsigned width = jas_image_cmptwidth(image, cmptno);
-		const unsigned height = jas_image_cmptheight(image, cmptno);
-		const unsigned n = JAS_MIN(16, width);
-		if (jas_image_readcmpt2(image, cmptno, 0, 0, n, 1, buf)) {
-			abort();
-		}
-		for (unsigned i = 0; i < n; ++i) {
-			fprintf(out, " f(%d,%d)=%ld", i, 0, buf[i]);
-		}
-		fprintf(out, "\n");
-		if (jas_image_readcmpt2(image, cmptno, width - n, height - 1, n, 1, buf)) {
-			abort();
-		}
-		for (unsigned i = 0; i < n; ++i) {
-			fprintf(out, " f(%d,%d)=%ld", width - n + i, height - 1, buf[i]);
-		}
-		fprintf(out, "\n");
-	}
-}
-
 int jas_image_depalettize(jas_image_t *image, unsigned cmptno, unsigned numlutents,
   const int_fast32_t *lutents, unsigned dtype, unsigned newcmptno)
 {
@@ -1045,8 +994,7 @@
 
 	cmpt = image->cmpts_[cmptno];
 
-	if (jas_stream_seek(cmpt->stream_, (cmpt->width_ * y + x) * cmpt->cps_,
-	  SEEK_SET) < 0) {
+	if (jas_stream_seek(cmpt->stream_, (cmpt->width_ * y + x) * cmpt->cps_, 0) < 0) {
 		return -1;
 	}
 	v = 0;
@@ -1068,8 +1016,7 @@
 
 	cmpt = image->cmpts_[cmptno];
 
-	if (jas_stream_seek(cmpt->stream_, (cmpt->width_ * y + x) * cmpt->cps_,
-	  SEEK_SET) < 0) {
+	if (jas_stream_seek(cmpt->stream_, (cmpt->width_ * y + x) * cmpt->cps_, 0) < 0) {
 		return;
 	}
 	t = inttobits(v, cmpt->prec_, cmpt->sgnd_);
@@ -1132,8 +1079,7 @@
 
 	bufptr = buf;
 	for (i = 0; i < height; ++i) {
-		if (jas_stream_seek(cmpt->stream_, (cmpt->width_ * (y + i) + x)
-		  * cmpt->cps_, SEEK_SET) < 0)
+		if (jas_stream_seek(cmpt->stream_, (cmpt->width_ * (y + i) + x) * cmpt->cps_, 0) < 0)
 			goto error;
 		for (j = 0; j < width; ++j) {
 			if (getint(cmpt->stream_, cmpt->sgnd_, cmpt->prec_, &v))
@@ -1166,8 +1112,7 @@
 
 	const long *bufptr = buf;
 	for (i = 0; i < height; ++i) {
-		if (jas_stream_seek(cmpt->stream_, (cmpt->width_ * (y + i) + x)
-		  * cmpt->cps_, SEEK_SET) < 0)
+		if (jas_stream_seek(cmpt->stream_, (cmpt->width_ * (y + i) + x) * cmpt->cps_, 0) < 0)
 			goto error;
 		for (j = 0; j < width; ++j) {
 			v = *bufptr++;
@@ -1257,8 +1202,7 @@
 			}
 			assert(oldx >= 0 && oldx < oldcmpt->width_ &&
 			  oldy >= 0 && oldy < oldcmpt->height_);
-			if (jas_stream_seek(oldcmpt->stream_, oldcmpt->cps_ *
-			  (oldy * oldcmpt->width_ + oldx), SEEK_SET) < 0)
+			if (jas_stream_seek(oldcmpt->stream_, oldcmpt->cps_ * (oldy * oldcmpt->width_ + oldx), 0) < 0)
 				goto error;
 			if (getint(oldcmpt->stream_, oldcmpt->sgnd_,
 			  oldcmpt->prec_, &v))
@@ -1443,11 +1387,6 @@
 	jas_cmcmptfmt_t *incmptfmts;
 	jas_cmcmptfmt_t *outcmptfmts;
 
-#if 0
-jas_eprintf("IMAGE\n");
-jas_image_dump(image, stderr);
-#endif
-
 	if (image->numcmpts_ == 0)
 		/* can't work with a file with no components;
 		   continuing would crash because we'd attempt to
@@ -1594,12 +1533,6 @@
 	jas_cmxform_destroy(xform);
 	jas_image_destroy(inimage);
 
-#if 0
-jas_eprintf("INIMAGE\n");
-jas_image_dump(inimage, stderr);
-jas_eprintf("OUTIMAGE\n");
-jas_image_dump(outimage, stderr);
-#endif
 	return outimage;
 error:
 	if (xform)
--- a/jas_malloc.c
+++ /dev/null
@@ -1,299 +1,0 @@
-/*
- * Copyright (c) 1999-2000 Image Power, Inc. and the University of
- *   British Columbia.
- * Copyright (c) 2001-2002 Michael David Adams.
- * All rights reserved.
- */
-
-/* __START_OF_JASPER_LICENSE__
- * 
- * JasPer License Version 2.0
- * 
- * Copyright (c) 2001-2006 Michael David Adams
- * Copyright (c) 1999-2000 Image Power, Inc.
- * Copyright (c) 1999-2000 The University of British Columbia
- * 
- * All rights reserved.
- * 
- * Permission is hereby granted, free of charge, to any person (the
- * "User") obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, and/or sell copies of the Software, and to permit
- * persons to whom the Software is furnished to do so, subject to the
- * following conditions:
- * 
- * 1.  The above copyright notices and this permission notice (which
- * includes the disclaimer below) shall be included in all copies or
- * substantial portions of the Software.
- * 
- * 2.  The name of a copyright holder shall not be used to endorse or
- * promote products derived from the Software without specific prior
- * written permission.
- * 
- * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS
- * LICENSE.  NO USE OF THE SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
- * THIS DISCLAIMER.  THE SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
- * "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
- * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.  IN NO
- * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
- * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
- * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
- * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.  NO ASSURANCES ARE
- * PROVIDED BY THE COPYRIGHT HOLDERS THAT THE SOFTWARE DOES NOT INFRINGE
- * THE PATENT OR OTHER INTELLECTUAL PROPERTY RIGHTS OF ANY OTHER ENTITY.
- * EACH COPYRIGHT HOLDER DISCLAIMS ANY LIABILITY TO THE USER FOR CLAIMS
- * BROUGHT BY ANY OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL
- * PROPERTY RIGHTS OR OTHERWISE.  AS A CONDITION TO EXERCISING THE RIGHTS
- * GRANTED HEREUNDER, EACH USER HEREBY ASSUMES SOLE RESPONSIBILITY TO SECURE
- * ANY OTHER INTELLECTUAL PROPERTY RIGHTS NEEDED, IF ANY.  THE SOFTWARE
- * IS NOT FAULT-TOLERANT AND IS NOT INTENDED FOR USE IN MISSION-CRITICAL
- * SYSTEMS, SUCH AS THOSE USED IN THE OPERATION OF NUCLEAR FACILITIES,
- * AIRCRAFT NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL
- * SYSTEMS, DIRECT LIFE SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH
- * THE FAILURE OF THE SOFTWARE OR SYSTEM COULD LEAD DIRECTLY TO DEATH,
- * PERSONAL INJURY, OR SEVERE PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH
- * RISK ACTIVITIES").  THE COPYRIGHT HOLDERS SPECIFICALLY DISCLAIM ANY
- * EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR HIGH RISK ACTIVITIES.
- * 
- * __END_OF_JASPER_LICENSE__
- */
-
-/*
- * Memory Allocator
- *
- * $Id$
- */
-
-/******************************************************************************\
-* Includes.
-\******************************************************************************/
-
-#include "jasper/jas_malloc.h"
-#include "jasper/jas_debug.h"
-#include "jasper/jas_math.h"
-
-/******************************************************************************\
-* Code.
-\******************************************************************************/
-
-#if defined(JAS_DEFAULT_MAX_MEM_USAGE)
-
-static size_t jas_mem = 0;
-static size_t jas_max_mem = JAS_DEFAULT_MAX_MEM_USAGE;
-
-typedef struct {
-	size_t size;
-} jas_mb_t;
-
-#define JAS_MB_ADJUST \
-  ((sizeof(jas_mb_t) + sizeof(max_align_t) - 1) / sizeof(max_align_t))
-#define JAS_MB_SIZE (JAS_MB_ADJUST * sizeof(max_align_t))
-
-jas_mb_t *jas_get_mb(void *ptr)
-{
-	return JAS_CAST(jas_mb_t *, JAS_CAST(max_align_t *, ptr) - JAS_MB_ADJUST);
-}
-
-void *jas_mb_get_data(jas_mb_t *mb)
-{
-	return JAS_CAST(void *, JAS_CAST(max_align_t *, mb) + JAS_MB_ADJUST);
-}
-
-void jas_set_max_mem_usage(size_t max_mem)
-{
-	jas_max_mem = max_mem;
-}
-
-size_t jas_get_mem_usage()
-{
-	return jas_mem;
-}
-
-void *jas_malloc(size_t size)
-{
-	void *result;
-	jas_mb_t *mb;
-	size_t ext_size;
-	size_t mem;
-
-	JAS_DBGLOG(100, ("jas_malloc(%zu)\n", size));
-#if defined(JAS_MALLOC_RETURN_NULL_PTR_FOR_ZERO_SIZE)
-	if (!size) {
-		return 0;
-	}
-#endif
-	if (!jas_safe_size_add(size, JAS_MB_SIZE, &ext_size)) {
-		jas_eprintf("requested memory size is too large\n");
-		result = 0;
-		mb = 0;
-	} else if (!jas_safe_size_add(jas_mem, size, &mem) || mem > jas_max_mem) {
-		jas_eprintf("maximum memory limit would be exceeded\n");
-		result = 0;
-		mb = 0;
-	} else {
-		JAS_DBGLOG(100, ("jas_malloc: ext_size=%zu\n", ext_size));
-		if ((mb = malloc(ext_size))) {
-			result = jas_mb_get_data(mb);
-			mb->size = size;
-			jas_mem = mem;
-		} else {
-			result = 0;
-		}
-	}
-	JAS_DBGLOG(99, ("jas_malloc(%zu) -> %p (mb=%p)\n", size, result, mb));
-	JAS_DBGLOG(102, ("max_mem=%zu; mem=%zu\n", jas_max_mem, jas_mem));
-	return result;
-}
-
-void *jas_realloc(void *ptr, size_t size)
-{
-	void *result;
-	jas_mb_t *mb;
-	jas_mb_t *old_mb;
-	size_t old_size;
-	size_t ext_size;
-	size_t mem;
-
-	JAS_DBGLOG(100, ("jas_realloc(%p, %zu)\n", ptr, size));
-	if (!ptr) {
-		return jas_malloc(size);
-	}
-	if (ptr && !size) {
-		jas_free(ptr);
-	}
-	if (!jas_safe_size_add(size, JAS_MB_SIZE, &ext_size)) {
-		jas_eprintf("requested memory size is too large\n");
-		return 0;
-	}
-	old_mb = jas_get_mb(ptr);
-	old_size = old_mb->size;
-	JAS_DBGLOG(101, ("jas_realloc: old_mb=%p; old_size=%zu\n", old_mb,
-	  old_size));
-	if (size > old_size) {
-		if (!jas_safe_size_add(jas_mem, ext_size, &mem) || mem > jas_max_mem) {
-			jas_eprintf("maximum memory limit would be exceeded\n");
-			return 0;
-		}
-	} else {
-		if (!jas_safe_size_sub(jas_mem, old_size - size, &jas_mem)) {
-			jas_eprintf("heap corruption detected\n");
-			abort();
-		}
-	}
-	JAS_DBGLOG(100, ("jas_realloc: realloc(%p, %zu)\n", old_mb, ext_size));
-	if (!(mb = realloc(old_mb, ext_size))) {
-		result = 0;
-	} else {
-		result = jas_mb_get_data(mb);
-		mb->size = size;
-		jas_mem = mem;
-	}
-	JAS_DBGLOG(100, ("jas_realloc(%p, %zu) -> %p (%p)\n", ptr, size, result,
-	  mb));
-	JAS_DBGLOG(102, ("max_mem=%zu; mem=%zu\n", jas_max_mem, jas_mem));
-	return result;
-}
-
-void jas_free(void *ptr)
-{
-	jas_mb_t *mb;
-	size_t mem;
-	size_t size;
-	JAS_DBGLOG(100, ("jas_free(%p)\n", ptr));
-	if (ptr) {
-		mb = jas_get_mb(ptr);
-		size = mb->size;
-		JAS_DBGLOG(101, ("jas_free(%p) (mb=%p; size=%zu)\n", ptr, mb, size));
-		if (!jas_safe_size_sub(jas_mem, size, &jas_mem)) {
-			jas_eprintf("heap corruption detected\n");
-			abort();
-		}
-		JAS_DBGLOG(100, ("jas_free: free(%p)\n", mb));
-		free(mb);
-	}
-	JAS_DBGLOG(102, ("max_mem=%zu; mem=%zu\n", jas_max_mem, jas_mem));
-}
-
-#endif
-
-/******************************************************************************\
-* Basic memory allocation and deallocation primitives.
-\******************************************************************************/
-
-#if !defined(JAS_DEFAULT_MAX_MEM_USAGE)
-
-void *jas_malloc(size_t size)
-{
-	void *result;
-	JAS_DBGLOG(101, ("jas_malloc(%zu)\n", size));
-	result = malloc(size);
-	JAS_DBGLOG(100, ("jas_malloc(%zu) -> %p\n", size, result));
-	return result;
-}
-
-void *jas_realloc(void *ptr, size_t size)
-{
-	void *result;
-	JAS_DBGLOG(101, ("jas_realloc(%p, %zu)\n", ptr, size));
-	result = realloc(ptr, size);
-	JAS_DBGLOG(100, ("jas_realloc(%p, %zu) -> %p\n", ptr, size, result));
-	return result;
-}
-
-void jas_free(void *ptr)
-{
-	JAS_DBGLOG(100, ("jas_free(%p)\n", ptr));
-	free(ptr);
-}
-
-#endif
-
-/******************************************************************************\
-* Additional memory allocation and deallocation primitives
-* (mainly for overflow checking).
-\******************************************************************************/
-
-void *jas_alloc2(size_t num_elements, size_t element_size)
-{
-	size_t size;
-	if (!jas_safe_size_mul(num_elements, element_size, &size)) {
-		return 0;
-	}
-	return jas_malloc(size);
-}
-
-void *jas_alloc3(size_t num_arrays, size_t array_size, size_t element_size)
-{
-	size_t size;
-	if (!jas_safe_size_mul(array_size, element_size, &size) ||
-	  !jas_safe_size_mul(size, num_arrays, &size)) {
-		return 0;
-	}
-	return jas_malloc(size);
-}
-
-void *jas_realloc2(void *ptr, size_t num_elements, size_t element_size)
-{
-	size_t size;
-	if (!jas_safe_size_mul(num_elements, element_size, &size)) {
-		return 0;
-	}
-	return jas_realloc(ptr, size);
-}
-
-void *jas_calloc(size_t num_elements, size_t element_size)
-{
-	void *ptr;
-	size_t size;
-	if (!jas_safe_size_mul(num_elements, element_size, &size)) {
-		return 0;
-	}
-	if (!(ptr = jas_malloc(size))) {
-		return 0;
-	}
-	memset(ptr, 0, size);
-	return ptr;
-}
--- a/jas_stream.c
+++ b/jas_stream.c
@@ -92,11 +92,6 @@
 static long mem_seek(jas_stream_obj_t *obj, long offset, int origin);
 static int mem_close(jas_stream_obj_t *obj);
 
-static int sfile_read(jas_stream_obj_t *obj, char *buf, unsigned cnt);
-static int sfile_write(jas_stream_obj_t *obj, const char *buf, unsigned cnt);
-static long sfile_seek(jas_stream_obj_t *obj, long offset, int origin);
-static int sfile_close(jas_stream_obj_t *obj);
-
 static int file_read(jas_stream_obj_t *obj, char *buf, unsigned cnt);
 static int file_write(jas_stream_obj_t *obj, const char *buf, unsigned cnt);
 static long file_seek(jas_stream_obj_t *obj, long offset, int origin);
@@ -113,13 +108,6 @@
 	file_close
 };
 
-static const jas_stream_ops_t jas_stream_sfileops = {
-	sfile_read,
-	sfile_write,
-	sfile_seek,
-	sfile_close
-};
-
 static const jas_stream_ops_t jas_stream_memops = {
 	mem_read,
 	mem_write,
@@ -252,14 +240,9 @@
 	size_t new_bufsize;
 
 	JAS_DBGLOG(100, ("jas_stream_memopen(%p, %d)\n", buf, bufsize));
-	if (bufsize < 0) {
-		jas_deprecated("negative buffer size for jas_stream_memopen");
-	}
-	if (buf && bufsize <= 0) {
-		// This was never a valid thing to do with the old API.
+	if (bufsize < 0 || (buf && bufsize <= 0)) {
 		jas_eprintf("Invalid use of jas_stream_memopen detected.\n");
-		jas_deprecated("A user-provided buffer for "
-		  "jas_stream_memopen cannot be growable.\n");
+		return nil;
 	}
 	if (bufsize <= 0) {
 		new_bufsize = 0;
@@ -311,7 +294,6 @@
 	}
 	obj->fd = -1;
 	obj->flags = 0;
-	obj->pathname[0] = '\0';
 	stream->obj_ = (void *) obj;
 
 	/* Select the operations for a file stream object. */
@@ -341,178 +323,6 @@
 	return stream;
 }
 
-jas_stream_t *jas_stream_freopen(const char *path, const char *mode, FILE *fp)
-{
-	jas_stream_t *stream;
-
-	JAS_DBGLOG(100, ("jas_stream_freopen(\"%s\", \"%s\", %p)\n", path, mode,
-	  fp));
-
-	/* Eliminate compiler warning about unused variable. */
-	USED(path);
-
-	/* Allocate a stream object. */
-	if (!(stream = jas_stream_create())) {
-		return 0;
-	}
-
-	/* Parse the mode string. */
-	stream->openmode_ = jas_strtoopenmode(mode);
-
-	stream->obj_ = JAS_CAST(void *, fp);
-
-	/* Select the operations for a file stream object. */
-	stream->ops_ = &jas_stream_sfileops;
-
-	/* By default, use full buffering for this type of stream. */
-	jas_stream_initbuf(stream, JAS_STREAM_FULLBUF, 0, 0);
-
-	return stream;
-}
-
-#ifndef _WIN32
-
-/**
- * Copy the absolute path of the directory for temporary files to the
- * given buffer (without a null terminator), including a trailing path
- * separator.
- *
- * @return the number of characters copied to the buffer or 0 on error
- */
-static size_t get_temp_directory(char *buffer, size_t size)
-{
-	const char *tmpdir = getenv("TMPDIR");
-	if (tmpdir == NULL)
-		tmpdir = "/tmp";
-
-	size_t length = strlen(tmpdir);
-	if (length + 1 > size)
-		return 0;
-
-	memcpy(buffer, tmpdir, length);
-	buffer[length++] = '/';
-	return length;
-}
-
-#endif /* !_WIN32 */
-
-/**
- * Generate a template for mkstemp().
- *
- * @return 0 on success, -1 on error
- */
-static int make_mkstemp_template(char *buffer, size_t size)
-{
-#ifdef _WIN32
-	char temp_directory[MAX_PATH];
-	if (GetTempPathA(sizeof(temp_directory), temp_directory) == 0)
-		return -1;
-
-	(void)size;
-
-	return GetTempFileNameA(temp_directory, "jasper", 0, buffer) > 0
-		? 0 : -1;
-#else
-	static const char base[] = "jasper.XXXXXXXXXXX";
-
-	size_t length = get_temp_directory(buffer, size);
-	if (length == 0 || length + sizeof(base) >= size)
-		return -1;
-
-	memcpy(buffer + length, base, sizeof(base));
-	return 0;
-#endif
-}
-
-/**
- * A wrapper for mkstemp() which generates a template for mkstemp()
- * before calling the function.
- *
- * @return a non-negative file descriptor on success, -1 on error
- */
-static int easy_mkstemp(char *buffer, size_t size)
-{
-#if defined(__linux__) && defined(O_TMPFILE)
-	/* try to use O_TMPFILE, which is a Linux-specific feature to
-	   create a temporary file without a name, not linked to any
-	   directory; this is even more secure than mkstemp() */
-	const char *tmpdir = getenv("TMPDIR");
-	if (tmpdir == NULL)
-		tmpdir = "/tmp";
-
-	int fd = open(tmpdir, O_TMPFILE|O_RDWR, JAS_STREAM_PERMS);
-	if (fd >= 0) {
-		*buffer = 0;
-		return fd;
-	}
-#endif
-
-	if (make_mkstemp_template(buffer, size))
-		return -1;
-
-#ifdef _WIN32
-	return open(buffer,
-		    O_CREAT | O_EXCL | O_RDWR | O_TRUNC | O_BINARY | O_CLOEXEC,
-		    JAS_STREAM_PERMS);
-#else
-#ifdef JAS_HAVE_MKOSTEMP
-	return mkostemp(buffer, O_CLOEXEC);
-#else
-	return create(mktemp(buffer), OTRUNC|ORDWR|OEXCL|OCEXEC, JAS_STREAM_PERMS);
-#endif
-#endif
-}
-
-jas_stream_t *jas_stream_tmpfile()
-{
-	jas_stream_t *stream;
-	jas_stream_fileobj_t *obj;
-
-	JAS_DBGLOG(100, ("jas_stream_tmpfile()\n"));
-
-	if (!(stream = jas_stream_create())) {
-		return 0;
-	}
-
-	/* A temporary file stream is always opened for both reading and
-	writing in binary mode. */
-	stream->openmode_ = JAS_STREAM_READ | JAS_STREAM_WRITE | JAS_STREAM_BINARY;
-
-	/* Allocate memory for the underlying temporary file object. */
-	if (!(obj = jas_malloc(sizeof(jas_stream_fileobj_t)))) {
-		jas_stream_destroy(stream);
-		return 0;
-	}
-	obj->fd = -1;
-	obj->flags = 0;
-	obj->pathname[0] = '\0';
-	stream->obj_ = obj;
-
-	/* Create the temporary file. */
-	if ((obj->fd = easy_mkstemp(obj->pathname, sizeof(obj->pathname))) < 0) {
-		jas_stream_destroy(stream);
-		return 0;
-	}
-
-	/* Unlink the file so that it will disappear if the program
-	terminates abnormally. */
-	/* Under UNIX, one can unlink an open file and continue to do I/O
-	on it.  Not all operating systems support this functionality, however.
-	For example, under Microsoft Windows the unlink operation will fail,
-	since the file is open. */
-	if (*obj->pathname != 0 && remove(obj->pathname) < 0) {
-		/* We will try unlinking the file again after it is closed. */
-		obj->flags |= JAS_STREAM_FILEOBJ_DELONCLOSE;
-	}
-
-	/* Use full buffering. */
-	jas_stream_initbuf(stream, JAS_STREAM_FULLBUF, 0, 0);
-
-	stream->ops_ = &jas_stream_fileops;
-
-	return stream;
-}
-
 jas_stream_t *jas_stream_fdopen(int fd, const char *mode)
 {
 	jas_stream_t *stream;
@@ -552,7 +362,6 @@
 	}
 	obj->fd = fd;
 	obj->flags = 0;
-	obj->pathname[0] = '\0';
 	stream->obj_ = (void *) obj;
 
 	/* Do not close the underlying file descriptor when the stream is
@@ -761,7 +570,7 @@
 	int ret;
 
 	va_start(ap, fmt);
-	ret = vsnprintf(buf, sizeof buf, fmt, ap);
+	ret = vsnprint(buf, sizeof buf, fmt, ap);
 	jas_stream_puts(stream, buf);
 	va_end(ap);
 	return ret;
@@ -811,7 +620,8 @@
 	JAS_DBGLOG(100, ("jas_stream_gobble(%p, %d)\n", stream, n));
 
 	if (n < 0) {
-		jas_deprecated("negative count for jas_stream_gobble");
+		jas_eprintf("negative count for jas_stream_gobble\n");
+		return 0;
 	}
 	for (m = n; m > 0; --m) {
 		if (jas_stream_getc(stream) == EOF) {
@@ -829,7 +639,8 @@
 	JAS_DBGLOG(100, ("jas_stream_pad(%p, %d, %d)\n", stream, n, c));
 
 	if (n < 0) {
-		jas_deprecated("negative count for jas_stream_pad");
+		jas_eprintf("negative count for jas_stream_pad\n");
+		return 0;
 	}
 	for (m = n; m > 0; --m) {
 		if (jas_stream_putc(stream, c) == EOF)
@@ -847,7 +658,7 @@
 	if (stream->ops_ == &jas_stream_memops) {
 		return 1;
 	} else if (stream->ops_ == &jas_stream_fileops) {
-		if ((*stream->ops_->seek_)(stream->obj_, 0, SEEK_CUR) < 0) {
+		if ((*stream->ops_->seek_)(stream->obj_, 0, 1) < 0) {
 			return 0;
 		}
 		return 1;
@@ -859,7 +670,7 @@
 int jas_stream_rewind(jas_stream_t *stream)
 {
 	JAS_DBGLOG(100, ("jas_stream_rewind(%p)\n", stream));
-	return jas_stream_seek(stream, 0, SEEK_SET);
+	return jas_stream_seek(stream, 0, 0);
 }
 
 long jas_stream_seek(jas_stream_t *stream, long offset, int origin)
@@ -877,7 +688,7 @@
 	stream->flags_ &= ~JAS_STREAM_EOF;
 
 	if (stream->bufmode_ & JAS_STREAM_RDBUF) {
-		if (origin == SEEK_CUR) {
+		if (origin == 1) {
 			offset -= stream->cnt_;
 		}
 	} else if (stream->bufmode_ & JAS_STREAM_WRBUF) {
@@ -912,7 +723,7 @@
 		adjust = 0;
 	}
 
-	if ((offset = (*stream->ops_->seek_)(stream->obj_, 0, SEEK_CUR)) < 0) {
+	if ((offset = (*stream->ops_->seek_)(stream->obj_, 0, 1)) < 0) {
 		return -1;
 	}
 
@@ -1144,58 +955,6 @@
 	return old;
 }
 
-/* FIXME integral type */
-int jas_stream_display(jas_stream_t *stream, FILE *fp, int n)
-{
-	unsigned char buf[16];
-	int i;
-	int j;
-	int m;
-	int c;
-	int display;
-	int cnt;
-
-	cnt = n - (n % 16);
-	display = 1;
-
-	for (i = 0; i < n; i += 16) {
-		if (n > 16 && i > 0) {
-			display = (i >= cnt) ? 1 : 0;
-		}
-		if (display) {
-			fprintf(fp, "%08x:", i);
-		}
-		m = JAS_MIN(n - i, 16);
-		for (j = 0; j < m; ++j) {
-			if ((c = jas_stream_getc(stream)) == EOF) {
-				abort();
-				return -1;
-			}
-			buf[j] = c;
-		}
-		if (display) {
-			for (j = 0; j < m; ++j) {
-				fprintf(fp, " %02x", buf[j]);
-			}
-			fputc(' ', fp);
-			for (; j < 16; ++j) {
-				fprintf(fp, "   ");
-			}
-			for (j = 0; j < m; ++j) {
-				if (isprint(buf[j])) {
-					fputc(buf[j], fp);
-				} else {
-					fputc(' ', fp);
-				}
-			}
-			fprintf(fp, "\n");
-		}
-
-
-	}
-	return 0;
-}
-
 long jas_stream_length(jas_stream_t *stream)
 {
 	long oldpos;
@@ -1203,13 +962,13 @@
 	if ((oldpos = jas_stream_tell(stream)) < 0) {
 		return -1;
 	}
-	if (jas_stream_seek(stream, 0, SEEK_END) < 0) {
+	if (jas_stream_seek(stream, 0, 2) < 0) {
 		return -1;
 	}
 	if ((pos = jas_stream_tell(stream)) < 0) {
 		return -1;
 	}
-	if (jas_stream_seek(stream, oldpos, SEEK_SET) < 0) {
+	if (jas_stream_seek(stream, oldpos, 0) < 0) {
 		return -1;
 	}
 	return pos;
@@ -1321,13 +1080,13 @@
 
 	JAS_DBGLOG(100, ("mem_seek(%p, %ld, %d)\n", obj, offset, origin));
 	switch (origin) {
-	case SEEK_SET:
+	case 0:
 		newpos = offset;
 		break;
-	case SEEK_END:
+	case 2:
 		newpos = m->len_ - offset;
 		break;
-	case SEEK_CUR:
+	case 1:
 		newpos = m->pos_ + offset;
 		break;
 	default:
@@ -1395,60 +1154,6 @@
 	JAS_DBGLOG(100, ("file_close(%p)\n", obj));
 	fileobj = JAS_CAST(jas_stream_fileobj_t *, obj);
 	ret = close(fileobj->fd);
-	if (fileobj->flags & JAS_STREAM_FILEOBJ_DELONCLOSE) {
-		remove(fileobj->pathname);
-	}
 	jas_free(fileobj);
 	return ret;
-}
-
-/******************************************************************************\
-* Stdio file stream object.
-\******************************************************************************/
-
-/* FIXME integral type */
-static int sfile_read(jas_stream_obj_t *obj, char *buf, unsigned cnt)
-{
-	FILE *fp;
-	size_t n;
-	int result;
-	JAS_DBGLOG(100, ("sfile_read(%p, %p, %u)\n", obj, buf, cnt));
-	fp = JAS_CAST(FILE *, obj);
-	n = fread(buf, 1, cnt, fp);
-	if (n != cnt) {
-		result = (!ferror(fp) && feof(fp)) ? 0 : -1;
-		if(result != 0) {
-			return result;
-		}
-	}
-	result = JAS_CAST(int, n);
-	return result;
-}
-
-/* FIXME integral type */
-static int sfile_write(jas_stream_obj_t *obj, const char *buf, unsigned cnt)
-{
-	FILE *fp;
-	size_t n;
-	JAS_DBGLOG(100, ("sfile_write(%p, %p, %d)\n", obj, buf, cnt));
-	fp = JAS_CAST(FILE *, obj);
-	n = fwrite(buf, 1, cnt, fp);
-	return (n != cnt) ? (-1) : (int)cnt;
-}
-
-/* FIXME integral type */
-static long sfile_seek(jas_stream_obj_t *obj, long offset, int origin)
-{
-	FILE *fp;
-	JAS_DBGLOG(100, ("sfile_seek(%p, %ld, %d)\n", obj, offset, origin));
-	fp = JAS_CAST(FILE *, obj);
-	return fseek(fp, offset, origin);
-}
-
-static int sfile_close(jas_stream_obj_t *obj)
-{
-	FILE *fp;
-	JAS_DBGLOG(100, ("sfile_close(%p)\n", obj));
-	fp = JAS_CAST(FILE *, obj);
-	return fclose(fp);
 }
--- a/jas_string.c
+++ /dev/null
@@ -1,94 +1,0 @@
-/*
- * Copyright (c) 1999-2000 Image Power, Inc. and the University of
- *   British Columbia.
- * Copyright (c) 2001-2002 Michael David Adams.
- * All rights reserved.
- */
-
-/* __START_OF_JASPER_LICENSE__
- * 
- * JasPer License Version 2.0
- * 
- * Copyright (c) 2001-2006 Michael David Adams
- * Copyright (c) 1999-2000 Image Power, Inc.
- * Copyright (c) 1999-2000 The University of British Columbia
- * 
- * All rights reserved.
- * 
- * Permission is hereby granted, free of charge, to any person (the
- * "User") obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, and/or sell copies of the Software, and to permit
- * persons to whom the Software is furnished to do so, subject to the
- * following conditions:
- * 
- * 1.  The above copyright notices and this permission notice (which
- * includes the disclaimer below) shall be included in all copies or
- * substantial portions of the Software.
- * 
- * 2.  The name of a copyright holder shall not be used to endorse or
- * promote products derived from the Software without specific prior
- * written permission.
- * 
- * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS
- * LICENSE.  NO USE OF THE SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
- * THIS DISCLAIMER.  THE SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
- * "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
- * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.  IN NO
- * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
- * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
- * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
- * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.  NO ASSURANCES ARE
- * PROVIDED BY THE COPYRIGHT HOLDERS THAT THE SOFTWARE DOES NOT INFRINGE
- * THE PATENT OR OTHER INTELLECTUAL PROPERTY RIGHTS OF ANY OTHER ENTITY.
- * EACH COPYRIGHT HOLDER DISCLAIMS ANY LIABILITY TO THE USER FOR CLAIMS
- * BROUGHT BY ANY OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL
- * PROPERTY RIGHTS OR OTHERWISE.  AS A CONDITION TO EXERCISING THE RIGHTS
- * GRANTED HEREUNDER, EACH USER HEREBY ASSUMES SOLE RESPONSIBILITY TO SECURE
- * ANY OTHER INTELLECTUAL PROPERTY RIGHTS NEEDED, IF ANY.  THE SOFTWARE
- * IS NOT FAULT-TOLERANT AND IS NOT INTENDED FOR USE IN MISSION-CRITICAL
- * SYSTEMS, SUCH AS THOSE USED IN THE OPERATION OF NUCLEAR FACILITIES,
- * AIRCRAFT NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL
- * SYSTEMS, DIRECT LIFE SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH
- * THE FAILURE OF THE SOFTWARE OR SYSTEM COULD LEAD DIRECTLY TO DEATH,
- * PERSONAL INJURY, OR SEVERE PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH
- * RISK ACTIVITIES").  THE COPYRIGHT HOLDERS SPECIFICALLY DISCLAIM ANY
- * EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR HIGH RISK ACTIVITIES.
- * 
- * __END_OF_JASPER_LICENSE__
- */
-
-/*
- * String Library
- *
- * $Id$
- */
-
-/******************************************************************************\
-* Includes
-\******************************************************************************/
-
-#include "jasper/jas_string.h"
-#include "jasper/jas_malloc.h"
-
-/******************************************************************************\
-* Miscellaneous Functions
-\******************************************************************************/
-
-/* This function is equivalent to the popular but non-standard (and
-  not-always-available) strdup function. */
-
-char *jas_strdup(const char *s)
-{
-	size_t n;
-	char *p;
-	n = strlen(s) + 1;
-	if (!(p = jas_malloc(n))) {
-		return 0;
-	}
-	strcpy(p, s);
-	return p;
-}
--- a/jasper/jas_cm.h
+++ b/jasper/jas_cm.h
@@ -162,7 +162,6 @@
 typedef struct {
 	void (*destroy)(struct jas_cmpxform_s *pxform);
 	int (*apply)(const struct jas_cmpxform_s *pxform, const jas_cmreal_t *in, jas_cmreal_t *out, unsigned  cnt);
-	void (*dump)(struct jas_cmpxform_s *pxform);
 } jas_cmpxformops_t;
 
 typedef struct {
--- a/jasper/jas_config.h
+++ b/jasper/jas_config.h
@@ -3,7 +3,6 @@
 
 #include <u.h>
 #include <libc.h>
-#include <stdio.h>
 #include <ctype.h>
 #include <jasper/jas_compiler.h>
 #include <jasper/jas_dll.h>
@@ -14,6 +13,7 @@
 #define JAS_INCLUDE_JPC_CODEC 1
 #define JAS_DEC_DEFAULT_MAX_SAMPLES (64 * ((size_t) 1048576))
 #define NDEBUG
+#define NULL nil
 
 typedef usize size_t;
 
--- a/jasper/jas_debug.h
+++ b/jasper/jas_debug.h
@@ -101,12 +101,6 @@
 /* Perform formatted output to standard error. */
 JAS_DLLEXPORT int jas_eprintf(const char *fmt, ...);
 
-/* Dump memory to a stream. */
-JAS_DLLEXPORT int jas_memdump(FILE *out, const void *data, size_t len);
-
-/* Warn about use of deprecated functionality. */
-JAS_DLLEXPORT void jas_deprecated(const char *s);
-
 /* Convert to a string literal */
 #define JAS_STRINGIFY(x) #x
 
--- a/jasper/jas_icc.h
+++ b/jasper/jas_icc.h
@@ -308,7 +308,6 @@
 	int (*output)(struct jas_iccattrval_s *, jas_stream_t *);
 //#endif
 	unsigned (*getsize)(const struct jas_iccattrval_s *);
-	void (*dump)(const struct jas_iccattrval_s *, FILE *);
 } jas_iccattrvalops_t;
 
 /* Attribute value type (type and value information). */
@@ -390,19 +389,14 @@
   jas_iccattrname_t name);
 JAS_DLLEXPORT int jas_iccprof_setattr(jas_iccprof_t *prof, jas_iccattrname_t name,
   jas_iccattrval_t *val);
-JAS_DLLEXPORT void jas_iccprof_dump(const jas_iccprof_t *prof, FILE *out);
-JAS_DLLEXPORT jas_iccprof_t *jas_iccprof_copy(const jas_iccprof_t *prof);
 JAS_DLLEXPORT int jas_iccprof_gethdr(const jas_iccprof_t *prof, jas_icchdr_t *hdr);
 JAS_DLLEXPORT int jas_iccprof_sethdr(jas_iccprof_t *prof, const jas_icchdr_t *hdr);
 
 JAS_DLLEXPORT void jas_iccattrval_destroy(jas_iccattrval_t *attrval);
-JAS_DLLEXPORT void jas_iccattrval_dump(const jas_iccattrval_t *attrval, FILE *out);
 JAS_DLLEXPORT int jas_iccattrval_allowmodify(jas_iccattrval_t **attrval);
 JAS_DLLEXPORT jas_iccattrval_t *jas_iccattrval_clone(jas_iccattrval_t *attrval);
 JAS_DLLEXPORT jas_iccattrval_t *jas_iccattrval_create(jas_iccuint32_t type);
 
-JAS_DLLEXPORT void jas_iccattrtab_dump(const jas_iccattrtab_t *attrtab, FILE *out);
-
 JAS_DLLEXPORT extern const jas_uchar jas_iccprofdata_srgb[];
 JAS_DLLEXPORT extern const unsigned jas_iccprofdata_srgblen;
 JAS_DLLEXPORT extern const jas_uchar jas_iccprofdata_sgray[];
@@ -409,6 +403,7 @@
 JAS_DLLEXPORT extern const unsigned jas_iccprofdata_sgraylen;
 JAS_DLLEXPORT jas_iccprof_t *jas_iccprof_createfrombuf(const jas_uchar *buf, unsigned len);
 JAS_DLLEXPORT jas_iccprof_t *jas_iccprof_createfromclrspc(unsigned clrspc);
+JAS_DLLEXPORT jas_iccprof_t *jas_iccprof_copy(const jas_iccprof_t *prof);
 
 #ifdef __cplusplus
 }
--- a/jasper/jas_image.h
+++ b/jasper/jas_image.h
@@ -696,11 +696,6 @@
 JAS_DLLEXPORT jas_image_t *jas_image_chclrspc(jas_image_t *image, const jas_cmprof_t *outprof,
   jas_cmxform_intent_t intent);
 
-/*!
-@brief Dump the information for an image (for debugging).
-*/
-JAS_DLLEXPORT void jas_image_dump(jas_image_t *image, FILE *out);
-
 /******************************************************************************\
 * Image format-dependent operations.
 \******************************************************************************/
--- a/jasper/jas_malloc.h
+++ b/jasper/jas_malloc.h
@@ -81,39 +81,13 @@
 extern "C" {
 #endif
 
-/******************************************************************************\
-* Functions.
-\******************************************************************************/
-
-/* Allocate memory. */
-JAS_DLLEXPORT void *jas_malloc(size_t size);
-
-/* Free memory. */
-JAS_DLLEXPORT void jas_free(void *ptr);
-
-/* Resize a block of allocated memory. */
-JAS_DLLEXPORT void *jas_realloc(void *ptr, size_t size);
-
-/* Allocate a block of memory and initialize the contents to zero. */
-JAS_DLLEXPORT void *jas_calloc(size_t num_elements, size_t element_size);
-
-/* Allocate array (with overflow checking) . */
-JAS_DLLEXPORT void *jas_alloc2(size_t num_elements, size_t element_size);
-
-/* Allocate array of arrays (with overflow checking) . */
-JAS_DLLEXPORT void *jas_alloc3(size_t num_arrays, size_t array_size, size_t element_size);
-
-/* Resize a block of allocated memory (with overflow checking) . */
-JAS_DLLEXPORT void *jas_realloc2(void *ptr, size_t num_elements, size_t element_size);
-
-#if defined(JAS_DEFAULT_MAX_MEM_USAGE)
-
-JAS_DLLEXPORT void jas_set_max_mem_usage(size_t max_mem);
-
-JAS_ATTRIBUTE_PURE
-JAS_DLLEXPORT size_t jas_get_mem_usage();
-
-#endif
+#define jas_malloc malloc
+#define jas_free free
+#define jas_realloc realloc
+#define jas_calloc calloc
+#define jas_alloc2(ne, esz) malloc(ne*esz)
+#define jas_alloc3(na, asz, esz) malloc(na*asz*esz)
+#define jas_realloc2(p, ne, esz) realloc(p, ne*esz)
 
 #ifdef __cplusplus
 }
--- a/jasper/jas_seq.h
+++ b/jasper/jas_seq.h
@@ -243,7 +243,7 @@
 /* Resize a matrix.  The previous contents of the matrix are lost. */
 JAS_DLLEXPORT int jas_matrix_resize(jas_matrix_t *matrix, jas_matind_t numrows, jas_matind_t numcols);
 
-JAS_DLLEXPORT int jas_matrix_output(jas_matrix_t *matrix, FILE *out);
+JAS_DLLEXPORT int jas_matrix_output(jas_matrix_t *matrix, int fd);
 
 /* Create a matrix that references part of another matrix. */
 JAS_DLLEXPORT int jas_matrix_bindsub(jas_matrix_t *mat0, jas_matrix_t *mat1, jas_matind_t r0,
@@ -300,7 +300,7 @@
 
 JAS_DLLEXPORT jas_matrix_t *jas_matrix_copy(jas_matrix_t *x);
 
-JAS_DLLEXPORT jas_matrix_t *jas_matrix_input(FILE *);
+JAS_DLLEXPORT jas_matrix_t *jas_matrix_input(int);
 
 JAS_ATTRIBUTE_CONST
 static inline jas_seqent_t jas_seqent_asl(jas_seqent_t x, unsigned n)
--- a/jasper/jas_stream.h
+++ b/jasper/jas_stream.h
@@ -95,6 +95,8 @@
 #define O_BINARY	0
 #endif
 
+#define EOF (-1)
+
 /*
  * Stream open flags.
  */
@@ -246,7 +248,6 @@
 typedef struct {
 	int fd;
 	int flags;
-	char pathname[L_tmpnam + 1];
 } jas_stream_fileobj_t;
 
 /* Delete underlying file object upon stream close. */
@@ -364,47 +365,6 @@
 jas_stream_t *jas_stream_fdopen(int fd, const char *mode);
 
 /*!
-@brief Open a stdio (i.e., C standard library) stream as a stream.
-
-@param path
-A pointer to a string containing the path of the filename associated
-with the stdio stream.
-@param mode
-A pointer to a string containing the open mode to be used for the
-(JasPer) stream.
-This string is similar to that used by the fdopen function in the
-C standard library.
-@param fp
-A pointer to the stdio stream.
-
-@details
-It is unspecified whether the open mode specified by mode can be
-changed from the open mode used for opening the stdio stream.
-
-@return
-Upon success, a pointer to the opened stream is returned.
-Otherwise, a null pointer is returned.
-*/
-JAS_DLLEXPORT
-jas_stream_t *jas_stream_freopen(const char *path, const char *mode, FILE *fp);
-
-/*!
-@brief Open a temporary file as a stream.
-
-@details
-A temporary file is created and opened as a stream.
-The temporary file is deleted when closed via jas_stream_close().
-Some operating systems provide a mechanism for ensuring that a file
-is removed when closed.
-Such functionality may be used by the implementation when available.
-
-@return
-Upon success, a pointer to the opened stream is returned.
-Otherwise, a null pointer is returned.
-*/
-JAS_DLLEXPORT jas_stream_t *jas_stream_tmpfile(void);
-
-/*!
 @brief Close a stream.
 
 @param stream
@@ -876,31 +836,6 @@
 TODO/FIXME: count should probably be a size_t; return type ssize_t?
 */
 JAS_DLLEXPORT int jas_stream_copy(jas_stream_t *destination, jas_stream_t *source, int count);
-
-/*!
-@brief Print a hex dump of data read from a stream.
-
-@param stream
-A pointer to the stream from which to read data.
-@param fp
-A pointer to a stdio stream (i.e., FILE) to which to print the hex dump.
-@param count
-The number of characters to include in the hex dump.
-
-@details
-This function prints a hex dump of data read from a stream to a
-stdio stream.
-This function is most likely to be useful for debugging.
-
-@return
-Upon success, 0 is returned.
-Otherwise, a negative value is returned.
-
-@todo
-TODO/FIXME: should count be unsigned int or size_t instead of int?
-*/
-JAS_DLLEXPORT
-int jas_stream_display(jas_stream_t *stream, FILE *fp, int count);
 
 /*!
 @brief Consume (i.e., discard) characters from stream.
--- a/jasper/jas_string.h
+++ /dev/null
@@ -1,94 +1,0 @@
-/*
- * Copyright (c) 1999-2000 Image Power, Inc. and the University of
- *   British Columbia.
- * Copyright (c) 2001-2002 Michael David Adams.
- * All rights reserved.
- */
-
-/* __START_OF_JASPER_LICENSE__
- * 
- * JasPer License Version 2.0
- * 
- * Copyright (c) 2001-2006 Michael David Adams
- * Copyright (c) 1999-2000 Image Power, Inc.
- * Copyright (c) 1999-2000 The University of British Columbia
- * 
- * All rights reserved.
- * 
- * Permission is hereby granted, free of charge, to any person (the
- * "User") obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, and/or sell copies of the Software, and to permit
- * persons to whom the Software is furnished to do so, subject to the
- * following conditions:
- * 
- * 1.  The above copyright notices and this permission notice (which
- * includes the disclaimer below) shall be included in all copies or
- * substantial portions of the Software.
- * 
- * 2.  The name of a copyright holder shall not be used to endorse or
- * promote products derived from the Software without specific prior
- * written permission.
- * 
- * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS
- * LICENSE.  NO USE OF THE SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
- * THIS DISCLAIMER.  THE SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
- * "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
- * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.  IN NO
- * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
- * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
- * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
- * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.  NO ASSURANCES ARE
- * PROVIDED BY THE COPYRIGHT HOLDERS THAT THE SOFTWARE DOES NOT INFRINGE
- * THE PATENT OR OTHER INTELLECTUAL PROPERTY RIGHTS OF ANY OTHER ENTITY.
- * EACH COPYRIGHT HOLDER DISCLAIMS ANY LIABILITY TO THE USER FOR CLAIMS
- * BROUGHT BY ANY OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL
- * PROPERTY RIGHTS OR OTHERWISE.  AS A CONDITION TO EXERCISING THE RIGHTS
- * GRANTED HEREUNDER, EACH USER HEREBY ASSUMES SOLE RESPONSIBILITY TO SECURE
- * ANY OTHER INTELLECTUAL PROPERTY RIGHTS NEEDED, IF ANY.  THE SOFTWARE
- * IS NOT FAULT-TOLERANT AND IS NOT INTENDED FOR USE IN MISSION-CRITICAL
- * SYSTEMS, SUCH AS THOSE USED IN THE OPERATION OF NUCLEAR FACILITIES,
- * AIRCRAFT NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL
- * SYSTEMS, DIRECT LIFE SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH
- * THE FAILURE OF THE SOFTWARE OR SYSTEM COULD LEAD DIRECTLY TO DEATH,
- * PERSONAL INJURY, OR SEVERE PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH
- * RISK ACTIVITIES").  THE COPYRIGHT HOLDERS SPECIFICALLY DISCLAIM ANY
- * EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR HIGH RISK ACTIVITIES.
- * 
- * __END_OF_JASPER_LICENSE__
- */
-
-/*!
- * @file jas_string.h
- * @brief String Library
- */
-
-#ifndef	JAS_STRING_H
-#define	JAS_STRING_H
-
-/******************************************************************************\
-* Includes.
-\******************************************************************************/
-
-/* The configuration header file should be included first. */
-#include <jasper/jas_config.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/******************************************************************************\
-* Functions.
-\******************************************************************************/
-
-/* Copy a string (a la strdup). */
-JAS_DLLEXPORT char *jas_strdup(const char *);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
--- a/jasper/jasper.h
+++ b/jasper/jasper.h
@@ -84,7 +84,6 @@
 #include <jasper/jas_malloc.h>
 #include <jasper/jas_seq.h>
 #include <jasper/jas_stream.h>
-#include <jasper/jas_string.h>
 
 #pragma lib "./libjp2.a"
 
--- a/jp2.c
+++ b/jp2.c
@@ -5,7 +5,7 @@
 static void
 usage(void)
 {
-	fprint(2, "usage: %s < FILE.jp2 > FILE.pic\n", argv0);
+	fprint(2, "usage: %s\n", argv0);
 	exits("usage");
 }
 
@@ -74,9 +74,8 @@
 			goto error;
 		}
 		for(y = 0; y < h; y++){
-			for(x = 0; x < w; x++){
+			for(x = 0; x < w; x++)
 				rgb[3*(y*w + x) + 2-i] = b[y*w + x];
-			}
 		}
 	}
 	jas_image_destroy(im);
--- a/jp2_cod.c
+++ b/jp2_cod.c
@@ -95,8 +95,6 @@
 
 static int jp2_getint(jas_stream_t *in, int s, int n, int_fast32_t *val);
 
-static void jp2_box_dump(const jp2_box_t *box, FILE *out);
-
 static int jp2_jp_getdata(jp2_box_t *box, jas_stream_t *in);
 static int jp2_jp_putdata(const jp2_box_t *box, jas_stream_t *out);
 static int jp2_ftyp_getdata(jp2_box_t *box, jas_stream_t *in);
@@ -108,20 +106,16 @@
 static int jp2_bpcc_putdata(const jp2_box_t *box, jas_stream_t *out);
 static int jp2_colr_getdata(jp2_box_t *box, jas_stream_t *in);
 static int jp2_colr_putdata(const jp2_box_t *box, jas_stream_t *out);
-static void jp2_colr_dumpdata(const jp2_box_t *box, FILE *out);
 static void jp2_colr_destroy(jp2_box_t *box);
 static void jp2_cdef_destroy(jp2_box_t *box);
 static int jp2_cdef_getdata(jp2_box_t *box, jas_stream_t *in);
 static int jp2_cdef_putdata(const jp2_box_t *box, jas_stream_t *out);
-static void jp2_cdef_dumpdata(const jp2_box_t *box, FILE *out);
 static void jp2_cmap_destroy(jp2_box_t *box);
 static int jp2_cmap_getdata(jp2_box_t *box, jas_stream_t *in);
 static int jp2_cmap_putdata(const jp2_box_t *box, jas_stream_t *out);
-static void jp2_cmap_dumpdata(const jp2_box_t *box, FILE *out);
 static void jp2_pclr_destroy(jp2_box_t *box);
 static int jp2_pclr_getdata(jp2_box_t *box, jas_stream_t *in);
 static int jp2_pclr_putdata(const jp2_box_t *box, jas_stream_t *out);
-static void jp2_pclr_dumpdata(const jp2_box_t *box, FILE *out);
 
 /******************************************************************************\
 * Local data.
@@ -128,49 +122,30 @@
 \******************************************************************************/
 
 static const jp2_boxinfo_t jp2_boxinfos[] = {
-	{JP2_BOX_JP, 0, "JP",
-	  {0, 0, jp2_jp_getdata, jp2_jp_putdata, 0}},
-	{JP2_BOX_FTYP, 0, "FTYP",
-	  {0, 0, jp2_ftyp_getdata, jp2_ftyp_putdata, 0}},
-	{JP2_BOX_JP2H, JP2_BOX_SUPER, "JP2H",
-	  {0, 0, 0, 0, 0}},
-	{JP2_BOX_IHDR, 0, "IHDR",
-	  {0, 0, jp2_ihdr_getdata, jp2_ihdr_putdata, 0}},
-	{JP2_BOX_BPCC, 0, "BPCC",
-	  {0, jp2_bpcc_destroy, jp2_bpcc_getdata, jp2_bpcc_putdata, 0}},
-	{JP2_BOX_COLR, 0, "COLR",
-	  {0, jp2_colr_destroy, jp2_colr_getdata, jp2_colr_putdata, jp2_colr_dumpdata}},
-	{JP2_BOX_PCLR, 0, "PCLR",
-	  {0, jp2_pclr_destroy, jp2_pclr_getdata, jp2_pclr_putdata, jp2_pclr_dumpdata}},
-	{JP2_BOX_CMAP, 0, "CMAP",
-	  {0, jp2_cmap_destroy, jp2_cmap_getdata, jp2_cmap_putdata, jp2_cmap_dumpdata}},
-	{JP2_BOX_CDEF, 0, "CDEF",
-	  {0, jp2_cdef_destroy, jp2_cdef_getdata, jp2_cdef_putdata, jp2_cdef_dumpdata}},
-	{JP2_BOX_RES, JP2_BOX_SUPER, "RES",
-	  {0, 0, 0, 0, 0}},
-	{JP2_BOX_RESC, 0, "RESC",
-	  {0, 0, 0, 0, 0}},
-	{JP2_BOX_RESD, 0, "RESD",
-	  {0, 0, 0, 0, 0}},
-	{JP2_BOX_JP2C, JP2_BOX_NODATA, "JP2C",
-	  {0, 0, 0, 0, 0}},
-	{JP2_BOX_JP2I, 0, "JP2I",
-	  {0, 0, 0, 0, 0}},
-	{JP2_BOX_XML, 0, "XML",
-	  {0, 0, 0, 0, 0}},
-	{JP2_BOX_UUID, 0, "UUID",
-	  {0, 0, 0, 0, 0}},
-	{JP2_BOX_UINF, JP2_BOX_SUPER, "UINF",
-	  {0, 0, 0, 0, 0}},
-	{JP2_BOX_ULST, 0, "ULST",
-	  {0, 0, 0, 0, 0}},
-	{JP2_BOX_URL, 0, "URL",
-	  {0, 0, 0, 0, 0}},
-	{0, 0, 0, {0, 0, 0, 0, 0}},
+	{JP2_BOX_JP, 0, "JP", {0, 0, jp2_jp_getdata, jp2_jp_putdata}},
+	{JP2_BOX_FTYP, 0, "FTYP", {0, 0, jp2_ftyp_getdata, jp2_ftyp_putdata}},
+	{JP2_BOX_JP2H, JP2_BOX_SUPER, "JP2H", {0, 0, 0, 0}},
+	{JP2_BOX_IHDR, 0, "IHDR", {0, 0, jp2_ihdr_getdata, jp2_ihdr_putdata}},
+	{JP2_BOX_BPCC, 0, "BPCC", {0, jp2_bpcc_destroy, jp2_bpcc_getdata, jp2_bpcc_putdata}},
+	{JP2_BOX_COLR, 0, "COLR", {0, jp2_colr_destroy, jp2_colr_getdata, jp2_colr_putdata}},
+	{JP2_BOX_PCLR, 0, "PCLR", {0, jp2_pclr_destroy, jp2_pclr_getdata, jp2_pclr_putdata}},
+	{JP2_BOX_CMAP, 0, "CMAP", {0, jp2_cmap_destroy, jp2_cmap_getdata, jp2_cmap_putdata}},
+	{JP2_BOX_CDEF, 0, "CDEF", {0, jp2_cdef_destroy, jp2_cdef_getdata, jp2_cdef_putdata}},
+	{JP2_BOX_RES, JP2_BOX_SUPER, "RES", {0, 0, 0, 0}},
+	{JP2_BOX_RESC, 0, "RESC", {0, 0, 0, 0}},
+	{JP2_BOX_RESD, 0, "RESD", {0, 0, 0, 0}},
+	{JP2_BOX_JP2C, JP2_BOX_NODATA, "JP2C", {0, 0, 0, 0}},
+	{JP2_BOX_JP2I, 0, "JP2I", {0, 0, 0, 0}},
+	{JP2_BOX_XML, 0, "XML", {0, 0, 0, 0}},
+	{JP2_BOX_UUID, 0, "UUID", {0, 0, 0, 0}},
+	{JP2_BOX_UINF, JP2_BOX_SUPER, "UINF", {0, 0, 0, 0}},
+	{JP2_BOX_ULST, 0, "ULST", {0, 0, 0, 0}},
+	{JP2_BOX_URL, 0, "URL", {0, 0, 0, 0}},
+	{0, 0, 0, {0, 0, 0, 0}},
 };
 
 static const jp2_boxinfo_t jp2_boxinfo_unk = {
-	0, 0, "Unknown", {0, 0, 0, 0, 0}
+	0, 0, "Unknown", {0, 0, 0, 0}
 };
 
 /******************************************************************************\
@@ -323,10 +298,6 @@
 		jas_stream_close(tmpstream);
 	}
 
-	if (jas_getdbglevel() >= 1) {
-		jp2_box_dump(box, stderr);
-	}
-
 	return box;
 
 error:
@@ -339,19 +310,6 @@
 	return 0;
 }
 
-static void jp2_box_dump(const jp2_box_t *box, FILE *out)
-{
-	const jp2_boxinfo_t *boxinfo = box->info;
-	assert(boxinfo);
-
-	fprintf(out, "JP2 box: ");
-	fprintf(out, "type=%c%s%c (0x%08"PRIxFAST32"); length=%"PRIuFAST32"\n", '"',
-	  boxinfo->name, '"', box->type, box->len);
-	if (box->ops->dumpdata) {
-		(*box->ops->dumpdata)(box, out);
-	}
-}
-
 static int jp2_jp_getdata(jp2_box_t *box, jas_stream_t *in)
 {
 	jp2_jp_t *jp = &box->data.jp;
@@ -418,20 +376,6 @@
 	return 0;
 }
 
-static void jp2_colr_dumpdata(const jp2_box_t *box, FILE *out)
-{
-	const jp2_colr_t *colr = &box->data.colr;
-	fprintf(out, "method=%d; pri=%d; approx=%d\n", (int)colr->method, (int)colr->pri, (int)colr->approx);
-	switch (colr->method) {
-	case JP2_COLR_ENUM:
-		fprintf(out, "csid=%d\n", (int)colr->csid);
-		break;
-	case JP2_COLR_ICC:
-		jas_memdump(out, colr->iccp, colr->iccplen);
-		break;
-	}
-}
-
 static int jp2_colr_getdata(jp2_box_t *box, jas_stream_t *in)
 {
 	if (box->datalen < 3)
@@ -472,17 +416,6 @@
 	return 0;
 }
 
-static void jp2_cdef_dumpdata(const jp2_box_t *box, FILE *out)
-{
-	const jp2_cdef_t *cdef = &box->data.cdef;
-	unsigned int i;
-	for (i = 0; i < cdef->numchans; ++i) {
-		fprintf(out,
-		  "channo=%"PRIuFAST16"; type=%"PRIuFAST16"; assoc=%"PRIuFAST16"\n",
-		  cdef->ents[i].channo, cdef->ents[i].type, cdef->ents[i].assoc);
-	}
-}
-
 static void jp2_colr_destroy(jp2_box_t *box)
 {
 	jp2_colr_t *colr = &box->data.colr;
@@ -820,18 +753,6 @@
 	return -1;
 }
 
-static void jp2_cmap_dumpdata(const jp2_box_t *box, FILE *out)
-{
-	const jp2_cmap_t *cmap = &box->data.cmap;
-	unsigned int i;
-	fprintf(out, "numchans = %d\n", (int) cmap->numchans);
-	for (i = 0; i < cmap->numchans; ++i) {
-		const jp2_cmapent_t *ent = &cmap->ents[i];
-		fprintf(out, "cmptno=%d; map=%d; pcol=%d\n",
-		  (int) ent->cmptno, (int) ent->map, (int) ent->pcol);
-	}
-}
-
 static void jp2_pclr_destroy(jp2_box_t *box)
 {
 	jp2_pclr_t *pclr = &box->data.pclr;
@@ -896,21 +817,6 @@
 	USED(box);
 	USED(out);
 	return -1;
-}
-
-static void jp2_pclr_dumpdata(const jp2_box_t *box, FILE *out)
-{
-	const jp2_pclr_t *pclr = &box->data.pclr;
-	unsigned int i;
-	int j;
-	fprintf(out, "numents=%d; numchans=%d\n", (int) pclr->numlutents,
-	  (int) pclr->numchans);
-	for (i = 0; i < pclr->numlutents; ++i) {
-		for (j = 0; j < pclr->numchans; ++j) {
-			fprintf(out, "LUT[%d][%d]=%"PRIiFAST32"\n", i, j,
-			  pclr->lutdata[i * pclr->numchans + j]);
-		}
-	}
 }
 
 static int jp2_getint(jas_stream_t *in, int s, int n, int_fast32_t *val)
--- a/jp2_cod.h
+++ b/jp2_cod.h
@@ -268,7 +268,6 @@
 	void (*destroy)(jp2_box_t *box);
 	int (*getdata)(jp2_box_t *box, jas_stream_t *in);
 	int (*putdata)(const jp2_box_t *box, jas_stream_t *out);
-	void (*dumpdata)(const jp2_box_t *box, FILE *out);
 } jp2_boxops_t;
 
 /******************************************************************************\
--- a/jpc_cs.c
+++ b/jpc_cs.c
@@ -94,7 +94,6 @@
 
 static const jpc_mstabent_t *jpc_mstab_lookup(int id);
 
-static int jpc_poc_dumpparms(jpc_ms_t *ms, FILE *out);
 static int jpc_poc_putparms(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *out);
 static int jpc_poc_getparms(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *in);
 static void jpc_poc_destroyparms(jpc_ms_t *ms);
@@ -127,20 +126,6 @@
 static int jpc_crg_putparms(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *out);
 static int jpc_com_putparms(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *out);
 
-static int jpc_sot_dumpparms(jpc_ms_t *ms, FILE *out);
-static int jpc_siz_dumpparms(jpc_ms_t *ms, FILE *out);
-static int jpc_cod_dumpparms(jpc_ms_t *ms, FILE *out);
-static int jpc_coc_dumpparms(jpc_ms_t *ms, FILE *out);
-static int jpc_qcd_dumpparms(jpc_ms_t *ms, FILE *out);
-static int jpc_qcc_dumpparms(jpc_ms_t *ms, FILE *out);
-static int jpc_rgn_dumpparms(jpc_ms_t *ms, FILE *out);
-static int jpc_unk_dumpparms(jpc_ms_t *ms, FILE *out);
-static int jpc_sop_dumpparms(jpc_ms_t *ms, FILE *out);
-static int jpc_ppm_dumpparms(jpc_ms_t *ms, FILE *out);
-static int jpc_ppt_dumpparms(jpc_ms_t *ms, FILE *out);
-static int jpc_crg_dumpparms(jpc_ms_t *ms, FILE *out);
-static int jpc_com_dumpparms(jpc_ms_t *ms, FILE *out);
-
 static void jpc_siz_destroyparms(jpc_ms_t *ms);
 static void jpc_qcd_destroyparms(jpc_ms_t *ms);
 static void jpc_qcc_destroyparms(jpc_ms_t *ms);
@@ -168,40 +153,26 @@
 \******************************************************************************/
 
 static const jpc_mstabent_t jpc_mstab[] = {
-	{JPC_MS_SOC, "SOC", {0, 0, 0, 0}},
-	{JPC_MS_SOT, "SOT", {0, jpc_sot_getparms, jpc_sot_putparms,
-	  jpc_sot_dumpparms}},
-	{JPC_MS_SOD, "SOD", {0, 0, 0, 0}},
-	{JPC_MS_EOC, "EOC", {0, 0, 0, 0}},
-	{JPC_MS_SIZ, "SIZ", {jpc_siz_destroyparms, jpc_siz_getparms,
-	  jpc_siz_putparms, jpc_siz_dumpparms}},
-	{JPC_MS_COD, "COD", {jpc_cod_destroyparms, jpc_cod_getparms,
-	  jpc_cod_putparms, jpc_cod_dumpparms}},
-	{JPC_MS_COC, "COC", {jpc_coc_destroyparms, jpc_coc_getparms,
-	  jpc_coc_putparms, jpc_coc_dumpparms}},
-	{JPC_MS_RGN, "RGN", {0, jpc_rgn_getparms, jpc_rgn_putparms,
-	  jpc_rgn_dumpparms}},
-	{JPC_MS_QCD, "QCD", {jpc_qcd_destroyparms, jpc_qcd_getparms,
-	  jpc_qcd_putparms, jpc_qcd_dumpparms}},
-	{JPC_MS_QCC, "QCC", {jpc_qcc_destroyparms, jpc_qcc_getparms,
-	  jpc_qcc_putparms, jpc_qcc_dumpparms}},
-	{JPC_MS_POC, "POC", {jpc_poc_destroyparms, jpc_poc_getparms,
-	  jpc_poc_putparms, jpc_poc_dumpparms}},
-	{JPC_MS_TLM, "TLM", {jpc_unk_destroyparms, jpc_unk_getparms, jpc_unk_putparms, 0}},
-	{JPC_MS_PLM, "PLM", {jpc_unk_destroyparms, jpc_unk_getparms, jpc_unk_putparms, 0}},
-	{JPC_MS_PPM, "PPM", {jpc_ppm_destroyparms, jpc_ppm_getparms,
-	  jpc_ppm_putparms, jpc_ppm_dumpparms}},
-	{JPC_MS_PPT, "PPT", {jpc_ppt_destroyparms, jpc_ppt_getparms,
-	  jpc_ppt_putparms, jpc_ppt_dumpparms}},
-	{JPC_MS_SOP, "SOP", {0, jpc_sop_getparms, jpc_sop_putparms,
-	  jpc_sop_dumpparms}},
-	{JPC_MS_EPH, "EPH", {0, 0, 0, 0}},
-	{JPC_MS_CRG, "CRG", {jpc_crg_destroyparms, jpc_crg_getparms,
-	  jpc_crg_putparms, jpc_crg_dumpparms}},
-	{JPC_MS_COM, "COM", {jpc_com_destroyparms, jpc_com_getparms,
-	  jpc_com_putparms, jpc_com_dumpparms}},
-	{-1, "UNKNOWN",  {jpc_unk_destroyparms, jpc_unk_getparms,
-	  jpc_unk_putparms, jpc_unk_dumpparms}}
+	{JPC_MS_SOC, "SOC", {0, 0, 0}},
+	{JPC_MS_SOT, "SOT", {0, jpc_sot_getparms, jpc_sot_putparms}},
+	{JPC_MS_SOD, "SOD", {0, 0, 0}},
+	{JPC_MS_EOC, "EOC", {0, 0, 0}},
+	{JPC_MS_SIZ, "SIZ", {jpc_siz_destroyparms, jpc_siz_getparms, jpc_siz_putparms}},
+	{JPC_MS_COD, "COD", {jpc_cod_destroyparms, jpc_cod_getparms, jpc_cod_putparms}},
+	{JPC_MS_COC, "COC", {jpc_coc_destroyparms, jpc_coc_getparms, jpc_coc_putparms}},
+	{JPC_MS_RGN, "RGN", {0, jpc_rgn_getparms, jpc_rgn_putparms}},
+	{JPC_MS_QCD, "QCD", {jpc_qcd_destroyparms, jpc_qcd_getparms, jpc_qcd_putparms}},
+	{JPC_MS_QCC, "QCC", {jpc_qcc_destroyparms, jpc_qcc_getparms, jpc_qcc_putparms}},
+	{JPC_MS_POC, "POC", {jpc_poc_destroyparms, jpc_poc_getparms, jpc_poc_putparms}},
+	{JPC_MS_TLM, "TLM", {jpc_unk_destroyparms, jpc_unk_getparms, jpc_unk_putparms,}},
+	{JPC_MS_PLM, "PLM", {jpc_unk_destroyparms, jpc_unk_getparms, jpc_unk_putparms}},
+	{JPC_MS_PPM, "PPM", {jpc_ppm_destroyparms, jpc_ppm_getparms, jpc_ppm_putparms}},
+	{JPC_MS_PPT, "PPT", {jpc_ppt_destroyparms, jpc_ppt_getparms, jpc_ppt_putparms}},
+	{JPC_MS_SOP, "SOP", {0, jpc_sop_getparms, jpc_sop_putparms}},
+	{JPC_MS_EPH, "EPH", {0, 0, 0}},
+	{JPC_MS_CRG, "CRG", {jpc_crg_destroyparms, jpc_crg_getparms, jpc_crg_putparms}},
+	{JPC_MS_COM, "COM", {jpc_com_destroyparms, jpc_com_getparms, jpc_com_putparms}},
+	{-1, "UNKNOWN",  {jpc_unk_destroyparms, jpc_unk_getparms, jpc_unk_putparms}}
 };
 
 /******************************************************************************\
@@ -267,7 +238,7 @@
 			return 0;
 		}
 		if (jas_stream_copy(tmpstream, in, ms->len) ||
-		  jas_stream_seek(tmpstream, 0, SEEK_SET) < 0) {
+		  jas_stream_seek(tmpstream, 0, 0) < 0) {
 			jas_stream_close(tmpstream);
 			jpc_ms_destroy(ms);
 			return 0;
@@ -280,10 +251,6 @@
 			return 0;
 		}
 
-		if (jas_getdbglevel() > 0) {
-			jpc_ms_dump(ms, stderr);
-		}
-
 		if (JAS_CAST(jas_ulong, jas_stream_tell(tmpstream)) != ms->len) {
 			jas_eprintf(
 			  "warning: trailing garbage in marker segment (%ld bytes)\n",
@@ -296,10 +263,6 @@
 	} else {
 		/* There are no marker segment parameters. */
 		ms->len = 0;
-
-		if (jas_getdbglevel() > 0) {
-			jpc_ms_dump(ms, stderr);
-		}
 	}
 
 	/* Update the code stream state information based on the type of
@@ -343,7 +306,7 @@
 		ms->len = len;
 		/* Write the marker segment length and parameter data to
 		  the output stream. */
-		if (jas_stream_seek(tmpstream, 0, SEEK_SET) < 0 ||
+		if (jas_stream_seek(tmpstream, 0, 0) < 0 ||
 		  jpc_putuint16(out, ms->len + 2) ||
 		  jas_stream_copy(out, tmpstream, ms->len) < 0) {
 			jas_stream_close(tmpstream);
@@ -359,10 +322,6 @@
 		cstate->numcomps = ms->parms.siz.numcomps;
 	}
 
-	if (jas_getdbglevel() > 0) {
-		jpc_ms_dump(ms, stderr);
-	}
-
 	return 0;
 }
 
@@ -396,24 +355,6 @@
 	jas_free(ms);
 }
 
-/* Dump a marker segment to a stream for debugging. */
-void jpc_ms_dump(jpc_ms_t *ms, FILE *out)
-{
-	const jpc_mstabent_t *mstabent;
-	mstabent = jpc_mstab_lookup(ms->id);
-	fprintf(out, "type = 0x%04"PRIxFAST16" (%s);", ms->id, mstabent->name);
-	if (JPC_MS_HASPARMS(ms->id)) {
-		fprintf(out, " len = %"PRIuFAST16";", ms->len + 2);
-		if (ms->ops->dumpparms) {
-			(*ms->ops->dumpparms)(ms, out);
-		} else {
-			fprintf(out, "\n");
-		}
-	} else {
-		fprintf(out, "\n");
-	}
-}
-
 /******************************************************************************\
 * SOT marker segment operations.
 \******************************************************************************/
@@ -456,15 +397,6 @@
 	return 0;
 }
 
-static int jpc_sot_dumpparms(jpc_ms_t *ms, FILE *out)
-{
-	jpc_sot_t *sot = &ms->parms.sot;
-	fprintf(out,
-	  "tileno = %"PRIuFAST16"; len = %"PRIuFAST32"; partno = %d; numparts = %d\n",
-	  sot->tileno, sot->len, sot->partno, sot->numparts);
-	return 0;
-}
-
 /******************************************************************************\
 * SIZ marker segment operations.
 \******************************************************************************/
@@ -602,26 +534,6 @@
 	return 0;
 }
 
-static int jpc_siz_dumpparms(jpc_ms_t *ms, FILE *out)
-{
-	jpc_siz_t *siz = &ms->parms.siz;
-	unsigned int i;
-	fprintf(out, "caps = 0x%02"PRIxFAST16";\n", siz->caps);
-	fprintf(out, "width = %"PRIuFAST32"; height = %"PRIuFAST32"; xoff = %"PRIuFAST32"; yoff = %" PRIuFAST32 ";\n",
-	  siz->width, siz->height, siz->xoff, siz->yoff);
-	fprintf(out, "tilewidth = %"PRIuFAST32"; tileheight = %"PRIuFAST32"; "
-	  "tilexoff = %"PRIuFAST32"; tileyoff = %" PRIuFAST32 ";\n",
-	  siz->tilewidth, siz->tileheight, siz->tilexoff, siz->tileyoff);
-	fprintf(out, "numcomps = %"PRIuFAST16";\n", siz->numcomps);
-	for (i = 0; i < siz->numcomps; ++i) {
-		fprintf(out, "prec[%d] = %d; sgnd[%d] = %d; hsamp[%d] = %d; "
-		  "vsamp[%d] = %d\n", i, siz->comps[i].prec, i,
-		  siz->comps[i].sgnd, i, siz->comps[i].hsamp, i,
-		  siz->comps[i].vsamp);
-	}
-	return 0;
-}
-
 /******************************************************************************\
 * COD marker segment operations.
 \******************************************************************************/
@@ -675,28 +587,6 @@
 	return 0;
 }
 
-static int jpc_cod_dumpparms(jpc_ms_t *ms, FILE *out)
-{
-	jpc_cod_t *cod = &ms->parms.cod;
-	int i;
-	fprintf(out, "csty = 0x%02x;\n", cod->compparms.csty);
-	fprintf(out, "numdlvls = %d; qmfbid = %d; mctrans = %d\n",
-	  cod->compparms.numdlvls, cod->compparms.qmfbid, cod->mctrans);
-	fprintf(out, "prg = %d; numlyrs = %"PRIuFAST16";\n",
-	  cod->prg, cod->numlyrs);
-	fprintf(out, "cblkwidthval = %d; cblkheightval = %d; "
-	  "cblksty = 0x%02x;\n", cod->compparms.cblkwidthval, cod->compparms.cblkheightval,
-	  cod->compparms.cblksty);
-	if (cod->csty & JPC_COX_PRT) {
-		for (i = 0; i < cod->compparms.numrlvls; ++i) {
-			jas_eprintf("prcwidth[%d] = %d, prcheight[%d] = %d\n",
-			  i, cod->compparms.rlvls[i].parwidthval,
-			  i, cod->compparms.rlvls[i].parheightval);
-		}
-	}
-	return 0;
-}
-
 /******************************************************************************\
 * COC marker segment operations.
 \******************************************************************************/
@@ -757,16 +647,6 @@
 	return 0;
 }
 
-static int jpc_coc_dumpparms(jpc_ms_t *ms, FILE *out)
-{
-	jpc_coc_t *coc = &ms->parms.coc;
-	fprintf(out, "compno = %"PRIuFAST16"; csty = 0x%02x; numdlvls = %d;\n",
-	  coc->compno, coc->compparms.csty, coc->compparms.numdlvls);
-	fprintf(out, "cblkwidthval = %d; cblkheightval = %d; "
-	  "cblksty = 0x%02x; qmfbid = %d;\n", coc->compparms.cblkwidthval,
-	  coc->compparms.cblkheightval, coc->compparms.cblksty, coc->compparms.qmfbid);
-	return 0;
-}
 /******************************************************************************\
 * COD/COC marker segment operation helper functions.
 \******************************************************************************/
@@ -898,14 +778,6 @@
 	return 0;
 }
 
-static int jpc_rgn_dumpparms(jpc_ms_t *ms, FILE *out)
-{
-	jpc_rgn_t *rgn = &ms->parms.rgn;
-	fprintf(out, "compno = %"PRIuFAST16"; roisty = %d; roishift = %d\n",
-	  rgn->compno, rgn->roisty, rgn->roishift);
-	return 0;
-}
-
 /******************************************************************************\
 * QCD marker segment operations.
 \******************************************************************************/
@@ -928,20 +800,6 @@
 	return jpc_qcx_putcompparms(compparms, cstate, out);
 }
 
-static int jpc_qcd_dumpparms(jpc_ms_t *ms, FILE *out)
-{
-	jpc_qcd_t *qcd = &ms->parms.qcd;
-	int i;
-	fprintf(out, "qntsty = %d; numguard = %d; numstepsizes = %d\n",
-	  (int) qcd->compparms.qntsty, qcd->compparms.numguard, qcd->compparms.numstepsizes);
-	for (i = 0; i < qcd->compparms.numstepsizes; ++i) {
-		fprintf(out, "expn[%d] = 0x%04x; mant[%d] = 0x%04x;\n",
-		  i, JAS_CAST(unsigned, JPC_QCX_GETEXPN(qcd->compparms.stepsizes[i])),
-		  i, JAS_CAST(unsigned, JPC_QCX_GETMANT(qcd->compparms.stepsizes[i])));
-	}
-	return 0;
-}
-
 /******************************************************************************\
 * QCC marker segment operations.
 \******************************************************************************/
@@ -998,21 +856,6 @@
 	return 0;
 }
 
-static int jpc_qcc_dumpparms(jpc_ms_t *ms, FILE *out)
-{
-	jpc_qcc_t *qcc = &ms->parms.qcc;
-	int i;
-	fprintf(out, "compno = %"PRIuFAST16"; qntsty = %d; numguard = %d; "
-	  "numstepsizes = %d\n", qcc->compno, qcc->compparms.qntsty, qcc->compparms.numguard,
-	  qcc->compparms.numstepsizes);
-	for (i = 0; i < qcc->compparms.numstepsizes; ++i) {
-		fprintf(out, "expn[%d] = 0x%04x; mant[%d] = 0x%04x;\n",
-		  i, (unsigned) JPC_QCX_GETEXPN(qcc->compparms.stepsizes[i]),
-		  i, (unsigned) JPC_QCX_GETMANT(qcc->compparms.stepsizes[i]));
-	}
-	return 0;
-}
-
 /******************************************************************************\
 * QCD/QCC marker segment helper functions.
 \******************************************************************************/
@@ -1144,13 +987,6 @@
 	return 0;
 }
 
-static int jpc_sop_dumpparms(jpc_ms_t *ms, FILE *out)
-{
-	jpc_sop_t *sop = &ms->parms.sop;
-	fprintf(out, "seqno = %"PRIuFAST16";\n", sop->seqno);
-	return 0;
-}
-
 /******************************************************************************\
 * PPM marker segment operations.
 \******************************************************************************/
@@ -1210,17 +1046,6 @@
 	return 0;
 }
 
-static int jpc_ppm_dumpparms(jpc_ms_t *ms, FILE *out)
-{
-	jpc_ppm_t *ppm = &ms->parms.ppm;
-	fprintf(out, "ind=%d; len = %"PRIuFAST16";\n", ppm->ind, ppm->len);
-	if (ppm->len > 0) {
-		fprintf(out, "data =\n");
-		jas_memdump(out, ppm->data, ppm->len);
-	}
-	return 0;
-}
-
 /******************************************************************************\
 * PPT marker segment operations.
 \******************************************************************************/
@@ -1282,17 +1107,6 @@
 	return 0;
 }
 
-static int jpc_ppt_dumpparms(jpc_ms_t *ms, FILE *out)
-{
-	jpc_ppt_t *ppt = &ms->parms.ppt;
-	fprintf(out, "ind=%d; len = %"PRIuFAST32";\n", ppt->ind, ppt->len);
-	if (ppt->len > 0) {
-		fprintf(out, "data =\n");
-		jas_memdump(out, ppt->data, ppt->len);
-	}
-	return 0;
-}
-
 /******************************************************************************\
 * POC marker segment operations.
 \******************************************************************************/
@@ -1383,23 +1197,6 @@
 	return 0;
 }
 
-static int jpc_poc_dumpparms(jpc_ms_t *ms, FILE *out)
-{
-	jpc_poc_t *poc = &ms->parms.poc;
-	jpc_pocpchg_t *pchg;
-	int pchgno;
-	for (pchgno = 0, pchg = poc->pchgs; pchgno < poc->numpchgs;
-	  ++pchgno, ++pchg) {
-		fprintf(out, "po[%d] = %d; ", pchgno, pchg->prgord);
-		fprintf(out, "cs[%d] = %"PRIuFAST16"; ce[%d] = %"PRIuFAST16"; ",
-		  pchgno, pchg->compnostart, pchgno, pchg->compnoend);
-		fprintf(out, "rs[%d] = %d; re[%d] = %d; ",
-		  pchgno, pchg->rlvlnostart, pchgno, pchg->rlvlnoend);
-		fprintf(out, "le[%d] = %"PRIuFAST16"\n", pchgno, pchg->lyrnoend);
-	}
-	return 0;
-}
-
 /******************************************************************************\
 * CRG marker segment operations.
 \******************************************************************************/
@@ -1451,19 +1248,6 @@
 	return 0;
 }
 
-static int jpc_crg_dumpparms(jpc_ms_t *ms, FILE *out)
-{
-	jpc_crg_t *crg = &ms->parms.crg;
-	int compno;
-	jpc_crgcomp_t *comp;
-	for (compno = 0, comp = crg->comps; compno < crg->numcomps; ++compno,
-	  ++comp) {
-		fprintf(out, "hoff[%d] = %"PRIuFAST16"; voff[%d] = %"PRIuFAST16"\n",
-		  compno, comp->hoff, compno, comp->voff);
-	}
-	return 0;
-}
-
 /******************************************************************************\
 * Operations for COM marker segment.
 \******************************************************************************/
@@ -1516,27 +1300,6 @@
 	return 0;
 }
 
-static int jpc_com_dumpparms(jpc_ms_t *ms, FILE *out)
-{
-	jpc_com_t *com = &ms->parms.com;
-	unsigned int i;
-	int printable;
-	fprintf(out, "regid = %"PRIuFAST16";\n", com->regid);
-	printable = 1;
-	for (i = 0; i < com->len; ++i) {
-		if (!isprint(com->data[i])) {
-			printable = 0;
-			break;
-		}
-	}
-	if (printable) {
-		fprintf(out, "data = ");
-		fwrite(com->data, sizeof(char), com->len, out);
-		fprintf(out, "\n");
-	}
-	return 0;
-}
-
 /******************************************************************************\
 * Operations for unknown types of marker segments.
 \******************************************************************************/
@@ -1584,16 +1347,6 @@
 	/* If this function is called, we are trying to write an unsupported
 	  type of marker segment.  Return with an error indication.  */
 	return -1;
-}
-
-static int jpc_unk_dumpparms(jpc_ms_t *ms, FILE *out)
-{
-	unsigned int i;
-	jpc_unk_t *unk = &ms->parms.unk;
-	for (i = 0; i < unk->len; ++i) {
-		fprintf(out, "%02x ", unk->data[i]);
-	}
-	return 0;
 }
 
 /******************************************************************************\
--- a/jpc_cs.h
+++ b/jpc_cs.h
@@ -726,9 +726,6 @@
 	/* Put the marker segment parameters to a stream. */
 	int (*putparms)(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *out);
 
-	/* Dump the marker segment parameters (for debugging). */
-	int (*dumpparms)(jpc_ms_t *ms, FILE *out);
-
 } jpc_msops_t;
 
 /******************************************************************************\
@@ -773,9 +770,6 @@
 
 /* Copy code stream data from one stream to another. */
 int jpc_putdata(jas_stream_t *out, jas_stream_t *in, long n);
-
-/* Dump a marker segment (for debugging). */
-void jpc_ms_dump(jpc_ms_t *ms, FILE *out);
 
 /* Read a 8-bit unsigned integer from a stream. */
 int jpc_getuint8(jas_stream_t *in, uint_fast8_t *val);
--- a/jpc_dec.c
+++ b/jpc_dec.c
@@ -131,8 +131,6 @@
 * Local function prototypes.
 \******************************************************************************/
 
-static int jpc_dec_dump(const jpc_dec_t *dec, FILE *out);
-
 static jpc_ppxstab_t *jpc_ppxstab_create(void);
 static void jpc_ppxstab_destroy(jpc_ppxstab_t *tab);
 static int jpc_ppxstab_grow(jpc_ppxstab_t *tab, unsigned maxents);
@@ -566,19 +564,15 @@
 			}
 		}
 		pos = jas_stream_tell(tile->pkthdrstream);
-		jas_stream_seek(tile->pkthdrstream, 0, SEEK_END);
+		jas_stream_seek(tile->pkthdrstream, 0, 2);
 		if (jpc_pptstabwrite(tile->pkthdrstream, tile->pptstab)) {
 			return -1;
 		}
-		jas_stream_seek(tile->pkthdrstream, pos, SEEK_SET);
+		jas_stream_seek(tile->pkthdrstream, pos, 0);
 		jpc_ppxstab_destroy(tile->pptstab);
 		tile->pptstab = 0;
 	}
 
-	if (jas_getdbglevel() >= 10) {
-		jpc_dec_dump(dec, stderr);
-	}
-
 	if (jpc_dec_decodepkts(dec, (tile->pkthdrstream) ? tile->pkthdrstream :
 	  dec->in, dec->in)) {
 		jas_eprintf("jpc_dec_decodepkts failed\n");
@@ -2123,83 +2117,6 @@
 		jas_stream_close(seg->stream);
 	}
 	jas_free(seg);
-}
-
-static int jpc_dec_dump(const jpc_dec_t *dec, FILE *out)
-{
-	assert(!dec->numtiles || dec->tiles);
-	unsigned tileno;
-	const jpc_dec_tile_t *tile;
-	for (tileno = 0, tile = dec->tiles; tileno < dec->numtiles;
-	  ++tileno, ++tile) {
-		assert(!dec->numcomps || tile->tcomps);
-		unsigned compno;
-		const jpc_dec_tcomp_t *tcomp;
-		for (compno = 0, tcomp = tile->tcomps; compno < dec->numcomps;
-		     ++compno, ++tcomp) {
-			unsigned rlvlno;
-			const jpc_dec_rlvl_t *rlvl;
-			for (rlvlno = 0, rlvl = tcomp->rlvls; rlvlno <
-			  tcomp->numrlvls; ++rlvlno, ++rlvl) {
-				fprintf(out, "RESOLUTION LEVEL %d\n", rlvlno);
-				fprintf(out, "xs = %"PRIuFAST32", ys = %"PRIuFAST32", xe = %"PRIuFAST32", ye = %"PRIuFAST32", w = %"PRIuFAST32", h = %"PRIuFAST32"\n",
-				  rlvl->xstart, rlvl->ystart, rlvl->xend, rlvl->yend,
-				  rlvl->xend - rlvl->xstart, rlvl->yend - rlvl->ystart);
-				assert(!rlvl->numbands || rlvl->bands);
-				unsigned bandno;
-				const jpc_dec_band_t *band;
-				for (bandno = 0, band = rlvl->bands;
-				  bandno < rlvl->numbands; ++bandno, ++band) {
-					fprintf(out, "BAND %d\n", bandno);
-					if (!band->data) {
-						fprintf(out, "band has no data (null pointer)\n");
-						assert(!band->prcs);
-						continue;
-					}
-					fprintf(out, "xs = %"PRIjas_seqent", ys = %"PRIjas_seqent", xe = %"PRIjas_seqent", ye = %"PRIjas_seqent", w = %"PRIjas_seqent", h = %"PRIjas_seqent"\n",
-					  jas_seq2d_xstart(band->data),
-					  jas_seq2d_ystart(band->data),
-					  jas_seq2d_xend(band->data),
-					  jas_seq2d_yend(band->data),
-					  jas_seq2d_xend(band->data) -
-					  jas_seq2d_xstart(band->data),
-					  jas_seq2d_yend(band->data) -
-					  jas_seq2d_ystart(band->data));
-					assert(!rlvl->numprcs || band->prcs);
-					unsigned prcno;
-					const jpc_dec_prc_t *prc;
-					for (prcno = 0, prc = band->prcs;
-					  prcno < rlvl->numprcs; ++prcno,
-					  ++prc) {
-						fprintf(out, "CODE BLOCK GROUP %d\n", prcno);
-						fprintf(out, "xs = %"PRIuFAST32", ys = %"PRIuFAST32", xe = %"PRIuFAST32", ye = %"PRIuFAST32", w = %"PRIuFAST32", h = %"PRIuFAST32"\n",
-						  prc->xstart, prc->ystart, prc->xend, prc->yend,
-						  prc->xend - prc->xstart, prc->yend - prc->ystart);
-						assert(!prc->numcblks || prc->cblks);
-						unsigned cblkno;
-						const jpc_dec_cblk_t *cblk;
-						for (cblkno = 0, cblk =
-						  prc->cblks; cblkno <
-						  prc->numcblks; ++cblkno,
-						  ++cblk) {
-							fprintf(out, "CODE BLOCK %d\n", cblkno);
-							fprintf(out, "xs = %"PRIjas_seqent", ys = %"PRIjas_seqent", xe = %"PRIjas_seqent", ye = %"PRIjas_seqent", w = %"PRIjas_seqent", h = %"PRIjas_seqent"\n",
-							  jas_seq2d_xstart(cblk->data),
-							  jas_seq2d_ystart(cblk->data),
-							  jas_seq2d_xend(cblk->data),
-							  jas_seq2d_yend(cblk->data),
-							  jas_seq2d_xend(cblk->data) -
-							  jas_seq2d_xstart(cblk->data),
-							  jas_seq2d_yend(cblk->data) -
-							  jas_seq2d_ystart(cblk->data));
-						}
-					}
-				}
-			}
-		}
-	}
-
-	return 0;
 }
 
 static jpc_streamlist_t *jpc_streamlist_create()
--- a/jpc_math.c
+++ b/jpc_math.c
@@ -93,37 +93,3 @@
 	}
 	return y;
 }
-
-/* Calculate the bit position of the first leading one in a nonnegative
-  integer. */
-/* This function is the basically the same as ceillog2(x), except that the
-  allowable range for x is slightly different. */
-int jpc_int_firstone(int x)
-{
-	int n;
-
-	/* The argument must be nonnegative. */
-	assert(x >= 0);
-
-	n = -1;
-	while (x > 0) {
-		x >>= 1;
-		++n;
-	}
-	return n;
-}
-
-int jpc_fix_firstone(jpc_fix_t x)
-{
-	int n;
-
-	/* The argument must be nonnegative. */
-	assert(x >= 0);
-
-	n = -1;
-	while (x > 0) {
-		x >>= 1;
-		++n;
-	}
-	return n;
-}
--- a/jpc_math.h
+++ b/jpc_math.h
@@ -90,14 +90,6 @@
 * Functions.
 \******************************************************************************/
 
-/* Calculate the bit position of the first leading one in a nonnegative
-  integer. */
-JAS_ATTRIBUTE_CONST
-int jpc_int_firstone(int x);
-
-JAS_ATTRIBUTE_CONST
-int jpc_fix_firstone(jpc_fix_t x);
-
 /* Calculate the integer quantity floor(log2(x)), where x is a positive
   integer. */
 JAS_ATTRIBUTE_CONST
--- a/jpc_mqdec.c
+++ b/jpc_mqdec.c
@@ -208,9 +208,7 @@
 {
 	bool bit;
 	JAS_DBGLOG(100, ("jpc_mqdec_getbit_func(%p)\n", mqdec));
-	MQDEC_CALL(100, jpc_mqdec_dump(mqdec, stderr));
 	bit = jpc_mqdec_getbit_macro(mqdec);
-	MQDEC_CALL(100, jpc_mqdec_dump(mqdec, stderr));
 	JAS_DBGLOG(100, ("ctx = %d, decoded %d\n", mqdec->curctx -
 	  mqdec->ctxs, bit));
 	return bit;
@@ -279,20 +277,4 @@
 		mqdec->creg += 0xff00;
 		mqdec->ctreg = 8;
 	}
-}
-
-/******************************************************************************\
-* Code for debugging.
-\******************************************************************************/
-
-/* Dump a MQ decoder to a stream for debugging. */
-
-void jpc_mqdec_dump(const jpc_mqdec_t *mqdec, FILE *out)
-{
-	fprintf(out, "MQDEC A = %08lx, C = %08lx, CT=%08lx, ",
-	  (unsigned long) mqdec->areg, (unsigned long) mqdec->creg,
-	  (unsigned long) mqdec->ctreg);
-	fprintf(out, "CTX = %" PRIdPTR ", ", mqdec->curctx - mqdec->ctxs);
-	fprintf(out, "IND %" PRIdPTR ", MPS %d, QEVAL %"PRIxLEAST16"\n", *mqdec->curctx -
-	  jpc_mqstates, (*mqdec->curctx)->mps, (*mqdec->curctx)->qeval);
 }
--- a/jpc_mqdec.h
+++ b/jpc_mqdec.h
@@ -172,13 +172,6 @@
 #endif
 
 /******************************************************************************\
-* Functions/macros for debugging.
-\******************************************************************************/
-
-/* Dump the MQ decoder state for debugging. */
-void jpc_mqdec_dump(const jpc_mqdec_t *dec, FILE *out);
-
-/******************************************************************************\
 * EVERYTHING BELOW THIS POINT IS IMPLEMENTATION SPECIFIC AND NOT PART OF THE
 * APPLICATION INTERFACE.  DO NOT RELY ON ANY OF THE INTERNAL FUNCTIONS/MACROS
 * GIVEN BELOW.
--- a/jpc_tagtree.c
+++ b/jpc_tagtree.c
@@ -366,21 +366,3 @@
 
 	return (node->value_ < threshold) ? 1 : 0;
 }
-
-/******************************************************************************\
-* Code for debugging.
-\******************************************************************************/
-
-void jpc_tagtree_dump(const jpc_tagtree_t *tree, FILE *out)
-{
-	int n;
-
-	const jpc_tagtreenode_t *node = tree->nodes_;
-	n = tree->numnodes_;
-	while (--n >= 0) {
-		fprintf(out, "node %p, parent %p, value %d, lower %d, known %d\n",
-		  (const void *) node, (const void *) node->parent_, node->value_, node->low_,
-		  node->known_);
-		++node;
-	}
-}
--- a/jpc_tagtree.h
+++ b/jpc_tagtree.h
@@ -159,7 +159,4 @@
 int jpc_tagtree_encode(jpc_tagtree_t *tree, jpc_tagtreenode_t *leaf,
   int threshold, jpc_bitstream_t *out);
 
-/* Dump a tag tree (for debugging purposes). */
-void jpc_tagtree_dump(const jpc_tagtree_t *tree, FILE *out);
-
 #endif
--- a/jpc_util.c
+++ /dev/null
@@ -1,186 +1,0 @@
-/*
- * Copyright (c) 1999-2000 Image Power, Inc. and the University of
- *   British Columbia.
- * Copyright (c) 2001-2003 Michael David Adams.
- * All rights reserved.
- */
-
-/* __START_OF_JASPER_LICENSE__
- * 
- * JasPer License Version 2.0
- * 
- * Copyright (c) 2001-2006 Michael David Adams
- * Copyright (c) 1999-2000 Image Power, Inc.
- * Copyright (c) 1999-2000 The University of British Columbia
- * 
- * All rights reserved.
- * 
- * Permission is hereby granted, free of charge, to any person (the
- * "User") obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, and/or sell copies of the Software, and to permit
- * persons to whom the Software is furnished to do so, subject to the
- * following conditions:
- * 
- * 1.  The above copyright notices and this permission notice (which
- * includes the disclaimer below) shall be included in all copies or
- * substantial portions of the Software.
- * 
- * 2.  The name of a copyright holder shall not be used to endorse or
- * promote products derived from the Software without specific prior
- * written permission.
- * 
- * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS
- * LICENSE.  NO USE OF THE SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
- * THIS DISCLAIMER.  THE SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
- * "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
- * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.  IN NO
- * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
- * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
- * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
- * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.  NO ASSURANCES ARE
- * PROVIDED BY THE COPYRIGHT HOLDERS THAT THE SOFTWARE DOES NOT INFRINGE
- * THE PATENT OR OTHER INTELLECTUAL PROPERTY RIGHTS OF ANY OTHER ENTITY.
- * EACH COPYRIGHT HOLDER DISCLAIMS ANY LIABILITY TO THE USER FOR CLAIMS
- * BROUGHT BY ANY OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL
- * PROPERTY RIGHTS OR OTHERWISE.  AS A CONDITION TO EXERCISING THE RIGHTS
- * GRANTED HEREUNDER, EACH USER HEREBY ASSUMES SOLE RESPONSIBILITY TO SECURE
- * ANY OTHER INTELLECTUAL PROPERTY RIGHTS NEEDED, IF ANY.  THE SOFTWARE
- * IS NOT FAULT-TOLERANT AND IS NOT INTENDED FOR USE IN MISSION-CRITICAL
- * SYSTEMS, SUCH AS THOSE USED IN THE OPERATION OF NUCLEAR FACILITIES,
- * AIRCRAFT NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL
- * SYSTEMS, DIRECT LIFE SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH
- * THE FAILURE OF THE SOFTWARE OR SYSTEM COULD LEAD DIRECTLY TO DEATH,
- * PERSONAL INJURY, OR SEVERE PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH
- * RISK ACTIVITIES").  THE COPYRIGHT HOLDERS SPECIFICALLY DISCLAIM ANY
- * EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR HIGH RISK ACTIVITIES.
- * 
- * __END_OF_JASPER_LICENSE__
- */
-
-/*
- * $Id$
- */
-
-/******************************************************************************\
-* Includes
-\******************************************************************************/
-
-#include "jpc_util.h"
-#include "jpc_fix.h"
-
-#include "jasper/jas_math.h"
-#include "jasper/jas_malloc.h"
-
-/******************************************************************************\
-* Miscellaneous Functions
-\******************************************************************************/
-
-int jpc_atoaf(const char *s, int *numvalues, double **values)
-{
-	static const char delim[] = ", \t\n";
-	char buf[4096];
-	int n;
-	double *vs;
-	char *cp;
-
-	strncpy(buf, s, sizeof(buf));
-	buf[sizeof(buf) - 1] = '\0';
-	n = 0;
-	if (strtok(buf, delim)) {
-		++n;
-		while ((cp = strtok(0, delim))) {
-			if (*cp != '\0') {
-				++n;
-			}
-		}
-	}
-
-	if (n) {
-		if (!(vs = jas_alloc2(n, sizeof(double)))) {
-			return -1;
-		}
-
-		strncpy(buf, s, sizeof(buf));
-		buf[sizeof(buf) - 1] = '\0';
-		n = 0;
-		if ((cp = strtok(buf, delim))) {
-			vs[n] = atof(cp);
-			++n;
-			while ((cp = strtok(0, delim))) {
-				if (*cp != '\0') {
-					vs[n] = atof(cp);
-					++n;
-				}
-			}
-		}
-	} else {
-		vs = 0;
-	}
-
-	*numvalues = n;
-	*values = vs;
-
-	return 0;
-}
-
-jas_seq_t *jpc_seq_upsample(const jas_seq_t *x, int m)
-{
-	jas_seq_t *z;
-	int i;
-
-	if (!(z = jas_seq_create(jas_seq_start(x) * m, (jas_seq_end(x) - 1) * m + 1)))
-		return 0;
-	for (i = jas_seq_start(z); i < jas_seq_end(z); i++) {
-		*jas_seq_getref(z, i) = (!JAS_MOD(i, m)) ? jas_seq_get(x, i / m) :
-		  jpc_inttofix(0);
-	}
-
-	return z;
-}
-
-jpc_fix_t jpc_seq_norm(const jas_seq_t *x)
-{
-	jpc_fix_t s;
-	int i;
-
-	s = jpc_inttofix(0);
-	for (i = jas_seq_start(x); i < jas_seq_end(x); i++) {
-		s = jpc_fix_add(s, jpc_fix_mul(jas_seq_get(x, i), jas_seq_get(x, i)));
-	}
-
-	return jpc_dbltofix(sqrt(jpc_fixtodbl(s)));
-}
-
-jas_seq_t *jpc_seq_conv(const jas_seq_t *x, const jas_seq_t *y)
-{
-	int i;
-	int j;
-	int k;
-	jas_seq_t *z;
-	jpc_fix_t s;
-	jpc_fix_t v;
-
-	z = jas_seq_create(jas_seq_start(x) + jas_seq_start(y),
-			   jas_seq_end(x) + jas_seq_end(y) - 1);
-	if (!z)
-		return NULL;
-	for (i = jas_seq_start(z); i < jas_seq_end(z); i++) {
-		s = jpc_inttofix(0);
-		for (j = jas_seq_start(y); j < jas_seq_end(y); j++) {
-			k = i - j;
-			if (k < jas_seq_start(x) || k >= jas_seq_end(x)) {
-				v = JPC_FIX_ZERO;
-			} else {
-				v = jas_seq_get(x, k);
-			}
-			s = jpc_fix_add(s, jpc_fix_mul(jas_seq_get(y, j), v));
-		}
-		*jas_seq_getref(z, i) = s;
-	}
-
-	return z;
-}
--- a/jpc_util.h
+++ /dev/null
@@ -1,82 +1,0 @@
-/*
- * Copyright (c) 2001-2002 Michael David Adams.
- * All rights reserved.
- */
-
-/* __START_OF_JASPER_LICENSE__
- * 
- * JasPer License Version 2.0
- * 
- * Copyright (c) 2001-2006 Michael David Adams
- * Copyright (c) 1999-2000 Image Power, Inc.
- * Copyright (c) 1999-2000 The University of British Columbia
- * 
- * All rights reserved.
- * 
- * Permission is hereby granted, free of charge, to any person (the
- * "User") obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, and/or sell copies of the Software, and to permit
- * persons to whom the Software is furnished to do so, subject to the
- * following conditions:
- * 
- * 1.  The above copyright notices and this permission notice (which
- * includes the disclaimer below) shall be included in all copies or
- * substantial portions of the Software.
- * 
- * 2.  The name of a copyright holder shall not be used to endorse or
- * promote products derived from the Software without specific prior
- * written permission.
- * 
- * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS
- * LICENSE.  NO USE OF THE SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
- * THIS DISCLAIMER.  THE SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
- * "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
- * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.  IN NO
- * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
- * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
- * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
- * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.  NO ASSURANCES ARE
- * PROVIDED BY THE COPYRIGHT HOLDERS THAT THE SOFTWARE DOES NOT INFRINGE
- * THE PATENT OR OTHER INTELLECTUAL PROPERTY RIGHTS OF ANY OTHER ENTITY.
- * EACH COPYRIGHT HOLDER DISCLAIMS ANY LIABILITY TO THE USER FOR CLAIMS
- * BROUGHT BY ANY OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL
- * PROPERTY RIGHTS OR OTHERWISE.  AS A CONDITION TO EXERCISING THE RIGHTS
- * GRANTED HEREUNDER, EACH USER HEREBY ASSUMES SOLE RESPONSIBILITY TO SECURE
- * ANY OTHER INTELLECTUAL PROPERTY RIGHTS NEEDED, IF ANY.  THE SOFTWARE
- * IS NOT FAULT-TOLERANT AND IS NOT INTENDED FOR USE IN MISSION-CRITICAL
- * SYSTEMS, SUCH AS THOSE USED IN THE OPERATION OF NUCLEAR FACILITIES,
- * AIRCRAFT NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL
- * SYSTEMS, DIRECT LIFE SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH
- * THE FAILURE OF THE SOFTWARE OR SYSTEM COULD LEAD DIRECTLY TO DEATH,
- * PERSONAL INJURY, OR SEVERE PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH
- * RISK ACTIVITIES").  THE COPYRIGHT HOLDERS SPECIFICALLY DISCLAIM ANY
- * EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR HIGH RISK ACTIVITIES.
- * 
- * __END_OF_JASPER_LICENSE__
- */
-
-#ifndef JPC_UTIL_H
-#define JPC_UTIL_H
-
-#include "jpc_fix.h"
-
-#include "jasper/jas_seq.h"
-
-/* Parse a comma separated list of real numbers into an array of doubles. */
-int jpc_atoaf(const char *s, int *numvalues, double **values);
-
-/* Upsample a sequence. */
-jas_seq_t *jpc_seq_upsample(const jas_seq_t *seq, int n);
-
-/* Convolve two sequences. */
-jas_seq_t *jpc_seq_conv(const jas_seq_t *seq0, const jas_seq_t *seq1);
-
-/* Compute the norm of a sequence. */
-JAS_ATTRIBUTE_PURE
-jpc_fix_t jpc_seq_norm(const jas_seq_t *x);
-
-#endif
--- a/mklib
+++ b/mklib
@@ -9,10 +9,8 @@
 	jas_iccdata.$O\
 	jas_image.$O\
 	jas_init.$O\
-	jas_malloc.$O\
 	jas_seq.$O\
 	jas_stream.$O\
-	jas_string.$O\
 	jp2_cod.$O\
 	jp2_dec.$O\
 	jpc_bs.$O\
@@ -29,7 +27,6 @@
 	jpc_t2dec.$O\
 	jpc_tagtree.$O\
 	jpc_tsfb.$O\
-	jpc_util.$O\
 
 HFILES=\