[trunk] Use stdint.h when available to compute fixed-type definition.
[openjpeg.git] / libopenjpeg / openjpeg.h
index d71b42868e35cf37cf74b2f6943ce0bd9525ac62..b5772263bbfc76055cff01240f4da584e2b74602 100644 (file)
@@ -76,17 +76,47 @@ typedef int opj_bool; /*FIXME it should be to follow the name of others OPJ_TYPE
 #define OPJ_TRUE 1
 #define OPJ_FALSE 0
 
-typedef unsigned int   OPJ_UINT32;
-typedef int                            OPJ_INT32;
-typedef unsigned short OPJ_UINT16;
-typedef short                  OPJ_INT16;
-typedef char                   OPJ_CHAR;
+typedef char          OPJ_CHAR;
+typedef float         OPJ_FLOAT32;
+typedef double        OPJ_FLOAT64;
 typedef unsigned char  OPJ_BYTE;
-typedef unsigned int   OPJ_SIZE_T;
-typedef double                 OPJ_FLOAT64;
-typedef float                  OPJ_FLOAT32;
+typedef size_t        OPJ_SIZE_T;
+
+#include "opj_config.h"
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+typedef int8_t   OPJ_INT8;
+typedef uint8_t  OPJ_UINT8;
+typedef int16_t  OPJ_INT16;
+typedef uint16_t OPJ_UINT16;
+typedef int32_t  OPJ_INT32;
+typedef uint32_t OPJ_UINT32;
+typedef int64_t  OPJ_INT64;
+typedef uint64_t OPJ_UINT64;
+#define OPJ_INT64_F  "ll"
+#define OPJ_UINT64_F "ll"
+#else
+#if defined(_WIN32)
+typedef   signed __int8   OPJ_INT8;
+typedef unsigned __int8   OPJ_UINT8;
+typedef   signed __int16  OPJ_INT16;
+typedef unsigned __int16  OPJ_UINT16;
+typedef   signed __int32  OPJ_INT32;
+typedef unsigned __int32  OPJ_UINT32;
+typedef   signed __int64  OPJ_INT64;
+typedef unsigned __int64  OPJ_UINT64;
+#define OPJ_INT64_F  "I64"
+#define OPJ_UINT64_F "I64"
+#else
+#error unsupported platform
+#endif
+#endif
+
+/* 64-bit file offset type */
+typedef OPJ_INT64 OPJ_OFF_T;
+#define OPJ_OFF_F OPJ_INT64_F
 
-// Avoid compile-time warning because parameter is not used
+/* Avoid compile-time warning because parameter is not used */
 #define OPJ_ARG_NOT_USED(x) (void)(x)
 
 /* 
@@ -186,7 +216,7 @@ typedef enum CODEC_FORMAT {
        CODEC_UNKNOWN = -1,     /**< place-holder */
        CODEC_J2K  = 0,         /**< JPEG-2000 codestream : read/write */
        CODEC_JPT  = 1,         /**< JPT-stream (JPEG 2000, JPIP) : read only */
-       CODEC_JP2  = 2,         /**< JPEG-2000 file format : read/write */
+       CODEC_JP2  = 2          /**< JPEG-2000 file format : read/write */
 } OPJ_CODEC_FORMAT;
 
 /** 
@@ -397,6 +427,8 @@ typedef struct opj_cparameters {
        opj_bool jpip_on;
 } opj_cparameters_t;
 
+#define OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG     0x0001
+
 /**
  * Decompression parameters
  * */
@@ -466,6 +498,7 @@ typedef struct opj_dparameters {
        */
        OPJ_LIMIT_DECODING cp_limit_decoding;
 
+       unsigned int flags;
 } opj_dparameters_t;
 
 
