Added information regarding the end of packet position in the index
This commit is contained in:
parent
acfe0ad645
commit
7a2d96efe1
|
@ -9,6 +9,7 @@ August 30, 2007
|
||||||
* [FOD] Changed the OpenJPEG library interface to enable users to access information regarding the codestream (also called codestream index).
|
* [FOD] Changed the OpenJPEG library interface to enable users to access information regarding the codestream (also called codestream index).
|
||||||
This index is usefull for all applications requiring to have a scalable acces to the codestream (like JPIP applications, ...)
|
This index is usefull for all applications requiring to have a scalable acces to the codestream (like JPIP applications, ...)
|
||||||
Currently, this information is only available when encoding an image.
|
Currently, this information is only available when encoding an image.
|
||||||
|
+ [FOD] Added the information regarding the end of packet position in the index
|
||||||
|
|
||||||
August 28, 2007
|
August 28, 2007
|
||||||
* [FOD] Fixed wrong destructors called in openjpeg.c
|
* [FOD] Fixed wrong destructors called in openjpeg.c
|
||||||
|
|
|
@ -598,14 +598,14 @@ int write_index_file(opj_codestream_info_t *cstr_info, char *index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
|
for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
|
||||||
int start_pos, end_pos;
|
int start_pos, end_ph_pos, end_pos;
|
||||||
double disto = 0;
|
double disto = 0;
|
||||||
pack_nb = 0;
|
pack_nb = 0;
|
||||||
|
|
||||||
fprintf(stream, "\nTILE %d DETAILS\n", tileno);
|
fprintf(stream, "\nTILE %d DETAILS\n", tileno);
|
||||||
if (cstr_info->prog == LRCP) { /* LRCP */
|
if (cstr_info->prog == LRCP) { /* LRCP */
|
||||||
|
|
||||||
fprintf(stream, "pack_nb tileno layno resno compno precno start_pos end_pos disto\n");
|
fprintf(stream, "LRCP\npack_nb tileno layno resno compno precno start_pos end_ph_pos end_pos disto\n");
|
||||||
|
|
||||||
for (layno = 0; layno < cstr_info->layer; layno++) {
|
for (layno = 0; layno < cstr_info->layer; layno++) {
|
||||||
for (resno = 0; resno < cstr_info->decomposition + 1; resno++) {
|
for (resno = 0; resno < cstr_info->decomposition + 1; resno++) {
|
||||||
|
@ -613,10 +613,11 @@ int write_index_file(opj_codestream_info_t *cstr_info, char *index) {
|
||||||
int prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
int prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||||
for (precno = 0; precno < prec_max; precno++) {
|
for (precno = 0; precno < prec_max; precno++) {
|
||||||
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||||
|
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||||
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||||
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||||
fprintf(stream, "%4d %6d %7d %5d %6d %6d %9d %9d %8e\n",
|
fprintf(stream, "%4d %6d %7d %5d %6d %6d %6d %6d %7d %8e\n",
|
||||||
pack_nb, tileno, layno, resno, compno, precno, start_pos, end_pos, disto);
|
pack_nb, tileno, layno, resno, compno, precno, start_pos, end_ph_pos, end_pos, disto);
|
||||||
total_disto += disto;
|
total_disto += disto;
|
||||||
pack_nb++;
|
pack_nb++;
|
||||||
}
|
}
|
||||||
|
@ -626,7 +627,7 @@ int write_index_file(opj_codestream_info_t *cstr_info, char *index) {
|
||||||
} /* LRCP */
|
} /* LRCP */
|
||||||
else if (cstr_info->prog == RLCP) { /* RLCP */
|
else if (cstr_info->prog == RLCP) { /* RLCP */
|
||||||
|
|
||||||
fprintf(stream, "pack_nb tileno resno layno compno precno start_pos end_pos disto\n");
|
fprintf(stream, "RLCP\npack_nb tileno resno layno compno precno start_pos end_ph_pos end_pos disto\n");
|
||||||
|
|
||||||
for (resno = 0; resno < cstr_info->decomposition + 1; resno++) {
|
for (resno = 0; resno < cstr_info->decomposition + 1; resno++) {
|
||||||
for (layno = 0; layno < cstr_info->layer; layno++) {
|
for (layno = 0; layno < cstr_info->layer; layno++) {
|
||||||
|
@ -634,10 +635,11 @@ int write_index_file(opj_codestream_info_t *cstr_info, char *index) {
|
||||||
int prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
int prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||||
for (precno = 0; precno < prec_max; precno++) {
|
for (precno = 0; precno < prec_max; precno++) {
|
||||||
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||||
|
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||||
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||||
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||||
fprintf(stream, "%4d %6d %5d %7d %6d %6d %9d %9d %8e\n",
|
fprintf(stream, "%4d %6d %5d %7d %6d %6d %9d %9d %7d %8e\n",
|
||||||
pack_nb, tileno, resno, layno, compno, precno, start_pos, end_pos, disto);
|
pack_nb, tileno, resno, layno, compno, precno, start_pos, end_ph_pos, end_pos, disto);
|
||||||
total_disto += disto;
|
total_disto += disto;
|
||||||
pack_nb++;
|
pack_nb++;
|
||||||
}
|
}
|
||||||
|
@ -647,7 +649,7 @@ int write_index_file(opj_codestream_info_t *cstr_info, char *index) {
|
||||||
} /* RLCP */
|
} /* RLCP */
|
||||||
else if (cstr_info->prog == RPCL) { /* RPCL */
|
else if (cstr_info->prog == RPCL) { /* RPCL */
|
||||||
|
|
||||||
fprintf(stream, "pack_nb tileno resno precno compno layno start_pos end_pos disto\n");
|
fprintf(stream, "RPCL\npack_nb tileno resno precno compno layno start_pos end_ph_pos end_pos disto\n");
|
||||||
|
|
||||||
for (resno = 0; resno < cstr_info->decomposition + 1; resno++) {
|
for (resno = 0; resno < cstr_info->decomposition + 1; resno++) {
|
||||||
/* I suppose components have same XRsiz, YRsiz */
|
/* I suppose components have same XRsiz, YRsiz */
|
||||||
|
@ -669,10 +671,11 @@ int write_index_file(opj_codestream_info_t *cstr_info, char *index) {
|
||||||
if (precno_x*pcx == x ) {
|
if (precno_x*pcx == x ) {
|
||||||
for (layno = 0; layno < cstr_info->layer; layno++) {
|
for (layno = 0; layno < cstr_info->layer; layno++) {
|
||||||
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||||
|
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||||
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||||
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||||
fprintf(stream, "%4d %6d %5d %6d %6d %7d %9d %9d %8e\n",
|
fprintf(stream, "%4d %6d %5d %6d %6d %7d %9d %9d %7d %8e\n",
|
||||||
pack_nb, tileno, resno, precno, compno, layno, start_pos, end_pos, disto);
|
pack_nb, tileno, resno, precno, compno, layno, start_pos, end_ph_pos, end_pos, disto);
|
||||||
total_disto += disto;
|
total_disto += disto;
|
||||||
pack_nb++;
|
pack_nb++;
|
||||||
}
|
}
|
||||||
|
@ -691,7 +694,7 @@ int write_index_file(opj_codestream_info_t *cstr_info, char *index) {
|
||||||
int x1 = x0 + cstr_info->tile_x;
|
int x1 = x0 + cstr_info->tile_x;
|
||||||
int y1 = y0 + cstr_info->tile_y;
|
int y1 = y0 + cstr_info->tile_y;
|
||||||
|
|
||||||
fprintf(stream, "pack_nb tileno precno compno resno layno start_pos end_pos disto\n");
|
fprintf(stream, "PCRL\npack_nb tileno precno compno resno layno start_pos end_ph_pos end_pos disto\n");
|
||||||
|
|
||||||
for (compno = 0; compno < cstr_info->comp; compno++) {
|
for (compno = 0; compno < cstr_info->comp; compno++) {
|
||||||
for (resno = 0; resno < cstr_info->decomposition + 1; resno++) {
|
for (resno = 0; resno < cstr_info->decomposition + 1; resno++) {
|
||||||
|
@ -708,10 +711,11 @@ int write_index_file(opj_codestream_info_t *cstr_info, char *index) {
|
||||||
if (precno_x*pcx == x ) {
|
if (precno_x*pcx == x ) {
|
||||||
for (layno = 0; layno < cstr_info->layer; layno++) {
|
for (layno = 0; layno < cstr_info->layer; layno++) {
|
||||||
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||||
|
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||||
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||||
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||||
fprintf(stream, "%4d %6d %6d %6d %5d %7d %9d %9d %8e\n",
|
fprintf(stream, "%4d %6d %6d %6d %5d %7d %9d %9d %7d %8e\n",
|
||||||
pack_nb, tileno, precno, compno, resno, layno, start_pos, end_pos, disto);
|
pack_nb, tileno, precno, compno, resno, layno, start_pos, end_ph_pos, end_pos, disto);
|
||||||
total_disto += disto;
|
total_disto += disto;
|
||||||
pack_nb++;
|
pack_nb++;
|
||||||
}
|
}
|
||||||
|
@ -725,7 +729,7 @@ int write_index_file(opj_codestream_info_t *cstr_info, char *index) {
|
||||||
} /* PCRL */
|
} /* PCRL */
|
||||||
else { /* CPRL */
|
else { /* CPRL */
|
||||||
|
|
||||||
fprintf(stream, "pack_nb tileno compno precno resno layno start_pos end_pos disto\n");
|
fprintf(stream, "CPRL\npack_nb tileno compno precno resno layno start_pos end_ph_pos end_pos disto\n");
|
||||||
|
|
||||||
for (compno = 0; compno < cstr_info->comp; compno++) {
|
for (compno = 0; compno < cstr_info->comp; compno++) {
|
||||||
/* I suppose components have same XRsiz, YRsiz */
|
/* I suppose components have same XRsiz, YRsiz */
|
||||||
|
@ -748,10 +752,11 @@ int write_index_file(opj_codestream_info_t *cstr_info, char *index) {
|
||||||
if (precno_x*pcx == x ) {
|
if (precno_x*pcx == x ) {
|
||||||
for (layno = 0; layno < cstr_info->layer; layno++) {
|
for (layno = 0; layno < cstr_info->layer; layno++) {
|
||||||
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||||
|
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||||
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||||
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||||
fprintf(stream, "%4d %6d %6d %6d %5d %7d %9d %9d %8e\n",
|
fprintf(stream, "%4d %6d %6d %6d %5d %7d %9d %9d %7d %8e\n",
|
||||||
pack_nb, tileno, compno, precno, resno, layno, start_pos, end_pos, disto);
|
pack_nb, tileno, compno, precno, resno, layno, start_pos, end_ph_pos, end_pos, disto);
|
||||||
total_disto += disto;
|
total_disto += disto;
|
||||||
pack_nb++;
|
pack_nb++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -590,9 +590,11 @@ typedef struct opj_image_comptparm {
|
||||||
Index structure : Information concerning a packet inside tile
|
Index structure : Information concerning a packet inside tile
|
||||||
*/
|
*/
|
||||||
typedef struct opj_packet_info {
|
typedef struct opj_packet_info {
|
||||||
/** start position */
|
/** packet start position (including SOP marker if it exists) */
|
||||||
int start_pos;
|
int start_pos;
|
||||||
/** end position */
|
/** end of packet header position (including EPH marker if it exists)*/
|
||||||
|
int end_ph_pos;
|
||||||
|
/** packet end position */
|
||||||
int end_pos;
|
int end_pos;
|
||||||
/** packet distorsion */
|
/** packet distorsion */
|
||||||
double disto;
|
double disto;
|
||||||
|
|
|
@ -128,7 +128,6 @@ static int t2_getnumpasses(opj_bio_t *bio) {
|
||||||
|
|
||||||
static int t2_encode_packet(opj_tcd_tile_t * tile, opj_tcp_t * tcp, opj_pi_iterator_t *pi, unsigned char *dest, int length, opj_codestream_info_t *cstr_info, int tileno) {
|
static int t2_encode_packet(opj_tcd_tile_t * tile, opj_tcp_t * tcp, opj_pi_iterator_t *pi, unsigned char *dest, int length, opj_codestream_info_t *cstr_info, int tileno) {
|
||||||
int bandno, cblkno;
|
int bandno, cblkno;
|
||||||
unsigned char *sop = 0, *eph = 0;
|
|
||||||
unsigned char *c = dest;
|
unsigned char *c = dest;
|
||||||
|
|
||||||
int compno = pi->compno; /* component value */
|
int compno = pi->compno; /* component value */
|
||||||
|
@ -143,15 +142,12 @@ static int t2_encode_packet(opj_tcd_tile_t * tile, opj_tcp_t * tcp, opj_pi_itera
|
||||||
|
|
||||||
/* <SOP 0xff91> */
|
/* <SOP 0xff91> */
|
||||||
if (tcp->csty & J2K_CP_CSTY_SOP) {
|
if (tcp->csty & J2K_CP_CSTY_SOP) {
|
||||||
sop = (unsigned char *) opj_malloc(6 * sizeof(unsigned char));
|
c[0] = 255;
|
||||||
sop[0] = 255;
|
c[1] = 145;
|
||||||
sop[1] = 145;
|
c[2] = 0;
|
||||||
sop[2] = 0;
|
c[3] = 4;
|
||||||
sop[3] = 4;
|
c[4] = (cstr_info->num % 65536) / 256;
|
||||||
sop[4] = (cstr_info->num % 65536) / 256;
|
c[5] = (cstr_info->num % 65536) % 256;
|
||||||
sop[5] = (cstr_info->num % 65536) % 256;
|
|
||||||
memcpy(c, sop, 6);
|
|
||||||
opj_free(sop);
|
|
||||||
c += 6;
|
c += 6;
|
||||||
}
|
}
|
||||||
/* </SOP> */
|
/* </SOP> */
|
||||||
|
@ -245,20 +241,25 @@ static int t2_encode_packet(opj_tcd_tile_t * tile, opj_tcp_t * tcp, opj_pi_itera
|
||||||
}
|
}
|
||||||
|
|
||||||
c += bio_numbytes(bio);
|
c += bio_numbytes(bio);
|
||||||
|
|
||||||
bio_destroy(bio);
|
bio_destroy(bio);
|
||||||
|
|
||||||
/* <EPH 0xff92> */
|
/* <EPH 0xff92> */
|
||||||
if (tcp->csty & J2K_CP_CSTY_EPH) {
|
if (tcp->csty & J2K_CP_CSTY_EPH) {
|
||||||
eph = (unsigned char *) opj_malloc(2 * sizeof(unsigned char));
|
c[0] = 255;
|
||||||
eph[0] = 255;
|
c[1] = 146;
|
||||||
eph[1] = 146;
|
|
||||||
memcpy(c, eph, 2);
|
|
||||||
opj_free(eph);
|
|
||||||
c += 2;
|
c += 2;
|
||||||
}
|
}
|
||||||
/* </EPH> */
|
/* </EPH> */
|
||||||
|
|
||||||
|
/* << INDEX */
|
||||||
|
// End of packet header position. Currently only represents the distance to start of packet
|
||||||
|
// Will be updated later by incrementing with packet start value
|
||||||
|
if(cstr_info && cstr_info->index_write && cstr_info->index_on) {
|
||||||
|
opj_packet_info_t *info_PK = &cstr_info->tile[tileno].packet[cstr_info->num];
|
||||||
|
info_PK->end_ph_pos = (int)(c - dest);
|
||||||
|
}
|
||||||
|
/* INDEX >> */
|
||||||
|
|
||||||
/* Writing the packet body */
|
/* Writing the packet body */
|
||||||
|
|
||||||
for (bandno = 0; bandno < res->numbands; bandno++) {
|
for (bandno = 0; bandno < res->numbands; bandno++) {
|
||||||
|
@ -277,16 +278,15 @@ static int t2_encode_packet(opj_tcd_tile_t * tile, opj_tcp_t * tcp, opj_pi_itera
|
||||||
memcpy(c, layer->data, layer->len);
|
memcpy(c, layer->data, layer->len);
|
||||||
cblk->numpasses += layer->numpasses;
|
cblk->numpasses += layer->numpasses;
|
||||||
c += layer->len;
|
c += layer->len;
|
||||||
/* ADD for index Cfr. Marcela --> delta disto by packet */
|
/* << INDEX */
|
||||||
if(cstr_info && cstr_info->index_write && cstr_info->index_on) {
|
if(cstr_info && cstr_info->index_write && cstr_info->index_on) {
|
||||||
opj_tile_info_t *info_TL = &cstr_info->tile[tileno];
|
opj_packet_info_t *info_PK = &cstr_info->tile[tileno].packet[cstr_info->num];
|
||||||
opj_packet_info_t *info_PK = &info_TL->packet[cstr_info->num];
|
|
||||||
info_PK->disto += layer->disto;
|
info_PK->disto += layer->disto;
|
||||||
if (cstr_info->D_max < info_PK->disto) {
|
if (cstr_info->D_max < info_PK->disto) {
|
||||||
cstr_info->D_max = info_PK->disto;
|
cstr_info->D_max = info_PK->disto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* </ADD> */
|
/* INDEX >> */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -630,6 +630,8 @@ int t2_encode_packets(opj_t2_t* t2,int tileno, opj_tcd_tile_t *tile, int maxlaye
|
||||||
info_PK->start_pos = (cp->tp_on && info_PK->start_pos) ? info_PK->start_pos : info_TL->packet[cstr_info->num - 1].end_pos + 1;
|
info_PK->start_pos = (cp->tp_on && info_PK->start_pos) ? info_PK->start_pos : info_TL->packet[cstr_info->num - 1].end_pos + 1;
|
||||||
}
|
}
|
||||||
info_PK->end_pos = info_PK->start_pos + e - 1;
|
info_PK->end_pos = info_PK->start_pos + e - 1;
|
||||||
|
info_PK->end_ph_pos += info_PK->start_pos - 1; // End of packet header which now only represents the distance
|
||||||
|
// to start of packet is incremented by value of start of packet
|
||||||
}
|
}
|
||||||
|
|
||||||
cstr_info->num++;
|
cstr_info->num++;
|
||||||
|
|
Loading…
Reference in New Issue