summaryrefslogtreecommitdiff
path: root/libopenjpeg/t2.c
diff options
context:
space:
mode:
authorFrancois-Olivier Devaux <fodevaux@users.noreply.github.com>2004-11-15 12:41:35 +0000
committerFrancois-Olivier Devaux <fodevaux@users.noreply.github.com>2004-11-15 12:41:35 +0000
commit1bdb07cefed67bb661f835d5165eb931c583c02d (patch)
tree84844be57eb29e550e3a53ff938b8b148954cbc0 /libopenjpeg/t2.c
parent0a879e22071bfdf39dcf2cb611db9cb364e62a04 (diff)
fprintf correctly redirected to stderr or stdout
Diffstat (limited to 'libopenjpeg/t2.c')
-rw-r--r--libopenjpeg/t2.c61
1 files changed, 59 insertions, 2 deletions
diff --git a/libopenjpeg/t2.c b/libopenjpeg/t2.c
index 9ccc64c3..092b509c 100644
--- a/libopenjpeg/t2.c
+++ b/libopenjpeg/t2.c
@@ -303,6 +303,7 @@ int t2_decode_packet(unsigned char *src, int len, tcd_tile_t * tile,
tcd_tilecomp_t *tilec = &tile->comps[compno];
tcd_resolution_t *res = &tilec->resolutions[resno];
unsigned char *c = src;
+
unsigned char *hd = NULL;
int present;
@@ -310,10 +311,15 @@ int t2_decode_packet(unsigned char *src, int len, tcd_tile_t * tile,
for (bandno = 0; bandno < res->numbands; bandno++) {
tcd_band_t *band = &res->bands[bandno];
tcd_precinct_t *prc = &band->precincts[precno];
+
+
//Add Antonin : sizebug1
+
if ((band->x1-band->x0 == 0)||(band->y1-band->y0 == 0)) continue;
+
//ddA
+
tgt_reset(prc->incltree);
tgt_reset(prc->imsbtree);
@@ -323,15 +329,25 @@ int t2_decode_packet(unsigned char *src, int len, tcd_tile_t * tile,
}
}
}
+
+
// SOP markers
+
if (tcp->csty & J2K_CP_CSTY_SOP) {
+
if ((*c) != 0xff || (*(c + 1) != 0x91)) {
- printf("Warning : expected SOP marker\n");
+
+ fprintf(stderr,"Warning : expected SOP marker\n");
+
} else {
+
c += 6;
+
}
+
//TODO : check the Nsop value
+
}
/* When the marker PPT/PPM is used the packet header are store in PPT/PPM marker
@@ -339,6 +355,7 @@ int t2_decode_packet(unsigned char *src, int len, tcd_tile_t * tile,
step 1: Read packet header in the saved structure
step 2: Return to codestream for decoding */
+
if (cp->ppm == 1) { /* PPM */
hd = cp->ppm_data;
bio_init_dec(hd, cp->ppm_len); //Mod Antonin : ppmbug1
@@ -346,47 +363,69 @@ int t2_decode_packet(unsigned char *src, int len, tcd_tile_t * tile,
hd = tcp->ppt_data;
bio_init_dec(hd, tcp->ppt_len); //Mod Antonin : ppmbug1
} else { /* Normal Case */
+
hd = c;
+
bio_init_dec(hd, src+len-hd);
+
}
present = bio_read(1);
if (!present) {
bio_inalign();
+
hd += bio_numbytes();
+
+
// EPH markers
+
if (tcp->csty & J2K_CP_CSTY_EPH) {
+
if ((*hd) != 0xff || (*(hd + 1) != 0x92)) {
+
printf("Error : expected EPH marker\n");
+
} else {
+
hd += 2;
+
}
+
}
if (cp->ppm == 1) { /* PPM case */
+
cp->ppm_len+=cp->ppm_data-hd;
cp->ppm_data = hd;
return c - src;
}
if (tcp->ppt == 1) { /* PPT case */
+
tcp->ppt_len+=tcp->ppt_data-hd;
tcp->ppt_data = hd;
return c - src;
}
+
return hd - src;
}
+
for (bandno = 0; bandno < res->numbands; bandno++) {
tcd_band_t *band = &res->bands[bandno];
tcd_precinct_t *prc = &band->precincts[precno];
+
+
//Add Antonin : sizebug1
+
if ((band->x1-band->x0 == 0)||(band->y1-band->y0 == 0)) continue;
+
//ddA
+
for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
int included, increment, n;
tcd_cblk_t *cblk = &prc->cblks[cblkno];
@@ -444,33 +483,50 @@ int t2_decode_packet(unsigned char *src, int len, tcd_tile_t * tile,
hd += bio_numbytes();
+
// EPH markers
if (tcp->csty & J2K_CP_CSTY_EPH) {
if ((*hd) != 0xff || (*(hd + 1) != 0x92)) {
- printf("Error : expected EPH marker\n");
+ fprintf(stderr,"Error : expected EPH marker\n");
} else {
hd += 2;
+
}
}
+
+
if (cp->ppm==1) {
+
cp->ppm_len+=cp->ppm_data-hd;
+
cp->ppm_data = hd;
+
} else if (tcp->ppt == 1) {
+
tcp->ppt_len+=tcp->ppt_data-hd;
+
tcp->ppt_data = hd;
+
} else {
+
c=hd;
+
}
for (bandno = 0; bandno < res->numbands; bandno++) {
tcd_band_t *band = &res->bands[bandno];
tcd_precinct_t *prc = &band->precincts[precno];
+
+
//Add Antonin : sizebug1
+
if ((band->x1-band->x0 == 0)||(band->y1-band->y0 == 0)) continue;
+
//ddA
+
for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
tcd_cblk_t *cblk = &prc->cblks[cblkno];
tcd_seg_t *seg;
@@ -478,6 +534,7 @@ int t2_decode_packet(unsigned char *src, int len, tcd_tile_t * tile,
continue;
if (!cblk->numsegs) {
seg = &cblk->segs[0];
+
cblk->numsegs++;
cblk->len = 0;
} else {