diff --git a/applications/codec/image_to_j2k.c b/applications/codec/image_to_j2k.c index 7d2bba0d..ed9a9a37 100644 --- a/applications/codec/image_to_j2k.c +++ b/applications/codec/image_to_j2k.c @@ -1536,38 +1536,59 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters, /** sample error callback expecting a FILE* client object */ -void error_callback(const char *msg, void *client_data) { +void error_file_callback(const char *msg, void *client_data) { FILE *stream = (FILE*)client_data; fprintf(stream, "[ERROR] %s", msg); } /** sample warning callback expecting a FILE* client object */ -void warning_callback(const char *msg, void *client_data) { +void warning_file_callback(const char *msg, void *client_data) { FILE *stream = (FILE*)client_data; fprintf(stream, "[WARNING] %s", msg); } /** sample debug callback expecting a FILE* client object */ -void info_callback(const char *msg, void *client_data) { +void info_file_callback(const char *msg, void *client_data) { FILE *stream = (FILE*)client_data; fprintf(stream, "[INFO] %s", msg); } +/** +sample error debug callback expecting no client object +*/ +void error_callback(const char *msg, void *client_data) { + (void)client_data; + fprintf(stdout, "[ERROR] %s", msg); +} +/** +sample warning debug callback expecting no client object +*/ +void warning_callback(const char *msg, void *client_data) { + (void)client_data; + fprintf(stdout, "[WARNING] %s", msg); +} +/** +sample debug callback expecting no client object +*/ +void info_callback(const char *msg, void *client_data) { + (void)client_data; + fprintf(stdout, "[INFO] %s", msg); +} + /* -------------------------------------------------------------------------- */ /** * IMAGE_TO_J2K MAIN */ /* -------------------------------------------------------------------------- */ int main(int argc, char **argv) { - FILE *f = NULL; + FILE *fout = NULL; opj_cparameters_t parameters; /* compression parameters */ - opj_event_mgr_t event_mgr; /* event manager */ - opj_stream_t *cio = 00; - opj_codec_t* cinfo = 00; + opj_stream_t *l_stream = 00; + opj_codec_t* l_codec = 00; opj_image_t *image = NULL; raw_cparameters_t raw_cp; opj_codestream_info_t cstr_info; /* Codestream information structure */ @@ -1580,15 +1601,6 @@ int main(int argc, char **argv) { opj_bool bSuccess; - /* - configure the event callbacks (not required) - setting of each callback is optionnal - */ - memset(&event_mgr, 0, sizeof(opj_event_mgr_t)); - event_mgr.error_handler = error_callback; - event_mgr.warning_handler = warning_callback; - event_mgr.info_handler = info_callback; - /* set encoding parameters to default values */ opj_set_default_encoder_parameters(¶meters); @@ -1768,56 +1780,61 @@ int main(int argc, char **argv) { case J2K_CFMT: /* JPEG-2000 codestream */ { /* Get a decoder handle */ - cinfo = opj_create_compress_v2(CODEC_J2K); + l_codec = opj_create_compress_v2(CODEC_J2K); break; } case JP2_CFMT: /* JPEG 2000 compressed image data */ { /* Get a decoder handle */ - cinfo = opj_create_compress_v2(CODEC_JP2); + l_codec = opj_create_compress_v2(CODEC_JP2); break; } default: fprintf(stderr, "skipping file..\n"); - opj_stream_destroy(cio); + opj_stream_destroy(l_stream); continue; } + + /* catch events using our callbacks and give a local context */ + opj_set_info_handler(l_codec, info_callback,00); + opj_set_warning_handler(l_codec, warning_callback,00); + opj_set_error_handler(l_codec, error_callback,00); - opj_setup_encoder_v2(cinfo, ¶meters, image); + opj_setup_encoder_v2(l_codec, ¶meters, image); /* Open the output file*/ - f = fopen(parameters.outfile, "wb"); - if (! f) { + fout = fopen(parameters.outfile, "wb"); + if (! fout) { fprintf(stderr, "Not enable to create output file!\n"); - opj_stream_destroy(cio); + opj_stream_destroy(l_stream); return 1; } /* open a byte stream for writing and allocate memory for all tiles */ - cio = opj_stream_create_default_file_stream(f,OPJ_FALSE); - if (! cio){ + l_stream = opj_stream_create_default_file_stream(fout,OPJ_FALSE); + if (! l_stream){ return 1; } /* encode the image */ - bSuccess = opj_start_compress(cinfo,image,cio); - bSuccess = bSuccess && opj_encode_v2(cinfo, cio); - bSuccess = bSuccess && opj_end_compress(cinfo, cio); + bSuccess = opj_start_compress(l_codec,image,l_stream); + bSuccess = bSuccess && opj_encode_v2(l_codec, l_stream); + bSuccess = bSuccess && opj_end_compress(l_codec, l_stream); if (!bSuccess) { - opj_stream_destroy(cio); - fclose(f); + opj_stream_destroy(l_stream); + fclose(fout); fprintf(stderr, "failed to encode image\n"); return 1; } fprintf(stderr,"Generated outfile %s\n",parameters.outfile); /* close and free the byte stream */ - opj_stream_destroy(cio); - fclose(f); + opj_stream_destroy(l_stream); + fclose(fout); /* free remaining compression structures */ - opj_destroy_codec(cinfo); + opj_destroy_codec(l_codec); /* free image data */ opj_image_destroy(image); diff --git a/applications/codec/j2k_dump.c b/applications/codec/j2k_dump.c index 0ac05499..c41becd3 100644 --- a/applications/codec/j2k_dump.c +++ b/applications/codec/j2k_dump.c @@ -369,6 +369,30 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i return 0; } +/* -------------------------------------------------------------------------- */ + +/** +sample error debug callback expecting no client object +*/ +void error_callback(const char *msg, void *client_data) { + (void)client_data; + fprintf(stdout, "[ERROR] %s", msg); +} +/** +sample warning debug callback expecting no client object +*/ +void warning_callback(const char *msg, void *client_data) { + (void)client_data; + fprintf(stdout, "[WARNING] %s", msg); +} +/** +sample debug callback expecting no client object +*/ +void info_callback(const char *msg, void *client_data) { + (void)client_data; + fprintf(stdout, "[INFO] %s", msg); +} + /* -------------------------------------------------------------------------- */ /** * J2K_DUMP MAIN @@ -379,10 +403,9 @@ int main(int argc, char *argv[]) FILE *fsrc = NULL, *fout = NULL; opj_dparameters_t parameters; /* Decompression parameters */ - opj_event_mgr_t event_mgr; /* Event manager */ opj_image_t* image = NULL; /* Image structure */ - opj_codec_t* dinfo = NULL; /* Handle to a decompressor */ - opj_stream_t *cio = NULL; /* Stream */ + opj_codec_t* l_codec = NULL; /* Handle to a decompressor */ + opj_stream_t *l_stream = NULL; /* Stream */ opj_codestream_info_v2_t* cstr_info = NULL; opj_codestream_index_t* cstr_index = NULL; @@ -407,9 +430,6 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; } - /* Set default event mgr */ - opj_initialize_default_event_handler(&event_mgr, parameters.m_verbose); - /* Initialize reading of directory */ if(img_fol.set_imgdir==1){ int it_image; @@ -471,8 +491,8 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; } - cio = opj_stream_create_default_file_stream(fsrc,1); - if (!cio){ + l_stream = opj_stream_create_default_file_stream(fsrc,1); + if (!l_stream){ fclose(fsrc); fprintf(stderr, "ERROR -> failed to create the stream from the file\n"); return EXIT_FAILURE; @@ -485,61 +505,66 @@ int main(int argc, char *argv[]) case J2K_CFMT: /* JPEG-2000 codestream */ { /* Get a decoder handle */ - dinfo = opj_create_decompress_v2(CODEC_J2K); + l_codec = opj_create_decompress_v2(CODEC_J2K); break; } case JP2_CFMT: /* JPEG 2000 compressed image data */ { /* Get a decoder handle */ - dinfo = opj_create_decompress_v2(CODEC_JP2); + l_codec = opj_create_decompress_v2(CODEC_JP2); break; } case JPT_CFMT: /* JPEG 2000, JPIP */ { /* Get a decoder handle */ - dinfo = opj_create_decompress_v2(CODEC_JPT); + l_codec = opj_create_decompress_v2(CODEC_JPT); break; } default: fprintf(stderr, "skipping file..\n"); - opj_stream_destroy(cio); + opj_stream_destroy(l_stream); continue; } + /* catch events using our callbacks and give a local context */ + opj_set_info_handler(l_codec, info_callback,00); + opj_set_warning_handler(l_codec, warning_callback,00); + opj_set_error_handler(l_codec, error_callback,00); + /* Setup the decoder decoding parameters using user parameters */ - if ( !opj_setup_decoder_v2(dinfo, ¶meters, &event_mgr) ){ + if ( !opj_setup_decoder_v2(l_codec, ¶meters) ){ fprintf(stderr, "ERROR -> j2k_dump: failed to setup the decoder\n"); - opj_stream_destroy(cio); + opj_stream_destroy(l_stream); fclose(fsrc); - opj_destroy_codec(dinfo); + opj_destroy_codec(l_codec); fclose(fout); return EXIT_FAILURE; } /* Read the main header of the codestream and if necessary the JP2 boxes*/ - if(! opj_read_header(cio, dinfo, &image)){ + if(! opj_read_header(l_stream, l_codec, &image)){ fprintf(stderr, "ERROR -> j2k_dump: failed to read the header\n"); - opj_stream_destroy(cio); + opj_stream_destroy(l_stream); fclose(fsrc); - opj_destroy_codec(dinfo); + opj_destroy_codec(l_codec); opj_image_destroy(image); fclose(fout); return EXIT_FAILURE; } - opj_dump_codec(dinfo, OPJ_IMG_INFO | OPJ_J2K_MH_INFO | OPJ_J2K_MH_IND, fout ); + opj_dump_codec(l_codec, OPJ_IMG_INFO | OPJ_J2K_MH_INFO | OPJ_J2K_MH_IND, fout ); - cstr_info = opj_get_cstr_info(dinfo); + cstr_info = opj_get_cstr_info(l_codec); - cstr_index = opj_get_cstr_index(dinfo); + cstr_index = opj_get_cstr_index(l_codec); /* close the byte stream */ - opj_stream_destroy(cio); + opj_stream_destroy(l_stream); fclose(fsrc); /* free remaining structures */ - if (dinfo) { - opj_destroy_codec(dinfo); + if (l_codec) { + opj_destroy_codec(l_codec); } /* destroy the image header */ diff --git a/applications/codec/j2k_to_image.c b/applications/codec/j2k_to_image.c index 30d80862..762763ab 100644 --- a/applications/codec/j2k_to_image.c +++ b/applications/codec/j2k_to_image.c @@ -667,10 +667,9 @@ int main(int argc, char **argv) FILE *fsrc = NULL; opj_dparameters_t parameters; /* decompression parameters */ - opj_event_mgr_t event_mgr; /* event manager */ opj_image_t* image = NULL; - opj_stream_t *cio = NULL; /* Stream */ - opj_codec_t* dinfo = NULL; /* Handle to a decompressor */ + opj_stream_t *l_stream = NULL; /* Stream */ + opj_codec_t* l_codec = NULL; /* Handle to a decompressor */ opj_codestream_index_t* cstr_index = NULL; char indexfilename[OPJ_PATH_LEN]; /* index file name */ @@ -679,12 +678,6 @@ int main(int argc, char **argv) img_fol_t img_fol; dircnt_t *dirptr = NULL; - /* configure the event callbacks (not required) */ - memset(&event_mgr, 0, sizeof(opj_event_mgr_t)); - event_mgr.error_handler = error_callback; - event_mgr.warning_handler = warning_callback; - event_mgr.info_handler = info_callback; - /* set decoding parameters to default values */ opj_set_default_decoder_parameters(¶meters); @@ -699,9 +692,6 @@ int main(int argc, char **argv) return EXIT_FAILURE; } - /* Set default event mgr */ - opj_initialize_default_event_handler(&event_mgr, 1); - /* Initialize reading of directory */ if(img_fol.set_imgdir==1){ int it_image; @@ -750,8 +740,8 @@ int main(int argc, char **argv) return EXIT_FAILURE; } - cio = opj_stream_create_default_file_stream(fsrc,1); - if (!cio){ + l_stream = opj_stream_create_default_file_stream(fsrc,1); + if (!l_stream){ fclose(fsrc); fprintf(stderr, "ERROR -> failed to create the stream from the file\n"); return EXIT_FAILURE; @@ -764,64 +754,69 @@ int main(int argc, char **argv) case J2K_CFMT: /* JPEG-2000 codestream */ { /* Get a decoder handle */ - dinfo = opj_create_decompress_v2(CODEC_J2K); + l_codec = opj_create_decompress_v2(CODEC_J2K); break; } case JP2_CFMT: /* JPEG 2000 compressed image data */ { /* Get a decoder handle */ - dinfo = opj_create_decompress_v2(CODEC_JP2); + l_codec = opj_create_decompress_v2(CODEC_JP2); break; } case JPT_CFMT: /* JPEG 2000, JPIP */ { /* Get a decoder handle */ - dinfo = opj_create_decompress_v2(CODEC_JPT); + l_codec = opj_create_decompress_v2(CODEC_JPT); break; } default: fprintf(stderr, "skipping file..\n"); - opj_stream_destroy(cio); + opj_stream_destroy(l_stream); continue; } + /* catch events using our callbacks and give a local context */ + opj_set_info_handler(l_codec, info_callback,00); + opj_set_warning_handler(l_codec, warning_callback,00); + opj_set_error_handler(l_codec, error_callback,00); + /* Setup the decoder decoding parameters using user parameters */ - if ( !opj_setup_decoder_v2(dinfo, ¶meters, &event_mgr) ){ + if ( !opj_setup_decoder_v2(l_codec, ¶meters) ){ fprintf(stderr, "ERROR -> j2k_dump: failed to setup the decoder\n"); - opj_stream_destroy(cio); + opj_stream_destroy(l_stream); fclose(fsrc); - opj_destroy_codec(dinfo); + opj_destroy_codec(l_codec); return EXIT_FAILURE; } /* Read the main header of the codestream and if necessary the JP2 boxes*/ - if(! opj_read_header(cio, dinfo, &image)){ + if(! opj_read_header(l_stream, l_codec, &image)){ fprintf(stderr, "ERROR -> j2k_to_image: failed to read the header\n"); - opj_stream_destroy(cio); + opj_stream_destroy(l_stream); fclose(fsrc); - opj_destroy_codec(dinfo); + opj_destroy_codec(l_codec); opj_image_destroy(image); return EXIT_FAILURE; } if (!parameters.nb_tile_to_decode) { // Optional if you want decode the entire image - if (!opj_set_decode_area(dinfo, image, parameters.DA_x0, + if (!opj_set_decode_area(l_codec, image, parameters.DA_x0, parameters.DA_y0, parameters.DA_x1, parameters.DA_y1)){ fprintf(stderr, "ERROR -> j2k_to_image: failed to set the decoded area\n"); - opj_stream_destroy(cio); - opj_destroy_codec(dinfo); + opj_stream_destroy(l_stream); + opj_destroy_codec(l_codec); opj_image_destroy(image); fclose(fsrc); return EXIT_FAILURE; } /* Get the decoded image */ - if (!(opj_decode_v2(dinfo, cio, image) && opj_end_decompress(dinfo, cio))) { + if (!(opj_decode_v2(l_codec, l_stream, image) && opj_end_decompress(l_codec, l_stream))) { fprintf(stderr,"ERROR -> j2k_to_image: failed to decode image!\n"); - opj_destroy_codec(dinfo); - opj_stream_destroy(cio); + opj_destroy_codec(l_codec); + opj_stream_destroy(l_stream); opj_image_destroy(image); fclose(fsrc); return EXIT_FAILURE; @@ -830,19 +825,19 @@ int main(int argc, char **argv) else { // It is just here to illustrate how to use the resolution after set parameters - /*if (!opj_set_decoded_resolution_factor(dinfo, 5)) { + /*if (!opj_set_decoded_resolution_factor(l_codec, 5)) { fprintf(stderr, "ERROR -> j2k_to_image: failed to set the resolution factor tile!\n"); - opj_destroy_codec(dinfo); - opj_stream_destroy(cio); + opj_destroy_codec(l_codec); + opj_stream_destroy(l_stream); opj_image_destroy(image); fclose(fsrc); return EXIT_FAILURE; }*/ - if (!opj_get_decoded_tile(dinfo, cio, image, parameters.tile_index)) { + if (!opj_get_decoded_tile(l_codec, l_stream, image, parameters.tile_index)) { fprintf(stderr, "ERROR -> j2k_to_image: failed to decode tile!\n"); - opj_destroy_codec(dinfo); - opj_stream_destroy(cio); + opj_destroy_codec(l_codec); + opj_stream_destroy(l_stream); opj_image_destroy(image); fclose(fsrc); return EXIT_FAILURE; @@ -851,7 +846,7 @@ int main(int argc, char **argv) } /* Close the byte stream */ - opj_stream_destroy(cio); + opj_stream_destroy(l_stream); fclose(fsrc); if(image->color_space == CLRSPC_SYCC){ @@ -940,8 +935,8 @@ int main(int argc, char **argv) } /* free remaining structures */ - if (dinfo) { - opj_destroy_codec(dinfo); + if (l_codec) { + opj_destroy_codec(l_codec); } diff --git a/libopenjpeg/event.c b/libopenjpeg/event.c index 2a700655..80d42d8f 100644 --- a/libopenjpeg/event.c +++ b/libopenjpeg/event.c @@ -122,32 +122,36 @@ opj_bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, .. } /* ----------------------------------------------------------------------- */ -opj_bool opj_event_msg_v2(opj_event_mgr_t* event_mgr, int event_type, const char *fmt, ...) { +opj_bool opj_event_msg_v2(opj_event_mgr_t* p_event_mgr, 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; + opj_msg_callback msg_handler = 00; + void * l_data = 00; - if(event_mgr != NULL) { + if(p_event_mgr != 00) { switch(event_type) { case EVT_ERROR: - msg_handler = event_mgr->error_handler; + msg_handler = p_event_mgr->error_handler; + l_data = p_event_mgr->m_error_data; break; case EVT_WARNING: - msg_handler = event_mgr->warning_handler; + msg_handler = p_event_mgr->warning_handler; + l_data = p_event_mgr->m_warning_data; break; case EVT_INFO: - msg_handler = event_mgr->info_handler; + msg_handler = p_event_mgr->info_handler; + l_data = p_event_mgr->m_info_data; break; default: break; } - if(msg_handler == NULL) { + if(msg_handler == 00) { return OPJ_FALSE; } } else { return OPJ_FALSE; } - if ((fmt != NULL) && (event_mgr != NULL)) { + if ((fmt != 00) && (p_event_mgr != 00)) { va_list arg; int str_length/*, i, j*/; /* UniPG */ char message[MSG_SIZE]; @@ -162,72 +166,8 @@ opj_bool opj_event_msg_v2(opj_event_mgr_t* event_mgr, int event_type, const char va_end(arg); /* output the message to the user program */ - msg_handler(message, event_mgr->client_data); + msg_handler(message, l_data); } return OPJ_TRUE; } - -/* ----------------------------------------------------------------------- */ -void OPJ_CALLCONV opj_initialize_default_event_handler(opj_event_mgr_t * p_event, opj_bool verbose) -{ - if (! p_event){ - fprintf(stderr, "[ERROR] Event structure provided to the opj_set_default_event_handler is equal to null pointer.\n"); - return; - } - - p_event->client_data = NULL; - p_event->error_handler = opj_error_default_callback; - - if (verbose) { - p_event->info_handler = opj_info_default_callback; - p_event->warning_handler = opj_warning_default_callback; - } - else { - /* FIXME (MSD) This message should be remove when the documentation will be updated */ - fprintf(stdout, "[INFO] Verbose mode = OFF => no other info/warning output.\n"); - p_event->info_handler = opj_default_callback ; - p_event->warning_handler = opj_default_callback ; - } -} - -/* ---------------------------------------------------------------------- */ -/* Default callback functions */ - -/** - * Default callback function. - * Do nothing. - */ -void opj_default_callback (const char *msg, void *client_data) -{ -} - -/** - * Default info callback function. - * Output = stdout. - */ -void opj_info_default_callback (const char *msg, void *client_data) -{ - (void)client_data; - fprintf(stdout, "[INFO] %s", msg); -} - -/** - * Default warning callback function. - * Output = stderr. - */ -void opj_warning_default_callback (const char *msg, void *client_data) -{ - (void)client_data; - fprintf(stderr, "[WARNING] %s", msg); -} - -/** - * Default error callback function. - * Output = stderr. - */ -void opj_error_default_callback (const char *msg, void *client_data) -{ - (void)client_data; - fprintf(stderr, "[ERROR] %s", msg); -} diff --git a/libopenjpeg/event.h b/libopenjpeg/event.h index e8e0a751..1b80fcb4 100644 --- a/libopenjpeg/event.h +++ b/libopenjpeg/event.h @@ -31,6 +31,30 @@ The functions in EVENT.C have for goal to send output messages (errors, warnings, debug) to the user. */ +/** +Message handler object +used for + +*/ +//typedef struct opj_event_mgr +//{ +// /** Data to call the event manager upon */ +// void * m_error_data; +// /** Data to call the event manager upon */ +// void * m_warning_data; +// /** Data to call the event manager upon */ +// void * m_info_data; +// /** Error message callback if available, NULL otherwise */ +// opj_msg_callback error_handler; +// /** Warning message callback if available, NULL otherwise */ +// opj_msg_callback warning_handler; +// /** Debug message callback if available, NULL otherwise */ +// opj_msg_callback info_handler; +//} opj_event_mgr_t; #define EVT_ERROR 1 /**< Error event type */ #define EVT_WARNING 2 /**< Warning event type */ @@ -53,7 +77,6 @@ Write formatted data to a string and send the string to a user callback. opj_bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...); /* ----------------------------------------------------------------------- */ -/*@}*/ /** * Write formatted data to a string and send the string to a user callback. @@ -65,27 +88,8 @@ opj_bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, .. * @return Returns true if successful, returns false otherwise */ opj_bool opj_event_msg_v2(opj_event_mgr_t* event_mgr, int event_type, const char *fmt, ...); - -/** - * Default callback function. No message sent to output. - */ -void opj_default_callback (const char *msg, void *client_data); - -/** - * Default info callback function, message is sent to the stdout output. - */ -void opj_info_default_callback (const char *msg, void *client_data); - -/** - * Default warning callback function, message is sent to stderr output. - */ -void opj_warning_default_callback (const char *msg, void *client_data); - -/** - * Default error callback function, message is sent to stderr output. - */ -void opj_error_default_callback (const char *msg, void *client_data); - +/* ----------------------------------------------------------------------- */ +/*@}*/ /*@}*/ diff --git a/libopenjpeg/openjpeg.c b/libopenjpeg/openjpeg.c index a4c5cb99..36964492 100644 --- a/libopenjpeg/openjpeg.c +++ b/libopenjpeg/openjpeg.c @@ -138,7 +138,7 @@ typedef struct opj_codec_private /** FIXME DOC*/ void * m_codec; /** Event handler */ - opj_event_mgr_t* m_event_mgr; + opj_event_mgr_t m_event_mgr; /** Flag to indicate if the codec is used to decode or encode*/ opj_bool is_decompressor; void (*opj_dump_codec) (void * p_codec, OPJ_INT32 info_flag, FILE* output_stream); @@ -147,7 +147,69 @@ typedef struct opj_codec_private } opj_codec_private_t; +/* ---------------------------------------------------------------------- */ +/** + * Default callback function. + * Do nothing. + */ +void opj_default_callback (const char *msg, void *client_data) +{ +} +void set_default_event_handler(opj_event_mgr_t * p_manager) +{ + p_manager->m_error_data = 00; + p_manager->m_warning_data = 00; + p_manager->m_info_data = 00; + p_manager->error_handler = opj_default_callback; + p_manager->info_handler = opj_default_callback; + p_manager->warning_handler = opj_default_callback; +} + +opj_bool OPJ_CALLCONV opj_set_info_handler( opj_codec_t * p_codec, + opj_msg_callback p_callback, + void * p_user_data) +{ + opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec; + if(! l_codec){ + return OPJ_FALSE; + } + + l_codec->m_event_mgr.info_handler = p_callback; + l_codec->m_event_mgr.m_info_data = p_user_data; + + return OPJ_TRUE; +} + +opj_bool OPJ_CALLCONV opj_set_warning_handler( opj_codec_t * p_codec, + opj_msg_callback p_callback, + void * p_user_data) +{ + opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec; + if (! l_codec) { + return OPJ_FALSE; + } + + l_codec->m_event_mgr.warning_handler = p_callback; + l_codec->m_event_mgr.m_warning_data = p_user_data; + + return OPJ_TRUE; +} + +opj_bool OPJ_CALLCONV opj_set_error_handler(opj_codec_t * p_codec, + opj_msg_callback p_callback, + void * p_user_data) +{ + opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec; + if (! l_codec) { + return OPJ_FALSE; + } + + l_codec->m_event_mgr.error_handler = p_callback; + l_codec->m_event_mgr.m_error_data = p_user_data; + + return OPJ_TRUE; +} /* ---------------------------------------------------------------------- */ @@ -260,47 +322,47 @@ opj_dinfo_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT format) { opj_codec_t* OPJ_CALLCONV opj_create_decompress_v2(OPJ_CODEC_FORMAT p_format) { - opj_codec_private_t *l_info = 00; + opj_codec_private_t *l_codec = 00; - l_info = (opj_codec_private_t*) opj_calloc(1, sizeof(opj_codec_private_t)); - if (!l_info){ + l_codec = (opj_codec_private_t*) opj_calloc(1, sizeof(opj_codec_private_t)); + if (!l_codec){ return 00; } - memset(l_info, 0, sizeof(opj_codec_private_t)); + memset(l_codec, 0, sizeof(opj_codec_private_t)); - l_info->is_decompressor = 1; + l_codec->is_decompressor = 1; switch (p_format) { case CODEC_J2K: - l_info->opj_dump_codec = (void (*) (void*, OPJ_INT32, FILE*)) j2k_dump; + l_codec->opj_dump_codec = (void (*) (void*, OPJ_INT32, FILE*)) j2k_dump; - l_info->opj_get_codec_info = (opj_codestream_info_v2_t* (*) (void*) ) j2k_get_cstr_info; + l_codec->opj_get_codec_info = (opj_codestream_info_v2_t* (*) (void*) ) j2k_get_cstr_info; - l_info->opj_get_codec_index = (opj_codestream_index_t* (*) (void*) ) j2k_get_cstr_index; + l_codec->opj_get_codec_index = (opj_codestream_index_t* (*) (void*) ) j2k_get_cstr_index; - l_info->m_codec_data.m_decompression.opj_decode = + l_codec->m_codec_data.m_decompression.opj_decode = (opj_bool (*) ( void *, struct opj_stream_private *, opj_image_t*, struct opj_event_mgr * )) j2k_decode_v2; - l_info->m_codec_data.m_decompression.opj_end_decompress = + l_codec->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 = + l_codec->m_codec_data.m_decompression.opj_read_header = (opj_bool (*) ( struct opj_stream_private *, void *, opj_image_t **, struct opj_event_mgr * )) j2k_read_header; - l_info->m_codec_data.m_decompression.opj_destroy = + l_codec->m_codec_data.m_decompression.opj_destroy = (void (*) (void *))j2k_destroy; - l_info->m_codec_data.m_decompression.opj_setup_decoder = + l_codec->m_codec_data.m_decompression.opj_setup_decoder = (void (*) (void * , opj_dparameters_t * )) j2k_setup_decoder_v2; - l_info->m_codec_data.m_decompression.opj_read_tile_header = + l_codec->m_codec_data.m_decompression.opj_read_tile_header = (opj_bool (*) ( void *, OPJ_UINT32*, OPJ_UINT32*, @@ -311,26 +373,26 @@ opj_codec_t* OPJ_CALLCONV opj_create_decompress_v2(OPJ_CODEC_FORMAT p_format) struct opj_stream_private *, struct opj_event_mgr * )) j2k_read_tile_header; - l_info->m_codec_data.m_decompression.opj_decode_tile_data = + l_codec->m_codec_data.m_decompression.opj_decode_tile_data = (opj_bool (*) (void *, OPJ_UINT32, OPJ_BYTE*, OPJ_UINT32, struct opj_stream_private *, struct opj_event_mgr *)) j2k_decode_tile; - l_info->m_codec_data.m_decompression.opj_set_decode_area = + l_codec->m_codec_data.m_decompression.opj_set_decode_area = (opj_bool (*) (void *, opj_image_t*, OPJ_INT32, OPJ_INT32, OPJ_INT32, OPJ_INT32, struct opj_event_mgr *)) j2k_set_decode_area; - l_info->m_codec_data.m_decompression.opj_get_decoded_tile = (opj_bool (*) ( void *p_codec, + l_codec->m_codec_data.m_decompression.opj_get_decoded_tile = (opj_bool (*) (void *p_codec, opj_stream_private_t *p_cio, opj_image_t *p_image, struct opj_event_mgr * p_manager, OPJ_UINT32 tile_index)) j2k_get_tile; - l_info->m_codec_data.m_decompression.opj_set_decoded_resolution_factor = (opj_bool (*) (void * p_codec, + l_codec->m_codec_data.m_decompression.opj_set_decoded_resolution_factor = (opj_bool (*) (void * p_codec, OPJ_UINT32 res_factor, struct opj_event_mgr * p_manager)) j2k_set_decoded_resolution_factor; - l_info->m_codec = j2k_create_decompress_v2(); + l_codec->m_codec = j2k_create_decompress_v2(); - if (! l_info->m_codec) { - opj_free(l_info); + if (! l_codec->m_codec) { + opj_free(l_codec); return NULL; } @@ -338,27 +400,27 @@ opj_codec_t* OPJ_CALLCONV opj_create_decompress_v2(OPJ_CODEC_FORMAT p_format) case CODEC_JP2: /* get a JP2 decoder handle */ - l_info->opj_dump_codec = (void (*) (void*, OPJ_INT32, FILE*)) jp2_dump; + l_codec->opj_dump_codec = (void (*) (void*, OPJ_INT32, FILE*)) jp2_dump; - l_info->opj_get_codec_info = (opj_codestream_info_v2_t* (*) (void*) ) jp2_get_cstr_info; + l_codec->opj_get_codec_info = (opj_codestream_info_v2_t* (*) (void*) ) jp2_get_cstr_info; - l_info->opj_get_codec_index = (opj_codestream_index_t* (*) (void*) ) jp2_get_cstr_index; + l_codec->opj_get_codec_index = (opj_codestream_index_t* (*) (void*) ) jp2_get_cstr_index; - l_info->m_codec_data.m_decompression.opj_decode = + l_codec->m_codec_data.m_decompression.opj_decode = (opj_bool (*) ( void *, struct opj_stream_private *, opj_image_t*, struct opj_event_mgr * )) jp2_decode_v2; - l_info->m_codec_data.m_decompression.opj_end_decompress = (opj_bool (*) (void *,struct opj_stream_private *,struct opj_event_mgr *)) jp2_end_decompress; + l_codec->m_codec_data.m_decompression.opj_end_decompress = (opj_bool (*) (void *,struct opj_stream_private *,struct opj_event_mgr *)) jp2_end_decompress; - l_info->m_codec_data.m_decompression.opj_read_header = (opj_bool (*) ( + l_codec->m_codec_data.m_decompression.opj_read_header = (opj_bool (*) ( struct opj_stream_private *, void *, opj_image_t **, struct opj_event_mgr * )) jp2_read_header; - l_info->m_codec_data.m_decompression.opj_read_tile_header = ( opj_bool (*) ( + l_codec->m_codec_data.m_decompression.opj_read_tile_header = ( opj_bool (*) ( void *, OPJ_UINT32*, OPJ_UINT32*, @@ -371,28 +433,28 @@ opj_codec_t* OPJ_CALLCONV opj_create_decompress_v2(OPJ_CODEC_FORMAT p_format) struct opj_stream_private *, struct opj_event_mgr * )) jp2_read_tile_header; - l_info->m_codec_data.m_decompression.opj_decode_tile_data = (opj_bool (*) (void *,OPJ_UINT32,OPJ_BYTE*,OPJ_UINT32,struct opj_stream_private *, struct opj_event_mgr * )) jp2_decode_tile; + l_codec->m_codec_data.m_decompression.opj_decode_tile_data = (opj_bool (*) (void *,OPJ_UINT32,OPJ_BYTE*,OPJ_UINT32,struct opj_stream_private *, struct opj_event_mgr * )) jp2_decode_tile; - l_info->m_codec_data.m_decompression.opj_destroy = (void (*) (void *))jp2_destroy; + l_codec->m_codec_data.m_decompression.opj_destroy = (void (*) (void *))jp2_destroy; - l_info->m_codec_data.m_decompression.opj_setup_decoder = (void (*) (void * ,opj_dparameters_t * )) jp2_setup_decoder_v2; + l_codec->m_codec_data.m_decompression.opj_setup_decoder = (void (*) (void * ,opj_dparameters_t * )) jp2_setup_decoder_v2; - l_info->m_codec_data.m_decompression.opj_set_decode_area = (opj_bool (*) (void *,opj_image_t*, OPJ_INT32,OPJ_INT32,OPJ_INT32,OPJ_INT32, struct opj_event_mgr * )) jp2_set_decode_area; + l_codec->m_codec_data.m_decompression.opj_set_decode_area = (opj_bool (*) (void *,opj_image_t*, OPJ_INT32,OPJ_INT32,OPJ_INT32,OPJ_INT32, struct opj_event_mgr * )) jp2_set_decode_area; - l_info->m_codec_data.m_decompression.opj_get_decoded_tile = (opj_bool (*) ( void *p_codec, + l_codec->m_codec_data.m_decompression.opj_get_decoded_tile = (opj_bool (*) (void *p_codec, opj_stream_private_t *p_cio, opj_image_t *p_image, struct opj_event_mgr * p_manager, OPJ_UINT32 tile_index)) jp2_get_tile; - l_info->m_codec_data.m_decompression.opj_set_decoded_resolution_factor = (opj_bool (*) (void * p_codec, + l_codec->m_codec_data.m_decompression.opj_set_decoded_resolution_factor = (opj_bool (*) (void * p_codec, OPJ_UINT32 res_factor, opj_event_mgr_t * p_manager)) jp2_set_decoded_resolution_factor; - l_info->m_codec = jp2_create(OPJ_TRUE); + l_codec->m_codec = jp2_create(OPJ_TRUE); - if (! l_info->m_codec) { - opj_free(l_info); + if (! l_codec->m_codec) { + opj_free(l_codec); return 00; } @@ -400,11 +462,12 @@ opj_codec_t* OPJ_CALLCONV opj_create_decompress_v2(OPJ_CODEC_FORMAT p_format) case CODEC_UNKNOWN: case CODEC_JPT: default: - opj_free(l_info); + opj_free(l_codec); return 00; } - return (opj_codec_t*) l_info; + set_default_event_handler(&(l_codec->m_event_mgr)); + return (opj_codec_t*) l_codec; } /* DEPRECATED */ @@ -467,30 +530,23 @@ void OPJ_CALLCONV opj_setup_decoder(opj_dinfo_t *dinfo, opj_dparameters_t *param } } -opj_bool OPJ_CALLCONV opj_setup_decoder_v2(opj_codec_t *p_info, opj_dparameters_t *parameters, opj_event_mgr_t* event_mgr) +opj_bool OPJ_CALLCONV opj_setup_decoder_v2( opj_codec_t *p_codec, + opj_dparameters_t *parameters + ) { - opj_codec_private_t * l_info = (opj_codec_private_t *) p_info; + if (p_codec && parameters) { + opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec; - if ( !p_info || !parameters || !event_mgr ){ - fprintf(stderr, "[ERROR] Input parameters of the setup_decoder function are incorrect.\n"); - return OPJ_FALSE; + if (! l_codec->is_decompressor) { + opj_event_msg_v2(&(l_codec->m_event_mgr), EVT_ERROR, "Codec provided to the opj_setup_decoder function is not a decompressor handler.\n"); + return OPJ_FALSE; + } + + l_codec->m_codec_data.m_decompression.opj_setup_decoder(l_codec->m_codec, + parameters); + return OPJ_TRUE; } - - if ( !event_mgr->error_handler || !event_mgr->warning_handler || !event_mgr->error_handler){ - fprintf(stderr, "[ERROR] Event handler provided to the setup_decoder function is not valid.\n"); - return OPJ_FALSE; - } - - if (! l_info->is_decompressor) { - opj_event_msg_v2(event_mgr, EVT_ERROR, "Codec provided to the setup_decoder function is not a decompressor handler.\n"); - return OPJ_FALSE; - } - - l_info->m_codec_data.m_decompression.opj_setup_decoder(l_info->m_codec, parameters); - - l_info->m_event_mgr = event_mgr; - - return OPJ_TRUE; + return OPJ_FALSE; } /* DEPRECATED */ @@ -516,6 +572,7 @@ opj_image_t* OPJ_CALLCONV opj_decode_with_info(opj_dinfo_t *dinfo, opj_cio_t *ci return NULL; } +/* DEPRECATED */ 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; @@ -552,48 +609,48 @@ opj_cinfo_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format) { opj_codec_t* OPJ_CALLCONV opj_create_compress_v2(OPJ_CODEC_FORMAT p_format) { - opj_codec_private_t *l_info = 00; + opj_codec_private_t *l_codec = 00; - l_info = (opj_codec_private_t*)opj_calloc(1, sizeof(opj_codec_private_t)); - if (!l_info) { + l_codec = (opj_codec_private_t*)opj_calloc(1, sizeof(opj_codec_private_t)); + if (!l_codec) { return 00; } - - memset(l_info, 0, sizeof(opj_codec_private_t)); - l_info->is_decompressor = 0; + memset(l_codec, 0, sizeof(opj_codec_private_t)); + + l_codec->is_decompressor = 0; switch(p_format) { case CODEC_J2K: - l_info->m_codec_data.m_compression.opj_encode = (opj_bool (*) ( void *, + l_codec->m_codec_data.m_compression.opj_encode = (opj_bool (*) (void *, struct opj_stream_private *, struct opj_event_mgr * )) j2k_encode_v2; - l_info->m_codec_data.m_compression.opj_end_compress = (opj_bool (*) ( void *, + l_codec->m_codec_data.m_compression.opj_end_compress = (opj_bool (*) ( void *, struct opj_stream_private *, struct opj_event_mgr *)) j2k_end_compress; - l_info->m_codec_data.m_compression.opj_start_compress = (opj_bool (*) ( void *, + l_codec->m_codec_data.m_compression.opj_start_compress = (opj_bool (*) (void *, struct opj_stream_private *, struct opj_image * , struct opj_event_mgr *)) j2k_start_compress; - l_info->m_codec_data.m_compression.opj_write_tile = (opj_bool (*) ( void *, + l_codec->m_codec_data.m_compression.opj_write_tile = (opj_bool (*) (void *, OPJ_UINT32, OPJ_BYTE*, OPJ_UINT32, struct opj_stream_private *, struct opj_event_mgr *) ) j2k_write_tile; - l_info->m_codec_data.m_compression.opj_destroy = (void (*) (void *)) j2k_destroy; + l_codec->m_codec_data.m_compression.opj_destroy = (void (*) (void *)) j2k_destroy; - l_info->m_codec_data.m_compression.opj_setup_encoder = (void (*) ( void *, + l_codec->m_codec_data.m_compression.opj_setup_encoder = (void (*) ( void *, opj_cparameters_t *, struct opj_image *, struct opj_event_mgr * )) j2k_setup_encoder_v2; - l_info->m_codec = j2k_create_compress_v2(); - if (! l_info->m_codec) { - opj_free(l_info); + l_codec->m_codec = j2k_create_compress_v2(); + if (! l_codec->m_codec) { + opj_free(l_codec); return 00; } @@ -601,36 +658,36 @@ opj_codec_t* OPJ_CALLCONV opj_create_compress_v2(OPJ_CODEC_FORMAT p_format) case CODEC_JP2: /* get a JP2 decoder handle */ - l_info->m_codec_data.m_compression.opj_encode = (opj_bool (*) ( void *, + l_codec->m_codec_data.m_compression.opj_encode = (opj_bool (*) (void *, struct opj_stream_private *, struct opj_event_mgr * )) opj_jp2_encode; - l_info->m_codec_data.m_compression.opj_end_compress = (opj_bool (*) ( void *, + l_codec->m_codec_data.m_compression.opj_end_compress = (opj_bool (*) ( void *, struct opj_stream_private *, struct opj_event_mgr *)) jp2_end_compress; - l_info->m_codec_data.m_compression.opj_start_compress = (opj_bool (*) ( void *, + l_codec->m_codec_data.m_compression.opj_start_compress = (opj_bool (*) (void *, struct opj_stream_private *, struct opj_image * , struct opj_event_mgr *)) jp2_start_compress; - l_info->m_codec_data.m_compression.opj_write_tile = (opj_bool (*) ( void *, + l_codec->m_codec_data.m_compression.opj_write_tile = (opj_bool (*) (void *, OPJ_UINT32, OPJ_BYTE*, OPJ_UINT32, struct opj_stream_private *, struct opj_event_mgr *)) jp2_write_tile; - l_info->m_codec_data.m_compression.opj_destroy = (void (*) (void *)) jp2_destroy; + l_codec->m_codec_data.m_compression.opj_destroy = (void (*) (void *)) jp2_destroy; - l_info->m_codec_data.m_compression.opj_setup_encoder = (void (*) ( void *, + l_codec->m_codec_data.m_compression.opj_setup_encoder = (void (*) ( void *, opj_cparameters_t *, struct opj_image *, struct opj_event_mgr * )) jp2_setup_encoder; - l_info->m_codec = jp2_create(OPJ_FALSE); - if (! l_info->m_codec) { - opj_free(l_info); + l_codec->m_codec = jp2_create(OPJ_FALSE); + if (! l_codec->m_codec) { + opj_free(l_codec); return 00; } @@ -639,15 +696,15 @@ opj_codec_t* OPJ_CALLCONV opj_create_compress_v2(OPJ_CODEC_FORMAT p_format) case CODEC_UNKNOWN: case CODEC_JPT: default: - opj_free(l_info); + opj_free(l_codec); return 00; } - /*set_default_event_handler(&(l_info->m_event_mgr));*/ - return (opj_codec_t*) l_info; + set_default_event_handler(&(l_codec->m_event_mgr)); + return (opj_codec_t*) l_codec; } - +/* DEPRECATED */ void OPJ_CALLCONV opj_destroy_compress(opj_cinfo_t *cinfo) { if(cinfo) { /* destroy the codec */ @@ -737,7 +794,9 @@ opj_stream_t* OPJ_CALLCONV opj_stream_create_default_file_stream (FILE * p_file, return opj_stream_create_file_stream(p_file,J2K_STREAM_CHUNK_SIZE,p_is_read_stream); } -opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream (FILE * p_file, OPJ_SIZE_T p_size, opj_bool p_is_read_stream) +opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream ( FILE * p_file, + OPJ_SIZE_T p_size, + opj_bool p_is_read_stream) { opj_stream_t* l_stream = 00; @@ -759,7 +818,7 @@ opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream (FILE * p_file, OPJ_SIZ return l_stream; } - +/* DEPRECATED */ void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_image_t *image) { if(cinfo && parameters && image) { switch(cinfo->codec_format) { @@ -777,13 +836,18 @@ void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *param } } -opj_bool OPJ_CALLCONV opj_setup_encoder_v2(opj_codec_t *p_info, opj_cparameters_t *parameters, opj_image_t *image) +opj_bool OPJ_CALLCONV opj_setup_encoder_v2( opj_codec_t *p_codec, + opj_cparameters_t *parameters, + opj_image_t *p_image) { - if (p_info && parameters && image) { - opj_codec_private_t * l_codec = ((opj_codec_private_t *) p_info); + if (p_codec && parameters && p_image) { + opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec; if (! l_codec->is_decompressor) { - l_codec->m_codec_data.m_compression.opj_setup_encoder(l_codec->m_codec,parameters,image,l_codec->m_event_mgr); + l_codec->m_codec_data.m_compression.opj_setup_encoder( l_codec->m_codec, + parameters, + p_image, + &(l_codec->m_event_mgr) ); return OPJ_TRUE; } } @@ -793,28 +857,33 @@ opj_bool OPJ_CALLCONV opj_setup_encoder_v2(opj_codec_t *p_info, opj_cparameters_ opj_bool OPJ_CALLCONV opj_start_compress ( opj_codec_t *p_codec, opj_image_t * p_image, - opj_stream_t *p_cio) + opj_stream_t *p_stream) { - if (p_codec && p_cio) { + if (p_codec && p_stream) { opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec; - opj_stream_private_t * l_cio = (opj_stream_private_t *) p_cio; + opj_stream_private_t * l_stream = (opj_stream_private_t *) p_stream; if (! l_codec->is_decompressor) { - return l_codec->m_codec_data.m_compression.opj_start_compress(l_codec->m_codec,l_cio,p_image,l_codec->m_event_mgr); + return l_codec->m_codec_data.m_compression.opj_start_compress( l_codec->m_codec, + l_stream, + p_image, + &(l_codec->m_event_mgr)); } } return OPJ_FALSE; } -opj_bool OPJ_CALLCONV opj_encode_v2(opj_codec_t *p_info, opj_stream_t *cio) +opj_bool OPJ_CALLCONV opj_encode_v2(opj_codec_t *p_info, opj_stream_t *p_stream) { - if (p_info && cio) { + if (p_info && p_stream) { opj_codec_private_t * l_codec = (opj_codec_private_t *) p_info; - opj_stream_private_t * l_cio = (opj_stream_private_t *) cio; + opj_stream_private_t * l_stream = (opj_stream_private_t *) p_stream; if (! l_codec->is_decompressor) { - l_codec->m_codec_data.m_compression.opj_encode(l_codec->m_codec,l_cio,l_codec->m_event_mgr); + l_codec->m_codec_data.m_compression.opj_encode( l_codec->m_codec, + l_stream, + &(l_codec->m_event_mgr)); return OPJ_TRUE; } } @@ -823,20 +892,24 @@ opj_bool OPJ_CALLCONV opj_encode_v2(opj_codec_t *p_info, opj_stream_t *cio) } -opj_bool OPJ_CALLCONV opj_end_compress (opj_codec_t *p_codec,opj_stream_t *p_cio) +opj_bool OPJ_CALLCONV opj_end_compress (opj_codec_t *p_codec, + opj_stream_t *p_stream) { - if (p_codec && p_cio) { + if (p_codec && p_stream) { opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec; - opj_stream_private_t * l_cio = (opj_stream_private_t *) p_cio; + opj_stream_private_t * l_stream = (opj_stream_private_t *) p_stream; if (! l_codec->is_decompressor) { - return l_codec->m_codec_data.m_compression.opj_end_compress(l_codec->m_codec,l_cio,l_codec->m_event_mgr); + return l_codec->m_codec_data.m_compression.opj_end_compress(l_codec->m_codec, + l_stream, + &(l_codec->m_event_mgr)); } } return OPJ_FALSE; } +/* DEPRECATED */ 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" @@ -845,6 +918,7 @@ opj_bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t return opj_encode_with_info(cinfo, cio, image, NULL); } +/* DEPRECATED */ 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) { @@ -861,6 +935,7 @@ opj_bool OPJ_CALLCONV opj_encode_with_info(opj_cinfo_t *cinfo, opj_cio_t *cio, o return OPJ_FALSE; } +/* DEPRECATED */ void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_t *cstr_info) { if (cstr_info) { int tileno; @@ -878,45 +953,43 @@ void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_t *cstr_info) { } -opj_bool OPJ_CALLCONV opj_read_header ( opj_stream_t *p_cio, +opj_bool OPJ_CALLCONV opj_read_header ( opj_stream_t *p_stream, opj_codec_t *p_codec, opj_image_t **p_image ) { - 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 (p_codec && p_stream) { + opj_codec_private_t* l_codec = (opj_codec_private_t*) p_codec; + opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream; - if(! l_info->is_decompressor) { - opj_event_msg_v2(l_info->m_event_mgr, EVT_ERROR, "Codec provided to the read_header function is not a decompressor handler.\n"); + if(! l_codec->is_decompressor) { + opj_event_msg_v2(&(l_codec->m_event_mgr), EVT_ERROR, "Codec provided to the opj_read_header function is not a decompressor handler.\n"); return OPJ_FALSE; } - return l_info->m_codec_data.m_decompression.opj_read_header( - l_cio, - l_info->m_codec, - p_image, - l_info->m_event_mgr); + return l_codec->m_codec_data.m_decompression.opj_read_header( l_stream, + l_codec->m_codec, + p_image, + &(l_codec->m_event_mgr) ); } - fprintf(stderr, "[ERROR] Input parameters of the read_header function are incorrect.\n"); return OPJ_FALSE; } -void OPJ_CALLCONV opj_destroy_codec(opj_codec_t *p_info) +void OPJ_CALLCONV opj_destroy_codec(opj_codec_t *p_codec) { - if (p_info) { - opj_codec_private_t * l_info = (opj_codec_private_t *) p_info; + if (p_codec) { + opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec; - if (l_info->is_decompressor) { - l_info->m_codec_data.m_decompression.opj_destroy(l_info->m_codec); + if (l_codec->is_decompressor) { + l_codec->m_codec_data.m_decompression.opj_destroy(l_codec->m_codec); } else { - l_info->m_codec_data.m_compression.opj_destroy(l_info->m_codec); + l_codec->m_codec_data.m_compression.opj_destroy(l_codec->m_codec); } - l_info->m_codec = 00; - opj_free(l_info); + l_codec->m_codec = 00; + opj_free(l_codec); } } @@ -938,17 +1011,17 @@ opj_bool OPJ_CALLCONV opj_set_decode_area( opj_codec_t *p_codec, ) { if (p_codec) { - opj_codec_private_t * l_info = (opj_codec_private_t *) p_codec; - if (! l_info->is_decompressor) { + opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec; + + if (! l_codec->is_decompressor) { return OPJ_FALSE; } - return l_info->m_codec_data.m_decompression.opj_set_decode_area( l_info->m_codec, + return l_codec->m_codec_data.m_decompression.opj_set_decode_area( l_codec->m_codec, p_image, p_start_x, p_start_y, p_end_x, p_end_y, - l_info->m_event_mgr); - + &(l_codec->m_event_mgr) ); } return OPJ_FALSE; } @@ -974,34 +1047,32 @@ opj_bool OPJ_CALLCONV opj_set_decode_area( opj_codec_t *p_codec, * @return true if the tile header could be decoded. In case the decoding should end, the returned value is still true. * returning false may be the result of a shortage of memory or an internal error. */ -opj_bool OPJ_CALLCONV opj_read_tile_header( - opj_codec_t *p_codec, - opj_stream_t * p_stream, - OPJ_UINT32 * p_tile_index, - OPJ_UINT32 * p_data_size, - OPJ_INT32 * p_tile_x0, OPJ_INT32 * p_tile_y0, - OPJ_INT32 * p_tile_x1, OPJ_INT32 * p_tile_y1, - OPJ_UINT32 * p_nb_comps, - opj_bool * p_should_go_on) +opj_bool OPJ_CALLCONV opj_read_tile_header( opj_codec_t *p_codec, + opj_stream_t * p_stream, + OPJ_UINT32 * p_tile_index, + OPJ_UINT32 * p_data_size, + OPJ_INT32 * p_tile_x0, OPJ_INT32 * p_tile_y0, + OPJ_INT32 * p_tile_x1, OPJ_INT32 * p_tile_y1, + OPJ_UINT32 * p_nb_comps, + opj_bool * p_should_go_on) { if (p_codec && p_stream && p_data_size && p_tile_index) { - opj_codec_private_t * l_info = (opj_codec_private_t *) p_codec; - opj_stream_private_t * l_cio = (opj_stream_private_t *) p_stream; + opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec; + opj_stream_private_t * l_stream = (opj_stream_private_t *) p_stream; - if (! l_info->is_decompressor) { + if (! l_codec->is_decompressor) { return OPJ_FALSE; } - return l_info->m_codec_data.m_decompression.opj_read_tile_header( - l_info->m_codec, - p_tile_index, - p_data_size, - p_tile_x0, p_tile_y0, - p_tile_x1, p_tile_y1, - p_nb_comps, - p_should_go_on, - l_cio, - l_info->m_event_mgr); + return l_codec->m_codec_data.m_decompression.opj_read_tile_header( l_codec->m_codec, + p_tile_index, + p_data_size, + p_tile_x0, p_tile_y0, + p_tile_x1, p_tile_y1, + p_nb_comps, + p_should_go_on, + l_stream, + &(l_codec->m_event_mgr)); } return OPJ_FALSE; } @@ -1018,28 +1089,27 @@ opj_bool OPJ_CALLCONV opj_read_tile_header( * * @return true if the data could be decoded. */ -opj_bool OPJ_CALLCONV opj_decode_tile_data( - opj_codec_t *p_codec, - OPJ_UINT32 p_tile_index, - OPJ_BYTE * p_data, - OPJ_UINT32 p_data_size, - opj_stream_t *p_stream - ) +opj_bool OPJ_CALLCONV opj_decode_tile_data( opj_codec_t *p_codec, + OPJ_UINT32 p_tile_index, + OPJ_BYTE * p_data, + OPJ_UINT32 p_data_size, + opj_stream_t *p_stream + ) { if (p_codec && p_data && p_stream) { - opj_codec_private_t * l_info = (opj_codec_private_t *) p_codec; - opj_stream_private_t * l_cio = (opj_stream_private_t *) p_stream; + opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec; + opj_stream_private_t * l_stream = (opj_stream_private_t *) p_stream; - if (! l_info->is_decompressor) { + if (! l_codec->is_decompressor) { return OPJ_FALSE; } - return l_info->m_codec_data.m_decompression.opj_decode_tile_data( l_info->m_codec, + return l_codec->m_codec_data.m_decompression.opj_decode_tile_data( l_codec->m_codec, p_tile_index, p_data, p_data_size, - l_cio, - l_info->m_event_mgr); + l_stream, + &(l_codec->m_event_mgr) ); } return OPJ_FALSE; } @@ -1120,29 +1190,31 @@ opj_codestream_index_t * OPJ_CALLCONV opj_get_cstr_index(opj_codec_t *p_codec) void OPJ_CALLCONV opj_destroy_cstr_index(opj_codestream_index_t **p_cstr_index) { if (*p_cstr_index){ - j2k_destroy_cstr_index(*p_cstr_index); (*p_cstr_index) = NULL; } } - -opj_bool OPJ_CALLCONV opj_decode_v2(opj_codec_t *p_info, - opj_stream_t *cio, +/* + * + * + */ +opj_bool OPJ_CALLCONV opj_decode_v2(opj_codec_t *p_codec, + opj_stream_t *p_stream, opj_image_t* p_image) { - if (p_info && cio) { - opj_codec_private_t * l_info = (opj_codec_private_t *) p_info; - opj_stream_private_t * l_cio = (opj_stream_private_t *) cio; + if (p_codec && p_stream) { + opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec; + opj_stream_private_t * l_stream = (opj_stream_private_t *) p_stream; - if (! l_info->is_decompressor) { + if (! l_codec->is_decompressor) { return OPJ_FALSE; } - return l_info->m_codec_data.m_decompression.opj_decode( l_info->m_codec, - l_cio, + return l_codec->m_codec_data.m_decompression.opj_decode(l_codec->m_codec, + l_stream, p_image, - l_info->m_event_mgr); + &(l_codec->m_event_mgr) ); } return OPJ_FALSE; @@ -1152,18 +1224,20 @@ opj_bool OPJ_CALLCONV opj_decode_v2(opj_codec_t *p_info, * * */ -opj_bool OPJ_CALLCONV opj_end_decompress (opj_codec_t *p_codec,opj_stream_t *p_cio) +opj_bool OPJ_CALLCONV opj_end_decompress ( opj_codec_t *p_codec, + opj_stream_t *p_stream) { - 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 (p_codec && p_stream) { + opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec; + opj_stream_private_t * l_stream = (opj_stream_private_t *) p_stream; - if (! l_info->is_decompressor) { + if (! l_codec->is_decompressor) { return OPJ_FALSE; } - return l_info->m_codec_data.m_decompression.opj_end_decompress( l_info->m_codec, - l_cio, - l_info->m_event_mgr); + + return l_codec->m_codec_data.m_decompression.opj_end_decompress(l_codec->m_codec, + l_stream, + &(l_codec->m_event_mgr) ); } return OPJ_FALSE; @@ -1174,21 +1248,22 @@ opj_bool OPJ_CALLCONV opj_end_decompress (opj_codec_t *p_codec,opj_stream_t *p_c * */ opj_bool OPJ_CALLCONV opj_get_decoded_tile( opj_codec_t *p_codec, - opj_stream_t *p_cio, + opj_stream_t *p_stream, opj_image_t *p_image, OPJ_UINT32 tile_index) { - if (p_codec && p_cio) { + if (p_codec && p_stream) { opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec; - opj_stream_private_t * l_stream = (opj_stream_private_t *) p_cio; + opj_stream_private_t * l_stream = (opj_stream_private_t *) p_stream; - if (! l_codec->is_decompressor) { - return OPJ_FALSE; + if (! l_codec->is_decompressor) { + return OPJ_FALSE; } + return l_codec->m_codec_data.m_decompression.opj_get_decoded_tile( l_codec->m_codec, l_stream, p_image, - l_codec->m_event_mgr, + &(l_codec->m_event_mgr), tile_index); } @@ -1199,7 +1274,8 @@ opj_bool OPJ_CALLCONV opj_get_decoded_tile( opj_codec_t *p_codec, * * */ -opj_bool OPJ_CALLCONV opj_set_decoded_resolution_factor(opj_codec_t *p_codec, OPJ_UINT32 res_factor) +opj_bool OPJ_CALLCONV opj_set_decoded_resolution_factor(opj_codec_t *p_codec, + OPJ_UINT32 res_factor ) { opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec; @@ -1208,9 +1284,9 @@ opj_bool OPJ_CALLCONV opj_set_decoded_resolution_factor(opj_codec_t *p_codec, OP return OPJ_FALSE; } - - l_codec->m_codec_data.m_decompression.opj_set_decoded_resolution_factor(l_codec->m_codec, res_factor, l_codec->m_event_mgr); - + l_codec->m_codec_data.m_decompression.opj_set_decoded_resolution_factor(l_codec->m_codec, + res_factor, + &(l_codec->m_event_mgr) ); return OPJ_TRUE; } @@ -1256,17 +1332,20 @@ opj_bool OPJ_CALLCONV opj_write_tile ( opj_codec_t *p_codec, opj_stream_t *p_stream ) { if (p_codec && p_stream && p_data) { - opj_codec_private_t * l_info = (opj_codec_private_t *) p_codec; + opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec; opj_stream_private_t * l_cio = (opj_stream_private_t *) p_stream; - if (l_info->is_decompressor) { + if (l_codec->is_decompressor) { return OPJ_FALSE; } - return l_info->m_codec_data.m_compression.opj_write_tile(l_info->m_codec,p_tile_index,p_data,p_data_size,l_cio,l_info->m_event_mgr); + return l_codec->m_codec_data.m_compression.opj_write_tile( l_codec->m_codec, + p_tile_index, + p_data, + p_data_size, + l_cio, + &(l_codec->m_event_mgr) ); } return OPJ_FALSE; } - - diff --git a/libopenjpeg/openjpeg.h b/libopenjpeg/openjpeg.h index f6004eb0..cb6c345f 100644 --- a/libopenjpeg/openjpeg.h +++ b/libopenjpeg/openjpeg.h @@ -79,7 +79,7 @@ typedef int opj_bool; /*FIXME it should be to follow the name of others OPJ_TYPE typedef char OPJ_CHAR; typedef float OPJ_FLOAT32; typedef double OPJ_FLOAT64; -typedef unsigned char OPJ_BYTE; +typedef unsigned char OPJ_BYTE; #include "opj_stdint.h" @@ -219,17 +219,25 @@ typedef enum LIMIT_DECODING { * */ typedef void (*opj_msg_callback) (const char *msg, void *client_data); -/** - * Message handler object used for - * - * */ -typedef struct opj_event_mgr { - /** FIXME DOC */ - void* client_data; + + +/** SHOULD BE MOVE IN EVET.H when we remove old functions +Message handler object +used for + +*/ +typedef struct opj_event_mgr +{ + /** Data to call the event manager upon */ + void * m_error_data; + /** Data to call the event manager upon */ + void * m_warning_data; + /** Data to call the event manager upon */ + void * m_info_data; /** Error message callback if available, NULL otherwise */ opj_msg_callback error_handler; /** Warning message callback if available, NULL otherwise */ @@ -238,7 +246,6 @@ typedef struct opj_event_mgr { opj_msg_callback info_handler; } opj_event_mgr_t; - /* ========================================================== codec typedef definitions @@ -247,7 +254,8 @@ typedef struct opj_event_mgr { /** * Progression order changes - * */ + * + */ typedef struct opj_poc { /** Resolution num start, Component num start, given by POC */ OPJ_UINT32 resno0, compno0; @@ -549,6 +557,7 @@ typedef void * opj_codec_t; /** Byte input-output stream (CIO) +DEPRECATED */ typedef struct opj_cio { /** codec context */ @@ -568,7 +577,7 @@ typedef struct opj_cio { unsigned char *end; /** pointer to the current position */ unsigned char *bp; -} opj_cio_t; +} opj_cio_t; /* @@ -951,7 +960,7 @@ typedef struct opj_tile_index { /** * Index structure of the codestream (FIXME should be expand and enhance) */ -typedef struct opj_codestream_index_ { +typedef struct opj_codestream_index { /** main header start position (SOC position) */ OPJ_OFF_T main_head_start; /** main header end position (first SOT position) */ @@ -1056,7 +1065,7 @@ OPJ_API opj_image_t* OPJ_CALLCONV opj_image_tile_create(OPJ_UINT32 numcmpts, opj stream functions definitions ========================================================== */ - +/* CIO functions are DEPRECATED see following stream functions */ /** Open and allocate a memory stream for read / write. On reading, the user must provide a buffer containing encoded data. The buffer will be @@ -1138,7 +1147,6 @@ OPJ_API void OPJ_CALLCONV opj_stream_set_skip_function(opj_stream_t* p_stream, o */ OPJ_API void OPJ_CALLCONV opj_stream_set_seek_function(opj_stream_t* p_stream, opj_stream_seek_fn p_function); - /** * Sets the given data to be used as a user data for the stream. * @param p_stream the stream to modify @@ -1153,7 +1161,6 @@ OPJ_API void OPJ_CALLCONV opj_stream_set_user_data (opj_stream_t* p_stream, void */ OPJ_API void OPJ_CALLCONV opj_stream_set_user_data_length(opj_stream_t* p_stream, OPJ_UINT64 data_length); - /** * Helper function. * Sets the stream to be a file stream. The FILE must have been open previously. @@ -1170,23 +1177,14 @@ OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream (FILE * p_file, event manager functions definitions ========================================================== */ +OPJ_API opj_bool OPJ_CALLCONV opj_set_info_handler(opj_codec_t * p_codec, opj_msg_callback p_callback,void * p_user_data); +OPJ_API opj_bool OPJ_CALLCONV opj_set_warning_handler(opj_codec_t * p_codec, opj_msg_callback p_callback,void * p_user_data); +OPJ_API opj_bool OPJ_CALLCONV opj_set_error_handler(opj_codec_t * p_codec, opj_msg_callback p_callback,void * p_user_data); /** */ DEPRECATED( OPJ_API opj_event_mgr_t* OPJ_CALLCONV opj_set_event_mgr(opj_common_ptr cinfo, opj_event_mgr_t *event_mgr, void *context)); -/** - * Initialize a default event handler. This function set the output of message event to be stderr for warning and error output - * and stdout for info output in the verbose mode. In the case of the non-verbose mode only the error message are displayed. - * You can initialize your own event handler struct when you fill the field of the event structure. If you provide a null - * structure to the opj_setup_decoder function, no output will be displayed. - * - * @param p_manager a opj_event_mgr structure which will be pass to the codec. - * - */ -OPJ_API void OPJ_CALLCONV opj_initialize_default_event_handler(opj_event_mgr_t * p_manager, opj_bool verbose); - - /* ========================================================== codec functions definitions @@ -1214,17 +1212,26 @@ Destroy a decompressor handle */ DEPRECATED( OPJ_API void OPJ_CALLCONV opj_destroy_decompress(opj_dinfo_t *dinfo) ); +/** + * Destroy a decompressor handle + * + * @param p_codec decompressor handle to destroy + */ +OPJ_API void OPJ_CALLCONV opj_destroy_codec(opj_codec_t * p_codec); + /** * Read after the codestream if necessary + * @param p_codec the JPEG2000 codec to read. + * @param p_stream the JPEG2000 stream. */ OPJ_API opj_bool OPJ_CALLCONV opj_end_decompress ( opj_codec_t *p_codec, - opj_stream_t *p_cio); + opj_stream_t *p_stream); /** -Set decoding parameters to default values -@param parameters Decompression parameters -*/ + * Set decoding parameters to default values + * @param parameters Decompression parameters + */ OPJ_API void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *parameters); /** @@ -1240,26 +1247,24 @@ DEPRECATED( OPJ_API void OPJ_CALLCONV opj_setup_decoder(opj_dinfo_t *dinfo, opj_ * Setup the decoder with decompression parameters provided by the user and with the message handler * provided by the user. * - * @param dinfo decompressor handlers + * @param p_codec decompressor handler * @param parameters decompression parameters - * @param event_mgr message handler * * @return true if the decoder is correctly set */ -OPJ_API opj_bool OPJ_CALLCONV opj_setup_decoder_v2( opj_codec_t *p_info, - opj_dparameters_t *parameters, - opj_event_mgr_t* event_mgr); +OPJ_API opj_bool OPJ_CALLCONV opj_setup_decoder_v2( opj_codec_t *p_codec, + opj_dparameters_t *parameters ); /** * Decodes an image header. * - * @param p_cio the jpeg2000 stream. + * @param p_stream the jpeg2000 stream. * @param p_codec the jpeg2000 codec to read. * @param p_image the image structure initialized with the characteristics of encoded image. * * @return true if the main header of the codestream and the JP2 header is correctly read. */ -OPJ_API opj_bool OPJ_CALLCONV opj_read_header ( opj_stream_t *p_cio, +OPJ_API opj_bool OPJ_CALLCONV opj_read_header ( opj_stream_t *p_stream, opj_codec_t *p_codec, opj_image_t **p_image); @@ -1289,41 +1294,38 @@ DEPRECATED( OPJ_API opj_image_t* OPJ_CALLCONV opj_decode(opj_dinfo_t *dinfo, opj /** * Decode an image from a JPEG-2000 codestream - * @param p_decompressor decompressor handle - * @param cio Input buffer stream - * @param p_image the decoded image - * @return Returns a true on success, otherwise false + * @param p_decompressor decompressor handle + * @param p_stream Input buffer stream + * @param p_image the decoded image + * @return true if success, otherwise false * */ OPJ_API opj_bool OPJ_CALLCONV opj_decode_v2(opj_codec_t *p_decompressor, - opj_stream_t * cio, + opj_stream_t *p_stream, opj_image_t *p_image); - /** * Get the decoded tile from the codec * @param p_codec the jpeg2000 codec. - * @param p_cio input streamm + * @param p_stream input streamm * @param p_image output image * @param tile_index index of the tile which will be decode * - * @return opj_true if all is ok. + * @return true if success, otherwise false */ OPJ_API opj_bool OPJ_CALLCONV opj_get_decoded_tile( opj_codec_t *p_codec, - opj_stream_t *p_cio, + opj_stream_t *p_stream, opj_image_t *p_image, OPJ_UINT32 tile_index); - /** * Set the resolution factor of the decoded image * @param p_codec the jpeg2000 codec. * @param res_factor resolution factor to set * - * @return opj_true if all is ok. + * @return true if success, otherwise false */ OPJ_API opj_bool OPJ_CALLCONV opj_set_decoded_resolution_factor(opj_codec_t *p_codec, OPJ_UINT32 res_factor); - /** * Writes a tile with the given data. * @@ -1342,8 +1344,6 @@ OPJ_API opj_bool OPJ_CALLCONV opj_write_tile ( opj_codec_t *p_codec, OPJ_UINT32 p_data_size, opj_stream_t *p_stream ); - - /** * Reads a tile header. This function is compulsory and allows one to know the size of the tile thta will be decoded. * The user may need to refer to the image got by opj_read_header to understand the size being taken by the tile. @@ -1374,7 +1374,6 @@ OPJ_API opj_bool OPJ_CALLCONV opj_read_tile_header( opj_codec_t *p_codec, OPJ_UINT32 * p_nb_comps, opj_bool * p_should_go_on ); - /** * Reads a tile data. This function is compulsory and allows one to decode tile data. opj_read_tile_header should be called before. * The user may need to refer to the image got by opj_read_header to understand the size being taken by the tile. @@ -1393,7 +1392,6 @@ OPJ_API opj_bool OPJ_CALLCONV opj_decode_tile_data( opj_codec_t *p_codec, OPJ_UINT32 p_data_size, opj_stream_t *p_stream ); - /** Decode an image from a JPEG-2000 codestream and extract the codestream information @param dinfo decompressor handle @@ -1410,21 +1408,21 @@ Creates a J2K/JP2 compression structure @param format Coder to select @return Returns a handle to a compressor if successful, returns NULL otherwise */ -OPJ_API opj_cinfo_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format); +DEPRECATED( OPJ_API opj_cinfo_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format)); /** -Creates a J2K/JP2 compression structure -@param format Coder to select -@return Returns a handle to a compressor if successful, returns NULL otherwise -*/ + * Creates a J2K/JP2 compression structure + * @param format Coder to select + * @return Returns a handle to a compressor if successful, returns NULL otherwise + */ OPJ_API opj_codec_t* OPJ_CALLCONV opj_create_compress_v2(OPJ_CODEC_FORMAT format); - /** Destroy a compressor handle @param cinfo compressor handle to destroy */ -OPJ_API void OPJ_CALLCONV opj_destroy_compress(opj_cinfo_t *cinfo); +DEPRECATED(OPJ_API void OPJ_CALLCONV opj_destroy_compress(opj_cinfo_t *cinfo) ); + /** Set encoding parameters to default values, that means :