+ : added
September 19, 2011
++ [mickael] WIP: new image_header struct is used and enable used of cstr_info
+ [mickael] WIP: manage the case of event_mgr is not provided to setup_decoder function
+ [mickael] WIP: insert elements from V2 framework into the trunk (add missing files).
+ [mickael] Work In Progress: insert elements from V2 framework into the trunk.
}
/* -------------------------------------------------------------------------- */
-static void j2k_dump_image(FILE *fd, opj_image_t * img);
-static void j2k_dump_cp(FILE *fd, opj_image_t * img, opj_cp_t * cp);
+static void j2k_dump_image(FILE *fd, opj_image_header_t * img);
+static void j2k_dump_cp(FILE *fd, opj_image_t * img, opj_cp_v2_t * cp);
int get_num_images(char *imgdirpath){
DIR *dir;
}
/* -------------------------------------------------------------------------- */
-int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol, char *indexfilename) {
+int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol) {
/* parse the command line */
int totlen, c;
opj_option_t long_option[]={
};
const char optlist[] = "i:o:h";
- OPJ_ARG_NOT_USED(indexfilename);
-
totlen=sizeof(long_option);
img_fol->set_out_format = 0;
do {
opj_dparameters_t parameters; /* decompression parameters */
img_fol_t img_fol;
opj_event_mgr_t event_mgr; /* event manager */
- opj_image_t *image = NULL;
+ opj_image_header_t* image = NULL;
FILE *fsrc = NULL, *fout = NULL;
opj_bool bResult;
int num_images;
dircnt_t *dirptr = NULL;
opj_codec_t* dinfo = NULL; /* handle to a decompressor */
opj_stream_t *cio = NULL;
- opj_codestream_info_t cstr_info; /* Codestream information structure */
- char indexfilename[OPJ_PATH_LEN]; /* index file name */
- OPJ_INT32 l_tile_x0,l_tile_y0;
- OPJ_UINT32 l_tile_width,l_tile_height,l_nb_tiles_x,l_nb_tiles_y;
+ opj_codestream_info_t* cstr_info =NULL; /* Codestream information structure */
+ //OPJ_INT32 l_tile_x0,l_tile_y0;
+ //OPJ_UINT32 l_tile_width,l_tile_height,l_nb_tiles_x,l_nb_tiles_y;
/* FIXME configure the event callbacks (not required) */
/* set decoding parameters to default values */
opj_set_default_decoder_parameters(¶meters);
- /* Initialize indexfilename and img_fol */
- *indexfilename = 0;
+ /* Initialize img_fol */
memset(&img_fol,0,sizeof(img_fol_t));
/* parse input and get user encoding parameters */
- if(parse_cmdline_decoder(argc, argv, ¶meters,&img_fol, indexfilename) == 1) {
+ if(parse_cmdline_decoder(argc, argv, ¶meters,&img_fol) == 1) {
return EXIT_FAILURE;
}
if(!dirptr->filename_buf){
return EXIT_FAILURE;
}
+
for(i=0;i<num_images;i++){
dirptr->filename[i] = dirptr->filename_buf + i*OPJ_PATH_LEN;
}
if(load_images(dirptr,img_fol.imgdirpath)==1){
return EXIT_FAILURE;
}
+
if (num_images==0){
fprintf(stdout,"Folder is empty\n");
return EXIT_FAILURE;
if (parameters.outfile[0] != 0){
fout = fopen(parameters.outfile,"w");
if (!fout){
- fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.outfile);
+ fprintf(stderr, "ERROR -> failed to open %s for writing\n", parameters.outfile);
return EXIT_FAILURE;
}
}
else
fout = stdout;
- /*Encoding image one by one*/
+ /*Read the header of each image one by one*/
for(imageno = 0; imageno < num_images ; imageno++){
image = NULL;
fprintf(stderr,"\n");
}
}
-/*NEW V2 STYLE*/
+ /*NEW V2 STYLE*/
/* read the input file and put it in memory */
/* ---------------------------------------- */
fsrc = fopen(parameters.infile, "rb");
return EXIT_FAILURE;
}
-
cio = opj_stream_create_default_file_stream(fsrc,1);
-
/* decode the code-stream */
/* ---------------------- */
continue;
}
- /* FIXME catch events using our callbacks and give a local context */
- //opj_set_event_mgr_v2(dinfo, &event_mgr, stderr);
-
-
-
/* setup the decoder decoding parameters using user parameters */
opj_setup_decoder_v2(dinfo, ¶meters, &event_mgr);
image = opj_decode_with_info(dinfo, cio, &cstr_info);
else
*/
- bResult = opj_read_header( dinfo,
+ //opj_codestream_info_t *cstr_info = NULL;
+
+ /*bResult = opj_read_header( dinfo,
&image,
&l_tile_x0,
&l_tile_y0,
&l_tile_height,
&l_nb_tiles_x,
&l_nb_tiles_y,
- cio);
+ cio);*/
+
+ bResult = opj_read_header(cio, dinfo, &image, &cstr_info);
if(!bResult){
fprintf(stderr, "ERROR -> j2k_to_image: failed to read header\n");
/* dump image */
j2k_dump_image(fout, image);
/* dump cp */
- //j2k_dump_cp(stdout, image, dinfo->m_codec);
+ //j2k_dump_cp(stdout, image, ((opj_codec_private_t)dinfo)->m_codec);
//j2k_dump_cp(fout, image, ((opj_j2k_t*)dinfo->j2k_handle)->cp);
}
else if (parameters.decod_format == JP2_CFMT){
fclose(fsrc);
/* Write the index to disk */
- if (*indexfilename) {
+ /*if (*indexfilename) {
char bSuccess;
bSuccess = write_index_file(&cstr_info, indexfilename);
if (bSuccess) {
else
ret = EXIT_SUCCESS;
}
- else
+ else*/
ret = EXIT_SUCCESS;
/* free remaining structures */
opj_destroy_codec(dinfo);
}
/* free codestream information structure */
- if (*indexfilename)
- opj_destroy_cstr_info(&cstr_info);
+ /*if (*indexfilename)
+ FIXME A GARDER opj_destroy_cstr_info(&cstr_info);*/
/* free image data structure */
- opj_image_destroy(image);
+ opj_image_header_destroy(image);
}
/*NEW V2 STYLE*/
}
-static void j2k_dump_image(FILE *fd, opj_image_t * img) {
+static void j2k_dump_image(FILE *fd, opj_image_header_t * img) {
int compno;
fprintf(fd, "image {\n");
fprintf(fd, " x0=%d, y0=%d, x1=%d, y1=%d\n", img->x0, img->y0, img->x1, img->y1);
fprintf(fd, " numcomps=%d\n", img->numcomps);
for (compno = 0; compno < img->numcomps; compno++) {
- opj_image_comp_t *comp = &img->comps[compno];
+ opj_image_comp_header_t *comp = &img->comps[compno];
fprintf(fd, " comp %d {\n", compno);
fprintf(fd, " dx=%d, dy=%d\n", comp->dx, comp->dy);
fprintf(fd, " prec=%d\n", comp->prec);
fprintf(fd, "}\n");
}
-static void j2k_dump_cp(FILE *fd, opj_image_t * img, opj_cp_t * cp) {
+static void j2k_dump_cp(FILE *fd, opj_image_t * img, opj_cp_v2_t * cp) {
int tileno, compno, layno, bandno, resno, numbands;
fprintf(fd, "coding parameters {\n");
fprintf(fd, " tx0=%d, ty0=%d\n", cp->tx0, cp->ty0);
fprintf(fd, " tdx=%d, tdy=%d\n", cp->tdx, cp->tdy);
fprintf(fd, " tw=%d, th=%d\n", cp->tw, cp->th);
for (tileno = 0; tileno < cp->tw * cp->th; tileno++) {
- opj_tcp_t *tcp = &cp->tcps[tileno];
+ opj_tcp_v2_t *tcp = &cp->tcps[tileno];
fprintf(fd, " tile %d {\n", tileno);
fprintf(fd, " csty=%x\n", tcp->csty);
fprintf(fd, " prg=%d\n", tcp->prg);
return image;
}
+opj_image_header_t* opj_image_header_create0(void) {
+ opj_image_header_t *image_header = (opj_image_header_t*)opj_calloc(1, sizeof(opj_image_header_t));
+ return image_header;
+}
+
opj_image_t* OPJ_CALLCONV opj_image_create(int numcmpts, opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc) {
int compno;
opj_image_t *image = NULL;
return image;
}
+// TODO remove this one
void OPJ_CALLCONV opj_image_destroy(opj_image_t *image) {
int i;
if(image) {
}
}
+
+void OPJ_CALLCONV opj_image_header_destroy(opj_image_header_t *image) {
+ if(image) {
+ if(image->comps) {
+ /* image components */
+ opj_free(image->comps);
+ }
+ opj_free(image);
+ }
+}
+
/**
- * Updates the components of the image from the coding parameters.
+ * Updates the components characteristics of the image from the coding parameters.
*
- * @param p_image the image to update.
- * @param p_cp the coding parameters from which to update the image.
+ * @param p_image_header the image header to update.
+ * @param p_cp the coding parameters from which to update the image.
*/
-void opj_image_comp_update(opj_image_t * p_image,const opj_cp_v2_t * p_cp)
+void opj_image_comp_header_update(opj_image_header_t * p_image_header, const opj_cp_v2_t * p_cp)
{
OPJ_UINT32 i, l_width, l_height;
- OPJ_INT32 l_x0,l_y0,l_x1,l_y1;
- OPJ_INT32 l_comp_x0,l_comp_y0,l_comp_x1,l_comp_y1;
- opj_image_comp_t * l_img_comp = 00;
+ OPJ_INT32 l_x0, l_y0, l_x1, l_y1;
+ OPJ_INT32 l_comp_x0, l_comp_y0, l_comp_x1, l_comp_y1;
+ opj_image_comp_header_t* l_img_comp = NULL;
- l_x0 = int_max(p_cp->tx0 , p_image->x0);
- l_y0 = int_max(p_cp->ty0 , p_image->y0);
- l_x1 = int_min(p_cp->tx0 + p_cp->tw * p_cp->tdx, p_image->x1);
- l_y1 = int_min(p_cp->ty0 + p_cp->th * p_cp->tdy, p_image->y1);
+ l_x0 = int_max(p_cp->tx0 , p_image_header->x0);
+ l_y0 = int_max(p_cp->ty0 , p_image_header->y0);
+ l_x1 = int_min(p_cp->tx0 + p_cp->tw * p_cp->tdx, p_image_header->x1);
+ l_y1 = int_min(p_cp->ty0 + p_cp->th * p_cp->tdy, p_image_header->y1);
- l_img_comp = p_image->comps;
- for (i = 0; i < p_image->numcomps; ++i) {
+ l_img_comp = p_image_header->comps;
+ for (i = 0; i < p_image_header->numcomps; ++i) {
l_comp_x0 = int_ceildiv(l_x0, l_img_comp->dx);
l_comp_y0 = int_ceildiv(l_y0, l_img_comp->dy);
l_comp_x1 = int_ceildiv(l_x1, l_img_comp->dx);
opj_image_t* opj_image_create0(void);
/**
- * Updates the components of the image from the coding parameters.
+Create an empty image header
+@return returns an image header if successful, returns NULL otherwise
+*/
+opj_image_header_t* opj_image_header_create0(void);
+
+
+/**
+ * Updates the components characteristics of the image from the coding parameters.
*
- * @param p_image the image to update.
+ * @param p_image_header the image header to update.
* @param p_cp the coding parameters from which to update the image.
*/
-void opj_image_comp_update(struct opj_image * p_image,const struct opj_cp_v2 * p_cp);
+void opj_image_comp_header_update(struct opj_image_header * p_image_header, const struct opj_cp_v2* p_cp);
/*@}*/
OPJ_UINT32 l_remaining_size;
OPJ_UINT32 l_nb_tiles;
OPJ_UINT32 l_tmp;
- opj_image_t *l_image = 00;
+ opj_image_header_t *l_image = 00;
opj_cp_v2_t *l_cp = 00;
- opj_image_comp_t * l_img_comp = 00;
+ opj_image_comp_header_t * l_img_comp = 00;
opj_tcp_v2_t * l_current_tile_param = 00;
// preconditions
assert(p_manager != 00);
assert(p_header_data != 00);
- l_image = p_j2k->m_image;
+ l_image = p_j2k->m_image_header;
l_cp = &(p_j2k->m_cp);
// minimum size == 39 - 3 (= minimum component parameter)
#endif /* USE_JPWL */
// Allocate the resulting image components
- l_image->comps = (opj_image_comp_t*) opj_calloc(l_image->numcomps, sizeof(opj_image_comp_t));
+ l_image->comps = (opj_image_comp_header_t*) opj_calloc(l_image->numcomps, sizeof(opj_image_comp_header_t));
if (l_image->comps == 00){
l_image->numcomps = 0;
opj_event_msg_v2(p_manager, EVT_ERROR, "Not enough memory to take in charge SIZ marker\n");
return OPJ_FALSE;
}
- memset(l_image->comps,0,l_image->numcomps * sizeof(opj_image_comp_t));
+ memset(l_image->comps,0,l_image->numcomps * sizeof(opj_image_comp_header_t));
l_img_comp = l_image->comps;
// Read the component information
}
p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_MH; // FIXME J2K_DEC_STATE_MH;
- opj_image_comp_update(l_image,l_cp);
+ opj_image_comp_header_update(l_image,l_cp);
/* Index */
if (p_j2k->cstr_info) {
- opj_codestream_info_t *cstr_info = p_j2k->cstr_info;
- cstr_info->image_w = l_image->x1 - l_image->x0;
- cstr_info->image_h = l_image->y1 - l_image->y0;
- cstr_info->numcomps = l_image->numcomps;
- cstr_info->tw = l_cp->tw;
- cstr_info->th = l_cp->th;
- cstr_info->tile_x = l_cp->tdx;
- cstr_info->tile_y = l_cp->tdy;
- cstr_info->tile_Ox = l_cp->tx0;
- cstr_info->tile_Oy = l_cp->ty0;
- cstr_info->tile = (opj_tile_info_t*) opj_calloc(l_nb_tiles, sizeof(opj_tile_info_t));
- if (cstr_info->tile == 00) {
+ //opj_codestream_info_t *cstr_info = p_j2k->cstr_info;
+ p_j2k->cstr_info->image_w = l_image->x1 - l_image->x0;
+ p_j2k->cstr_info->image_h = l_image->y1 - l_image->y0;
+ p_j2k->cstr_info->numcomps = l_image->numcomps;
+ p_j2k->cstr_info->tw = l_cp->tw;
+ p_j2k->cstr_info->th = l_cp->th;
+ p_j2k->cstr_info->tile_x = l_cp->tdx;
+ p_j2k->cstr_info->tile_y = l_cp->tdy;
+ p_j2k->cstr_info->tile_Ox = l_cp->tx0;
+ p_j2k->cstr_info->tile_Oy = l_cp->ty0;
+ p_j2k->cstr_info->tile = (opj_tile_info_t*) opj_calloc(l_nb_tiles, sizeof(opj_tile_info_t));
+ if (p_j2k->cstr_info->tile == 00) {
opj_event_msg_v2(p_manager, EVT_ERROR, "Not enough memory to take in charge SIZ marker\n");
return OPJ_FALSE;
}
- memset(cstr_info->tile,0,l_nb_tiles * sizeof(opj_tile_info_t));
+ memset(p_j2k->cstr_info->tile,0,l_nb_tiles * sizeof(opj_tile_info_t));
}
return OPJ_TRUE;
}
OPJ_UINT32 l_tmp;
opj_cp_v2_t *l_cp = 00;
opj_tcp_v2_t *l_tcp = 00;
- opj_image_t *l_image = 00;
+ opj_image_header_t *l_image = 00;
// preconditions
assert(p_header_data != 00);
l_cp = &(p_j2k->m_cp);
l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH) /*FIXME J2K_DEC_STATE_TPH)*/ ? &l_cp->tcps[p_j2k->m_current_tile_number] : p_j2k->m_specific_param.m_decoder.m_default_tcp;
- l_image = p_j2k->m_image;
+ l_image = p_j2k->m_image_header;
// make sure room is sufficient
if (p_header_size < 5) {
/* Index */
if (p_j2k->cstr_info) {
- opj_codestream_info_t *l_cstr_info = p_j2k->cstr_info;
- l_cstr_info->prog = l_tcp->prg;
- l_cstr_info->numlayers = l_tcp->numlayers;
- l_cstr_info->numdecompos = (OPJ_INT32*) opj_malloc(l_image->numcomps * sizeof(OPJ_UINT32));
+ //opj_codestream_info_t *l_cstr_info = p_j2k->cstr_info;
+ p_j2k->cstr_info->prog = l_tcp->prg;
+ p_j2k->cstr_info->numlayers = l_tcp->numlayers;
+ p_j2k->cstr_info->numdecompos = (OPJ_INT32*) opj_malloc(l_image->numcomps * sizeof(OPJ_UINT32));
for (i = 0; i < l_image->numcomps; ++i) {
- l_cstr_info->numdecompos[i] = l_tcp->tccps[i].numresolutions - 1;
+ p_j2k->cstr_info->numdecompos[i] = l_tcp->tccps[i].numresolutions - 1;
}
}
return OPJ_TRUE;
{
opj_cp_v2_t *l_cp = NULL;
opj_tcp_v2_t *l_tcp = NULL;
- opj_image_t *l_image = NULL;
+ opj_image_header_t *l_image = NULL;
OPJ_UINT32 l_comp_room;
OPJ_UINT32 l_comp_no;
l_cp = &(p_j2k->m_cp);
l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH /*FIXME J2K_DEC_STATE_TPH*/) ? &l_cp->tcps[p_j2k->m_current_tile_number] : p_j2k->m_specific_param.m_decoder.m_default_tcp;
- l_image = p_j2k->m_image;
+ l_image = p_j2k->m_image_header;
l_comp_room = l_image->numcomps <= 256 ? 1 : 2;
assert(p_j2k != 00);
assert(p_manager != 00);
- l_num_comp = p_j2k->m_image->numcomps;
+ l_num_comp = p_j2k->m_image_header->numcomps;
#ifdef USE_JPWL
if (p_j2k->m_cp->correct) {
{
OPJ_UINT32 i;
OPJ_UINT32 l_nb_comp;
- opj_image_t * l_image = 00;
+ opj_image_header_t * l_image = 00;
OPJ_UINT32 l_old_poc_nb,l_current_poc_nb,l_current_poc_remaining;
OPJ_UINT32 l_chunk_size;
OPJ_UINT32 l_tmp;
assert(p_j2k != 00);
assert(p_manager != 00);
- l_image = p_j2k->m_image;
+ l_image = p_j2k->m_image_header;
l_nb_comp = l_image->numcomps;
if (l_nb_comp <= 256) {
l_comp_room = 1;
assert(p_j2k != 00);
assert(p_manager != 00);
- l_nb_comp = p_j2k->m_image->numcomps;
+ l_nb_comp = p_j2k->m_image_header->numcomps;
if (p_header_size != l_nb_comp *4) {
opj_event_msg_v2(p_manager, EVT_ERROR, "Error reading CRG marker\n");
)
{
OPJ_UINT32 l_nb_comp;
- opj_image_t * l_image = 00;
+ opj_image_header_t * l_image = 00;
opj_cp_v2_t *l_cp = 00;
opj_tcp_v2_t *l_tcp = 00;
assert(p_j2k != 00);
assert(p_manager != 00);
- l_image = p_j2k->m_image;
+ l_image = p_j2k->m_image_header;
l_nb_comp = l_image->numcomps;
if (l_nb_comp <= 256) {
*
* @return true if the box is valid.
*/
-opj_bool j2k_read_header(
- opj_j2k_v2_t *p_j2k,
- struct opj_image ** p_image,
- OPJ_INT32 * p_tile_x0,
- OPJ_INT32 * p_tile_y0,
- OPJ_UINT32 * p_tile_width,
- OPJ_UINT32 * p_tile_height,
- OPJ_UINT32 * p_nb_tiles_x,
- OPJ_UINT32 * p_nb_tiles_y,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager
- )
+opj_bool j2k_read_header( struct opj_stream_private *p_stream,
+ opj_j2k_v2_t* p_j2k,
+ struct opj_image_header** image_header,
+ struct opj_codestream_info** cstr_info,
+ struct opj_event_mgr* p_manager )
{
// preconditions
assert(p_j2k != 00);
assert(p_stream != 00);
assert(p_manager != 00);
+ //p_image_header = NULL;
- *p_image = 00;
- /* create an empty image */
- p_j2k->m_image = opj_image_create0();
- if
- (! p_j2k->m_image)
- {
+ /* create an empty image header */
+ p_j2k->m_image_header = opj_image_header_create0();
+ if (! p_j2k->m_image_header) {
return OPJ_FALSE;
}
/* customization of the validation */
- j2k_setup_decoding_validation (p_j2k);
+ j2k_setup_decoding_validation(p_j2k);
/* validation of the parameters codec */
- if
- (! j2k_exec(p_j2k,p_j2k->m_validation_list,p_stream,p_manager))
- {
- opj_image_destroy(p_j2k->m_image);
- p_j2k->m_image = 00;
+ if (! j2k_exec(p_j2k, p_j2k->m_validation_list, p_stream,p_manager)) {
+ opj_image_header_destroy(p_j2k->m_image_header);
+ p_j2k->m_image_header = NULL;
return OPJ_FALSE;
}
j2k_setup_header_reading(p_j2k);
/* read header */
- if
- (! j2k_exec (p_j2k,p_j2k->m_procedure_list,p_stream,p_manager))
- {
- opj_image_destroy(p_j2k->m_image);
- p_j2k->m_image = 00;
+ if (! j2k_exec (p_j2k,p_j2k->m_procedure_list,p_stream,p_manager)) {
+ opj_image_header_destroy(p_j2k->m_image_header);
+ p_j2k->m_image_header = NULL;
return OPJ_FALSE;
}
- *p_image = p_j2k->m_image;
- * p_tile_x0 = p_j2k->m_cp.tx0;
- * p_tile_y0 = p_j2k->m_cp.ty0;
- * p_tile_width = p_j2k->m_cp.tdx;
- * p_tile_height = p_j2k->m_cp.tdy;
- * p_nb_tiles_x = p_j2k->m_cp.tw;
- * p_nb_tiles_y = p_j2k->m_cp.th;
+
+ *cstr_info = p_j2k->cstr_info;
+
+ *image_header = p_j2k->m_image_header;
+ (*image_header)->tile_x0 = p_j2k->m_cp.tx0;
+ (*image_header)->tile_y0 = p_j2k->m_cp.ty0;
+ (*image_header)->tile_width = p_j2k->m_cp.tdx;
+ (*image_header)->tile_height = p_j2k->m_cp.tdy;
+ (*image_header)->nb_tiles_x = p_j2k->m_cp.tw;
+ (*image_header)->nb_tiles_y = p_j2k->m_cp.th;
+
return OPJ_TRUE;
}
opj_tccp_t *l_current_tccp = 00;
OPJ_UINT32 l_tccp_size;
OPJ_UINT32 l_mct_size;
- opj_image_t * l_image;
+ opj_image_header_t * l_image;
OPJ_UINT32 l_mcc_records_size,l_mct_records_size;
opj_mct_data_t * l_src_mct_rec, *l_dest_mct_rec;
opj_simple_mcc_decorrelation_data_t * l_src_mcc_rec, *l_dest_mcc_rec;
assert(p_manager != 00);
- l_image = p_j2k->m_image;
+ l_image = p_j2k->m_image_header;
l_nb_tiles = p_j2k->m_cp.th * p_j2k->m_cp.tw;
l_tcp = p_j2k->m_cp.tcps;
l_tccp_size = l_image->numcomps * sizeof(opj_tccp_t);
{
tcd_destroy_v2(p_j2k->m_tcd);
p_j2k->m_tcd = 00;
-#ifdef TOTO_MSD
- opj_event_msg(p_manager, EVT_ERROR, "Cannot decode tile, memory error\n");
-#endif
+ opj_event_msg_v2(p_manager, EVT_ERROR, "Cannot decode tile, memory error\n");
return OPJ_FALSE;
}
return OPJ_TRUE;
opj_j2k_v2_t* j2k_create_decompress_v2()
{
opj_j2k_v2_t *l_j2k = (opj_j2k_v2_t*) opj_malloc(sizeof(opj_j2k_v2_t));
- if
- (!l_j2k)
- {
+ if (!l_j2k) {
return 00;
}
memset(l_j2k,0,sizeof(opj_j2k_v2_t));
+
l_j2k->m_is_decoder = 1;
l_j2k->m_cp.m_is_decoder = 1;
l_j2k->m_specific_param.m_decoder.m_default_tcp = (opj_tcp_v2_t*) opj_malloc(sizeof(opj_tcp_v2_t));
- if
- (!l_j2k->m_specific_param.m_decoder.m_default_tcp)
- {
+
+ if (!l_j2k->m_specific_param.m_decoder.m_default_tcp) {
opj_free(l_j2k);
return 00;
}
memset(l_j2k->m_specific_param.m_decoder.m_default_tcp,0,sizeof(opj_tcp_v2_t));
l_j2k->m_specific_param.m_decoder.m_header_data = (OPJ_BYTE *) opj_malloc(J2K_DEFAULT_HEADER_SIZE);
- if
- (! l_j2k->m_specific_param.m_decoder.m_header_data)
- {
+ if (! l_j2k->m_specific_param.m_decoder.m_header_data) {
j2k_destroy(l_j2k);
return 00;
}
+
l_j2k->m_specific_param.m_decoder.m_header_data_size = J2K_DEFAULT_HEADER_SIZE;
+ // codestream info creation
+ l_j2k->cstr_info = (opj_codestream_info_t*) opj_malloc(sizeof(opj_codestream_info_t));
+ if (!l_j2k->cstr_info){
+ opj_free(l_j2k);
+ return NULL;
+ }
+
// validation list creation
l_j2k->m_validation_list = opj_procedure_list_create();
- if
- (! l_j2k->m_validation_list)
- {
+ if (! l_j2k->m_validation_list) {
j2k_destroy(l_j2k);
return 00;
}
// execution list creation
l_j2k->m_procedure_list = opj_procedure_list_create();
- if
- (! l_j2k->m_procedure_list)
- {
+ if (! l_j2k->m_procedure_list) {
j2k_destroy(l_j2k);
return 00;
}
+
return l_j2k;
}
l_tcp = p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH /* FIXME J2K_DEC_STATE_TPH*/ ? &l_cp->tcps[p_j2k->m_current_tile_number] : p_j2k->m_specific_param.m_decoder.m_default_tcp;
// precondition again
- assert(compno < p_j2k->m_image->numcomps);
+ assert(compno < p_j2k->m_image_header->numcomps);
l_tccp = &l_tcp->tccps[compno];
l_current_ptr = p_header_data;
l_copied_tccp = l_ref_tccp + 1;
l_prc_size = l_ref_tccp->numresolutions * sizeof(OPJ_UINT32);
- for (i=1;i<p_j2k->m_image->numcomps;++i) {
+ for (i=1;i<p_j2k->m_image_header->numcomps;++i) {
l_copied_tccp->numresolutions = l_ref_tccp->numresolutions;
l_copied_tccp->cblkw = l_ref_tccp->cblkw;
l_copied_tccp->cblkh = l_ref_tccp->cblkh;
l_cp = &(p_j2k->m_cp);
l_tcp = p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH /*FIXME J2K_DEC_STATE_TPH*/ ? &l_cp->tcps[p_j2k->m_current_tile_number] : p_j2k->m_specific_param.m_decoder.m_default_tcp;
// precondition again
- assert(p_comp_no < p_j2k->m_image->numcomps);
+ assert(p_comp_no < p_j2k->m_image_header->numcomps);
l_tccp = &l_tcp->tccps[p_comp_no];
l_current_ptr = p_header_data;
l_copied_tccp = l_ref_tccp + 1;
l_size = J2K_MAXBANDS * sizeof(opj_stepsize_t);
- for (i=1;i<p_j2k->m_image->numcomps;++i) {
+ for (i=1;i<p_j2k->m_image_header->numcomps;++i) {
l_copied_tccp->qntsty = l_ref_tccp->qntsty;
l_copied_tccp->numgbits = l_ref_tccp->numgbits;
memcpy(l_copied_tccp->stepsizes,l_ref_tccp->stepsizes,l_size);
OPJ_UINT32 m_current_tile_number;
/** pointer to the encoded / decoded image */
- opj_image_t *m_image;
+ //opj_image_t *m_image;
+ opj_image_header_t* m_image_header;
/** Coding parameters */
opj_cp_v2_t m_cp;
*
* @return true if the box is valid.
*/
-opj_bool j2k_read_header(
- opj_j2k_v2_t *p_j2k,
- struct opj_image ** p_image,
- OPJ_INT32 * p_tile_x0,
- OPJ_INT32 * p_tile_y0,
- OPJ_UINT32 * p_tile_width,
- OPJ_UINT32 * p_tile_height,
- OPJ_UINT32 * p_nb_tiles_x,
- OPJ_UINT32 * p_nb_tiles_y,
- struct opj_stream_private *cio,
- struct opj_event_mgr * p_manager
- );
+opj_bool j2k_read_header( struct opj_stream_private *p_stream,
+ opj_j2k_v2_t* p_j2k,
+ struct opj_image_header** image_header,
+ struct opj_codestream_info** cstr_info,
+ struct opj_event_mgr* p_manager );
+
/**
* Destroys a jpeg2000 codec.
typedef struct opj_decompression
{
opj_bool (* opj_read_header) (
- void *p_codec,
- opj_image_t **,
- OPJ_INT32 * p_tile_x0,
- OPJ_INT32 * p_tile_y0,
- OPJ_UINT32 * p_tile_width,
- OPJ_UINT32 * p_tile_height,
- OPJ_UINT32 * p_nb_tiles_x,
- OPJ_UINT32 * p_nb_tiles_y,
- struct opj_stream_private *cio,
- struct opj_event_mgr * p_manager);
+ struct opj_stream_private * cio,
+ void * p_codec,
+ opj_image_header_t ** image_header,
+ opj_codestream_info_t ** cstr_info,
+ struct opj_event_mgr * p_manager);
opj_image_t* (* opj_decode) (void * p_codec, struct opj_stream_private *p_cio, struct opj_event_mgr * p_manager);
opj_bool (*opj_read_tile_header)(
void * p_codec,
l_info->m_codec_data.m_decompression.opj_decode = (opj_image_t* (*) (void *, struct opj_stream_private *, struct opj_event_mgr * ))j2k_decode;
l_info->m_codec_data.m_decompression.opj_end_decompress = (opj_bool (*) (void *,struct opj_stream_private *,struct opj_event_mgr *))j2k_end_decompress;
l_info->m_codec_data.m_decompression.opj_read_header = (opj_bool (*) (
- void *,
- opj_image_t **,
- OPJ_INT32 * ,
- OPJ_INT32 * ,
- OPJ_UINT32 * ,
- OPJ_UINT32 * ,
- OPJ_UINT32 * ,
- OPJ_UINT32 * ,
- struct opj_stream_private *,
- struct opj_event_mgr * )) j2k_read_header;
+ struct opj_stream_private *,
+ void *,
+ opj_image_header_t **,
+ opj_codestream_info_t**,
+ struct opj_event_mgr * )) j2k_read_header;
l_info->m_codec_data.m_decompression.opj_destroy = (void (*) (void *))j2k_destroy;
l_info->m_codec_data.m_decompression.opj_setup_decoder = (void (*) (void * ,opj_dparameters_t * )) j2k_setup_decoder;
l_info->m_codec_data.m_decompression.opj_read_tile_header = (opj_bool (*) (
opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream (FILE * p_file, OPJ_UINT32 p_size, opj_bool p_is_read_stream)
{
opj_stream_t* l_stream = 00;
- if
- (! p_file)
- {
- return 00;
+
+ if (! p_file) {
+ return NULL;
}
+
l_stream = opj_stream_create(p_size,p_is_read_stream);
- if
- (! l_stream)
- {
- return 00;
+ if (! l_stream) {
+ return NULL;
}
- opj_stream_set_user_data(l_stream,p_file);
- opj_stream_set_read_function(l_stream,(opj_stream_read_fn) opj_read_from_file);
+
+ opj_stream_set_user_data(l_stream, p_file);
+ opj_stream_set_read_function(l_stream, (opj_stream_read_fn) opj_read_from_file);
opj_stream_set_write_function(l_stream, (opj_stream_write_fn) opj_write_from_file);
opj_stream_set_skip_function(l_stream, (opj_stream_skip_fn) opj_skip_from_file);
opj_stream_set_seek_function(l_stream, (opj_stream_seek_fn) opj_seek_from_file);
+
return l_stream;
}
}
}
-
+#ifdef OLD_WAY_MS
opj_bool OPJ_CALLCONV opj_read_header (
opj_codec_t *p_codec,
opj_image_t ** p_image,
OPJ_UINT32 * p_nb_tiles_y,
opj_stream_t *p_cio)
{
- if
- (p_codec && p_cio)
- {
+ if (p_codec && p_cio) {
opj_codec_private_t * l_info = (opj_codec_private_t *) p_codec;
opj_stream_private_t * l_cio = (opj_stream_private_t *) p_cio;
- if
- (! l_info->is_decompressor)
- {
+
+ if(! l_info->is_decompressor) {
return OPJ_FALSE;
}
+
return l_info->m_codec_data.m_decompression.opj_read_header(
l_info->m_codec,
p_image,
p_nb_tiles_x,
p_nb_tiles_y,
l_cio,
- //&(l_info->m_event_mgr));
- l_info->m_event_mgr);
+ l_info->m_event_mgr); //&(l_info->m_event_mgr));
+ }
+ return OPJ_FALSE;
+}
+#endif
+
+opj_bool OPJ_CALLCONV opj_read_header ( opj_stream_t *p_cio,
+ opj_codec_t *p_codec,
+ opj_image_header_t **p_image_header,
+ opj_codestream_info_t **p_cstr_info )
+
+{
+ if (p_codec && p_cio) {
+ opj_codec_private_t* l_info = (opj_codec_private_t*) p_codec;
+ opj_stream_private_t* l_cio = (opj_stream_private_t*) p_cio;
+
+ if(! l_info->is_decompressor) {
+ return OPJ_FALSE;
+ }
+
+ return l_info->m_codec_data.m_decompression.opj_read_header(
+ l_cio,
+ l_info->m_codec,
+ p_image_header,
+ p_cstr_info,
+ l_info->m_event_mgr);
}
return OPJ_FALSE;
}
+
void OPJ_CALLCONV opj_destroy_codec(opj_codec_t *p_info)
{
if
int sgnd;
} opj_image_cmptparm_t;
+
+
+/**
+Defines a single image component characteristics (uses in new API)
+*/
+typedef struct opj_image_comp_header {
+ /** XRsiz: horizontal separation of a sample of ith component with respect to the reference grid */
+ int dx;
+ /** YRsiz: vertical separation of a sample of ith component with respect to the reference grid */
+ int dy;
+ /** data width */
+ int w;
+ /** data height */
+ int h;
+ /** x component offset compared to the whole image */
+ int x0;
+ /** y component offset compared to the whole image */
+ int y0;
+ /** precision */
+ int prec;
+ /** image depth in bits */
+ int bpp;
+ /** signed (1) / unsigned (0) */
+ int sgnd;
+ /** number of decoded resolution */
+ int resno_decoded;
+ /** number of division by 2 of the out image compared to the original size of image */
+ int factor;
+} opj_image_comp_header_t;
+
+/**
+Defines image characteristics (uses in new API)
+*/
+typedef struct opj_image_header {
+ /** XOsiz: horizontal offset from the origin of the reference grid to the left side of the image area */
+ OPJ_UINT32 x0;
+ /** YOsiz: vertical offset from the origin of the reference grid to the top side of the image area */
+ OPJ_UINT32 y0;
+ /** Xsiz: width of the reference grid */
+ OPJ_UINT32 x1;
+ /** Ysiz: height of the reference grid */
+ OPJ_UINT32 y1;
+ /** number of components in the image */
+ OPJ_UINT16 numcomps;
+ /** color space: sRGB, Greyscale or YUV */
+ OPJ_COLOR_SPACE color_space;
+ /** image components */
+ opj_image_comp_header_t *comps;
+
+ /** XTOsiz */
+ OPJ_UINT32 tile_x0;
+ /** YTOsiz */
+ OPJ_UINT32 tile_y0;
+ /** XTsiz */
+ OPJ_UINT32 tile_width;
+ /** YTsiz */
+ OPJ_UINT32 tile_height;
+ /** number of tiles in width */
+ OPJ_UINT32 nb_tiles_x;
+ /** number of tiles in height */
+ OPJ_UINT32 nb_tiles_y;
+
+ /** 'restricted' ICC profile */
+ unsigned char *icc_profile_buf;
+ /** size of ICC profile */
+ int icc_profile_len;
+} opj_image_header_t;
+
+
/*
==========================================================
Information on the JPEG 2000 codestream
*/
OPJ_API void OPJ_CALLCONV opj_image_destroy(opj_image_t *image);
+OPJ_API void OPJ_CALLCONV opj_image_header_destroy(opj_image_header_t *image);
+
/*
==========================================================
stream functions definitions
* @param p_nb_tiles_x pointer to a value that will hold the number of tiles in the x direction.
* @param p_nb_tiles_y pointer to a value that will hold the number of tiles in the y direction.
*/
-OPJ_API opj_bool OPJ_CALLCONV opj_read_header (
- opj_codec_t *p_codec,
- opj_image_t ** p_image,
- OPJ_INT32 * p_tile_x0,
- OPJ_INT32 * p_tile_y0,
- OPJ_UINT32 * p_tile_width,
- OPJ_UINT32 * p_tile_height,
- OPJ_UINT32 * p_nb_tiles_x,
- OPJ_UINT32 * p_nb_tiles_y,
- opj_stream_t *p_cio);
+OPJ_API opj_bool OPJ_CALLCONV opj_read_header ( opj_stream_t *p_cio,
+ opj_codec_t *p_codec,
+ opj_image_header_t **p_image_header,
+ opj_codestream_info_t **p_cstr_info );
/**
Destroy a decompressor handle
* @param p_resolutions pointer to an area corresponding to the one described above.
*/
void get_all_encoding_parameters(
- const opj_image_t *p_image,
+ const opj_image_header_t *p_image,
const opj_cp_v2_t *p_cp,
OPJ_UINT32 tileno,
OPJ_INT32 * p_tx0,
* @param p_tile_no the index of the tile from which creating the packet iterator.
*/
opj_pi_iterator_t * pi_create(
- const opj_image_t *image,
+ const opj_image_header_t *image,
const opj_cp_v2_t *cp,
OPJ_UINT32 tileno
);
opj_pi_iterator_t *pi_create_decode_v2(
- opj_image_t *p_image,
+ opj_image_header_t *p_image,
opj_cp_v2_t *p_cp,
OPJ_UINT32 p_tile_no
)
opj_tcp_v2_t *l_tcp = 00;
const opj_tccp_t *l_tccp = 00;
opj_pi_comp_t *l_current_comp = 00;
- opj_image_comp_t * l_img_comp = 00;
+ opj_image_comp_header_t * l_img_comp = 00;
opj_pi_iterator_t * l_current_pi = 00;
OPJ_UINT32 * l_encoding_value_ptr = 00;
}
// memory allocation for pi
- l_pi = pi_create(p_image,p_cp,p_tile_no);
- if
- (!l_pi)
- {
+ l_pi = pi_create(p_image, p_cp, p_tile_no);
+ if (!l_pi) {
opj_free(l_tmp_data);
opj_free(l_tmp_ptr);
return 00;
(pino = 1 ; pino<l_bound ; ++pino )
{
opj_pi_comp_t *l_current_comp = l_current_pi->comps;
- opj_image_comp_t * l_img_comp = p_image->comps;
+ opj_image_comp_header_t * l_img_comp = p_image->comps;
l_tccp = l_tcp->tccps;
l_current_pi->tx0 = l_tx0;
* @param p_resolutions pointer to an area corresponding to the one described above.
*/
void get_all_encoding_parameters(
- const opj_image_t *p_image,
+ const opj_image_header_t *p_image,
const opj_cp_v2_t *p_cp,
OPJ_UINT32 tileno,
OPJ_INT32 * p_tx0,
// pointers
const opj_tcp_v2_t *tcp = 00;
const opj_tccp_t * l_tccp = 00;
- const opj_image_comp_t * l_img_comp = 00;
+ const opj_image_comp_header_t * l_img_comp = 00;
// to store l_dx, l_dy, w and h for each resolution and component.
OPJ_UINT32 * lResolutionPtr;
* @param p_tile_no the index of the tile from which creating the packet iterator.
*/
opj_pi_iterator_t * pi_create(
- const opj_image_t *image,
+ const opj_image_header_t *image,
const opj_cp_v2_t *cp,
OPJ_UINT32 tileno
)
tcp = &cp->tcps[tileno];
l_poc_bound = tcp->numpocs+1;
-
// memory allocations
l_pi = (opj_pi_iterator_t*) opj_calloc((l_poc_bound), sizeof(opj_pi_iterator_t));
-
- if
- (!l_pi)
- {
- return 00;
+ if (!l_pi) {
+ return NULL;
}
memset(l_pi,0,l_poc_bound * sizeof(opj_pi_iterator_t));
+
l_current_pi = l_pi;
- for
- (pino = 0; pino < l_poc_bound ; ++pino)
- {
+ for (pino = 0; pino < l_poc_bound ; ++pino) {
+
l_current_pi->comps = (opj_pi_comp_t*) opj_calloc(image->numcomps, sizeof(opj_pi_comp_t));
- if
- (! l_current_pi->comps)
- {
+ if (! l_current_pi->comps) {
pi_destroy_v2(l_pi, l_poc_bound);
- return 00;
+ return NULL;
}
+
l_current_pi->numcomps = image->numcomps;
memset(l_current_pi->comps,0,image->numcomps * sizeof(opj_pi_comp_t));
- for
- (compno = 0; compno < image->numcomps; ++compno)
- {
+
+ for (compno = 0; compno < image->numcomps; ++compno) {
opj_pi_comp_t *comp = &l_current_pi->comps[compno];
+
tccp = &tcp->tccps[compno];
+
comp->resolutions = (opj_pi_resolution_t*) opj_malloc(tccp->numresolutions * sizeof(opj_pi_resolution_t));
- if
- (!comp->resolutions)
- {
+ if (!comp->resolutions) {
pi_destroy_v2(l_pi, l_poc_bound);
return 00;
}
+
comp->numresolutions = tccp->numresolutions;
memset(comp->resolutions,0,tccp->numresolutions * sizeof(opj_pi_resolution_t));
}
@return Returns a packet iterator that points to the first packet of the tile
@see pi_destroy
*/
-opj_pi_iterator_t *pi_create_decode_v2(struct opj_image * image, struct opj_cp_v2 * cp, OPJ_UINT32 tileno);
+opj_pi_iterator_t *pi_create_decode_v2(struct opj_image_header * image, struct opj_cp_v2 * cp, OPJ_UINT32 tileno);
/**
OPJ_BYTE *l_current_data = p_src;
opj_pi_iterator_t *l_pi = 00;
OPJ_UINT32 pino;
- opj_image_t *l_image = p_t2->image;
+ opj_image_header_t *l_image = p_t2->image;
opj_cp_v2_t *l_cp = p_t2->cp;
opj_cp_v2_t *cp = p_t2->cp;
opj_tcp_v2_t *l_tcp = &(p_t2->cp->tcps[p_tile_no]);
OPJ_UINT32 curtp = 0;
OPJ_UINT32 tp_start_packno;
opj_packet_info_t *l_pack_info = 00;
- opj_image_comp_t* l_img_comp = 00;
+ opj_image_comp_header_t* l_img_comp = 00;
- if
- (p_cstr_info)
- {
+ if (p_cstr_info) {
l_pack_info = p_cstr_info->tile[p_tile_no].packet;
}
/* create a packet iterator */
l_pi = pi_create_decode_v2(l_image, l_cp, p_tile_no);
- if
- (!l_pi)
- {
+ if (!l_pi) {
return OPJ_FALSE;
}
tp_start_packno = 0;
l_current_pi = l_pi;
- for
- (pino = 0; pino <= l_tcp->numpocs; ++pino)
- {
- while
- (pi_next(l_current_pi))
- {
+ for (pino = 0; pino <= l_tcp->numpocs; ++pino) {
- if
- (l_tcp->num_layers_to_decode > l_current_pi->layno && l_current_pi->resno < p_tile->comps[l_current_pi->compno].minimum_num_resolutions)
- {
+ while (pi_next(l_current_pi)) {
+
+ if (l_tcp->num_layers_to_decode > l_current_pi->layno
+ && l_current_pi->resno < p_tile->comps[l_current_pi->compno].minimum_num_resolutions) {
l_nb_bytes_read = 0;
- if
- (! t2_decode_packet_v2(p_t2,p_tile,l_tcp,l_current_pi,l_current_data,&l_nb_bytes_read,p_max_len,l_pack_info))
- {
+
+ if (! t2_decode_packet_v2(p_t2,p_tile,l_tcp,l_current_pi,l_current_data,&l_nb_bytes_read,p_max_len,l_pack_info)) {
pi_destroy_v2(l_pi,l_nb_pocs);
return OPJ_FALSE;
}
+
l_img_comp = &(l_image->comps[l_current_pi->compno]);
l_img_comp->resno_decoded = uint_max(l_current_pi->resno, l_img_comp->resno_decoded);
}
- else
- {
+ else {
l_nb_bytes_read = 0;
- if
- (! t2_skip_packet(p_t2,p_tile,l_tcp,l_current_pi,l_current_data,&l_nb_bytes_read,p_max_len,l_pack_info))
- {
+ if (! t2_skip_packet(p_t2,p_tile,l_tcp,l_current_pi,l_current_data,&l_nb_bytes_read,p_max_len,l_pack_info)) {
pi_destroy_v2(l_pi,l_nb_pocs);
return OPJ_FALSE;
}
}
+
l_current_data += l_nb_bytes_read;
p_max_len -= l_nb_bytes_read;
* @return a new T2 handle if successful, NULL otherwise.
*/
opj_t2_v2_t* t2_create_v2(
- opj_image_t *p_image,
+ opj_image_header_t *p_image,
opj_cp_v2_t *p_cp)
{
/* create the tcd structure */
*p_data_read = 0;
- if
- (! t2_read_packet_header(p_t2,p_tile,p_tcp,p_pi,&l_read_data,p_src,&l_nb_bytes_read,p_max_length,p_pack_info))
- {
+ if (! t2_read_packet_header(p_t2,p_tile,p_tcp,p_pi,&l_read_data,p_src,&l_nb_bytes_read,p_max_length,p_pack_info)) {
return OPJ_FALSE;
}
+
p_src += l_nb_bytes_read;
l_nb_total_bytes_read += l_nb_bytes_read;
p_max_length -= l_nb_bytes_read;
+
/* we should read data for the packet */
- if
- (l_read_data)
- {
+ if (l_read_data) {
l_nb_bytes_read = 0;
- if
- (! t2_read_packet_data(p_t2,p_tile,p_pi,p_src,&l_nb_bytes_read,p_max_length,p_pack_info))
- {
+
+ if (! t2_read_packet_data(p_t2,p_tile,p_pi,p_src,&l_nb_bytes_read,p_max_length,p_pack_info)) {
return OPJ_FALSE;
}
+
l_nb_total_bytes_read += l_nb_bytes_read;
}
+
*p_data_read = l_nb_total_bytes_read;
+
return OPJ_FALSE;
}
opj_common_ptr cinfo;
/** Encoding: pointer to the src image. Decoding: pointer to the dst image. */
- opj_image_t *image;
+ opj_image_header_t *image;
/** pointer to the image coding parameters */
opj_cp_v2_t *cp;
} opj_t2_v2_t;
* @param p_cp Image coding parameters.
* @return a new T2 handle if successful, NULL otherwise.
*/
-opj_t2_v2_t* t2_create_v2(struct opj_image *p_image, opj_cp_v2_t *p_cp);
+opj_t2_v2_t* t2_create_v2(struct opj_image_header *p_image, opj_cp_v2_t *p_cp);
/**
Create a T2 handle
}
-opj_bool tcd_init_v2(
- opj_tcd_v2_t *p_tcd,
- opj_image_t * p_image,
- opj_cp_v2_t * p_cp
- )
+opj_bool tcd_init_v2( opj_tcd_v2_t *p_tcd,
+ opj_image_header_t * p_image_header,
+ opj_cp_v2_t * p_cp )
{
OPJ_UINT32 l_tile_comp_size;
- p_tcd->image = p_image;
+ p_tcd->image_header = p_image_header;
p_tcd->cp = p_cp;
p_tcd->tcd_image->tiles = (opj_tcd_tile_t *) opj_malloc(sizeof(opj_tcd_tile_t));
- if
- (! p_tcd->tcd_image->tiles)
- {
+ if (! p_tcd->tcd_image->tiles) {
return OPJ_FALSE;
}
memset(p_tcd->tcd_image->tiles,0, sizeof(opj_tcd_tile_t));
- l_tile_comp_size = p_image->numcomps * sizeof(opj_tcd_tilecomp_t);
+ l_tile_comp_size = p_image_header->numcomps * sizeof(opj_tcd_tilecomp_t);
p_tcd->tcd_image->tiles->comps = (opj_tcd_tilecomp_t *) opj_malloc(l_tile_comp_size);
- if
- (! p_tcd->tcd_image->tiles->comps )
- {
+ if (! p_tcd->tcd_image->tiles->comps ) {
return OPJ_FALSE;
}
memset( p_tcd->tcd_image->tiles->comps , 0 , l_tile_comp_size);
- p_tcd->tcd_image->tiles->numcomps = p_image->numcomps;
+
+ p_tcd->tcd_image->tiles->numcomps = p_image_header->numcomps;
p_tcd->tp_pos = p_cp->m_specific_param.m_enc.m_tp_pos;
+
return OPJ_TRUE;
}
opj_stepsize_t * l_step_size = 00; \
opj_tcd_precinct_t *l_current_precinct = 00; \
TYPE* l_code_block = 00; \
- opj_image_t * l_image = 00; \
+ opj_image_header_t * l_image = 00; \
OPJ_UINT32 p,q; \
OPJ_UINT32 l_level_no; \
OPJ_UINT32 l_pdx, l_pdy; \
l_tile = p_tcd->tcd_image->tiles; \
l_tccp = l_tcp->tccps; \
l_tilec = l_tile->comps; \
- l_image = p_tcd->image; \
- l_image_comp = p_tcd->image->comps; \
+ l_image = p_tcd->image_header; \
+ l_image_comp = p_tcd->image_header->comps; \
\
p = p_tile_no % l_cp->tw; /* tile coordinates */ \
q = p_tile_no / l_cp->tw; \
{
OPJ_UINT32 i;
OPJ_UINT32 l_data_size = 0;
- opj_image_comp_t * l_img_comp = 00;
+ opj_image_comp_header_t * l_img_comp = 00;
opj_tcd_tilecomp_t * l_tile_comp = 00;
opj_tcd_resolution_t * l_res = 00;
OPJ_UINT32 l_size_comp, l_remaining;
l_tile_comp = p_tcd->tcd_image->tiles->comps;
- l_img_comp = p_tcd->image->comps;
+ l_img_comp = p_tcd->image_header->comps;
for
- (i=0;i<p_tcd->image->numcomps;++i)
+ (i=0;i<p_tcd->image_header->numcomps;++i)
{
l_size_comp = l_img_comp->prec >> 3; /*(/ 8)*/
l_remaining = l_img_comp->prec & 7; /* (%8) */
)
{
OPJ_UINT32 i,j,k,l_data_size = 0;
- opj_image_comp_t * l_img_comp = 00;
+ opj_image_comp_header_t * l_img_comp = 00;
opj_tcd_tilecomp_t * l_tilec = 00;
opj_tcd_resolution_t * l_res;
OPJ_UINT32 l_size_comp, l_remaining;
}
l_tilec = p_tcd->tcd_image->tiles->comps;
- l_img_comp = p_tcd->image->comps;
+ l_img_comp = p_tcd->image_header->comps;
for
- (i=0;i<p_tcd->image->numcomps;++i)
+ (i=0;i<p_tcd->image_header->numcomps;++i)
{
l_size_comp = l_img_comp->prec >> 3; /*(/ 8)*/
l_remaining = l_img_comp->prec & 7; /* (%8) */
{
opj_t2_v2_t * l_t2;
- l_t2 = t2_create_v2(p_tcd->image, p_tcd->cp);
+ l_t2 = t2_create_v2(p_tcd->image_header, p_tcd->cp);
if
(l_t2 == 00)
{
opj_tcd_tile_t * l_tile = p_tcd->tcd_image->tiles;
opj_tcd_tilecomp_t * l_tile_comp = l_tile->comps;
opj_tccp_t * l_tccp = p_tcd->tcp->tccps;
- opj_image_comp_t * l_img_comp = p_tcd->image->comps;
+ opj_image_comp_header_t * l_img_comp = p_tcd->image_header->comps;
for
(compno = 0; compno < l_tile->numcomps; compno++)
// nb of components (i.e. size of pData)
l_tile->numcomps,
// tells if the data is signed
- p_tcd->image->comps->sgnd))
+ p_tcd->image_header->comps->sgnd))
{
opj_free(l_data);
return OPJ_FALSE;
OPJ_UINT32 compno;
opj_tcd_tilecomp_t * l_tile_comp = 00;
opj_tccp_t * l_tccp = 00;
- opj_image_comp_t * l_img_comp = 00;
+ opj_image_comp_header_t * l_img_comp = 00;
opj_tcd_resolution_t* l_res = 00;
opj_tcp_v2_t * l_tcp = 00;
opj_tcd_tile_t * l_tile;
l_tile_comp = l_tile->comps;
l_tcp = p_tcd->tcp;
l_tccp = p_tcd->tcp->tccps;
- l_img_comp = p_tcd->image->comps;
+ l_img_comp = p_tcd->image_header->comps;
for
(compno = 0; compno < l_tile->numcomps; compno++)
OPJ_UINT32 cur_pino;
/** info on each image tile */
opj_tcd_image_t *tcd_image;
- /** image */
- struct opj_image *image;
+ /** image header */
+ struct opj_image_header *image_header;
/** coding parameters */
struct opj_cp_v2 *cp;
/** coding/decoding parameters common to all tiles */
opj_bool tcd_init_v2(
opj_tcd_v2_t *p_tcd,
//struct opj_image * p_image,
- opj_image_t * p_image,
+ opj_image_header_t * p_image_header,
//struct opj_cp * p_cp
opj_cp_v2_t * p_cp
);