diff options
| author | Francois-Olivier Devaux <fodevaux@users.noreply.github.com> | 2007-09-17 14:00:43 +0000 |
|---|---|---|
| committer | Francois-Olivier Devaux <fodevaux@users.noreply.github.com> | 2007-09-17 14:00:43 +0000 |
| commit | 569bbb00776f08211f7184ea4ea94571b652adae (patch) | |
| tree | 1366a336e13bdb6f5c2f508fc36a5ccc1fadedb8 /libopenjpeg | |
| parent | abfba20b9922af6dd25593f5e0aa2e232253e7ce (diff) | |
Fixed issues with cstr_info when codestream has components with different number of resolutions.
Diffstat (limited to 'libopenjpeg')
| -rw-r--r-- | libopenjpeg/j2k.c | 25 | ||||
| -rw-r--r-- | libopenjpeg/openjpeg.h | 4 | ||||
| -rw-r--r-- | libopenjpeg/t2.c | 4 | ||||
| -rw-r--r-- | libopenjpeg/tcd.c | 38 |
4 files changed, 45 insertions, 26 deletions
diff --git a/libopenjpeg/j2k.c b/libopenjpeg/j2k.c index 651ef215..a58ab6c3 100644 --- a/libopenjpeg/j2k.c +++ b/libopenjpeg/j2k.c @@ -675,7 +675,7 @@ static void j2k_read_siz(opj_j2k_t *j2k) { cstr_info->tile_y = cp->tdy; cstr_info->tile_Ox = cp->tx0; cstr_info->tile_Oy = cp->ty0; - cstr_info->tile = (opj_tile_info_t*) opj_malloc(cp->tw * cp->th * sizeof(opj_tile_info_t)); + cstr_info->tile = (opj_tile_info_t*) opj_malloc(cp->tw * cp->th * sizeof(opj_tile_info_t)); } } @@ -824,7 +824,10 @@ static void j2k_read_cod(opj_j2k_t *j2k) { opj_codestream_info_t *cstr_info = j2k->cstr_info; cstr_info->prog = tcp->prg; cstr_info->numlayers = tcp->numlayers; - cstr_info->numdecompos = tcp->tccps[0].numresolutions - 1; + cstr_info->numdecompos = (int*) malloc (image->numcomps * sizeof(int)); + for (i = 0; i < image->numcomps; i++) { + cstr_info->numdecompos[i] = tcp->tccps[i].numresolutions - 1; + } } } @@ -1376,10 +1379,14 @@ static void j2k_read_sot(opj_j2k_t *j2k) { j2k->cstr_info->tile[tileno].start_pos = cio_tell(cio) - 12; j2k->cstr_info->tile[tileno].end_pos = j2k->cstr_info->tile[tileno].start_pos + totlen - 1; j2k->cstr_info->tile[tileno].num_tps = numparts; - j2k->cstr_info->tile[tileno].tp = (opj_tp_info_t *) opj_malloc(numparts * sizeof(opj_tp_info_t)); + if (numparts) + j2k->cstr_info->tile[tileno].tp = (opj_tp_info_t *) opj_malloc(numparts * sizeof(opj_tp_info_t)); + else + j2k->cstr_info->tile[tileno].tp = (opj_tp_info_t *) opj_malloc(10 * sizeof(opj_tp_info_t)); // Fixme (10) } - else + else { j2k->cstr_info->tile[tileno].end_pos += totlen; + } j2k->cstr_info->tile[tileno].tp[partno].tp_start_pos = cio_tell(cio) - 12; j2k->cstr_info->tile[tileno].tp[partno].tp_end_pos = j2k->cstr_info->tile[tileno].tp[partno].tp_start_pos + totlen - 1; @@ -1477,7 +1484,7 @@ static void j2k_read_sod(opj_j2k_t *j2k) { if (len == cio_numbytesleft(cio) + 1) { truncate = 1; /* Case of a truncate codestream */ - } + } data = (unsigned char *) opj_malloc((j2k->tile_len[curtileno] + len) * sizeof(unsigned char)); @@ -2278,6 +2285,7 @@ bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestre /* INDEX >> */ j2k->cstr_info = cstr_info; if (cstr_info) { + int compno; cstr_info->tile = (opj_tile_info_t *) opj_malloc(cp->tw * cp->th * sizeof(opj_tile_info_t)); cstr_info->image_w = image->x1 - image->x0; cstr_info->image_h = image->y1 - image->y0; @@ -2290,7 +2298,10 @@ bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestre cstr_info->tile_Oy = cp->ty0; /* new version parser */ cstr_info->numcomps = image->numcomps; cstr_info->numlayers = (&cp->tcps[0])->numlayers; - cstr_info->numdecompos = (&cp->tcps[0])->tccps->numresolutions - 1; + cstr_info->numdecompos = (int*) malloc (image->numcomps * sizeof(int)); + for (compno=0; compno < image->numcomps; compno++) { + cstr_info->numdecompos[compno] = (&cp->tcps[0])->tccps->numresolutions - 1; + } cstr_info->D_max = 0; /* ADD Marcela */ cstr_info->main_head_start = cio_tell(cio); /* position of SOC */ } @@ -2469,3 +2480,5 @@ bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestre + + diff --git a/libopenjpeg/openjpeg.h b/libopenjpeg/openjpeg.h index 876c0ab1..20ff7cf7 100644 --- a/libopenjpeg/openjpeg.h +++ b/libopenjpeg/openjpeg.h @@ -690,8 +690,8 @@ typedef struct opj_codestream_info { int numcomps; /** number of layer */ int numlayers; - /** number of decomposition of first component */ - int numdecompos; + /** number of decomposition for each component */ + int *numdecompos; /* UniPG>> */ /** number of markers */ int marknum; diff --git a/libopenjpeg/t2.c b/libopenjpeg/t2.c index 5d0d9856..5692a1ec 100644 --- a/libopenjpeg/t2.c +++ b/libopenjpeg/t2.c @@ -748,7 +748,7 @@ int t2_decode_packets(opj_t2_t *t2, unsigned char *src, int len, int tileno, opj return e; } - return (c - src); + return (c - src); } /* ----------------------------------------------------------------------- */ @@ -771,3 +771,5 @@ void t2_destroy(opj_t2_t *t2) { } + + diff --git a/libopenjpeg/tcd.c b/libopenjpeg/tcd.c index 767e7f3d..8f59caa4 100644 --- a/libopenjpeg/tcd.c +++ b/libopenjpeg/tcd.c @@ -1309,25 +1309,27 @@ bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, op /* INDEX >> */ if(cstr_info) { - int i, numpacks = 0; - opj_tcp_t *tcp = &tcd->cp->tcps[0]; - opj_tccp_t *tccp = &tcp->tccps[0]; - opj_tcd_tilecomp_t *tilec_idx = &tile->comps[0]; /* based on component 0 */ - for (i = 0; i < tilec_idx->numresolutions; i++) { - opj_tcd_resolution_t *res_idx = &tilec_idx->resolutions[i]; - cstr_info->tile[tileno].pw[i] = res_idx->pw; - cstr_info->tile[tileno].ph[i] = res_idx->ph; - numpacks += res_idx->pw * res_idx->ph; - if (tccp->csty & J2K_CP_CSTY_PRT) { - cstr_info->tile[tileno].pdx[i] = tccp->prcw[i]; - cstr_info->tile[tileno].pdy[i] = tccp->prch[i]; - } - else { - cstr_info->tile[tileno].pdx[i] = 15; - cstr_info->tile[tileno].pdx[i] = 15; + int resno, compno, numprec = 0; + for (compno = 0; compno < cstr_info->numcomps; compno++) { + opj_tcp_t *tcp = &tcd->cp->tcps[0]; + opj_tccp_t *tccp = &tcp->tccps[compno]; + opj_tcd_tilecomp_t *tilec_idx = &tile->comps[compno]; + for (resno = 0; resno < tilec_idx->numresolutions; resno++) { + opj_tcd_resolution_t *res_idx = &tilec_idx->resolutions[resno]; + cstr_info->tile[tileno].pw[resno] = res_idx->pw; + cstr_info->tile[tileno].ph[resno] = res_idx->ph; + numprec += res_idx->pw * res_idx->ph; + if (tccp->csty & J2K_CP_CSTY_PRT) { + cstr_info->tile[tileno].pdx[resno] = tccp->prcw[resno]; + cstr_info->tile[tileno].pdy[resno] = tccp->prch[resno]; + } + else { + cstr_info->tile[tileno].pdx[resno] = 15; + cstr_info->tile[tileno].pdx[resno] = 15; + } } } - cstr_info->tile[tileno].packet = (opj_packet_info_t *) opj_malloc(cstr_info->numcomps * cstr_info->numlayers * numpacks * sizeof(opj_packet_info_t)); + cstr_info->tile[tileno].packet = (opj_packet_info_t *) opj_malloc(cstr_info->numlayers * numprec * sizeof(opj_packet_info_t)); cstr_info->packno = 0; } /* << INDEX */ @@ -1472,3 +1474,5 @@ void tcd_free_decode_tile(opj_tcd_t *tcd, int tileno) { + + |
