[trunk] merge r1479 from branch 1.5 over to trunk
[openjpeg.git] / libopenjpeg / openjpeg.h
index 3c82498c04942b9f815cd8aa410d49633791ce62..26698abcd9cd61aac38f3dcaac3a464f6d4eb065 100644 (file)
@@ -76,6 +76,7 @@ typedef int opj_bool; /*FIXME it should be to follow the name of others OPJ_TYPE
 #define OPJ_TRUE 1
 #define OPJ_FALSE 0
 
+/* FIXME : should be better defined by configure/CMake test */
 typedef unsigned int   OPJ_UINT32;
 typedef int                            OPJ_INT32;
 typedef unsigned short OPJ_UINT16;
@@ -86,7 +87,28 @@ typedef unsigned int OPJ_SIZE_T;
 typedef double                 OPJ_FLOAT64;
 typedef float                  OPJ_FLOAT32;
 
-// Avoid compile-time warning because parameter is not used
+#if (defined(WIN32) || defined(WIN64)) && !defined(__MINGW32__)
+
+typedef signed __int64     OPJ_INT64;
+#define OPJ_INT64_F "I64"
+typedef unsigned __int64   OPJ_UINT64;
+#define OPJ_UINT64_F "I64"
+
+#else
+
+typedef long long          OPJ_INT64;
+#define OPJ_INT64_F "ll"
+
+typedef unsigned long long OPJ_UINT64;
+#define OPJ_UINT64_F "ll"
+
+#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 */
 #define OPJ_ARG_NOT_USED(x) (void)(x)
 
 /* 
@@ -397,6 +419,8 @@ typedef struct opj_cparameters {
        opj_bool jpip_on;
 } opj_cparameters_t;
 
+#define OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG     0x0001
+
 /**
  * Decompression parameters
  * */
@@ -439,6 +463,11 @@ typedef struct opj_dparameters {
        /** Verbose mode */
        opj_bool m_verbose;
 
+       /** tile number ot the decoded tile*/
+       OPJ_UINT32 tile_index;
+       /** Nb of tile to decode */
+       OPJ_UINT32 nb_tile_to_decode;
+
        /*@}*/
 
 /* UniPG>> */
@@ -461,6 +490,7 @@ typedef struct opj_dparameters {
        */
        OPJ_LIMIT_DECODING cp_limit_decoding;
 
+       unsigned int flags;
 } opj_dparameters_t;
 
 
@@ -555,10 +585,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.
@@ -662,11 +692,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;
@@ -680,7 +710,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;
@@ -889,14 +919,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;
 
@@ -937,12 +964,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 */
@@ -1072,7 +1099,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
@@ -1123,14 +1150,14 @@ 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);
@@ -1261,9 +1288,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,
@@ -1277,13 +1305,25 @@ OPJ_API opj_bool OPJ_CALLCONV opj_decode_v2(opj_codec_t *p_decompressor,
  * @param      p_image                 output image
  * @param      tile_index              index of the tile which will be decode
  *
- * @return                                     a pointer to a JP2 index structure.
+ * @return                                     opj_true if all is ok.
  */
 OPJ_API opj_bool OPJ_CALLCONV opj_get_decoded_tile(    opj_codec_t *p_codec,
                                                                                                        opj_stream_t *p_cio,
                                                                                                        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.
+ */
+OPJ_API opj_bool OPJ_CALLCONV opj_set_decoded_resolution_factor(opj_codec_t *p_codec, OPJ_UINT32 res_factor);
+
+
+
 /**
  * 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.
@@ -1420,7 +1460,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);