/* length to use */
dL4 = min(max_postlen, post_len);
- if (epb_mark = jpwl_epb_create(
+ if ((epb_mark = jpwl_epb_create(
j2k, /* this encoder handle */
latest ? (dL4 < max_postlen) : false, /* is it the latest? */
packed, /* is it packed? */
hprot, /* protection type parameters of following data */
0, /* pre-data: nothing for now */
dL4 /* post-data: the stub computed previously */
- )) {
+ ))) {
/* Add this marker to the 'insertanda' list */
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].m.epbmark = epb_mark; /* the EPB */
jwmarker[*jwmarker_num].pos = (int) place_pos; /* after SOT */
jwmarker[*jwmarker_num].dpos = place_pos + 0.0000001 * (double)(*idx); /* not very first! */
jwmarker[*jwmarker_num].len = epb_mark->Lepb; /* its length */
unsigned long int pre_len, unsigned long int post_len) {
jpwl_epb_ms_t *epb = NULL;
- unsigned short int data_len = 0;
+ /*unsigned short int data_len = 0;*/
unsigned short int L2, L3;
unsigned long int L1, L4;
- unsigned char *predata_in = NULL;
+ /*unsigned char *predata_in = NULL;*/
bool insideMH = (tileno == -1);
return epb;
}
-void jpwl_epb_write(jpwl_epb_ms_t *epb, unsigned char *buf) {
+void jpwl_epb_write(opj_j2k_t *j2k, jpwl_epb_ms_t *epb, unsigned char *buf) {
/* Marker */
*(buf++) = (unsigned char) (J2K_MS_EPB >> 8);
/* Data */
/*memcpy(buf, epb->data, (size_t) epb->Lepb - 11);*/
memset(buf, 0, (size_t) epb->Lepb - 11);
+
+ /* update markers struct */
+ j2k_add_marker(j2k->cstr_info, J2K_MS_EPB, -1, epb->Lepb + 2);
+
};
jpwl_epc_ms_t *epc = NULL;
/* Alloc space */
- if (!(epc = (jpwl_epc_ms_t *) malloc((size_t) 1 * sizeof (jpwl_epc_ms_t)))) {
+ if (!(epc = (jpwl_epc_ms_t *) opj_malloc((size_t) 1 * sizeof (jpwl_epc_ms_t)))) {
opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not allocate room for EPC MS\n");
return NULL;
};
return true;
}
+ /* Disable correction in case of missing or bad head EPB */
+ /* We can't do better! */
+ /* PATCHED: 2008-01-25 */
+ /* MOVED UP: 2008-02-01 */
+ if (!status) {
+ j2k->cp->correct = false;
+ opj_event_msg(j2k->cinfo, EVT_WARNING, "Couldn't find the MH EPB: disabling JPWL\n");
+ }
+
}
}
j2k->state = J2K_STATE_MHSOC;
/* cycle all over the markers */
- while ((unsigned int) cio_tell(cio) < cio->length) {
+ while (cio_tell(cio) < cio->length) {
/* read the marker */
mark_pos = cio_tell(cio);
case 3:
/* automatic setup */
+ opj_event_msg(j2k->cinfo, EVT_ERROR, "Auto. setup not yet implemented\n");
+ return false;
break;
default:
if (((Pepb & 0xF0000000) >> 28) == 0)
sprintf(str1, "pred"); /* predefined */
else if (((Pepb & 0xF0000000) >> 28) == 1)
- sprintf(str1, "crc-%d", 16 * ((Pepb & 0x00000001) + 1)); /* CRC mode */
+ sprintf(str1, "crc-%lu", 16 * ((Pepb & 0x00000001) + 1)); /* CRC mode */
else if (((Pepb & 0xF0000000) >> 28) == 2)
- sprintf(str1, "rs(%d,32)", (Pepb & 0x0000FF00) >> 8); /* RS mode */
+ sprintf(str1, "rs(%lu,32)", (Pepb & 0x0000FF00) >> 8); /* RS mode */
else if (Pepb == 0xFFFFFFFF)
sprintf(str1, "nometh"); /* RS mode */
else
return true;
}
-void jpwl_epc_write(jpwl_epc_ms_t *epc, unsigned char *buf) {
+void jpwl_epc_write(opj_j2k_t *j2k, jpwl_epc_ms_t *epc, unsigned char *buf) {
/* Marker */
*(buf++) = (unsigned char) (J2K_MS_EPC >> 8);
/* Data */
/*memcpy(buf, epc->data, (size_t) epc->Lepc - 9);*/
memset(buf, 0, (size_t) epc->Lepc - 9);
+
+ /* update markers struct */
+ j2k_add_marker(j2k->cstr_info, J2K_MS_EPC, -1, epc->Lepc + 2);
+
};
int jpwl_esds_add(opj_j2k_t *j2k, jpwl_marker_t *jwmarker, int *jwmarker_num,
jpwl_esd_ms_t *esd = NULL;
/* Alloc space */
- if (!(esd = (jpwl_esd_ms_t *) malloc((size_t) 1 * sizeof (jpwl_esd_ms_t)))) {
+ if (!(esd = (jpwl_esd_ms_t *) opj_malloc((size_t) 1 * sizeof (jpwl_esd_ms_t)))) {
opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not allocate room for ESD MS\n");
return NULL;
};
int i;
unsigned long int vv;
- unsigned long int addr1, addr2;
- double dvalue, Omax2, tmp, TSE, MSE, oldMSE, PSNR, oldPSNR;
+ unsigned long int addr1 = 0L, addr2 = 0L;
+ double dvalue = 0.0, Omax2, tmp, TSE = 0.0, MSE, oldMSE = 0.0, PSNR, oldPSNR = 0.0;
unsigned short int pfpvalue;
unsigned long int addrmask = 0x00000000;
bool doneMH = false, doneTPH = false;
return true;
}
-void jpwl_esd_write(jpwl_esd_ms_t *esd, unsigned char *buf) {
+void jpwl_esd_write(opj_j2k_t *j2k, jpwl_esd_ms_t *esd, unsigned char *buf) {
/* Marker */
*(buf++) = (unsigned char) (J2K_MS_ESD >> 8);
else
memset(buf, 0xAA, (size_t) esd->Lesd - 5);
/*memcpy(buf, esd->data, (size_t) esd->Lesd - 5);*/
+
+ /* update markers struct */
+ j2k_add_marker(j2k->cstr_info, J2K_MS_ESD, -1, esd->Lesd + 2);
+
}
unsigned short int jpwl_double_to_pfp(double V, int bytes) {
/* end_pos: increment with markers before the end of this tile */
/* code is disabled, since according to JPWL no markers can be beyond TPH */
- /*addlen = 0;
+ addlen = 0;
for (mm = 0; mm < jwmarker_num; mm++)
if (jwmarker[mm].pos < (unsigned long int) info->tile[tileno].end_pos)
- addlen += jwmarker[mm].len + 2;*/
+ addlen += jwmarker[mm].len + 2;
info->tile[tileno].end_pos += addlen;
/* navigate through all the tile parts */
/* start_pos: increment with markers before the packet */
/* disabled for the same reason as before */
+ addlen = 0;
+ for (mm = 0; mm < jwmarker_num; mm++)
+ if (jwmarker[mm].pos <= (unsigned long int) info->tile[tileno].packet[packno].start_pos)
+ addlen += jwmarker[mm].len + 2;
+ info->tile[tileno].packet[packno].start_pos += addlen;
+
+ /* end_ph_pos: increment with markers before the packet */
+ /* disabled for the same reason as before */
/*addlen = 0;
for (mm = 0; mm < jwmarker_num; mm++)
- if (jwmarker[mm].pos < (unsigned long int) info->tile[tileno].packet[packno].start_pos)
+ if (jwmarker[mm].pos < (unsigned long int) info->tile[tileno].packet[packno].end_ph_pos)
addlen += jwmarker[mm].len + 2;*/
- info->tile[tileno].packet[packno].start_pos += addlen;
+ info->tile[tileno].packet[packno].end_ph_pos += addlen;
/* end_pos: increment if marker is before the end of packet */
/* disabled for the same reason as before */
}
}
+ /* reorder the markers list */
+
return true;
}