! : changed
+ : added
+May 18, 2011
+! [antonin] defined new type "opj_bool", and new constants OPJ_FALSE and OPJ_TRUE, to avoid having to deal with "stdbool.h" (patch from Winfried)
+
May 16, 2011
* [antonin] fixed another bug related to the number of packets in a tile-part, not correctly taken into acccount when generating an index file during decoding.
* [antonin] fixed part of issue 69, when tile-part index is inconsistent with the total number of tile-parts
}
int tga_writeheader(FILE *fp, int bits_per_pixel, int width, int height,
- bool flip_image)
+ opj_bool flip_image)
{
tga_header tga;
opj_image_cmptparm_t cmptparm[4]; /* maximum 4 components */
int numcomps;
OPJ_COLOR_SPACE color_space;
- bool mono ;
- bool save_alpha;
+ opj_bool mono ;
+ opj_bool save_alpha;
int subsampling_dx, subsampling_dy;
int i;
int imagetotga(opj_image_t * image, const char *outfile) {
int width, height, bpp, x, y;
- bool write_alpha;
+ opj_bool write_alpha;
int i;
unsigned int alpha_channel;
float r,g,b,a;
// Write TGA header
bpp = write_alpha ? 32 : 24;
- if (!tga_writeheader(fdest, bpp, width , height, true))
+ if (!tga_writeheader(fdest, bpp, width , height, OPJ_TRUE))
return 1;
alpha_channel = image->numcomps-1;
/** bit depth of the raw image */
int rawBitDepth;
/** signed/unsigned raw image */
- bool rawSigned;
+ opj_bool rawSigned;
/*@}*/
} raw_cparameters_t;
}
void cinema_parameters(opj_cparameters_t *parameters){
- parameters->tile_size_on = false;
+ parameters->tile_size_on = OPJ_FALSE;
parameters->cp_tdx=1;
parameters->cp_tdy=1;
char *s = optarg;
if (sscanf(s, "%d,%d,%d,%d,%c", &raw_cp->rawWidth, &raw_cp->rawHeight, &raw_cp->rawComp, &raw_cp->rawBitDepth, &signo) == 5) {
if (signo == 's') {
- raw_cp->rawSigned = true;
+ raw_cp->rawSigned = OPJ_TRUE;
fprintf(stdout,"\nRaw file parameters: %d,%d,%d,%d Signed\n", raw_cp->rawWidth, raw_cp->rawHeight, raw_cp->rawComp, raw_cp->rawBitDepth);
}
else if (signo == 'u') {
- raw_cp->rawSigned = false;
+ raw_cp->rawSigned = OPJ_FALSE;
fprintf(stdout,"\nRaw file parameters: %d,%d,%d,%d Unsigned\n", raw_cp->rawWidth, raw_cp->rawHeight, raw_cp->rawComp, raw_cp->rawBitDepth);
}
else {
case 't': /* tiles */
{
sscanf(optarg, "%d,%d", ¶meters->cp_tdx, ¶meters->cp_tdy);
- parameters->tile_size_on = true;
+ parameters->tile_size_on = OPJ_TRUE;
}
break;
/* some info */
fprintf(stdout, "Info: JPWL capabilities enabled\n");
- parameters->jpwl_epc_on = true;
+ parameters->jpwl_epc_on = OPJ_TRUE;
}
break;
/* -------------------------------------------------------------------------- */
int main(int argc, char **argv) {
- bool bSuccess;
+ opj_bool bSuccess;
opj_cparameters_t parameters; /* compression parameters */
img_fol_t img_fol;
opj_event_mgr_t event_mgr; /* event manager */
/* next token or bust */
token = strtok(NULL, ",");
};
- parameters->jpwl_correct = true;
+ parameters->jpwl_correct = OPJ_TRUE;
fprintf(stdout, "JPWL correction capability activated\n");
fprintf(stdout, "- expecting %d components\n", parameters->jpwl_exp_comps);
}
FILE *mj2file;
int sampleno;
opj_cinfo_t* cinfo;
- bool bSuccess;
+ opj_bool bSuccess;
int numframes;
int prec = 8;/* DEFAULT */
double total_time = 0;
/* ----------------------------------------------------- */
case 't': /* tiles */
sscanf(optarg, "%d,%d", &j2k_parameters->cp_tdx, &j2k_parameters->cp_tdy);
- j2k_parameters->tile_size_on = true;
+ j2k_parameters->tile_size_on = OPJ_TRUE;
break;
/* ----------------------------------------------------- */
case 'n': /* resolution */
/** @name Local static functions */
/*@{*/
-/**
-Read box headers
-@param cinfo Codec context info
-@param cio Input stream
-@param box
-@return Returns true if successful, returns false otherwise
-*/
-/*-- UNUSED
-static bool jp2_read_boxhdr(opj_common_ptr cinfo, opj_cio_t *cio, opj_jp2_box_t *box);
---*/
/*
*
* Read box headers
opj_dinfo_t *dinfo = (opj_dinfo_t*) opj_calloc(1, sizeof(opj_dinfo_t));
if(!dinfo) return NULL;
- dinfo->is_decompressor = true;
+ dinfo->is_decompressor = OPJ_TRUE;
mj2 = (opj_mj2_t*) opj_calloc(1, sizeof(opj_mj2_t));
dinfo->mj2_handle = mj2;
@param index Name of the index file if required, NULL otherwise
@return Returns true if successful, returns false otherwise
*/
-bool mj2_encode(opj_mj2_t *movie, opj_cio_t *cio, opj_image_t *image, char *index);
+opj_bool mj2_encode(opj_mj2_t *movie, opj_cio_t *cio, opj_image_t *image, char *index);
/**
Init a Standard MJ2 movie
// -----------------------
-bool imagetoyuv(opj_image_t * img, char *outfile)
+opj_bool imagetoyuv(opj_image_t * img, char *outfile)
{
FILE *f;
int *data;
|| img->comps[1].dx != img->comps[2].dx) {
fprintf(stderr,
"Error with the input image components size: cannot create yuv file)\n");
- return false;
+ return OPJ_FALSE;
}
} else if (!(img->numcomps == 1)) {
fprintf(stderr,
"Error with the number of image components(must be one or three)\n");
- return false;
+ return OPJ_FALSE;
}
f = fopen(outfile, "a+b");
if (!f) {
fprintf(stderr, "failed to open %s for writing\n", outfile);
- return false;
+ return OPJ_FALSE;
}
is_16 = (img->comps[0].prec > 8);
prec_bytes = (is_16?2:1);
}
}
fclose(f);
- return true;
+ return OPJ_TRUE;
}
// -----------------------
/*
* Write a byte.
*/
-bool cio_byteout(opj_cio_t *cio, unsigned char v) {
+opj_bool cio_byteout(opj_cio_t *cio, unsigned char v) {
if (cio->bp >= cio->end) {
opj_event_msg(cio->cinfo, EVT_ERROR, "write error\n");
- return false;
+ return OPJ_FALSE;
}
*cio->bp++ = v;
- return true;
+ return OPJ_TRUE;
}
/*
return NULL;
}
-bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...) {
+opj_bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...) {
#define MSG_SIZE 512 /* 512 bytes should be more than enough for a short message */
opj_msg_callback msg_handler = NULL;
break;
}
if(msg_handler == NULL) {
- return false;
+ return OPJ_FALSE;
}
} else {
- return false;
+ return OPJ_FALSE;
}
if ((fmt != NULL) && (event_mgr != NULL)) {
msg_handler(message, cinfo->client_data);
}
- return true;
+ return OPJ_TRUE;
}
@param fmt Format-control string (plus optionnal arguments)
@return Returns true if successful, returns false otherwise
*/
-bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...);
+opj_bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...);
/* ----------------------------------------------------------------------- */
/*@}*/
static void j2k_read_eoc(opj_j2k_t *j2k) {
int i, tileno;
- bool success;
+ opj_bool success;
/* if packets should be decoded */
if (j2k->cp->limit_decoding != DECODE_ALL_BUT_PACKETS) {
opj_free(j2k->tile_data[tileno]);
j2k->tile_data[tileno] = NULL;
tcd_free_decode_tile(tcd, i);
- if (success == false) {
+ if (success == OPJ_FALSE) {
j2k->state |= J2K_STATE_ERR;
break;
}
if (j2k->cp->correct) {
int orig_pos = cio_tell(cio);
- bool status;
+ opj_bool status;
/* call the corrector */
status = jpwl_correct(j2k);
int i;
/* set JPWL on */
- cp->epc_on = true;
- cp->info_on = false; /* no informative technique */
+ cp->epc_on = OPJ_TRUE;
+ cp->info_on = OPJ_FALSE; /* no informative technique */
/* set EPB on */
if ((parameters->jpwl_hprot_MH > 0) || (parameters->jpwl_hprot_TPH[0] > 0)) {
- cp->epb_on = true;
+ cp->epb_on = OPJ_TRUE;
cp->hprot_MH = parameters->jpwl_hprot_MH;
for (i = 0; i < JPWL_MAX_NO_TILESPECS; i++) {
/* set ESD writing */
if ((parameters->jpwl_sens_size == 1) || (parameters->jpwl_sens_size == 2)) {
- cp->esd_on = true;
+ cp->esd_on = OPJ_TRUE;
cp->sens_size = parameters->jpwl_sens_size;
cp->sens_addr = parameters->jpwl_sens_addr;
}
/* always set RED writing to false: we are at the encoder */
- cp->red_on = false;
+ cp->red_on = OPJ_FALSE;
} else {
- cp->epc_on = false;
+ cp->epc_on = OPJ_FALSE;
}
#endif /* USE_JPWL */
}
}
-bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) {
+opj_bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) {
int tileno, compno;
opj_cp_t *cp = NULL;
}
#endif /* USE_JPWL */
- return true;
+ return OPJ_TRUE;
}
/* UniPG>> */
#ifdef USE_JPWL
/** enables writing of EPC in MH, thus activating JPWL */
- bool epc_on;
+ opj_bool epc_on;
/** enables writing of EPB, in case of activated JPWL */
- bool epb_on;
+ opj_bool epb_on;
/** enables writing of ESD, in case of activated JPWL */
- bool esd_on;
+ opj_bool esd_on;
/** enables writing of informative techniques of ESD, in case of activated JPWL */
- bool info_on;
+ opj_bool info_on;
/** enables writing of RED, in case of activated JPWL */
- bool red_on;
+ opj_bool red_on;
/** error protection method for MH (0,1,16,32,37-128) */
int hprot_MH;
/** tile number of header protection specification (>=0) */
/** sensitivity methods for TPHs (-1,0-7) */
int sens_TPH[JPWL_MAX_NO_TILESPECS];
/** enables JPWL correction at the decoder */
- bool correct;
+ opj_bool correct;
/** expected number of components at the decoder */
int exp_comps;
/** maximum number of tiles at the decoder */
@param cstr_info Codestream information structure if required, NULL otherwise
@return Returns true if successful, returns false otherwise
*/
-bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info);
+opj_bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info);
/* ----------------------------------------------------------------------- */
/*@}*/
@param box
@return Returns true if successful, returns false otherwise
*/
-static bool jp2_read_boxhdr(opj_common_ptr cinfo, opj_cio_t *cio, opj_jp2_box_t *box);
+static opj_bool jp2_read_boxhdr(opj_common_ptr cinfo, opj_cio_t *cio, opj_jp2_box_t *box);
/*static void jp2_write_url(opj_cio_t *cio, char *Idx_file);*/
/**
Read the IHDR box - Image Header box
@param cio Input buffer stream
@return Returns true if successful, returns false otherwise
*/
-static bool jp2_read_ihdr(opj_jp2_t *jp2, opj_cio_t *cio);
+static opj_bool jp2_read_ihdr(opj_jp2_t *jp2, opj_cio_t *cio);
static void jp2_write_ihdr(opj_jp2_t *jp2, opj_cio_t *cio);
static void jp2_write_bpcc(opj_jp2_t *jp2, opj_cio_t *cio);
-static bool jp2_read_bpcc(opj_jp2_t *jp2, opj_cio_t *cio);
+static opj_bool jp2_read_bpcc(opj_jp2_t *jp2, opj_cio_t *cio);
static void jp2_write_colr(opj_jp2_t *jp2, opj_cio_t *cio);
/**
Write the FTYP box - File type box
@param cio Input buffer stream
@return Returns true if successful, returns false otherwise
*/
-static bool jp2_read_ftyp(opj_jp2_t *jp2, opj_cio_t *cio);
+static opj_bool jp2_read_ftyp(opj_jp2_t *jp2, opj_cio_t *cio);
static int jp2_write_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info);
-static bool jp2_read_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, unsigned int *j2k_codestream_length, unsigned int *j2k_codestream_offset);
+static opj_bool jp2_read_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, unsigned int *j2k_codestream_length, unsigned int *j2k_codestream_offset);
static void jp2_write_jp(opj_cio_t *cio);
/**
Read the JP box - JPEG 2000 signature
@param cio Input buffer stream
@return Returns true if successful, returns false otherwise
*/
-static bool jp2_read_jp(opj_jp2_t *jp2, opj_cio_t *cio);
+static opj_bool jp2_read_jp(opj_jp2_t *jp2, opj_cio_t *cio);
/**
Decode the structure of a JP2 file
@param jp2 JP2 handle
@param color Collector for profile, cdef and pclr data
@return Returns true if successful, returns false otherwise
*/
-static bool jp2_read_struct(opj_jp2_t *jp2, opj_cio_t *cio,
+static opj_bool jp2_read_struct(opj_jp2_t *jp2, opj_cio_t *cio,
opj_jp2_color_t *color);
/**
Apply collected palette data
@param color Collector for profile, cdef and pclr data
@return Returns true if successful, returns false otherwise
*/
-static bool jp2_read_pclr(opj_jp2_t *jp2, opj_cio_t *cio,
+static opj_bool jp2_read_pclr(opj_jp2_t *jp2, opj_cio_t *cio,
opj_jp2_box_t *box, opj_jp2_color_t *color);
/**
Collect component mapping data
@param color Collector for profile, cdef and pclr data
@return Returns true if successful, returns false otherwise
*/
-static bool jp2_read_cmap(opj_jp2_t *jp2, opj_cio_t *cio,
+static opj_bool jp2_read_cmap(opj_jp2_t *jp2, opj_cio_t *cio,
opj_jp2_box_t *box, opj_jp2_color_t *color);
/**
Collect colour specification data
@param color Collector for profile, cdef and pclr data
@return Returns true if successful, returns false otherwise
*/
-static bool jp2_read_colr(opj_jp2_t *jp2, opj_cio_t *cio,
+static opj_bool jp2_read_colr(opj_jp2_t *jp2, opj_cio_t *cio,
opj_jp2_box_t *box, opj_jp2_color_t *color);
/*@}*/
/* ----------------------------------------------------------------------- */
-static bool jp2_read_boxhdr(opj_common_ptr cinfo, opj_cio_t *cio, opj_jp2_box_t *box) {
+static opj_bool jp2_read_boxhdr(opj_common_ptr cinfo, opj_cio_t *cio, opj_jp2_box_t *box) {
box->init_pos = cio_tell(cio);
box->length = cio_read(cio, 4);
box->type = cio_read(cio, 4);
if (box->length == 1) {
if (cio_read(cio, 4) != 0) {
opj_event_msg(cinfo, EVT_ERROR, "Cannot handle box sizes higher than 2^32\n");
- return false;
+ return OPJ_FALSE;
}
box->length = cio_read(cio, 4);
if (box->length == 0)
box->length = cio_numbytesleft(cio) + 8;
}
- return true;
+ return OPJ_TRUE;
}
#if 0
}
#endif
-static bool jp2_read_ihdr(opj_jp2_t *jp2, opj_cio_t *cio) {
+static opj_bool jp2_read_ihdr(opj_jp2_t *jp2, opj_cio_t *cio) {
opj_jp2_box_t box;
opj_common_ptr cinfo = jp2->cinfo;
jp2_read_boxhdr(cinfo, cio, &box);
if (JP2_IHDR != box.type) {
opj_event_msg(cinfo, EVT_ERROR, "Expected IHDR Marker\n");
- return false;
+ return OPJ_FALSE;
}
jp2->h = cio_read(cio, 4); /* HEIGHT */
if (cio_tell(cio) - box.init_pos != box.length) {
opj_event_msg(cinfo, EVT_ERROR, "Error with IHDR Box\n");
- return false;
+ return OPJ_FALSE;
}
- return true;
+ return OPJ_TRUE;
}
static void jp2_write_ihdr(opj_jp2_t *jp2, opj_cio_t *cio) {
}
-static bool jp2_read_bpcc(opj_jp2_t *jp2, opj_cio_t *cio) {
+static opj_bool jp2_read_bpcc(opj_jp2_t *jp2, opj_cio_t *cio) {
unsigned int i;
opj_jp2_box_t box;
jp2_read_boxhdr(cinfo, cio, &box);
if (JP2_BPCC != box.type) {
opj_event_msg(cinfo, EVT_ERROR, "Expected BPCC Marker\n");
- return false;
+ return OPJ_FALSE;
}
for (i = 0; i < jp2->numcomps; i++) {
if (cio_tell(cio) - box.init_pos != box.length) {
opj_event_msg(cinfo, EVT_ERROR, "Error with BPCC Box\n");
- return false;
+ return OPJ_FALSE;
}
- return true;
+ return OPJ_TRUE;
}
static void jp2_write_colr(opj_jp2_t *jp2, opj_cio_t *cio) {
}/* apply_pclr() */
-static bool jp2_read_pclr(opj_jp2_t *jp2, opj_cio_t *cio,
+static opj_bool jp2_read_pclr(opj_jp2_t *jp2, opj_cio_t *cio,
opj_jp2_box_t *box, opj_jp2_color_t *color)
{
opj_jp2_pclr_t *jp2_pclr;
/* Part 1, I.5.3.4: 'There shall be at most one Palette box inside
* a JP2 Header box' :
*/
- if(color->jp2_pclr) return false;
+ if(color->jp2_pclr) return OPJ_FALSE;
nr_entries = cio_read(cio, 2); /* NE */
nr_channels = cio_read(cio, 1);/* NPC */
}
}
- return true;
+ return OPJ_TRUE;
}/* jp2_read_pclr() */
-static bool jp2_read_cmap(opj_jp2_t *jp2, opj_cio_t *cio,
+static opj_bool jp2_read_cmap(opj_jp2_t *jp2, opj_cio_t *cio,
opj_jp2_box_t *box, opj_jp2_color_t *color)
{
opj_jp2_cmap_comp_t *cmap;
unsigned short i, nr_channels;
/* Need nr_channels: */
- if(color->jp2_pclr == NULL) return false;
+ if(color->jp2_pclr == NULL) return OPJ_FALSE;
/* Part 1, I.5.3.5: 'There shall be at most one Component Mapping box
* inside a JP2 Header box' :
*/
- if(color->jp2_pclr->cmap) return false;
+ if(color->jp2_pclr->cmap) return OPJ_FALSE;
nr_channels = color->jp2_pclr->nr_channels;
cmap = (opj_jp2_cmap_comp_t*)
}
color->jp2_pclr->cmap = cmap;
- return true;
+ return OPJ_TRUE;
}/* jp2_read_cmap() */
static void jp2_apply_cdef(opj_image_t *image, opj_jp2_color_t *color)
}/* jp2_apply_cdef() */
-static bool jp2_read_cdef(opj_jp2_t *jp2, opj_cio_t *cio,
+static opj_bool jp2_read_cdef(opj_jp2_t *jp2, opj_cio_t *cio,
opj_jp2_box_t *box, opj_jp2_color_t *color)
{
opj_jp2_cdef_info_t *info;
/* Part 1, I.5.3.6: 'The shall be at most one Channel Definition box
* inside a JP2 Header box.'
*/
- if(color->jp2_cdef) return false;
+ if(color->jp2_cdef) return OPJ_FALSE;
- if((n = cio_read(cio, 2)) == 0) return false; /* szukw000: FIXME */
+ if((n = cio_read(cio, 2)) == 0) return OPJ_FALSE; /* szukw000: FIXME */
info = (opj_jp2_cdef_info_t*)
opj_malloc(n * sizeof(opj_jp2_cdef_info_t));
info[i].asoc = cio_read(cio, 2);
}
- return true;
+ return OPJ_TRUE;
}/* jp2_read_cdef() */
-static bool jp2_read_colr(opj_jp2_t *jp2, opj_cio_t *cio,
+static opj_bool jp2_read_colr(opj_jp2_t *jp2, opj_cio_t *cio,
opj_jp2_box_t *box, opj_jp2_color_t *color)
{
int skip_len;
/* Part 1, I.5.3.3 : 'A conforming JP2 reader shall ignore all Colour
* Specification boxes after the first.'
*/
- if(color->jp2_has_colr) return false;
+ if(color->jp2_has_colr) return OPJ_FALSE;
cinfo = jp2->cinfo;
if (skip_len < 0)
{
opj_event_msg(cinfo, EVT_ERROR, "Error with COLR box size\n");
- return false;
+ return OPJ_FALSE;
}
if(skip_len > 0)
{
if (cio_tell(cio) - box->init_pos != box->length)
{
opj_event_msg(cinfo, EVT_ERROR, "Error with COLR Box\n");
- return false;
+ return OPJ_FALSE;
}
color->jp2_has_colr = 1;
- return true;
+ return OPJ_TRUE;
}/* jp2_read_colr() */
-bool jp2_read_jp2h(opj_jp2_t *jp2, opj_cio_t *cio, opj_jp2_color_t *color)
+opj_bool jp2_read_jp2h(opj_jp2_t *jp2, opj_cio_t *cio, opj_jp2_color_t *color)
{
opj_jp2_box_t box;
int jp2h_end;
if (box.type == JP2_JP2C)
{
opj_event_msg(cinfo, EVT_ERROR, "Expected JP2H Marker\n");
- return false;
+ return OPJ_FALSE;
}
cio_skip(cio, box.length - 8);
- if(cio->bp >= cio->end) return false;
+ if(cio->bp >= cio->end) return OPJ_FALSE;
jp2_read_boxhdr(cinfo, cio, &box);
}
} while(JP2_JP2H != box.type);
if (!jp2_read_ihdr(jp2, cio))
- return false;
+ return OPJ_FALSE;
jp2h_end = box.init_pos + box.length;
if (jp2->bpc == 255)
{
if (!jp2_read_bpcc(jp2, cio))
- return false;
+ return OPJ_FALSE;
}
jp2_read_boxhdr(cinfo, cio, &box);
cio_seek(cio, box.init_pos + box.length);
}
-static bool jp2_read_ftyp(opj_jp2_t *jp2, opj_cio_t *cio) {
+static opj_bool jp2_read_ftyp(opj_jp2_t *jp2, opj_cio_t *cio) {
int i;
opj_jp2_box_t box;
if (JP2_FTYP != box.type) {
opj_event_msg(cinfo, EVT_ERROR, "Expected FTYP Marker\n");
- return false;
+ return OPJ_FALSE;
}
jp2->brand = cio_read(cio, 4); /* BR */
if (cio_tell(cio) - box.init_pos != box.length) {
opj_event_msg(cinfo, EVT_ERROR, "Error with FTYP Box\n");
- return false;
+ return OPJ_FALSE;
}
- return true;
+ return OPJ_TRUE;
}
static int jp2_write_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) {
return box.length;
}
-static bool jp2_read_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, unsigned int *j2k_codestream_length, unsigned int *j2k_codestream_offset) {
+static opj_bool jp2_read_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, unsigned int *j2k_codestream_length, unsigned int *j2k_codestream_offset) {
opj_jp2_box_t box;
opj_common_ptr cinfo = jp2->cinfo;
*j2k_codestream_offset = cio_tell(cio);
*j2k_codestream_length = box.length - 8;
- return true;
+ return OPJ_TRUE;
}
static void jp2_write_jp(opj_cio_t *cio) {
cio_seek(cio, box.init_pos + box.length);
}
-static bool jp2_read_jp(opj_jp2_t *jp2, opj_cio_t *cio) {
+static opj_bool jp2_read_jp(opj_jp2_t *jp2, opj_cio_t *cio) {
opj_jp2_box_t box;
opj_common_ptr cinfo = jp2->cinfo;
jp2_read_boxhdr(cinfo, cio, &box);
if (JP2_JP != box.type) {
opj_event_msg(cinfo, EVT_ERROR, "Expected JP Marker\n");
- return false;
+ return OPJ_FALSE;
}
if (0x0d0a870a != cio_read(cio, 4)) {
opj_event_msg(cinfo, EVT_ERROR, "Error with JP Marker\n");
- return false;
+ return OPJ_FALSE;
}
if (cio_tell(cio) - box.init_pos != box.length) {
opj_event_msg(cinfo, EVT_ERROR, "Error with JP Box size\n");
- return false;
+ return OPJ_FALSE;
}
- return true;
+ return OPJ_TRUE;
}
-static bool jp2_read_struct(opj_jp2_t *jp2, opj_cio_t *cio,
+static opj_bool jp2_read_struct(opj_jp2_t *jp2, opj_cio_t *cio,
opj_jp2_color_t *color) {
if (!jp2_read_jp(jp2, cio))
- return false;
+ return OPJ_FALSE;
if (!jp2_read_ftyp(jp2, cio))
- return false;
+ return OPJ_FALSE;
if (!jp2_read_jp2h(jp2, cio, color))
- return false;
+ return OPJ_FALSE;
if (!jp2_read_jp2c(jp2, cio, &jp2->j2k_codestream_length, &jp2->j2k_codestream_offset))
- return false;
+ return OPJ_FALSE;
- return true;
+ return OPJ_TRUE;
}
/* ----------------------------------------------------------------------- */
}
-bool opj_jp2_encode(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) {
+opj_bool opj_jp2_encode(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) {
/* JP2 encoding */
if(!jp2_write_jp2c(jp2, cio, image, cstr_info)) {
opj_event_msg(jp2->cinfo, EVT_ERROR, "Failed to encode image\n");
- return false;
+ return OPJ_FALSE;
}
- return true;
+ return OPJ_TRUE;
}
@param ext Collector for profile, cdef and pclr data
@return Returns true if successful, returns false otherwise
*/
-bool jp2_read_jp2h(opj_jp2_t *jp2, opj_cio_t *cio, opj_jp2_color_t *color);
+opj_bool jp2_read_jp2h(opj_jp2_t *jp2, opj_cio_t *cio, opj_jp2_color_t *color);
/**
Creates a JP2 decompression structure
@param cinfo Codec context info
@param cstr_info Codestream information structure if required, NULL otherwise
@return Returns true if successful, returns false otherwise
*/
-bool opj_jp2_encode(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info);
+opj_bool opj_jp2_encode(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info);
/* ----------------------------------------------------------------------- */
/*@}*/
@param info_on true if informative techniques are activated\r
@return returns the freshly created EPC\r
*/\r
-jpwl_epc_ms_t *jpwl_epc_create(opj_j2k_t *j2k, bool esd_on, bool red_on, bool epb_on, bool info_on);\r
+jpwl_epc_ms_t *jpwl_epc_create(opj_j2k_t *j2k, opj_bool esd_on, opj_bool red_on, opj_bool epb_on, opj_bool info_on);\r
\r
/*@}*/\r
\r
j2k->cp->esd_on, /* is ESD present? */\r
j2k->cp->red_on, /* is RED present? */\r
j2k->cp->epb_on, /* is EPB present? */\r
- false /* are informative techniques present? */\r
+ OPJ_FALSE /* are informative techniques present? */\r
))) {\r
\r
/* Add this marker to the 'insertanda' list */\r
jwmarker[jwmarker_num].pos = soc_pos + socsiz_len; /* after SIZ */\r
jwmarker[jwmarker_num].dpos = (double) jwmarker[jwmarker_num].pos + 0.1; /* not so first */\r
jwmarker[jwmarker_num].len = epc_mark->Lepc; /* its length */\r
- jwmarker[jwmarker_num].len_ready = true; /* ready */\r
- jwmarker[jwmarker_num].pos_ready = true; /* ready */\r
- jwmarker[jwmarker_num].parms_ready = false; /* not ready */\r
- jwmarker[jwmarker_num].data_ready = true; /* ready */\r
+ jwmarker[jwmarker_num].len_ready = OPJ_TRUE; /* ready */\r
+ jwmarker[jwmarker_num].pos_ready = OPJ_TRUE; /* ready */\r
+ jwmarker[jwmarker_num].parms_ready = OPJ_FALSE; /* not ready */\r
+ jwmarker[jwmarker_num].data_ready = OPJ_TRUE; /* ready */\r
jwmarker_num++;\r
};\r
\r
jwmarker[jwmarker_num].pos = soc_pos + socsiz_len; /* we choose to place it after SIZ */\r
jwmarker[jwmarker_num].dpos = (double) jwmarker[jwmarker_num].pos + 0.2; /* not first at all! */\r
jwmarker[jwmarker_num].len = esd_mark->Lesd; /* its length */\r
- jwmarker[jwmarker_num].len_ready = true; /* not ready, yet */\r
- jwmarker[jwmarker_num].pos_ready = true; /* ready */\r
- jwmarker[jwmarker_num].parms_ready = true; /* not ready */\r
- jwmarker[jwmarker_num].data_ready = false; /* not ready */\r
+ jwmarker[jwmarker_num].len_ready = OPJ_TRUE; /* not ready, yet */\r
+ jwmarker[jwmarker_num].pos_ready = OPJ_TRUE; /* ready */\r
+ jwmarker[jwmarker_num].parms_ready = OPJ_TRUE; /* not ready */\r
+ jwmarker[jwmarker_num].data_ready = OPJ_FALSE; /* not ready */\r
jwmarker_num++;\r
}\r
\r
jwmarker[jwmarker_num].pos = j2k->cstr_info->tile[tileno].tp[tpno].tp_start_pos + sot_len + 2; /* after SOT */\r
jwmarker[jwmarker_num].dpos = (double) jwmarker[jwmarker_num].pos + 0.2; /* not first at all! */\r
jwmarker[jwmarker_num].len = esd_mark->Lesd; /* its length */\r
- jwmarker[jwmarker_num].len_ready = true; /* ready, yet */\r
- jwmarker[jwmarker_num].pos_ready = true; /* ready */\r
- jwmarker[jwmarker_num].parms_ready = true; /* not ready */\r
- jwmarker[jwmarker_num].data_ready = false; /* ready */\r
+ jwmarker[jwmarker_num].len_ready = OPJ_TRUE; /* ready, yet */\r
+ jwmarker[jwmarker_num].pos_ready = OPJ_TRUE; /* ready */\r
+ jwmarker[jwmarker_num].parms_ready = OPJ_TRUE; /* not ready */\r
+ jwmarker[jwmarker_num].data_ready = OPJ_FALSE; /* ready */\r
jwmarker_num++;\r
}\r
\r
/* Create the EPB */\r
if ((epb_mark = jpwl_epb_create(\r
j2k, /* this encoder handle */\r
- true, /* is it the latest? */\r
- true, /* is it packed? not for now */\r
+ OPJ_TRUE, /* is it the latest? */\r
+ OPJ_TRUE, /* is it packed? not for now */\r
-1, /* we are in main header */\r
0, /* its index is 0 (first) */\r
j2k->cp->hprot_MH, /* protection type parameters of data */\r
jwmarker[jwmarker_num].pos = soc_pos + socsiz_len; /* after SIZ */\r
jwmarker[jwmarker_num].dpos = (double) jwmarker[jwmarker_num].pos; /* first first first! */\r
jwmarker[jwmarker_num].len = epb_mark->Lepb; /* its length */\r
- jwmarker[jwmarker_num].len_ready = true; /* ready */\r
- jwmarker[jwmarker_num].pos_ready = true; /* ready */\r
- jwmarker[jwmarker_num].parms_ready = true; /* ready */\r
- jwmarker[jwmarker_num].data_ready = false; /* not ready */\r
+ jwmarker[jwmarker_num].len_ready = OPJ_TRUE; /* ready */\r
+ jwmarker[jwmarker_num].pos_ready = OPJ_TRUE; /* ready */\r
+ jwmarker[jwmarker_num].parms_ready = OPJ_TRUE; /* ready */\r
+ jwmarker[jwmarker_num].data_ready = OPJ_FALSE; /* not ready */\r
jwmarker_num++;\r
}\r
\r
/* Create the EPB */\r
if ((epb_mark = jpwl_epb_create(\r
j2k, /* this encoder handle */\r
- false, /* is it the latest? in TPH, no for now (if huge data size in TPH, we'd need more) */\r
- true, /* is it packed? yes for now */\r
+ OPJ_FALSE, /* is it the latest? in TPH, no for now (if huge data size in TPH, we'd need more) */\r
+ OPJ_TRUE, /* is it packed? yes for now */\r
tileno, /* we are in TPH */\r
epb_index++, /* its index is 0 (first) */\r
hprot, /* protection type parameters of following data */\r
jwmarker[jwmarker_num].pos = j2k->cstr_info->tile[tileno].tp[tpno].tp_start_pos + sot_len + 2; /* after SOT */\r
jwmarker[jwmarker_num].dpos = (double) jwmarker[jwmarker_num].pos; /* first first first! */\r
jwmarker[jwmarker_num].len = epb_mark->Lepb; /* its length */\r
- jwmarker[jwmarker_num].len_ready = true; /* ready */\r
- jwmarker[jwmarker_num].pos_ready = true; /* ready */\r
- jwmarker[jwmarker_num].parms_ready = true; /* ready */\r
- jwmarker[jwmarker_num].data_ready = false; /* not ready */\r
+ jwmarker[jwmarker_num].len_ready = OPJ_TRUE; /* ready */\r
+ jwmarker[jwmarker_num].pos_ready = OPJ_TRUE; /* ready */\r
+ jwmarker[jwmarker_num].parms_ready = OPJ_TRUE; /* ready */\r
+ jwmarker[jwmarker_num].data_ready = OPJ_FALSE; /* not ready */\r
jwmarker_num++;\r
}\r
\r
j2k, /* J2K handle */\r
jwmarker, /* pointer to JPWL markers list */\r
&jwmarker_num, /* pointer to the number of current markers */\r
- false, /* latest */\r
- true, /* packed */\r
- false, /* inside MH */\r
+ OPJ_FALSE, /* latest */\r
+ OPJ_TRUE, /* packed */\r
+ OPJ_FALSE, /* inside MH */\r
&epb_index, /* pointer to EPB index */\r
pprot, /* protection type */\r
/****** (double) (j2k->cstr_info->tile[tileno].start_pos + sot_len + 2) + 0.0001, */ /* position */\r
j2k, /* J2K handle */\r
jwmarker, /* pointer to JPWL markers list */\r
&jwmarker_num, /* pointer to the number of current markers */\r
- true, /* latest */\r
- true, /* packed */\r
- false, /* inside MH */\r
+ OPJ_TRUE, /* latest */\r
+ OPJ_TRUE, /* packed */\r
+ OPJ_FALSE, /* inside MH */\r
&epb_index, /* pointer to EPB index */\r
pprot, /* protection type */\r
/***** (double) (j2k->cstr_info->tile[tileno].start_pos + sot_len + 2) + 0.0001,*/ /* position */\r
/* we can now check if the TPH EPB was really the last one */\r
if (tph_epb && (epb_index == 1)) {\r
/* set the TPH EPB to be the last one in current header */\r
- tph_epb->Depb |= (unsigned char) ((true & 0x0001) << 6);\r
+ tph_epb->Depb |= (unsigned char) ((OPJ_TRUE & 0x0001) << 6);\r
tph_epb = NULL;\r
}\r
\r
unsigned short int Lepb;\r
unsigned char Depb;\r
char str1[25] = "";\r
- bool status;\r
- static bool first_in_tph = true;\r
+ opj_bool status;\r
+ static opj_bool first_in_tph = OPJ_TRUE;\r
int type, pre_len, post_len;\r
static unsigned char *redund = NULL;\r
\r
/* we are in TPH */\r
type = 1; /* TPH */\r
pre_len = 12; /* SOC+SIZ */\r
- first_in_tph = false;\r
+ first_in_tph = OPJ_FALSE;\r
post_len = -1; /* auto */\r
\r
} else {\r
/* last in current header? */\r
if (Depb & 0x40) {\r
redund = NULL; /* reset the pointer to L4 buffer */\r
- first_in_tph = true;\r
+ first_in_tph = OPJ_TRUE;\r
}\r
\r
/* advance to EPB endpoint */\r
cio_skip(cio, Lred - 3); \r
}\r
\r
-bool jpwl_check_tile(opj_j2k_t *j2k, opj_tcd_t *tcd, int tileno) {\r
+opj_bool jpwl_check_tile(opj_j2k_t *j2k, opj_tcd_t *tcd, int tileno) {\r
\r
#ifdef oerhgierhgvhreit4u\r
/*\r
"JPWL: wrong x-cord of block origin %d => x-prec is (%d, %d)\n",\r
block->x0, prec->x0, prec->x1);\r
if (!JPWL_ASSUME || JPWL_ASSUME)\r
- return false;\r
+ return OPJ_FALSE;\r
};\r
}\r
} \r
\r
#endif\r
\r
- return true;\r
+ return OPJ_TRUE;\r
}\r
\r
/*@}*/\r
/**
Assume a basic codestream structure, so you can resort better from uncorrected errors
*/
-#define JPWL_ASSUME true
+#define JPWL_ASSUME OPJ_TRUE
/**
EPB (Error Protection Block) Marker segment
/**@name Private fields set by epb_create */
/*@{*/
/** is the latest in header? */
- bool latest;
+ opj_bool latest;
/** is it in packed mode? */
- bool packed;
+ opj_bool packed;
/** TH where this marker has been placed (-1 means MH) */
int tileno;
/** index in current header (0-63) */
*/
typedef struct jpwl_epc_ms {
/** is ESD active? */
- bool esd_on;
+ opj_bool esd_on;
/** is RED active? */
- bool red_on;
+ opj_bool red_on;
/** is EPB active? */
- bool epb_on;
+ opj_bool epb_on;
/** are informative techniques active? */
- bool info_on;
+ opj_bool info_on;
/**@name Marker segment fields */
/*@{*/
/** two bytes for the length of EPC MS, exluding the marker itself (9 to 65535 bytes) */
/** length of the marker segment (marker excluded) */
unsigned short int len;
/** the marker length is ready or not? */
- bool len_ready;
+ opj_bool len_ready;
/** the marker position is ready or not? */
- bool pos_ready;
+ opj_bool pos_ready;
/** the marker parameters are ready or not? */
- bool parms_ready;
+ opj_bool parms_ready;
/** are the written data ready or not */
- bool data_ready;
+ opj_bool data_ready;
} jpwl_marker_t;
/**
@param post_len length of post-protected data
@return returns the freshly created EPB
*/
-jpwl_epb_ms_t *jpwl_epb_create(opj_j2k_t *j2k, bool latest, bool packed, int tileno, int idx, int hprot,
+jpwl_epb_ms_t *jpwl_epb_create(opj_j2k_t *j2k, opj_bool latest, opj_bool packed, int tileno, int idx, int hprot,
unsigned long int pre_len, unsigned long int post_len);
/** add a number of EPB marker segments
@return returns the length of all added markers
*/
int jpwl_epbs_add(opj_j2k_t *j2k, jpwl_marker_t *jwmarker, int *jwmarker_num,
- bool latest, bool packed, bool insideMH, int *idx, int hprot,
+ opj_bool latest, opj_bool packed, opj_bool insideMH, int *idx, int hprot,
double place_pos, int tileno,
unsigned long int pre_len, unsigned long int post_len);
@param jwmarker_num number of JPWL markers
@return returns true in case of success
*/
-bool jpwl_update_info(opj_j2k_t *j2k, jpwl_marker_t *jwmarker, int jwmarker_num);
+opj_bool jpwl_update_info(opj_j2k_t *j2k, jpwl_marker_t *jwmarker, int jwmarker_num);
-bool jpwl_esd_fill(opj_j2k_t *j2k, jpwl_esd_ms_t *esdmark, unsigned char *buf);
+opj_bool jpwl_esd_fill(opj_j2k_t *j2k, jpwl_esd_ms_t *esdmark, unsigned char *buf);
-bool jpwl_epb_fill(opj_j2k_t *j2k, jpwl_epb_ms_t *epbmark, unsigned char *buf, unsigned char *post_buf);
+opj_bool jpwl_epb_fill(opj_j2k_t *j2k, jpwl_epb_ms_t *epbmark, unsigned char *buf, unsigned char *post_buf);
void j2k_add_marker(opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len);
@param j2k J2K compressor handle
@return true if correction is performed correctly
*/
-bool jpwl_correct(opj_j2k_t *j2k);
+opj_bool jpwl_correct(opj_j2k_t *j2k);
/** corrects the data protected by an EPB
@param j2k J2K compressor handle
@param L4_bufp is a pointer to the buffer pointer of redundancy data
@return returns true if correction could be succesfully performed
*/
-bool jpwl_epb_correct(opj_j2k_t *j2k, unsigned char *buffer, int type, int pre_len, int post_len, int *conn,
+opj_bool jpwl_epb_correct(opj_j2k_t *j2k, unsigned char *buffer, int type, int pre_len, int post_len, int *conn,
unsigned char **L4_bufp);
/** check that a tile and its children have valid data
@param tcd Tile decompressor handle
@param tileno number of the tile to check
*/
-bool jpwl_check_tile(opj_j2k_t *j2k, opj_tcd_t *tcd, int tileno);
+opj_bool jpwl_check_tile(opj_j2k_t *j2k, opj_tcd_t *tcd, int tileno);
/** Macro functions for CRC computation */
}
int jpwl_epbs_add(opj_j2k_t *j2k, jpwl_marker_t *jwmarker, int *jwmarker_num,
- bool latest, bool packed, bool insideMH, int *idx, int hprot,
+ opj_bool latest, opj_bool packed, opj_bool insideMH, int *idx, int hprot,
double place_pos, int tileno,
unsigned long int pre_len, unsigned long int post_len) {
if ((epb_mark = jpwl_epb_create(
j2k, /* this encoder handle */
- latest ? (dL4 < max_postlen) : false, /* is it the latest? */
+ latest ? (dL4 < max_postlen) : OPJ_FALSE, /* is it the latest? */
packed, /* is it packed? */
tileno, /* we are in TPH */
*idx, /* its index */
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 */
- jwmarker[*jwmarker_num].len_ready = true; /* ready */
- jwmarker[*jwmarker_num].pos_ready = true; /* ready */
- jwmarker[*jwmarker_num].parms_ready = true; /* ready */
- jwmarker[*jwmarker_num].data_ready = false; /* not ready */
+ jwmarker[*jwmarker_num].len_ready = OPJ_TRUE; /* ready */
+ jwmarker[*jwmarker_num].pos_ready = OPJ_TRUE; /* ready */
+ jwmarker[*jwmarker_num].parms_ready = OPJ_TRUE; /* ready */
+ jwmarker[*jwmarker_num].data_ready = OPJ_FALSE; /* not ready */
(*jwmarker_num)++;
}
}
-jpwl_epb_ms_t *jpwl_epb_create(opj_j2k_t *j2k, bool latest, bool packed, int tileno, int idx, int hprot,
+jpwl_epb_ms_t *jpwl_epb_create(opj_j2k_t *j2k, opj_bool latest, opj_bool packed, int tileno, int idx, int hprot,
unsigned long int pre_len, unsigned long int post_len) {
jpwl_epb_ms_t *epb = NULL;
unsigned long int L1, L4;
/*unsigned char *predata_in = NULL;*/
- bool insideMH = (tileno == -1);
+ opj_bool insideMH = (tileno == -1);
/* Alloc space */
if (!(epb = (jpwl_epb_ms_t *) opj_malloc((size_t) 1 * sizeof (jpwl_epb_ms_t)))) {
};
-jpwl_epc_ms_t *jpwl_epc_create(opj_j2k_t *j2k, bool esd_on, bool red_on, bool epb_on, bool info_on) {
+jpwl_epc_ms_t *jpwl_epc_create(opj_j2k_t *j2k, opj_bool esd_on, opj_bool red_on, opj_bool epb_on, opj_bool info_on) {
jpwl_epc_ms_t *epc = NULL;
return (epc);
}
-bool jpwl_epb_fill(opj_j2k_t *j2k, jpwl_epb_ms_t *epb, unsigned char *buf, unsigned char *post_buf) {
+opj_bool jpwl_epb_fill(opj_j2k_t *j2k, jpwl_epb_ms_t *epb, unsigned char *buf, unsigned char *post_buf) {
unsigned long int L1, L2, L3, L4;
int remaining;
/* some consistency check */
if (!buf) {
opj_event_msg(j2k->cinfo, EVT_ERROR, "There is no operating buffer for EPBs\n");
- return false;
+ return OPJ_FALSE;
}
if (!post_buf && !L4_buf) {
opj_event_msg(j2k->cinfo, EVT_ERROR, "There is no operating buffer for EPBs data\n");
- return false;
+ return OPJ_FALSE;
}
/*
}
- return true;
+ return OPJ_TRUE;
}
-bool jpwl_correct(opj_j2k_t *j2k) {
+opj_bool jpwl_correct(opj_j2k_t *j2k) {
opj_cio_t *cio = j2k->cio;
- bool status;
- static bool mh_done = false;
+ opj_bool status;
+ static opj_bool mh_done = OPJ_FALSE;
int mark_pos, id, len, skips, sot_pos;
unsigned long int Psot = 0;
if (status && (mark_val == J2K_MS_EPB)) {
/* we found it! */
- mh_done = true;
- return true;
+ mh_done = OPJ_TRUE;
+ return OPJ_TRUE;
}
/* Disable correction in case of missing or bad head EPB */
/* PATCHED: 2008-01-25 */
/* MOVED UP: 2008-02-01 */
if (!status) {
- j2k->cp->correct = false;
+ j2k->cp->correct = OPJ_FALSE;
opj_event_msg(j2k->cinfo, EVT_WARNING, "Couldn't find the MH EPB: disabling JPWL\n");
}
}
- if (true /*(j2k->state == J2K_STATE_TPHSOT) || (j2k->state == J2K_STATE_TPH)*/) {
+ if (OPJ_TRUE /*(j2k->state == J2K_STATE_TPHSOT) || (j2k->state == J2K_STATE_TPH)*/) {
/* else, look if 12 positions ahead there is an EPB, in case of TPH */
cio_seek(cio, mark_pos);
if ((cio->bp + 12) < cio->end) {
);
if (status)
/* we found it! */
- return true;
+ return OPJ_TRUE;
}
}
- return false;
+ return OPJ_FALSE;
/* for now, don't use this code */
);
if (status)
/* we found it! */
- return true;
+ return OPJ_TRUE;
}
/* nope, no EPBs probably, or they are so damaged that we can give up */
- return false;
+ return OPJ_FALSE;
- return true;
+ return OPJ_TRUE;
/* AN ATTEMPT OF PARSER */
/* NOT USED ACTUALLY */
}
-bool jpwl_epb_correct(opj_j2k_t *j2k, unsigned char *buffer, int type, int pre_len, int post_len, int *conn,
+opj_bool jpwl_epb_correct(opj_j2k_t *j2k, unsigned char *buffer, int type, int pre_len, int post_len, int *conn,
unsigned char **L4_bufp) {
/* Operating buffer */
unsigned char Depb;
char str1[25] = "";
int myconn, errnum = 0;
- bool errflag = false;
+ opj_bool errflag = OPJ_FALSE;
opj_cio_t *cio = j2k->cio;
/* check for common errors */
if (!buffer) {
opj_event_msg(j2k->cinfo, EVT_ERROR, "The EPB pointer is a NULL buffer\n");
- return false;
+ return OPJ_FALSE;
}
/* set bignesses */
case 3:
/* automatic setup */
opj_event_msg(j2k->cinfo, EVT_ERROR, "Auto. setup not yet implemented\n");
- return false;
+ return OPJ_FALSE;
break;
default:
/* unknown type */
opj_event_msg(j2k->cinfo, EVT_ERROR, "Unknown expected EPB type\n");
- return false;
+ return OPJ_FALSE;
break;
}
/*if (conn == NULL)
opj_event_msg(j2k->cinfo, EVT_WARNING,
"Possible decoding error in codeword @ position #%d\n", (L1_buf - buffer) / k_pre);*/
- errflag = true;
+ errflag = OPJ_TRUE;
/* we can try to safely get out from the function:
if we are here, either this is not an EPB or the first codeword
is too damaged to be helpful */
- /*return false;*/
+ /*return OPJ_FALSE;*/
} else if (status == 0) {
/*if (conn == NULL)
} else {
/*if (conn == NULL)
opj_event_msg(j2k->cinfo, EVT_WARNING, "EPB correction capability exceeded\n");
- return false;*/
- errflag = true;
+ return OPJ_FALSE;*/
+ errflag = OPJ_TRUE;
}
(float) errnum / ((float) n_pre * (float) L1 / (float) k_pre));*/
if (errflag) {
/*opj_event_msg(j2k->cinfo, EVT_INFO, "+ there were unrecoverable errors\n");*/
- return false;
+ return OPJ_FALSE;
}
}
printf("connected = %d\n", myconn);*/
/*cio_seek(j2k->cio, orig_pos);
- return true;*/
+ return OPJ_TRUE;*/
/* post-data
the position of L4 buffer is at the end of currently connected EPBs
/* Do a further check here on the read parameters */
if (L4 > (unsigned long) cio_numbytesleft(j2k->cio))
/* overflow */
- return false;
+ return OPJ_FALSE;
/* we are ready for decoding the remaining data */
if (((Pepb & 0xF0000000) >> 28) == 1) {
} else {
if (conn == NULL)
opj_event_msg(j2k->cinfo, EVT_WARNING, "- CRC is KO (r=%d, c=%d)\n", filecrc, mycrc);
- errflag = true;
+ errflag = OPJ_TRUE;
}
}
} else {
if (conn == NULL)
opj_event_msg(j2k->cinfo, EVT_WARNING, "- CRC is KO (r=%d, c=%d)\n", filecrc, mycrc);
- errflag = true;
+ errflag = OPJ_TRUE;
}
}
/*if (conn == NULL)
opj_event_msg(j2k->cinfo, EVT_WARNING,
"Possible decoding error in codeword @ position #%d\n", (L4_buf - (buffer + Lepb + 2)) / k_post);*/
- errflag = true;
+ errflag = OPJ_TRUE;
} else if (status == 0) {
/*if (conn == NULL)
} else {
/*if (conn == NULL)
opj_event_msg(j2k->cinfo, EVT_WARNING, "EPB correction capability exceeded\n");
- return false;*/
- errflag = true;
+ return OPJ_FALSE;*/
+ errflag = OPJ_TRUE;
}
cio_seek(j2k->cio, orig_pos);
- return true;
+ return OPJ_TRUE;
}
void jpwl_epc_write(opj_j2k_t *j2k, jpwl_epc_ms_t *epc, unsigned char *buf) {
return (esd);
}
-bool jpwl_esd_fill(opj_j2k_t *j2k, jpwl_esd_ms_t *esd, unsigned char *buf) {
+opj_bool jpwl_esd_fill(opj_j2k_t *j2k, jpwl_esd_ms_t *esd, unsigned char *buf) {
int i;
unsigned long int vv;
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;
+ opj_bool doneMH = OPJ_FALSE, doneTPH = OPJ_FALSE;
/* sensitivity values in image info are as follows:
- for each tile, distotile is the starting distortion for that tile, sum of all components
if (esd->data) {
for (i = 0; i < (int) esd->svalnum; i++)
*(buf++) = esd->data[i];
- return true;
+ return OPJ_TRUE;
}
/* addressing mask */
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 */
+ doneMH = OPJ_TRUE; /* don't come here anymore */
vv--; /* wrap back loop counter */
} else if (!doneTPH) {
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 */
+ doneTPH = OPJ_TRUE; /* don't come here till the next tile */
vv--; /* wrap back loop counter */
}
} else
- doneTPH = false; /* reset TPH counter */
+ doneTPH = OPJ_FALSE; /* reset TPH counter */
/* write the addresses to the buffer */
switch (esd->ad_size) {
}
- return true;
+ return OPJ_TRUE;
}
void jpwl_esd_write(opj_j2k_t *j2k, jpwl_esd_ms_t *esd, unsigned char *buf) {
}
-bool jpwl_update_info(opj_j2k_t *j2k, jpwl_marker_t *jwmarker, int jwmarker_num) {
+opj_bool jpwl_update_info(opj_j2k_t *j2k, jpwl_marker_t *jwmarker, int jwmarker_num) {
int mm;
unsigned long int addlen;
if (!j2k || !jwmarker ) {
opj_event_msg(j2k->cinfo, EVT_ERROR, "J2K handle or JPWL markers list badly allocated\n");
- return false;
+ return OPJ_FALSE;
}
/* main_head_end: how many markers are there before? */
/* reorder the markers list */
- return true;
+ return OPJ_TRUE;
}
#endif /* USE_JPWL */
opj_dinfo_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT format) {
opj_dinfo_t *dinfo = (opj_dinfo_t*)opj_calloc(1, sizeof(opj_dinfo_t));
if(!dinfo) return NULL;
- dinfo->is_decompressor = true;
+ dinfo->is_decompressor = OPJ_TRUE;
switch(format) {
case CODEC_J2K:
case CODEC_JPT:
parameters->cod_format = -1;
/* UniPG>> */
#ifdef USE_JPWL
- parameters->jpwl_correct = false;
+ parameters->jpwl_correct = OPJ_FALSE;
parameters->jpwl_exp_comps = JPWL_EXPECTED_COMPONENTS;
parameters->jpwl_max_tiles = JPWL_MAXIMUM_TILES;
#endif /* USE_JPWL */
opj_cinfo_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format) {
opj_cinfo_t *cinfo = (opj_cinfo_t*)opj_calloc(1, sizeof(opj_cinfo_t));
if(!cinfo) return NULL;
- cinfo->is_decompressor = false;
+ cinfo->is_decompressor = OPJ_FALSE;
switch(format) {
case CODEC_J2K:
/* get a J2K coder handle */
/* UniPG>> */
#ifdef USE_JPWL
- parameters->jpwl_epc_on = false;
+ parameters->jpwl_epc_on = OPJ_FALSE;
parameters->jpwl_hprot_MH = -1; /* -1 means unassigned */
{
int i;
}
}
-bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index) {
+opj_bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index) {
if (index != NULL)
opj_event_msg((opj_common_ptr)cinfo, EVT_WARNING, "Set index to NULL when calling the opj_encode function.\n"
"To extract the index, use the opj_encode_with_info() function.\n"
return opj_encode_with_info(cinfo, cio, image, NULL);
}
-bool OPJ_CALLCONV opj_encode_with_info(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) {
+opj_bool OPJ_CALLCONV opj_encode_with_info(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) {
if(cinfo && cio && image) {
switch(cinfo->codec_format) {
case CODEC_J2K:
break;
}
}
- return false;
+ return OPJ_FALSE;
}
void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_t *cstr_info) {
#endif /* OPJ_EXPORTS */
#endif /* !OPJ_STATIC || !_WIN32 */
-#ifndef __cplusplus
-#if defined(HAVE_STDBOOL_H)
-/*
-The C language implementation does correctly provide the standard header
-file "stdbool.h".
- */
-#include <stdbool.h>
-#else
-/*
-The C language implementation does not provide the standard header file
-"stdbool.h" as required by ISO/IEC 9899:1999. Try to compensate for this
-braindamage below.
-*/
-#if !defined(bool)
-#define bool int
-#endif
-#if !defined(true)
-#define true 1
-#endif
-#if !defined(false)
-#define false 0
-#endif
-#endif
-#endif /* __cplusplus */
+typedef int opj_bool;
+#define OPJ_TRUE 1
+#define OPJ_FALSE 0
/*
==========================================================
*/
typedef struct opj_cparameters {
/** size of tile: tile_size_on = false (not in argument) or = true (in argument) */
- bool tile_size_on;
+ opj_bool tile_size_on;
/** XTOsiz */
int cp_tx0;
/** YTOsiz */
/**@name JPWL encoding parameters */
/*@{*/
/** enables writing of EPC in MH, thus activating JPWL */
- bool jpwl_epc_on;
+ opj_bool jpwl_epc_on;
/** error protection method for MH (0,1,16,32,37-128) */
int jpwl_hprot_MH;
/** tile number of header protection specification (>=0) */
/**@name JPWL decoding parameters */
/*@{*/
/** activates the JPWL correction capabilities */
- bool jpwl_correct;
+ opj_bool jpwl_correct;
/** expected number of components */
int jpwl_exp_comps;
/** maximum number of tiles */
#define opj_common_fields \
opj_event_mgr_t *event_mgr; /**< pointer to the event manager */\
void * client_data; /**< Available for use by application */\
- bool is_decompressor; /**< So common code can tell which is which */\
+ opj_bool is_decompressor; /**< So common code can tell which is which */\
OPJ_CODEC_FORMAT codec_format; /**< selected codec */\
void *j2k_handle; /**< pointer to the J2K codec */\
void *jp2_handle; /**< pointer to the JP2 codec */\
@param index Depreacted -> Set to NULL. To extract index, used opj_encode_wci()
@return Returns true if successful, returns false otherwise
*/
-OPJ_API bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index);
+OPJ_API opj_bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index);
/**
Encode an image into a JPEG-2000 codestream and extract the codestream information
@param cinfo compressor handle
@param cstr_info Codestream information structure if needed afterwards, NULL otherwise
@return Returns true if successful, returns false otherwise
*/
-OPJ_API bool OPJ_CALLCONV opj_encode_with_info(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info);
+OPJ_API opj_bool OPJ_CALLCONV opj_encode_with_info(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info);
/**
Destroy Codestream information after compression or decompression
@param cstr_info Codestream information structure
@param pi packet iterator to modify
@return returns false if pi pointed to the last packet or else returns true
*/
-static bool pi_next_lrcp(opj_pi_iterator_t * pi);
+static opj_bool pi_next_lrcp(opj_pi_iterator_t * pi);
/**
Get next packet in resolution-layer-component-precinct order.
@param pi packet iterator to modify
@return returns false if pi pointed to the last packet or else returns true
*/
-static bool pi_next_rlcp(opj_pi_iterator_t * pi);
+static opj_bool pi_next_rlcp(opj_pi_iterator_t * pi);
/**
Get next packet in resolution-precinct-component-layer order.
@param pi packet iterator to modify
@return returns false if pi pointed to the last packet or else returns true
*/
-static bool pi_next_rpcl(opj_pi_iterator_t * pi);
+static opj_bool pi_next_rpcl(opj_pi_iterator_t * pi);
/**
Get next packet in precinct-component-resolution-layer order.
@param pi packet iterator to modify
@return returns false if pi pointed to the last packet or else returns true
*/
-static bool pi_next_pcrl(opj_pi_iterator_t * pi);
+static opj_bool pi_next_pcrl(opj_pi_iterator_t * pi);
/**
Get next packet in component-precinct-resolution-layer order.
@param pi packet iterator to modify
@return returns false if pi pointed to the last packet or else returns true
*/
-static bool pi_next_cprl(opj_pi_iterator_t * pi);
+static opj_bool pi_next_cprl(opj_pi_iterator_t * pi);
/*@}*/
==========================================================
*/
-static bool pi_next_lrcp(opj_pi_iterator_t * pi) {
+static opj_bool pi_next_lrcp(opj_pi_iterator_t * pi) {
opj_pi_comp_t *comp = NULL;
opj_pi_resolution_t *res = NULL;
long index = 0;
index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
if (!pi->include[index]) {
pi->include[index] = 1;
- return true;
+ return OPJ_TRUE;
}
LABEL_SKIP:;
}
}
}
- return false;
+ return OPJ_FALSE;
}
-static bool pi_next_rlcp(opj_pi_iterator_t * pi) {
+static opj_bool pi_next_rlcp(opj_pi_iterator_t * pi) {
opj_pi_comp_t *comp = NULL;
opj_pi_resolution_t *res = NULL;
long index = 0;
index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
if (!pi->include[index]) {
pi->include[index] = 1;
- return true;
+ return OPJ_TRUE;
}
LABEL_SKIP:;
}
}
}
- return false;
+ return OPJ_FALSE;
}
-static bool pi_next_rpcl(opj_pi_iterator_t * pi) {
+static opj_bool pi_next_rpcl(opj_pi_iterator_t * pi) {
opj_pi_comp_t *comp = NULL;
opj_pi_resolution_t *res = NULL;
long index = 0;
index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
if (!pi->include[index]) {
pi->include[index] = 1;
- return true;
+ return OPJ_TRUE;
}
LABEL_SKIP:;
}
}
}
- return false;
+ return OPJ_FALSE;
}
-static bool pi_next_pcrl(opj_pi_iterator_t * pi) {
+static opj_bool pi_next_pcrl(opj_pi_iterator_t * pi) {
opj_pi_comp_t *comp = NULL;
opj_pi_resolution_t *res = NULL;
long index = 0;
index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
if (!pi->include[index]) {
pi->include[index] = 1;
- return true;
+ return OPJ_TRUE;
}
LABEL_SKIP:;
}
}
}
- return false;
+ return OPJ_FALSE;
}
-static bool pi_next_cprl(opj_pi_iterator_t * pi) {
+static opj_bool pi_next_cprl(opj_pi_iterator_t * pi) {
opj_pi_comp_t *comp = NULL;
opj_pi_resolution_t *res = NULL;
long index = 0;
index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
if (!pi->include[index]) {
pi->include[index] = 1;
- return true;
+ return OPJ_TRUE;
}
LABEL_SKIP:;
}
}
}
- return false;
+ return OPJ_FALSE;
}
/*
}
}
-bool pi_next(opj_pi_iterator_t * pi) {
+opj_bool pi_next(opj_pi_iterator_t * pi) {
switch (pi->poc.prg) {
case LRCP:
return pi_next_lrcp(pi);
case CPRL:
return pi_next_cprl(pi);
case PROG_UNKNOWN:
- return false;
+ return OPJ_FALSE;
}
- return false;
+ return OPJ_FALSE;
}
-bool pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos, J2K_T2_MODE t2_mode,int cur_totnum_tp){
+opj_bool pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos, J2K_T2_MODE t2_mode,int cur_totnum_tp){
char prog[4];
int i;
int incr_top=1,resetX=0;
case RPCL: strncpy(prog, "RPCL",4);
break;
case PROG_UNKNOWN:
- return true;
+ return OPJ_TRUE;
}
if(!(cp->tp_on && ((!cp->cinema && (t2_mode == FINAL_PASS)) || cp->cinema))){
}
}
}
- return false;
+ return OPJ_FALSE;
}
@param cur_totnum_tp The total number of tile parts in the current tile
@return Returns true if an error is detected
*/
-bool pi_create_encode(opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos, J2K_T2_MODE t2_mode,int cur_totnum_tp);
+opj_bool pi_create_encode(opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos, J2K_T2_MODE t2_mode,int cur_totnum_tp);
/**
Create a packet iterator for Decoder
@param image Raw image for which the packets will be listed
@param pi Packet iterator to modify
@return Returns false if pi pointed to the last packet or else returns true
*/
-bool pi_next(opj_pi_iterator_t * pi);
+opj_bool pi_next(opj_pi_iterator_t * pi);
/* ----------------------------------------------------------------------- */
/*@}*/
return wmsedec;
}
-static bool allocate_buffers(
+static opj_bool allocate_buffers(
opj_t1_t *t1,
int w,
int h)
opj_aligned_free(t1->data);
t1->data = (int*) opj_aligned_malloc(datasize * sizeof(int));
if(!t1->data){
- return false;
+ return OPJ_FALSE;
}
t1->datasize=datasize;
}
opj_aligned_free(t1->flags);
t1->flags = (flag_t*) opj_aligned_malloc(flagssize * sizeof(flag_t));
if(!t1->flags){
- return false;
+ return OPJ_FALSE;
}
t1->flagssize=flagssize;
}
t1->w=w;
t1->h=h;
- return true;
+ return OPJ_TRUE;
}
/** mod fixed_quality */
}
}
-bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_codestream_info_t *cstr_info) {
+opj_bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_codestream_info_t *cstr_info) {
int compno, resno, bandno, precno, cblkno, passno, layno;
double min, max;
double cumdisto[100]; /* fixed_quality */
}
if (!success) {
- return false;
+ return OPJ_FALSE;
}
if(cstr_info) { /* Threshold for Marcela Index */
cumdisto[layno] = (layno == 0) ? tcd_tile->distolayer[0] : (cumdisto[layno - 1] + tcd_tile->distolayer[layno]);
}
- return true;
+ return OPJ_TRUE;
}
int tcd_encode_tile(opj_tcd_t *tcd, int tileno, unsigned char *dest, int len, opj_codestream_info_t *cstr_info) {
return l;
}
-bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, opj_codestream_info_t *cstr_info) {
+opj_bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, opj_codestream_info_t *cstr_info) {
int l;
int compno;
int eof = 0;
if (tcd->image->comps[compno].resno_decoded < 0) {
opj_event_msg(tcd->cinfo, EVT_ERROR, "Error decoding tile. The number of resolutions to remove [%d+1] is higher than the number "
" of resolutions in the original codestream [%d]\nModify the cp_reduce parameter.\n", tcd->cp->reduce, tile->comps[compno].numresolutions);
- return false;
+ return OPJ_FALSE;
}
}
opj_event_msg(tcd->cinfo, EVT_INFO, "- tile decoded in %f s\n", tile_time);
if (eof) {
- return false;
+ return OPJ_FALSE;
}
- return true;
+ return OPJ_TRUE;
}
void tcd_free_decode(opj_tcd_t *tcd) {
void tcd_makelayer_fixed(opj_tcd_t *tcd, int layno, int final);
void tcd_rateallocate_fixed(opj_tcd_t *tcd);
void tcd_makelayer(opj_tcd_t *tcd, int layno, double thresh, int final);
-bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_codestream_info_t *cstr_info);
+opj_bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_codestream_info_t *cstr_info);
/**
Encode a tile from the raw image into a buffer
@param tcd TCD handle
@param tileno Number that identifies one of the tiles to be decoded
@param cstr_info Codestream information structure
*/
-bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, opj_codestream_info_t *cstr_info);
+opj_bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, opj_codestream_info_t *cstr_info);
/**
Free the memory allocated for decoding
@param tcd TCD handle