]> granicus.if.org Git - openjpeg/commitdiff
bug fixed when asking for an index with more than (layer*resolutions*100) packets...
authorAntonin Descampe <antonin@gmail.com>
Tue, 20 Sep 2005 15:40:13 +0000 (15:40 +0000)
committerAntonin Descampe <antonin@gmail.com>
Tue, 20 Sep 2005 15:40:13 +0000 (15:40 +0000)
libopenjpeg/j2k.c
libopenjpeg/tcd.c

index 0af9f18a55be1b53a01042ecb5ebc9efcb973394..65a08bfc94087a7ae634f02621fb91cd592beadf 100644 (file)
@@ -875,10 +875,6 @@ void j2k_write_sod()
   if (info_IM.index_on) {
     info_IM.tile[j2k_curtileno].end_header =
       cio_tell() + pos_correction - 1;
-    info_IM.tile[j2k_curtileno].packet =
-      (info_packet *) calloc(info_IM.Comp * info_IM.Layer *
-      (info_IM.Decomposition + 1) * 100,
-      sizeof(info_packet));
   }
   /* << INDEX */
   
index f39d34030962c3c79e79aa6de40d872ea579fa32..3c8abf6038a3d2e0ddd349f0f9500207d64981ca 100644 (file)
@@ -1156,7 +1156,7 @@ tcd_encode_tile_pxm(int tileno, unsigned char *dest, int len,
                    info_image * info_IM)
 {
   int compno;
-  int l, i;
+  int l, i, npck=0;
   clock_t time7;
   tcd_tile_t *tile;
   j2k_tcp_t *tcp = &tcd_cp->tcps[0];
@@ -1176,11 +1176,14 @@ tcd_encode_tile_pxm(int tileno, unsigned char *dest, int len,
 
       info_IM->tile[tileno].pw[i] = res_idx->pw;
       info_IM->tile[tileno].ph[i] = res_idx->ph;
+      
+      npck+=res_idx->pw * res_idx->ph;
 
       info_IM->tile[tileno].pdx[i] = tccp->prcw[i];
       info_IM->tile[tileno].pdy[i] = tccp->prch[i];
 
     }
+    info_IM->tile[tileno].packet = (info_packet *) calloc(info_IM->Comp * info_IM->Layer * npck, sizeof(info_packet));
   }
   /* << INDEX */