[trunk] Import patch from sumatrapdf team. This handle some testcase with no input...
[openjpeg.git] / src / lib / openjp2 / openjpeg.h
index 1fcc0fa5f0c38225904f43c295225deadf7fd420..338a771dee05ac4c25951e3fd54c34950171d685 100644 (file)
 
 /* deprecated attribute */
 #ifdef __GNUC__
-       #define DEPRECATED(func) func __attribute__ ((deprecated))
+       #define OPJ_DEPRECATED(func) func __attribute__ ((deprecated))
 #elif defined(_MSC_VER)
-       #define DEPRECATED(func) __declspec(deprecated) func
+       #define OPJ_DEPRECATED(func) __declspec(deprecated) func
 #else
        #pragma message("WARNING: You need to implement DEPRECATED for this compiler")
-       #define DEPRECATED(func) func
+       #define OPJ_DEPRECATED(func) func
 #endif
 
 #if defined(OPJ_STATIC) || !defined(_WIN32)
@@ -80,7 +80,7 @@ defined with this macro as being exported.
 #endif /* OPJ_EXPORTS */
 #endif /* !OPJ_STATIC || !_WIN32 */
 
-typedef int OPJ_BOOL; /*FIXME it should be to follow the name of others OPJ_TYPE -> OPJ_BOOL*/
+typedef int OPJ_BOOL;
 #define OPJ_TRUE 1
 #define OPJ_FALSE 0
 
@@ -100,6 +100,11 @@ typedef uint32_t OPJ_UINT32;
 typedef int64_t  OPJ_INT64;
 typedef uint64_t OPJ_UINT64;
 
+typedef int64_t  OPJ_OFF_T; /* 64-bit file offset type */
+
+#include <stdio.h>
+typedef size_t   OPJ_SIZE_T;
+
 /* Avoid compile-time warning because parameter is not used */
 #define OPJ_ARG_NOT_USED(x) (void)(x)
 
@@ -188,10 +193,11 @@ typedef enum PROG_ORDER {
 */
 typedef enum COLOR_SPACE {
        OPJ_CLRSPC_UNKNOWN = -1,        /**< not supported by the library */
-       OPJ_CLRSPC_UNSPECIFIED = 0, /**< not specified in the codestream */ 
+       OPJ_CLRSPC_UNSPECIFIED = 0,     /**< not specified in the codestream */ 
        OPJ_CLRSPC_SRGB = 1,            /**< sRGB */
        OPJ_CLRSPC_GRAY = 2,            /**< grayscale */
-       OPJ_CLRSPC_SYCC = 3                     /**< YUV */
+       OPJ_CLRSPC_SYCC = 3,            /**< YUV */
+  OPJ_CLRSPC_EYCC = 4          /**< e-YCC */
 } OPJ_COLOR_SPACE;
 
 /**
@@ -382,9 +388,10 @@ typedef struct opj_cparameters {
        char tcp_mct;
        /** Enable JPIP indexing*/
        OPJ_BOOL jpip_on;
-       /** Naive implementation of MCT restricted to a single reversible array based encoding without offset concerning all the components. */
+       /** Naive implementation of MCT restricted to a single reversible array based 
+        encoding without offset concerning all the components. */
        void * mct_data;
-} opj_cparameters_t;
+} opj_cparameters_t;  
 
 #define OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG     0x0001
 
@@ -449,11 +456,9 @@ typedef struct opj_dparameters {
        /*@}*/
 /* <<UniPG */
 
-
        unsigned int flags;
-} opj_dparameters_t;
-
 
+} opj_dparameters_t;
 
 
 /**
@@ -534,6 +539,8 @@ typedef struct opj_image_comp {
        OPJ_UINT32 factor;
        /** image component data */
        OPJ_INT32 *data;
+  /** alpha channel */
+  OPJ_UINT16 alpha;
 } opj_image_comp_t;
 
 /** 
@@ -1000,8 +1007,16 @@ OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create(OPJ_SIZE_T p_buffer_size, O
  *
  * @param      p_stream        the stream to destroy.
  */
-OPJ_API void OPJ_CALLCONV opj_stream_destroy(opj_stream_t* p_stream);
+OPJ_DEPRECATED(OPJ_API void OPJ_CALLCONV opj_stream_destroy(opj_stream_t* p_stream));
 
+/**
+ * Destroys a stream created by opj_create_stream. This function does NOT close the abstract stream. 
+ * If needed the user must close its own implementation of the stream.
+ *
+ * @param      p_stream        the stream to destroy.
+ */
+OPJ_API void OPJ_CALLCONV opj_stream_destroy_v3(opj_stream_t* p_stream);
 /**
  * Sets the given function to be used as a read function.
  * @param              p_stream        the stream to modify
@@ -1051,16 +1066,34 @@ OPJ_API void OPJ_CALLCONV opj_stream_set_user_data_length(opj_stream_t* p_stream
  * @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_DEPRECATED(OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create_default_file_stream (FILE * p_file, OPJ_BOOL p_is_read_stream));
 
+/**
+ * Create a stream from a file identified with its filename with default parameters (helper function)
+ * @param fname             the filename of the file to stream
+ * @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_v3 (const char *fname, OPJ_BOOL p_is_read_stream);
 /**
  * FIXME DOC
  * @param p_file            the file stream to operate on
  * @param p_buffer_size     size of the chunk used to stream
  * @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_file_stream (FILE * p_file, OPJ_SIZE_T p_buffer_size, OPJ_BOOL p_is_read_stream);
+OPJ_DEPRECATED(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));
 
+/** Create a stream from a file identified with its filename with a specific buffer size
+ * @param fname             the filename of the file to stream
+ * @param p_buffer_size     size of the chunk used to stream
+ * @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_file_stream_v3 (const char *fname, 
+                                                                     OPJ_SIZE_T p_buffer_size,
+                                                                     OPJ_BOOL p_is_read_stream);
 /* 
 ==========================================================
    event manager functions definitions
@@ -1214,7 +1247,8 @@ OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_decoded_resolution_factor(opj_codec_t *p_c
  * @param      p_codec                 the jpeg2000 codec.
  * @param      p_tile_index            the index of the tile to write. At the moment, the tiles must be written from 0 to n-1 in sequence.
  * @param      p_data                          pointer to the data to write. Data is arranged in sequence, data_comp0, then data_comp1, then ... NO INTERLEAVING should be set.
- * @param      p_data_size                     this value os used to make sure the data being written is correct. The size must be equal to the sum for each component of tile_width * tile_height * component_size. component_size can be 1,2 or 4 bytes, depending on the precision of the given component.
+ * @param      p_data_size                     this value os used to make sure the data being written is correct. The size must be equal to the sum for each component of 
+ *                              tile_width * tile_height * component_size. component_size can be 1,2 or 4 bytes, depending on the precision of the given component.
  * @param      p_stream                        the stream to write data to.
  *
  * @return     true if the data could be written.