\r
int sot_len, Psot, Psotp, mm, epb_index = 0, prot_len = 0;\r
unsigned long sot_pos, post_sod_pos;\r
-\r
unsigned long int left_THmarks_len, epbs_len = 0;\r
-\r
int startpack = 0, stoppack = j2k->image_info->num;\r
+ jpwl_epb_ms_t *tph_epb;\r
\r
sot_pos = j2k->image_info->tile[tileno].start_pos;\r
cio_seek(cio, sot_pos + 2); \r
Psotp = cio_tell(cio);\r
Psot = cio_read(cio, 4); /* tile length */\r
\r
+ /* a-priori length of the data dwelling between SOT and SOD */\r
post_sod_pos = j2k->image_info->tile[tileno].end_header + 1;\r
left_THmarks_len = post_sod_pos - (sot_pos + sot_len + 2);\r
\r
- /* add all the lengths of the markers which are len-ready and stay within SOT and SOD */\r
+ /* add all the lengths of the JPWL markers which are len-ready and stay within SOT and SOD */\r
for (mm = 0; mm < jwmarker_num; mm++) {\r
if ((jwmarker[mm].pos >= sot_pos) && (jwmarker[mm].pos < post_sod_pos)) {\r
if (jwmarker[mm].len_ready)\r
/* Create the EPB */\r
if (epb_mark = jpwl_epb_create(\r
j2k, /* this encoder handle */\r
- false, /* is it the latest? in TPH, yes for now (if huge data size in TPH, we'd need more) */\r
- true, /* is it packed? not for now */\r
+ false, /* is it the latest? in TPH, no for now (if huge data size in TPH, we'd need more) */\r
+ true, /* is it packed? yes for now */\r
tileno, /* we are in TPH */\r
epb_index++, /* its index is 0 (first) */\r
hprot, /* protection type parameters of following data */\r
hprot\r
);\r
\r
+ /* save this TPH EPB address */\r
+ tph_epb = epb_mark;\r
+\r
} else {\r
/* ooops, problems */\r
opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not create TPH EPB #%d\n", tileno); \r
\r
/* let's add the EPBs */\r
Psot += jpwl_epbs_add(\r
- j2k, /* J2K handle */\r
- jwmarker, /* pointer to JPWL markers list */\r
- &jwmarker_num, /* pointer to the number of current markers */\r
- false, /* latest */\r
- true, /* packed */\r
- false, /* inside MH */\r
- &epb_index, /* pointer to EPB index */\r
- pprot, /* protection type */\r
- (double) (j2k->image_info->tile[tileno].start_pos + sot_len + 2) + 0.0001, /* position */\r
- tileno, /* number of tile */\r
- 0, /* length of pre-data */\r
- prot_len /*4000*/ /* length of post-data */\r
- );\r
+ j2k, /* J2K handle */\r
+ jwmarker, /* pointer to JPWL markers list */\r
+ &jwmarker_num, /* pointer to the number of current markers */\r
+ false, /* latest */\r
+ true, /* packed */\r
+ false, /* inside MH */\r
+ &epb_index, /* pointer to EPB index */\r
+ pprot, /* protection type */\r
+ (double) (j2k->image_info->tile[tileno].start_pos + sot_len + 2) + 0.0001, /* position */\r
+ tileno, /* number of tile */\r
+ 0, /* length of pre-data */\r
+ prot_len /*4000*/ /* length of post-data */\r
+ );\r
}\r
\r
startpack = packno;\r
);\r
}\r
\r
+ /* we can now check if the TPH EPB was really the last one */\r
+ if (epb_index == 1) {\r
+ /* set the TPH EPB to be the last one in current header */\r
+ tph_epb->Depb |= (unsigned char) ((true & 0x0001) << 6);\r
+\r
+ }\r
+\r
/* write back Psot */\r
cio_seek(cio, Psotp);\r
cio_write(cio, Psot, 4);\r
\r
};\r
\r
-\r
/* reset the position */\r
cio_seek(cio, ciopos);\r
\r