[v2.0] Fixed MJ2 codec bugs (issues 23-24 on google code). Thanks to Winfried for...
authorFrancois-Olivier Devaux <fodevaux@users.noreply.github.com>
Thu, 8 Apr 2010 18:01:45 +0000 (18:01 +0000)
committerFrancois-Olivier Devaux <fodevaux@users.noreply.github.com>
Thu, 8 Apr 2010 18:01:45 +0000 (18:01 +0000)
ChangeLog
mj2/mj2_convert.c
mj2/mj2_to_frames.c
mj2/wrap_j2k_in_mj2.c

index 352f3697b7726b141e232f8db2636ff3ec46b5ca..26bd6794499820734fd0044e10f90437f3c8c615 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,9 @@ What's New for OpenJPEG
 ! : changed
 + : added
 
+April 8, 2010
+* [FOD] Fixed MJ2 codec bugs (issues 23-24 on google code). Thanks to Winfried for these patches.
+
 March 26, 2010
 + [FOD] Added support for "jpc" codestreams which are equivalent to "j2c" codestreams. Thanks to Winfried for this patch
 
index 8868843a02719f68d6287f3e31b423bf852bdfac..c7e0c04f0678f30d7f127fee563bff7223ae2032 100644 (file)
@@ -324,8 +324,6 @@ int imagetobmp(opj_image_t * img, char *outfile) {
       }
     }
     fclose(f);
-    opj_free(img->comps[1].data);
-    opj_free(img->comps[2].data);
   }
   return 0;
 }
index a94f6612d27cd81dcd6892744cc46c3637a06cf1..a3a504691eac4ed5b147063ad9afdbddbb78fb29 100644 (file)
@@ -182,7 +182,7 @@ int main(int argc, char *argv[]) {
     {
       fprintf(stdout,"The frames will be output in a bmp format (output_1.bmp, ...)\n");
       sprintf(outfilename,"output_%d.bmp",snum);
-      if (imagetobmp(img, outfilename))        // Convert image to YUV
+      if (imagetobmp(img, outfilename))        // Convert image to BMP
                                return 1;
       
     }
index dd2af757bd57c65b4e936afdbd360d3a8fe4af71..92e0b157f4b65654c899c42b6222b8626c4f68bd 100644 (file)
@@ -132,16 +132,26 @@ static void setparams(opj_mj2_t *movie, opj_image_t *image) {
   movie->tk[0].depth = image->comps[0].prec;
        
   if (image->numcomps==3) {
-    if ((image->comps[0].dx == 1) && (image->comps[1].dx == 1) && (image->comps[1].dx == 1)) 
+    if ((image->comps[0].dx == 1) 
+       && (image->comps[1].dx == 1) 
+       && (image->comps[2].dx == 1)) 
       movie->tk[0].CbCr_subsampling_dx = 1;
-    else if ((image->comps[0].dx == 1) && (image->comps[1].dx == 2) && (image->comps[1].dx == 2))
+    else 
+       if ((image->comps[0].dx == 1) 
+       && (image->comps[1].dx == 2) 
+       && (image->comps[2].dx == 2))
       movie->tk[0].CbCr_subsampling_dx = 2;
     else
       fprintf(stderr,"Image component sizes are incoherent\n");
     
-    if ((image->comps[0].dy == 1) && (image->comps[1].dy == 1) && (image->comps[1].dy == 1)) 
+    if ((image->comps[0].dy == 1) 
+       && (image->comps[1].dy == 1) 
+       && (image->comps[2].dy == 1)) 
       movie->tk[0].CbCr_subsampling_dy = 1;
-    else if ((image->comps[0].dy == 1) && (image->comps[1].dy == 2) && (image->comps[1].dy == 2))
+    else 
+       if ((image->comps[0].dy == 1) 
+       && (image->comps[1].dy == 2) 
+       && (image->comps[2].dy == 2))
       movie->tk[0].CbCr_subsampling_dy = 2;
     else
       fprintf(stderr,"Image component sizes are incoherent\n");
@@ -189,16 +199,26 @@ static void setparams(opj_mj2_t *movie, opj_image_t *image) {
   else
     movie->tk[0].jp2_struct.meth = 2;
        
-  if (image->numcomps == 1)
-    movie->tk[0].jp2_struct.enumcs = 17;  // Grayscale
+    if (image->numcomps == 1)
+     movie->tk[0].jp2_struct.enumcs = 17;  // Grayscale
   
-  else   if ((image->comps[0].dx == 1) && (image->comps[1].dx == 1) && (image->comps[1].dx == 1) &&
-    (image->comps[0].dy == 1) && (image->comps[1].dy == 1) && (image->comps[1].dy == 1)) 
-    movie->tk[0].jp2_struct.enumcs = 16;    // RGB
+    else   
+       if ((image->comps[0].dx == 1) 
+       && (image->comps[1].dx == 1) 
+       && (image->comps[2].dx == 1) 
+    && (image->comps[0].dy == 1) 
+       && (image->comps[1].dy == 1) 
+       && (image->comps[2].dy == 1)) 
+     movie->tk[0].jp2_struct.enumcs = 16;    // RGB
   
-  else   if ((image->comps[0].dx == 1) && (image->comps[1].dx == 2) && (image->comps[1].dx == 2) &&
-    (image->comps[0].dy == 1) && (image->comps[1].dy == 2) && (image->comps[1].dy == 2)) 
-    movie->tk[0].jp2_struct.enumcs = 18;  // YUV
+    else   
+       if ((image->comps[0].dx == 1) 
+       && (image->comps[1].dx == 2) 
+       && (image->comps[2].dx == 2) 
+    && (image->comps[0].dy == 1) 
+       && (image->comps[1].dy == 2) 
+       && (image->comps[2].dy == 2)) 
+     movie->tk[0].jp2_struct.enumcs = 18;  // YUV
   
   else
     movie->tk[0].jp2_struct.enumcs = 0;        // Unkown profile */