about summary refs log tree commit diff
path: root/converter/other/jpeg2000/libjasper/base/jas_image.c
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2020-09-06 09:44:03 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2020-09-06 09:44:03 +0000
commitb1bb4601306e9c6fa4fc9bdda14457609bc07f3d (patch)
tree3055e2e94179582761af5340e381e9bc613c72b9 /converter/other/jpeg2000/libjasper/base/jas_image.c
parent9772cdac86222754259a32b7862093a3eeb5cc4c (diff)
downloadnetpbm-mirror-b1bb4601306e9c6fa4fc9bdda14457609bc07f3d.tar.gz
netpbm-mirror-b1bb4601306e9c6fa4fc9bdda14457609bc07f3d.tar.xz
netpbm-mirror-b1bb4601306e9c6fa4fc9bdda14457609bc07f3d.zip
Add diagnostics
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@3945 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter/other/jpeg2000/libjasper/base/jas_image.c')
-rw-r--r--converter/other/jpeg2000/libjasper/base/jas_image.c41
1 files changed, 34 insertions, 7 deletions
diff --git a/converter/other/jpeg2000/libjasper/base/jas_image.c b/converter/other/jpeg2000/libjasper/base/jas_image.c
index 5c2822be..d474dfe4 100644
--- a/converter/other/jpeg2000/libjasper/base/jas_image.c
+++ b/converter/other/jpeg2000/libjasper/base/jas_image.c
@@ -126,6 +126,8 @@
 #include <assert.h>
 #include <ctype.h>
 
+#include "netpbm/nstring.h"
+
 #include "jasper/jas_math.h"
 #include "jasper/jas_image.h"
 #include "jasper/jas_malloc.h"
@@ -379,22 +381,47 @@ static void jas_image_cmpt_destroy(jas_image_cmpt_t *cmpt)
 * Load and save operations.
 \*****************************************************************************/
 
-jas_image_t *jas_image_decode(jas_stream_t *in, int fmt, char *optstr)
-{
+void
+jas_image_decode(jas_stream_t * const in,
+				 int            const fmtArg,
+				 const char *   const optstr,
+				 jas_image_t ** const imagePP,
+				 const char **  const errorP) {
+/*----------------------------------------------------------------------------
+  Create an image from a stream in some specified format
+-----------------------------------------------------------------------------*/
 	jas_image_fmtinfo_t *fmtinfo;
+	int fmt;
 
 	/* If possible, try to determine the format of the input data. */
-	if (fmt < 0) {
+	if (fmtArg < 0) {
 		if ((fmt = jas_image_getfmt(in)) < 0) {
-			return 0;
+			pm_asprintf(errorP, "jas_image_getfmt failed");
+			return;
 		}
-	}
+	} else
+		fmt = fmtArg;
+
 	if (!(fmtinfo = jas_image_lookupfmtbyid(fmt))) {
-		return 0;
+		pm_asprintf(errorP, "jas_image_lookupfmtbyid of format %d failed",
+					fmt);
+		return;
+	}
+	{
+		const char * error;
+
+		(*fmtinfo->ops.decode)(in, optstr, imagePP, &error);
+		if (error) {
+			pm_asprintf(errorP, "decoder failed.  %s", error);
+			pm_strfree(error);
+		} else {
+			*errorP = NULL;
+		}
 	}
-	return (fmtinfo->ops.decode) ? (*fmtinfo->ops.decode)(in, optstr) : 0;
 }
 
+
+
 int jas_image_encode(jas_image_t *image, jas_stream_t *out, int fmt, char *optstr)
 {
 	jas_image_fmtinfo_t *fmtinfo;