[trunk] WIP: correct some memory leaks in applications functions
[openjpeg.git] / libopenjpeg / openjpeg.h
index 26b96c4db1729ddce24b691e5c43cc9a446e0c7c..0c59889c86d7e9249fd855330e4a156df53eed95 100644 (file)
@@ -563,29 +563,29 @@ Defines a single image component
 */
 typedef struct opj_image_comp {
        /** XRsiz: horizontal separation of a sample of ith component with respect to the reference grid */
-       int dx;
+       OPJ_UINT32 dx;
        /** YRsiz: vertical separation of a sample of ith component with respect to the reference grid */
-       int dy;
+       OPJ_UINT32 dy;
        /** data width */
-       int w;
+       OPJ_UINT32 w;
        /** data height */
-       int h;
+       OPJ_UINT32 h;
        /** x component offset compared to the whole image */
-       int x0;
+       OPJ_UINT32 x0;
        /** y component offset compared to the whole image */
-       int y0;
+       OPJ_UINT32 y0;
        /** precision */
-       int prec;
+       OPJ_UINT32 prec;
        /** image depth in bits */
-       int bpp;
+       OPJ_UINT32 bpp;
        /** signed (1) / unsigned (0) */
-       int sgnd;
+       OPJ_UINT32 sgnd;
        /** number of decoded resolution */
-       int resno_decoded;
+       OPJ_UINT32 resno_decoded;
        /** number of division by 2 of the out image compared to the original size of image */
-       int factor;
+       OPJ_UINT32 factor;
        /** image component data */
-       int *data;
+       OPJ_INT32 *data;
 } opj_image_comp_t;
 
 /** 
@@ -601,15 +601,15 @@ typedef struct opj_image {
        /** Ysiz: height of the reference grid */
        OPJ_UINT32 y1;
        /** number of components in the image */
-       OPJ_UINT16 numcomps;
+       OPJ_UINT32 numcomps;
        /** color space: sRGB, Greyscale or YUV */
        OPJ_COLOR_SPACE color_space;
        /** image components */
        opj_image_comp_t *comps;
        /** 'restricted' ICC profile */
-       unsigned char *icc_profile_buf;
+       OPJ_BYTE *icc_profile_buf;
        /** size of ICC profile */
-       int icc_profile_len;
+       OPJ_INT32 icc_profile_len;
 } opj_image_t;
 
 
@@ -639,58 +639,6 @@ typedef struct opj_image_comptparm {
 
 
 
-/**
-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;
-
-       /** 'restricted' ICC profile */
-       unsigned char *icc_profile_buf;
-       /** size of ICC profile */
-       int icc_profile_len;
-} opj_image_header_t;
 
 
 /* 
@@ -1036,19 +984,12 @@ Create an image
 OPJ_API opj_image_t* OPJ_CALLCONV opj_image_create(int numcmpts, opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc);
 
 /**
-Deallocate any resources associated with an image
-@param image image to be destroyed
-*/
+ * Deallocate any resources associated with an image
+ * @param image image to be destroyed
+ */
 OPJ_API void OPJ_CALLCONV opj_image_destroy(opj_image_t *image);
 
 
-/**
- * Deallocate any resources associated with an image header
- *
- * @param image_header         image header to be destroyed
- */
-OPJ_API void OPJ_CALLCONV opj_image_header_destroy(opj_image_header_t *image_header);
-
 /* 
 ==========================================================
    stream functions definitions
@@ -1144,6 +1085,13 @@ OPJ_API void OPJ_CALLCONV opj_stream_set_seek_function(opj_stream_t* p_stream, o
 */
 OPJ_API void OPJ_CALLCONV opj_stream_set_user_data (opj_stream_t* p_stream, void * p_data);
 
+/**
+ * Sets the length of the user data for the stream.
+ * @param              p_stream                the stream to modify
+ * @param              data_length             length of the user_data.
+*/
+OPJ_API void OPJ_CALLCONV opj_stream_set_user_data_length(opj_stream_t* p_stream, OPJ_UINT32 data_length);
+
 
 /**
  * Helper function.
@@ -1164,19 +1112,20 @@ OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream (FILE * p_file,
 
 /**
  * FIXME DOC 
- * FIXME Need to adapt this function to the V2 framework
+ * FIXME 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);
 
 /**
- * Set the default event handler. This function set the output of message event to be stderr for warning and error output
- * and stdout for info output. It is optional, you can set your own event handler or provide a null structure to the
- * opj_setup_decoder function. In this last case no output will be displayed.
+ * 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_set_default_event_handler(opj_event_mgr_t * p_manager, opj_bool verbose);
+OPJ_API void OPJ_CALLCONV opj_initialize_default_event_handler(opj_event_mgr_t * p_manager, opj_bool verbose);
 
 
 /* 
@@ -1225,7 +1174,7 @@ OPJ_API void OPJ_CALLCONV opj_setup_decoder(opj_dinfo_t *dinfo, opj_dparameters_
  *
  * @param dinfo                decompressor handlers
  * @param parameters   decompression parameters
- * @param vent_mgr             message handler
+ * @param event_mgr            message handler
  *
  * @return true                        if the decoder is correctly set
  */
@@ -1313,19 +1262,20 @@ Destroy Codestream information after compression or decompression
 */
 OPJ_API void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_t *cstr_info);
 
+OPJ_API void OPJ_CALLCONV opj_destroy_cstr_info_v2(opj_codestream_info_v2_t **cstr_info);
 
 /**
  * Decodes an image header.
  *
  * @param      p_cio                   the jpeg2000 stream.
  * @param      p_codec                 the jpeg2000 codec to read.
- * @param      p_image                 header of the image hold in the codestream.
+ * @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_codec_t *p_codec,
-                                                                                               opj_image_header_t * p_img_header);
+                                                                                               opj_image_t **p_image);
 
 /**
  * Destroy a decompressor handle
@@ -1437,6 +1387,9 @@ OPJ_API opj_codestream_info_v2_t* OPJ_CALLCONV opj_get_cstr_info(opj_codec_t *p_
  */
 OPJ_API opj_codestream_index_t * OPJ_CALLCONV opj_get_cstr_index(opj_codec_t *p_codec);
 
+OPJ_API void OPJ_CALLCONV opj_destroy_cstr_index(opj_codestream_index_t **p_cstr_index);
+
+
 /**
  * Get the JP2 file information from the codec FIXME
  *
@@ -1457,6 +1410,19 @@ OPJ_API opj_jp2_metadata_t* OPJ_CALLCONV opj_get_jp2_metadata(opj_codec_t *p_cod
  */
 OPJ_API opj_jp2_index_t* OPJ_CALLCONV opj_get_jp2_index(opj_codec_t *p_codec);
 
+/**
+Decode an image from a JPEG-2000 codestream
+@param dinfo decompressor handle
+@param cio Input buffer stream
+@return Returns a decoded image if successful, returns NULL otherwise
+*/
+OPJ_API opj_bool OPJ_CALLCONV opj_decode_v2(opj_codec_t *p_decompressor,
+                                                                                       opj_stream_t * cio,
+                                                                                       opj_image_t *p_image);
+
+OPJ_API opj_bool OPJ_CALLCONV opj_end_decompress (     opj_codec_t *p_codec,
+                                                                                                       opj_stream_t *p_cio);
+
 
 #ifdef __cplusplus
 }