Fixed the following bug:

- when using -W h,h0 the EPBs in TPHs always get a "not latest in current header" signature, even if they are really the latest.

The fix checks for additional EPBs, after the TPH one (e.g. UEP EPBs), and sets the Depb field of the TPH EPB accordingly.
This commit is contained in:
Giuseppe Baruffa 2006-12-04 15:28:48 +00:00
parent dc069254c3
commit 9eaaf55f7a
1 changed files with 28 additions and 19 deletions

View File

@ -375,10 +375,9 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
int sot_len, Psot, Psotp, mm, epb_index = 0, prot_len = 0; int sot_len, Psot, Psotp, mm, epb_index = 0, prot_len = 0;
unsigned long sot_pos, post_sod_pos; unsigned long sot_pos, post_sod_pos;
unsigned long int left_THmarks_len, epbs_len = 0; unsigned long int left_THmarks_len, epbs_len = 0;
int startpack = 0, stoppack = j2k->image_info->num; int startpack = 0, stoppack = j2k->image_info->num;
jpwl_epb_ms_t *tph_epb;
sot_pos = j2k->image_info->tile[tileno].start_pos; sot_pos = j2k->image_info->tile[tileno].start_pos;
cio_seek(cio, sot_pos + 2); cio_seek(cio, sot_pos + 2);
@ -387,10 +386,11 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
Psotp = cio_tell(cio); Psotp = cio_tell(cio);
Psot = cio_read(cio, 4); /* tile length */ Psot = cio_read(cio, 4); /* tile length */
/* a-priori length of the data dwelling between SOT and SOD */
post_sod_pos = j2k->image_info->tile[tileno].end_header + 1; post_sod_pos = j2k->image_info->tile[tileno].end_header + 1;
left_THmarks_len = post_sod_pos - (sot_pos + sot_len + 2); left_THmarks_len = post_sod_pos - (sot_pos + sot_len + 2);
/* add all the lengths of the markers which are len-ready and stay within SOT and SOD */ /* add all the lengths of the JPWL markers which are len-ready and stay within SOT and SOD */
for (mm = 0; mm < jwmarker_num; mm++) { for (mm = 0; mm < jwmarker_num; mm++) {
if ((jwmarker[mm].pos >= sot_pos) && (jwmarker[mm].pos < post_sod_pos)) { if ((jwmarker[mm].pos >= sot_pos) && (jwmarker[mm].pos < post_sod_pos)) {
if (jwmarker[mm].len_ready) if (jwmarker[mm].len_ready)
@ -413,8 +413,8 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
/* Create the EPB */ /* Create the EPB */
if (epb_mark = jpwl_epb_create( if (epb_mark = jpwl_epb_create(
j2k, /* this encoder handle */ j2k, /* this encoder handle */
false, /* is it the latest? in TPH, yes for now (if huge data size in TPH, we'd need more) */ false, /* is it the latest? in TPH, no for now (if huge data size in TPH, we'd need more) */
true, /* is it packed? not for now */ true, /* is it packed? yes for now */
tileno, /* we are in TPH */ tileno, /* we are in TPH */
epb_index++, /* its index is 0 (first) */ epb_index++, /* its index is 0 (first) */
hprot, /* protection type parameters of following data */ hprot, /* protection type parameters of following data */
@ -445,6 +445,9 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
hprot hprot
); );
/* save this TPH EPB address */
tph_epb = epb_mark;
} else { } else {
/* ooops, problems */ /* ooops, problems */
opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not create TPH EPB #%d\n", tileno); opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not create TPH EPB #%d\n", tileno);
@ -551,13 +554,19 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
); );
} }
/* we can now check if the TPH EPB was really the last one */
if (epb_index == 1) {
/* set the TPH EPB to be the last one in current header */
tph_epb->Depb |= (unsigned char) ((true & 0x0001) << 6);
}
/* write back Psot */ /* write back Psot */
cio_seek(cio, Psotp); cio_seek(cio, Psotp);
cio_write(cio, Psot, 4); cio_write(cio, Psot, 4);
}; };
/* reset the position */ /* reset the position */
cio_seek(cio, ciopos); cio_seek(cio, ciopos);