]> granicus.if.org Git - openjpeg/commitdiff
Import patch from winfried on mailing list: patch for mj2.c in branch
authorMathieu Malaterre <mathieu.malaterre@gmail.com>
Tue, 20 Dec 2011 17:14:55 +0000 (17:14 +0000)
committerMathieu Malaterre <mathieu.malaterre@gmail.com>
Tue, 20 Dec 2011 17:14:55 +0000 (17:14 +0000)
applications/mj2/mj2.c

index fe48415be7dd5936f9c5effed0c0bc5abdcb8a98..b2b2c37730f68468f3705cabbb707793b2143a03 100644 (file)
@@ -1098,7 +1098,8 @@ int mj2_read_smj2(opj_image_t * img, mj2_tk_t * tk, opj_cio_t *cio)
   mj2_box_t box2;
   int i;
   opj_jp2_color_t color;
-       
+  opj_bool ok;
+
   mj2_read_boxhdr(&box, cio);
        
   if (MJ2_MJ2 != box.type) {
@@ -1156,11 +1157,17 @@ int mj2_read_smj2(opj_image_t * img, mj2_tk_t * tk, opj_cio_t *cio)
        
   cio_skip(cio,2);                     /* Pre-defined = -1 */
   memset(&color, 0, sizeof(opj_jp2_color_t));
-       
-  if (!jp2_read_jp2h(&tk->jp2_struct, cio, &color)) {
-               opj_event_msg(tk->cinfo, EVT_ERROR, "Error reading JP2H Box\n");
+  tk->jp2_struct.cinfo = tk->cinfo;
+
+  ok = jp2_read_jp2h(&tk->jp2_struct, cio, &color);
+
+  tk->jp2_struct.cinfo = NULL;
+
+  if(ok == OPJ_FALSE)
+ {
+       opj_event_msg(tk->cinfo, EVT_ERROR, "Error reading JP2H Box\n");
     return 1;
 }
+ }
 
   tk->jp2_struct.comps = (opj_jp2_comps_t*) opj_malloc(tk->jp2_struct.numcomps * sizeof(opj_jp2_comps_t));
   tk->jp2_struct.cl = (unsigned int*) opj_malloc(sizeof(unsigned int));