Fixed the following bug:
authorGiuseppe Baruffa <gbaruffa@users.noreply.github.com>
Mon, 4 Dec 2006 15:28:48 +0000 (15:28 +0000)
committerGiuseppe Baruffa <gbaruffa@users.noreply.github.com>
Mon, 4 Dec 2006 15:28:48 +0000 (15:28 +0000)
- 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.

jpwl/jpwl.c

index e4ad0cb53d3be0d1a083a43e4ef355e466f784f0..72c5644d0924ebbd6aa3ef1ff22a4b98a7e8f6ec 100644 (file)
@@ -375,10 +375,9 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
 \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
@@ -387,10 +386,11 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
                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
@@ -413,8 +413,8 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
                        /* 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
@@ -445,6 +445,9 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
                                        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
@@ -486,19 +489,19 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
 \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
@@ -551,13 +554,19 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
                                                );\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