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.

This commit is contained in:
Giuseppe Baruffa 2007-09-04 14:19:55 +00:00
parent 564e16d5ce
commit d3d2a36fbc
4 changed files with 94 additions and 4 deletions

View File

@ -5,6 +5,8 @@ What's New for OpenJPEG
! : changed ! : changed
+ : added + : added
September 4, 2007
+ [GB] 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.
September 3, 2007 September 3, 2007
+ [GB] Added the knowledge of JPSEC SEC and INSEC markers (you have to compile the JPWL project). Management of these markers is limited to skipping them without crashing: no real security function at this stage. Deprecated USE_JPSEC will be removed next + [GB] Added the knowledge of JPSEC SEC and INSEC markers (you have to compile the JPWL project). Management of these markers is limited to skipping them without crashing: no real security function at this stage. Deprecated USE_JPSEC will be removed next

View File

@ -559,6 +559,9 @@ int write_index_file(opj_codestream_info_t *cstr_info, char *index) {
int tileno, compno, layno, resno, precno, pack_nb, x, y; int tileno, compno, layno, resno, precno, pack_nb, x, y;
FILE *stream = NULL; FILE *stream = NULL;
double total_disto = 0; double total_disto = 0;
/* UniPG>> */
int tilepartno;
/* <<UniPG */
if (!cstr_info) if (!cstr_info)
return 1; return 1;
@ -582,17 +585,31 @@ int write_index_file(opj_codestream_info_t *cstr_info, char *index) {
(1 << cstr_info->tile[0].pdx[resno]), (1 << cstr_info->tile[0].pdx[resno])); /* based on tile 0 */ (1 << cstr_info->tile[0].pdx[resno]), (1 << cstr_info->tile[0].pdx[resno])); /* based on tile 0 */
} }
fprintf(stream, "\n"); fprintf(stream, "\n");
/* UniPG>> */
fprintf(stream, "%d\n", cstr_info->main_head_start);
/* <<UniPG */
fprintf(stream, "%d\n", cstr_info->main_head_end); fprintf(stream, "%d\n", cstr_info->main_head_end);
fprintf(stream, "%d\n", cstr_info->codestream_size); fprintf(stream, "%d\n", cstr_info->codestream_size);
fprintf(stream, "\nINFO ON TILES\n"); fprintf(stream, "\nINFO ON TILES\n");
fprintf(stream, "tileno start_pos end_hd end_tile disto nbpix disto/nbpix\n"); fprintf(stream, "tileno start_pos end_hd end_tile"
/* UniPG>> */
" nbparts"
/* <<UniPG */
" disto nbpix disto/nbpix\n");
for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) { for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
fprintf(stream, "%4d %9d %9d %9d %9e %9d %9e\n", fprintf(stream, "%4d %9d %9d %9d "
/* UniPG>> */
"%9d "
/* <<UniPG */
"%9e %9d %9e\n",
cstr_info->tile[tileno].num_tile, cstr_info->tile[tileno].num_tile,
cstr_info->tile[tileno].start_pos, cstr_info->tile[tileno].start_pos,
cstr_info->tile[tileno].end_header, cstr_info->tile[tileno].end_header,
cstr_info->tile[tileno].end_pos, cstr_info->tile[tileno].end_pos,
/* UniPG>> */
cstr_info->tile[tileno].num_tps,
/* <<UniPG */
cstr_info->tile[tileno].distotile, cstr_info->tile[tileno].nbpix, cstr_info->tile[tileno].distotile, cstr_info->tile[tileno].nbpix,
cstr_info->tile[tileno].distotile / cstr_info->tile[tileno].nbpix); cstr_info->tile[tileno].distotile / cstr_info->tile[tileno].nbpix);
} }
@ -603,6 +620,16 @@ int write_index_file(opj_codestream_info_t *cstr_info, char *index) {
pack_nb = 0; pack_nb = 0;
fprintf(stream, "\nTILE %d DETAILS\n", tileno); fprintf(stream, "\nTILE %d DETAILS\n", tileno);
/* UniPG>> */
fprintf(stream, "part_nb tileno start_pos end_tph_pos end_pos\n");
for (tilepartno = 0; tilepartno < cstr_info->tile[tileno].num_tps; tilepartno++)
fprintf(stream, "%4d %9d %9d %11d %9d\n",
tilepartno, tileno,
cstr_info->tile[tileno].tp_start_pos[tilepartno],
cstr_info->tile[tileno].tp_end_header[tilepartno],
cstr_info->tile[tileno].tp_end_pos[tilepartno]
);
/* <<UniPG */
if (cstr_info->prog == LRCP) { /* LRCP */ if (cstr_info->prog == LRCP) { /* LRCP */
fprintf(stream, "LRCP\npack_nb tileno layno resno compno precno start_pos end_ph_pos end_pos disto\n"); fprintf(stream, "LRCP\npack_nb tileno layno resno compno precno start_pos end_ph_pos end_pos disto\n");

View File

@ -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); pi_destroy(pi, cp, tileno);
} }
j2k->cur_totnum_tp[tileno] = cur_totnum_tp; 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; 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_tile_info_t *tile_info = &cstr_info->tile[tileno];
opj_free(tile_info->thresh); opj_free(tile_info->thresh);
opj_free(tile_info->packet); 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); 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->layer = (&cp->tcps[0])->numlayers;
cstr_info->decomposition = (&cp->tcps[0])->tccps->numresolutions - 1; cstr_info->decomposition = (&cp->tcps[0])->tccps->numresolutions - 1;
cstr_info->D_max = 0; /* ADD Marcela */ cstr_info->D_max = 0; /* ADD Marcela */
/* UniPG>> */
cstr_info->main_head_start = cio_tell(cio); /* position of SOC */
/* <<UniPG */
} }
else if (cstr_info) { else if (cstr_info) {
cstr_info->index_on = 0; 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++){ for(tilepartno = 0; tilepartno < tot_num_tp ; tilepartno++){
j2k->tp_num = 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); j2k_write_sot(j2k);
if(j2k->cur_tp_num == 0 && cp->cinema == 0){ 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); 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 ++; j2k->cur_tp_num ++;
} }
@ -2365,6 +2406,12 @@ bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestre
if(cstr_info && cstr_info->index_on) { 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 #ifdef USE_JPWL

View File

@ -628,6 +628,16 @@ typedef struct opj_tile_info {
int nbpix; int nbpix;
/** add fixed_quality */ /** add fixed_quality */
double distotile; 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; } opj_tile_info_t;
/** /**
@ -666,6 +676,10 @@ typedef struct opj_codestream_info {
int layer; int layer;
/** number of decomposition */ /** number of decomposition */
int decomposition; int decomposition;
/* UniPG>> */
/** main header position */
int main_head_start;
/* <<UniPG */
/** main header position */ /** main header position */
int main_head_end; int main_head_end;
/** codestream's size */ /** codestream's size */