@@ -560,10 +593,10 @@ typedef struct opj_cio {
 /*
  * FIXME DOC
  */
-typedef OPJ_UINT32 (* opj_stream_read_fn) (void * p_buffer, OPJ_UINT32 p_nb_bytes, void * p_user_data) ;
-typedef OPJ_UINT32 (* opj_stream_write_fn) (void * p_buffer, OPJ_UINT32 p_nb_bytes, void * p_user_data) ;
-typedef OPJ_SIZE_T (* opj_stream_skip_fn) (OPJ_SIZE_T p_nb_bytes, void * p_user_data) ;
-typedef opj_bool (* opj_stream_seek_fn) (OPJ_SIZE_T p_nb_bytes, void * p_user_data) ;
+typedef OPJ_SIZE_T (* opj_stream_read_fn) (void * p_buffer, OPJ_SIZE_T p_nb_bytes, void * p_user_data) ;
+typedef OPJ_SIZE_T (* opj_stream_write_fn) (void * p_buffer, OPJ_SIZE_T p_nb_bytes, void * p_user_data) ;
+typedef OPJ_OFF_T (* opj_stream_skip_fn) (OPJ_OFF_T p_nb_bytes, void * p_user_data) ;
+typedef opj_bool (* opj_stream_seek_fn) (OPJ_OFF_T p_nb_bytes, void * p_user_data) ;
 
 /*
  * JPEG2000 Stream.
@@ -667,11 +700,11 @@ typedef struct opj_image_comptparm {
  * */
 typedef struct opj_packet_info {
        /** packet start position (including SOP marker if it exists) */
-       int start_pos;
+       OPJ_OFF_T start_pos;
        /** end of packet header position (including EPH marker if it exists)*/
-       int end_ph_pos;
+       OPJ_OFF_T end_ph_pos;
        /** packet end position */
-       int end_pos;
+       OPJ_OFF_T end_pos;
        /** packet distorsion */
        double disto;
 } opj_packet_info_t;
@@ -685,7 +718,7 @@ typedef struct opj_marker_info_t {
        /** marker type */
        unsigned short int type;
        /** position in codestream */
-       int pos;
+       OPJ_OFF_T pos;
        /** length, marker val included */
        int len;
 } opj_marker_info_t;
@@ -894,14 +927,11 @@ typedef struct opj_codestream_info_v2 {
  */
 typedef struct opj_tp_index {
        /** start position */
-       OPJ_UINT32 start_pos;
+       OPJ_OFF_T start_pos;
        /** end position of the header */
-       OPJ_UINT32 end_header;
+       OPJ_OFF_T end_header;
        /** end position */
-       OPJ_UINT32 end_pos;
-
-
-
+       OPJ_OFF_T end_pos;
 
 } opj_tp_index_t;
 
@@ -942,12 +972,12 @@ typedef struct opj_tile_index {
  */
 typedef struct opj_codestream_index_ {
        /** main header start position (SOC position) */
-       OPJ_UINT32 main_head_start;
+       OPJ_OFF_T main_head_start;
        /** main header end position (first SOT position) */
-       OPJ_UINT32 main_head_end;
+       OPJ_OFF_T main_head_end;
 
        /** codestream's size */
-       OPJ_UINT32 codestream_size;
+       OPJ_UINT64 codestream_size;
 
 /* UniPG>> */
        /** number of markers */
@@ -1077,7 +1107,7 @@ OPJ_API void OPJ_CALLCONV cio_seek(opj_cio_t *cio, int pos);
  * @return     a stream object.
 */
 OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_default_create(opj_bool p_is_input);
-OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create(OPJ_UINT32 p_size, opj_bool p_is_input);
+OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create(OPJ_SIZE_T p_buffer_size, opj_bool p_is_input);
 
 /**
  * Destroys a stream created by opj_create_stream. This function does NOT close the abstract stream. If needed the user must
@@ -1128,17 +1158,17 @@ OPJ_API void OPJ_CALLCONV opj_stream_set_user_data (opj_stream_t* p_stream, void
  * @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);
+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.
- * @param              p_stream        the stream to modify
- * @param              p_file          handler to an already open file.
+ * @param p_file the file stream to operate on
+ * @param p_is_read_stream whether the stream is a read stream (true) or not (false)
 */
 OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create_default_file_stream (FILE * p_file, opj_bool p_is_read_stream);
-OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream (FILE * p_file, OPJ_UINT32 p_buffer_size, opj_bool p_is_read_stream);
+OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream (FILE * p_file, OPJ_SIZE_T p_buffer_size, opj_bool p_is_read_stream);
 
 /* -----------> */
 
@@ -1266,9 +1296,10 @@ DEPRECATED( OPJ_API opj_image_t* OPJ_CALLCONV opj_decode(opj_dinfo_t *dinfo, opj
 
 /**
  * Decode an image from a JPEG-2000 codestream
- * @param dinfo decompressor handle
+ * @param p_decompressor decompressor handle
  * @param cio Input buffer stream
- * @return Returns a decoded image if successful, returns NULL otherwise
+ * @param p_image the decoded image
+ * @return Returns a true on success, otherwise false
  * */
 OPJ_API opj_bool OPJ_CALLCONV opj_decode_v2(opj_codec_t *p_decompressor,
                                                                                        opj_stream_t * cio,
@@ -1437,7 +1468,7 @@ OPJ_API void OPJ_CALLCONV opj_destroy_cstr_info_v2(opj_codestream_info_v2_t **cs
 /**
  * Destroy a decompressor handle
  *
- * @param      dinfo                   decompressor handle to destroy
+ * @param      p_codec                 decompressor handle to destroy
  */
 OPJ_API void OPJ_CALLCONV opj_destroy_codec(opj_codec_t * p_codec);