summaryrefslogtreecommitdiff
path: root/src/lib/openjp2/t2.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/openjp2/t2.c')
-rw-r--r--src/lib/openjp2/t2.c76
1 files changed, 53 insertions, 23 deletions
diff --git a/src/lib/openjp2/t2.c b/src/lib/openjp2/t2.c
index 1481e16f..48f8949b 100644
--- a/src/lib/openjp2/t2.c
+++ b/src/lib/openjp2/t2.c
@@ -1229,6 +1229,7 @@ static OPJ_BOOL opj_t2_read_packet_header(opj_t2_t* p_t2,
++i;
}
+ l_cblk->Mb = (OPJ_UINT32)l_band->numbps;
l_cblk->numbps = (OPJ_UINT32)l_band->numbps + 1 - i;
l_cblk->numlenbits = 3;
}
@@ -1258,34 +1259,63 @@ static OPJ_BOOL opj_t2_read_packet_header(opj_t2_t* p_t2,
}
n = (OPJ_INT32)l_cblk->numnewpasses;
- do {
- OPJ_UINT32 bit_number;
- l_cblk->segs[l_segno].numnewpasses = (OPJ_UINT32)opj_int_min((OPJ_INT32)(
- l_cblk->segs[l_segno].maxpasses - l_cblk->segs[l_segno].numpasses), n);
- bit_number = l_cblk->numlenbits + opj_uint_floorlog2(
- l_cblk->segs[l_segno].numnewpasses);
- if (bit_number > 32) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Invalid bit number %d in opj_t2_read_packet_header()\n",
- bit_number);
- opj_bio_destroy(l_bio);
- return OPJ_FALSE;
- }
- l_cblk->segs[l_segno].newlen = opj_bio_read(l_bio, bit_number);
- JAS_FPRINTF(stderr, "included=%d numnewpasses=%d increment=%d len=%d \n",
- l_included, l_cblk->segs[l_segno].numnewpasses, l_increment,
- l_cblk->segs[l_segno].newlen);
+ if ((p_tcp->tccps[p_pi->compno].cblksty & J2K_CCP_CBLKSTY_HT) != 0)
+ do {
+ OPJ_UINT32 bit_number;
+ l_cblk->segs[l_segno].numnewpasses = l_segno == 0 ? 1 : (OPJ_UINT32)n;
+ bit_number = l_cblk->numlenbits + opj_uint_floorlog2(
+ l_cblk->segs[l_segno].numnewpasses);
+ if (bit_number > 32) {
+ opj_event_msg(p_manager, EVT_ERROR,
+ "Invalid bit number %d in opj_t2_read_packet_header()\n",
+ bit_number);
+ opj_bio_destroy(l_bio);
+ return OPJ_FALSE;
+ }
+ l_cblk->segs[l_segno].newlen = opj_bio_read(l_bio, bit_number);
+ JAS_FPRINTF(stderr, "included=%d numnewpasses=%d increment=%d len=%d \n",
+ l_included, l_cblk->segs[l_segno].numnewpasses, l_increment,
+ l_cblk->segs[l_segno].newlen);
- n -= (OPJ_INT32)l_cblk->segs[l_segno].numnewpasses;
- if (n > 0) {
- ++l_segno;
+ n -= (OPJ_INT32)l_cblk->segs[l_segno].numnewpasses;
+ if (n > 0) {
+ ++l_segno;
- if (! opj_t2_init_seg(l_cblk, l_segno, p_tcp->tccps[p_pi->compno].cblksty, 0)) {
+ if (! opj_t2_init_seg(l_cblk, l_segno, p_tcp->tccps[p_pi->compno].cblksty, 0)) {
+ opj_bio_destroy(l_bio);
+ return OPJ_FALSE;
+ }
+ }
+ } while (n > 0);
+ else
+ do {
+ OPJ_UINT32 bit_number;
+ l_cblk->segs[l_segno].numnewpasses = (OPJ_UINT32)opj_int_min((OPJ_INT32)(
+ l_cblk->segs[l_segno].maxpasses - l_cblk->segs[l_segno].numpasses), n);
+ bit_number = l_cblk->numlenbits + opj_uint_floorlog2(
+ l_cblk->segs[l_segno].numnewpasses);
+ if (bit_number > 32) {
+ opj_event_msg(p_manager, EVT_ERROR,
+ "Invalid bit number %d in opj_t2_read_packet_header()\n",
+ bit_number);
opj_bio_destroy(l_bio);
return OPJ_FALSE;
}
- }
- } while (n > 0);
+ l_cblk->segs[l_segno].newlen = opj_bio_read(l_bio, bit_number);
+ JAS_FPRINTF(stderr, "included=%d numnewpasses=%d increment=%d len=%d \n",
+ l_included, l_cblk->segs[l_segno].numnewpasses, l_increment,
+ l_cblk->segs[l_segno].newlen);
+
+ n -= (OPJ_INT32)l_cblk->segs[l_segno].numnewpasses;
+ if (n > 0) {
+ ++l_segno;
+
+ if (! opj_t2_init_seg(l_cblk, l_segno, p_tcp->tccps[p_pi->compno].cblksty, 0)) {
+ opj_bio_destroy(l_bio);
+ return OPJ_FALSE;
+ }
+ }
+ } while (n > 0);
++l_cblk;
}