diff options
| author | Giuseppe Baruffa <gbaruffa@users.noreply.github.com> | 2007-09-04 14:19:55 +0000 |
|---|---|---|
| committer | Giuseppe Baruffa <gbaruffa@users.noreply.github.com> | 2007-09-04 14:19:55 +0000 |
| commit | d3d2a36fbc2b856bd9b6e1a8ed0cab9277e9d517 (patch) | |
| tree | 4d5df25249f810cde9d67b2c7560ecd3f2cfe108 /libopenjpeg | |
| parent | 564e16d5cea51dc877870055e2703330ad323cdd (diff) | |
Added some fields in the codestream_info structure: they are used to record the position of single tile parts. Changed also the write_index function in the codec, to reflect the presence of this new information.
Diffstat (limited to 'libopenjpeg')
| -rw-r--r-- | libopenjpeg/j2k.c | 49 | ||||
| -rw-r--r-- | libopenjpeg/openjpeg.h | 14 |
2 files changed, 62 insertions, 1 deletions
diff --git a/libopenjpeg/j2k.c b/libopenjpeg/j2k.c index 476b68c5..9a6d7458 100644 --- a/libopenjpeg/j2k.c +++ b/libopenjpeg/j2k.c @@ -421,6 +421,16 @@ int j2k_calculate_tp(opj_cp_t *cp,int img_numcomp,opj_image_t *image,opj_j2k_t * pi_destroy(pi, cp, tileno); } j2k->cur_totnum_tp[tileno] = cur_totnum_tp; +/* UniPG>> */ + /* INDEX >> */ + if (j2k->cstr_info && j2k->cstr_info->index_on) { + j2k->cstr_info->tile[tileno].num_tps = cur_totnum_tp; + j2k->cstr_info->tile[tileno].tp_start_pos = (int *) opj_malloc(cur_totnum_tp * sizeof(int)); + j2k->cstr_info->tile[tileno].tp_end_header = (int *) opj_malloc(cur_totnum_tp * sizeof(int)); + j2k->cstr_info->tile[tileno].tp_end_pos = (int *) opj_malloc(cur_totnum_tp * sizeof(int)); + } + /* << INDEX */ +/* <<UniPG */ } return totnum_tp; } @@ -1913,6 +1923,13 @@ void j2k_destroy_compress(opj_j2k_t *j2k) { opj_tile_info_t *tile_info = &cstr_info->tile[tileno]; opj_free(tile_info->thresh); opj_free(tile_info->packet); +/* UniPG>> */ + /* INDEX >> */ + opj_free(tile_info->tp_start_pos); + opj_free(tile_info->tp_end_header); + opj_free(tile_info->tp_end_pos); + /* << INDEX */ +/* <<UniPG */ } opj_free(cstr_info->tile); } @@ -2229,6 +2246,9 @@ bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestre cstr_info->layer = (&cp->tcps[0])->numlayers; cstr_info->decomposition = (&cp->tcps[0])->tccps->numresolutions - 1; cstr_info->D_max = 0; /* ADD Marcela */ +/* UniPG>> */ + cstr_info->main_head_start = cio_tell(cio); /* position of SOC */ +/* <<UniPG */ } else if (cstr_info) { cstr_info->index_on = 0; @@ -2313,6 +2333,13 @@ bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestre for(tilepartno = 0; tilepartno < tot_num_tp ; tilepartno++){ j2k->tp_num = tilepartno; +/* UniPG>> */ + /* INDEX >> */ + if(cstr_info && cstr_info->index_on) + cstr_info->tile[j2k->curtileno].tp_start_pos[j2k->cur_tp_num] = + cio_tell(cio) + j2k->pos_correction; + /* << INDEX */ +/* <<UniPG */ j2k_write_sot(j2k); if(j2k->cur_tp_num == 0 && cp->cinema == 0){ @@ -2325,7 +2352,21 @@ bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestre } } +/* UniPG>> */ + /* INDEX >> */ + if(cstr_info && cstr_info->index_on) + cstr_info->tile[j2k->curtileno].tp_end_header[j2k->cur_tp_num] = + cio_tell(cio) + j2k->pos_correction + 1; + /* << INDEX */ +/* <<UniPG */ j2k_write_sod(j2k, tcd); +/* UniPG>> */ + /* INDEX >> */ + if(cstr_info && cstr_info->index_on) + cstr_info->tile[j2k->curtileno].tp_end_pos[j2k->cur_tp_num] = + cio_tell(cio) + j2k->pos_correction - 1; + /* << INDEX */ +/* <<UniPG */ j2k->cur_tp_num ++; } @@ -2364,7 +2405,13 @@ bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestre j2k_write_eoc(j2k); if(cstr_info && cstr_info->index_on) { - cstr_info->codestream_size = cio_tell(cio) + j2k->pos_correction; + cstr_info->codestream_size = cio_tell(cio) + j2k->pos_correction; +/* UniPG>> */ + /* The following adjustment is done to adjust the codestream size */ + /* if SOD is not at 0 in the buffer. Useful in case of JP2, where */ + /* the first unch of bytes is not in the codestream */ + cstr_info->codestream_size -= cstr_info->main_head_start; +/* <<UniPG */ } #ifdef USE_JPWL diff --git a/libopenjpeg/openjpeg.h b/libopenjpeg/openjpeg.h index c2bb3c58..2460d925 100644 --- a/libopenjpeg/openjpeg.h +++ b/libopenjpeg/openjpeg.h @@ -628,6 +628,16 @@ typedef struct opj_tile_info { int nbpix; /** add fixed_quality */ double distotile; + /* UniPG>> */ + /** number of tile parts */ + int num_tps; + /** start position of tile part */ + int *tp_start_pos; + /** end position of tile part header */ + int *tp_end_header; + /** end position of tile part */ + int *tp_end_pos; + /* << UniPG */ } opj_tile_info_t; /** @@ -666,6 +676,10 @@ typedef struct opj_codestream_info { int layer; /** number of decomposition */ int decomposition; +/* UniPG>> */ + /** main header position */ + int main_head_start; +/* <<UniPG */ /** main header position */ int main_head_end; /** codestream's size */ |
