From 7b88544d467c721f5f996ef496bd7e49f4bd1979 Mon Sep 17 00:00:00 2001 From: Mickael Savinaud Date: Thu, 9 Aug 2012 12:40:22 +0000 Subject: [PATCH] [trunk] remove deprecated v1 style function opj_encode and opj_encode_with_info --- libopenjpeg/openjpeg.c | 97 ++++++++++++++++-------------------------- libopenjpeg/openjpeg.h | 19 --------- 2 files changed, 37 insertions(+), 79 deletions(-) diff --git a/libopenjpeg/openjpeg.c b/libopenjpeg/openjpeg.c index 3954ddcd..14b516ed 100644 --- a/libopenjpeg/openjpeg.c +++ b/libopenjpeg/openjpeg.c @@ -637,42 +637,6 @@ void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *paramete } } -/** - * Helper function. - * Sets the stream to be a file stream. The FILE must have been open previously. - * @param p_stream the stream to modify - * @param p_file handler to an already open file. -*/ -opj_stream_t* OPJ_CALLCONV opj_stream_create_default_file_stream (FILE * p_file, opj_bool p_is_read_stream) -{ - 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* l_stream = 00; - - if (! p_file) { - return NULL; - } - - l_stream = opj_stream_create(p_size,p_is_read_stream); - if (! l_stream) { - return NULL; - } - - opj_stream_set_user_data(l_stream, p_file); - opj_stream_set_user_data_length(l_stream, opj_get_data_length_from_file(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; -} - opj_bool OPJ_CALLCONV opj_setup_encoder(opj_codec_t *p_codec, opj_cparameters_t *parameters, opj_image_t *p_image) @@ -746,31 +710,7 @@ opj_bool OPJ_CALLCONV opj_end_compress (opj_codec_t *p_codec, } -/* 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" - "To extract the index, use the opj_encode_with_info() function.\n" - "No index will be generated during this encoding\n"); - 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) { - case CODEC_J2K: - return j2k_encode((opj_j2k_t*)cinfo->j2k_handle, cio, image, cstr_info); - case CODEC_JP2: - return opj_jp2_encode((opj_jp2_t*)cinfo->jp2_handle, cio, image, cstr_info); - case CODEC_JPT: - case CODEC_UNKNOWN: - default: - break; - } - } - return OPJ_FALSE; -} /* DEPRECATED */ void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_t *cstr_info) { @@ -1186,3 +1126,40 @@ opj_bool OPJ_CALLCONV opj_write_tile ( opj_codec_t *p_codec, return OPJ_FALSE; } + +/* ---------------------------------------------------------------------- */ +/** + * Helper function. + * Sets the stream to be a file stream. The FILE must have been open previously. + * @param p_stream the stream to modify + * @param p_file handler to an already open file. +*/ +opj_stream_t* OPJ_CALLCONV opj_stream_create_default_file_stream (FILE * p_file, opj_bool p_is_read_stream) +{ + 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* l_stream = 00; + + if (! p_file) { + return NULL; + } + + l_stream = opj_stream_create(p_size,p_is_read_stream); + if (! l_stream) { + return NULL; + } + + opj_stream_set_user_data(l_stream, p_file); + opj_stream_set_user_data_length(l_stream, opj_get_data_length_from_file(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; +} \ No newline at end of file diff --git a/libopenjpeg/openjpeg.h b/libopenjpeg/openjpeg.h index e3ee72a6..5b8d3a81 100644 --- a/libopenjpeg/openjpeg.h +++ b/libopenjpeg/openjpeg.h @@ -1426,25 +1426,6 @@ OPJ_API opj_bool OPJ_CALLCONV opj_end_compress (opj_codec_t *p_codec, OPJ_API opj_bool OPJ_CALLCONV opj_encode_v2(opj_codec_t *p_codec, opj_stream_t *p_stream); -/** -Encode an image into a JPEG-2000 codestream -3@param cinfo compressor handle -@param cio Output buffer stream -@param image Image to encode -@param index Depreacted -> Set to NULL. To extract index, used opj_encode_wci() -@return Returns true if successful, returns false otherwise -*/ -DEPRECATED( OPJ_API opj_bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index) ); -/** -Encode an image into a JPEG-2000 codestream and extract the codestream information -@param cinfo compressor handle -@param cio Output buffer stream -@param image Image to encode -@param cstr_info Codestream information structure if needed afterwards, NULL otherwise -@return Returns true if successful, returns false otherwise -*/ -DEPRECATED( OPJ_API opj_bool OPJ_CALLCONV opj_encode_with_info(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) ); - /** Destroy Codestream information after compression or decompression