summaryrefslogtreecommitdiff
path: root/jpwl
diff options
context:
space:
mode:
authorFrancois-Olivier Devaux <fodevaux@users.noreply.github.com>2007-08-30 09:51:20 +0000
committerFrancois-Olivier Devaux <fodevaux@users.noreply.github.com>2007-08-30 09:51:20 +0000
commitacfe0ad6458db913aac469804d4d17bea671682a (patch)
tree3a8d4afee950198a5f8fa1c3acff2f96d0cdd7e5 /jpwl
parentd07fa5d9d0b5f3452831e4c0c9da1f03d30a1299 (diff)
Changed the OpenJPEG library interface to enable users to access information regarding the codestream (also called index).
Diffstat (limited to 'jpwl')
-rw-r--r--jpwl/jpwl.c56
-rw-r--r--jpwl/jpwl_lib.c38
2 files changed, 47 insertions, 47 deletions
diff --git a/jpwl/jpwl.c b/jpwl/jpwl.c
index 97937b4c..dbd145f6 100644
--- a/jpwl/jpwl.c
+++ b/jpwl/jpwl.c
@@ -179,7 +179,7 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
(unsigned char) j2k->cp->sens_MH, /* sensitivity method */
j2k->cp->sens_size, /* sensitivity size */
-1, /* this ESD is in main header */
- 0 /*j2k->image_info->num*/, /* number of packets in codestream */
+ 0 /*j2k->cstr_info->num*/, /* number of packets in codestream */
NULL /*sensval*/ /* pointer to sensitivity data of packets */
)) {
@@ -215,21 +215,21 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
/* cycle through TPHs */
sens = -1; /* default spec: no ESD */
tilespec = 0; /* first tile spec */
- for (tileno = 0; tileno < j2k->image_info->tw * j2k->image_info->th; tileno++) {
+ for (tileno = 0; tileno < j2k->cstr_info->tw * j2k->cstr_info->th; tileno++) {
int sot_len, Psot, Psotp, mm;
unsigned long sot_pos, post_sod_pos;
unsigned long int left_THmarks_len;
- sot_pos = j2k->image_info->tile[tileno].start_pos;
+ sot_pos = j2k->cstr_info->tile[tileno].start_pos;
cio_seek(cio, sot_pos + 2);
sot_len = cio_read(cio, 2); /* SOT Len */
cio_skip(cio, 2);
Psotp = cio_tell(cio);
Psot = cio_read(cio, 4); /* tile length */
- post_sod_pos = j2k->image_info->tile[tileno].end_header + 1;
+ post_sod_pos = j2k->cstr_info->tile[tileno].end_header + 1;
left_THmarks_len = post_sod_pos - sot_pos;
/* add all the lengths of the markers which are len-ready and stay within SOT and SOD */
@@ -269,7 +269,7 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
if (jwmarker_num < JPWL_MAX_NO_MARKERS) {
jwmarker[jwmarker_num].id = J2K_MS_ESD; /* its type */
jwmarker[jwmarker_num].esdmark = esd_mark; /* the EPB */
- jwmarker[jwmarker_num].pos = j2k->image_info->tile[tileno].start_pos + sot_len + 2; /* after SOT */
+ jwmarker[jwmarker_num].pos = j2k->cstr_info->tile[tileno].start_pos + sot_len + 2; /* after SOT */
jwmarker[jwmarker_num].dpos = (double) jwmarker[jwmarker_num].pos + 0.2; /* not first at all! */
jwmarker[jwmarker_num].len = esd_mark->Lesd; /* its length */
jwmarker[jwmarker_num].len_ready = true; /* ready, yet */
@@ -307,7 +307,7 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
int mm;
/* position of SOT */
- unsigned int sot_pos = j2k->image_info->main_head_end + 1;
+ unsigned int sot_pos = j2k->cstr_info->main_head_end + 1;
/* how much space is there between end of SIZ and beginning of SOT? */
int left_MHmarks_len = sot_pos - socsiz_len;
@@ -371,15 +371,15 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
lastileno = 0;
packspec = 0;
pprot = -1;
- for (tileno = 0; tileno < j2k->image_info->tw * j2k->image_info->th; tileno++) {
+ for (tileno = 0; tileno < j2k->cstr_info->tw * j2k->cstr_info->th; tileno++) {
int sot_len, Psot, Psotp, mm, epb_index = 0, prot_len = 0;
unsigned long sot_pos, post_sod_pos;
unsigned long int left_THmarks_len, epbs_len = 0;
- int startpack = 0, stoppack = j2k->image_info->num;
+ int startpack = 0, stoppack = j2k->cstr_info->num;
jpwl_epb_ms_t *tph_epb = NULL;
- sot_pos = j2k->image_info->tile[tileno].start_pos;
+ sot_pos = j2k->cstr_info->tile[tileno].start_pos;
cio_seek(cio, sot_pos + 2);
sot_len = cio_read(cio, 2); /* SOT Len */
cio_skip(cio, 2);
@@ -387,7 +387,7 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
Psot = cio_read(cio, 4); /* tile length */
/* a-priori length of the data dwelling between SOT and SOD */
- post_sod_pos = j2k->image_info->tile[tileno].end_header + 1;
+ post_sod_pos = j2k->cstr_info->tile[tileno].end_header + 1;
left_THmarks_len = post_sod_pos - (sot_pos + sot_len + 2);
/* add all the lengths of the JPWL markers which are len-ready and stay within SOT and SOD */
@@ -426,7 +426,7 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
if (jwmarker_num < JPWL_MAX_NO_MARKERS) {
jwmarker[jwmarker_num].id = J2K_MS_EPB; /* its type */
jwmarker[jwmarker_num].epbmark = epb_mark; /* the EPB */
- jwmarker[jwmarker_num].pos = j2k->image_info->tile[tileno].start_pos + sot_len + 2; /* after SOT */
+ jwmarker[jwmarker_num].pos = j2k->cstr_info->tile[tileno].start_pos + sot_len + 2; /* after SOT */
jwmarker[jwmarker_num].dpos = (double) jwmarker[jwmarker_num].pos; /* first first first! */
jwmarker[jwmarker_num].len = epb_mark->Lepb; /* its length */
jwmarker[jwmarker_num].len_ready = true; /* ready */
@@ -457,7 +457,7 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
startpack = 0;
/* EPB MSs for UEP packet data protection in Tile Parts */
- for (packno = 0; packno < j2k->image_info->num; packno++) {
+ for (packno = 0; packno < j2k->cstr_info->num; packno++) {
if ((packspec < JPWL_MAX_NO_PACKSPECS) &&
(j2k->cp->pprot_tileno[packspec] == tileno) && (j2k->cp->pprot_packno[packspec] == packno)) {
@@ -471,19 +471,19 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
tileno,
startpack,
stoppack,
- j2k->image_info->tile[tileno].packet[startpack].start_pos,
- j2k->image_info->tile[tileno].packet[stoppack].end_pos,
+ j2k->cstr_info->tile[tileno].packet[startpack].start_pos,
+ j2k->cstr_info->tile[tileno].packet[stoppack].end_pos,
pprot);
- prot_len = j2k->image_info->tile[tileno].packet[stoppack].end_pos + 1 -
- j2k->image_info->tile[tileno].packet[startpack].start_pos;
+ prot_len = j2k->cstr_info->tile[tileno].packet[stoppack].end_pos + 1 -
+ j2k->cstr_info->tile[tileno].packet[startpack].start_pos;
/*
particular case: if this is the last header and the last packet,
then it is better to protect even the EOC marker
*/
- if ((tileno == ((j2k->image_info->tw * j2k->image_info->th) - 1)) &&
- (stoppack == (j2k->image_info->num - 1)))
+ if ((tileno == ((j2k->cstr_info->tw * j2k->cstr_info->th) - 1)) &&
+ (stoppack == (j2k->cstr_info->num - 1)))
/* add the EOC len */
prot_len += 2;
@@ -497,7 +497,7 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
false, /* inside MH */
&epb_index, /* pointer to EPB index */
pprot, /* protection type */
- (double) (j2k->image_info->tile[tileno].start_pos + sot_len + 2) + 0.0001, /* position */
+ (double) (j2k->cstr_info->tile[tileno].start_pos + sot_len + 2) + 0.0001, /* position */
tileno, /* number of tile */
0, /* length of pre-data */
prot_len /*4000*/ /* length of post-data */
@@ -521,19 +521,19 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
tileno,
startpack,
stoppack,
- j2k->image_info->tile[tileno].packet[startpack].start_pos,
- j2k->image_info->tile[tileno].packet[stoppack].end_pos,
+ j2k->cstr_info->tile[tileno].packet[startpack].start_pos,
+ j2k->cstr_info->tile[tileno].packet[stoppack].end_pos,
pprot);
- prot_len = j2k->image_info->tile[tileno].packet[stoppack].end_pos + 1 -
- j2k->image_info->tile[tileno].packet[startpack].start_pos;
+ prot_len = j2k->cstr_info->tile[tileno].packet[stoppack].end_pos + 1 -
+ j2k->cstr_info->tile[tileno].packet[startpack].start_pos;
/*
particular case: if this is the last header and the last packet,
then it is better to protect even the EOC marker
*/
- if ((tileno == ((j2k->image_info->tw * j2k->image_info->th) - 1)) &&
- (stoppack == (j2k->image_info->num - 1)))
+ if ((tileno == ((j2k->cstr_info->tw * j2k->cstr_info->th) - 1)) &&
+ (stoppack == (j2k->cstr_info->num - 1)))
/* add the EOC len */
prot_len += 2;
@@ -547,7 +547,7 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
false, /* inside MH */
&epb_index, /* pointer to EPB index */
pprot, /* protection type */
- (double) (j2k->image_info->tile[tileno].start_pos + sot_len + 2) + 0.0001, /* position */
+ (double) (j2k->cstr_info->tile[tileno].start_pos + sot_len + 2) + 0.0001, /* position */
tileno, /* number of tile */
0, /* length of pre-data */
prot_len /*4000*/ /* length of post-data */
@@ -575,7 +575,7 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
void jpwl_dump_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
int mm;
- unsigned long int old_size = j2k->image_info->codestream_size;
+ unsigned long int old_size = j2k->cstr_info->codestream_size;
unsigned long int new_size = old_size;
int ciopos = cio_tell(cio);
unsigned char *jpwl_buf, *orig_buf;
@@ -655,7 +655,7 @@ void jpwl_dump_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
update info file based on added markers
*/
if (!jpwl_update_info(j2k, jwmarker, jwmarker_num))
- opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not update OPJ image_info structure\n");
+ opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not update OPJ cstr_info structure\n");
/* now we need to repass some markers and fill their data fields */
diff --git a/jpwl/jpwl_lib.c b/jpwl/jpwl_lib.c
index b24aa09f..14d5c48d 100644
--- a/jpwl/jpwl_lib.c
+++ b/jpwl/jpwl_lib.c
@@ -1216,7 +1216,7 @@ jpwl_esd_ms_t *jpwl_esd_create(opj_j2k_t *j2k, int comp, unsigned char addrm, un
if (ad_size == 0)
/* if there are more than 66% of (2^16 - 1) bytes, switch to 4 bytes
(we keep space for possible EPBs being inserted) */
- ad_size = (j2k->image_info->codestream_size > (1 * 65535 / 3)) ? 4 : 2;
+ ad_size = (j2k->cstr_info->codestream_size > (1 * 65535 / 3)) ? 4 : 2;
esd->sensval_size = ad_size + ad_size + se_size;
break;
@@ -1225,7 +1225,7 @@ jpwl_esd_ms_t *jpwl_esd_create(opj_j2k_t *j2k, int comp, unsigned char addrm, un
/* auto sense address size */
if (ad_size == 0)
/* if there are more than 2^16 - 1 packets, switch to 4 bytes */
- ad_size = (j2k->image_info->num > 65535) ? 4 : 2;
+ ad_size = (j2k->cstr_info->num > 65535) ? 4 : 2;
esd->sensval_size = ad_size + ad_size + se_size;
break;
@@ -1246,17 +1246,17 @@ jpwl_esd_ms_t *jpwl_esd_create(opj_j2k_t *j2k, int comp, unsigned char addrm, un
/* just based on the portions of a codestream */
case (0):
/* MH + no. of THs + no. of packets */
- svalnum = 1 + (j2k->image_info->tw * j2k->image_info->th) * (1 + j2k->image_info->num);
+ svalnum = 1 + (j2k->cstr_info->tw * j2k->cstr_info->th) * (1 + j2k->cstr_info->num);
break;
/* all the ones that are based on the packets */
default:
if (tileno < 0)
/* MH: all the packets and all the tiles info is written */
- svalnum = j2k->image_info->tw * j2k->image_info->th * j2k->image_info->num;
+ svalnum = j2k->cstr_info->tw * j2k->cstr_info->th * j2k->cstr_info->num;
else
/* TPH: only that tile info is written */
- svalnum = j2k->image_info->num;
+ svalnum = j2k->cstr_info->num;
break;
}
@@ -1356,26 +1356,26 @@ bool jpwl_esd_fill(opj_j2k_t *j2k, jpwl_esd_ms_t *esd, unsigned char *buf) {
buf += 7;
/* let's fill the data fields */
- for (vv = (esd->tileno < 0) ? 0 : (j2k->image_info->num * esd->tileno); vv < esd->svalnum; vv++) {
+ for (vv = (esd->tileno < 0) ? 0 : (j2k->cstr_info->num * esd->tileno); vv < esd->svalnum; vv++) {
- int thistile = vv / j2k->image_info->num, thispacket = vv % j2k->image_info->num;
+ int thistile = vv / j2k->cstr_info->num, thispacket = vv % j2k->cstr_info->num;
/* skip for the hack some lines below */
- if (thistile == j2k->image_info->tw * j2k->image_info->th)
+ if (thistile == j2k->cstr_info->tw * j2k->cstr_info->th)
break;
/* starting tile distortion */
if (thispacket == 0) {
- TSE = j2k->image_info->tile[thistile].distotile;
- oldMSE = TSE / j2k->image_info->tile[thistile].nbpix;
+ TSE = j2k->cstr_info->tile[thistile].distotile;
+ oldMSE = TSE / j2k->cstr_info->tile[thistile].nbpix;
oldPSNR = 10.0 * log10(Omax2 / oldMSE);
}
/* TSE */
- TSE -= j2k->image_info->tile[thistile].packet[thispacket].disto;
+ TSE -= j2k->cstr_info->tile[thistile].packet[thispacket].disto;
/* MSE */
- MSE = TSE / j2k->image_info->tile[thistile].nbpix;
+ MSE = TSE / j2k->cstr_info->tile[thistile].nbpix;
/* PSNR */
PSNR = 10.0 * log10(Omax2 / MSE);
@@ -1391,9 +1391,9 @@ bool jpwl_esd_fill(opj_j2k_t *j2k, jpwl_esd_ms_t *esd, unsigned char *buf) {
/* byte range */
case (1):
/* start address of packet */
- addr1 = (j2k->image_info->tile[thistile].packet[thispacket].start_pos) & addrmask;
+ addr1 = (j2k->cstr_info->tile[thistile].packet[thispacket].start_pos) & addrmask;
/* end address of packet */
- addr2 = (j2k->image_info->tile[thistile].packet[thispacket].end_pos) & addrmask;
+ addr2 = (j2k->cstr_info->tile[thistile].packet[thispacket].end_pos) & addrmask;
break;
/* packet range */
@@ -1417,7 +1417,7 @@ bool jpwl_esd_fill(opj_j2k_t *j2k, jpwl_esd_ms_t *esd, unsigned char *buf) {
if ((thistile == 0) && !doneMH) {
/* we have to manage MH addresses */
addr1 = 0; /* start of MH */
- addr2 = j2k->image_info->main_head_end; /* end of MH */
+ addr2 = j2k->cstr_info->main_head_end; /* end of MH */
/* set special dvalue for this MH */
dvalue = -10.0;
doneMH = true; /* don't come here anymore */
@@ -1425,8 +1425,8 @@ bool jpwl_esd_fill(opj_j2k_t *j2k, jpwl_esd_ms_t *esd, unsigned char *buf) {
} else if (!doneTPH) {
/* we have to manage TPH addresses */
- addr1 = j2k->image_info->tile[thistile].start_pos;
- addr2 = j2k->image_info->tile[thistile].end_header;
+ addr1 = j2k->cstr_info->tile[thistile].start_pos;
+ addr2 = j2k->cstr_info->tile[thistile].end_header;
/* set special dvalue for this TPH */
dvalue = -1.0;
doneTPH = true; /* don't come here till the next tile */
@@ -1484,7 +1484,7 @@ bool jpwl_esd_fill(opj_j2k_t *j2k, jpwl_esd_ms_t *esd, unsigned char *buf) {
else
/* packet: first is most important, and then in decreasing order
down to the last, which counts for 1 */
- dvalue = jpwl_pfp_to_double((unsigned short) (j2k->image_info->num - thispacket), esd->se_size);
+ dvalue = jpwl_pfp_to_double((unsigned short) (j2k->cstr_info->num - thispacket), esd->se_size);
break;
/* MSE */
@@ -1657,7 +1657,7 @@ bool jpwl_update_info(opj_j2k_t *j2k, jpwl_marker_t *jwmarker, int jwmarker_num)
int mm;
unsigned long int addlen;
- opj_image_info_t *info = j2k->image_info;
+ opj_codestream_info_t *info = j2k->cstr_info;
int tileno, packno, numtiles = info->th * info->tw, numpacks = info->num;
if (!j2k || !jwmarker ) {