Update ABI/API compatibility reports after commit 4980f46210f19bd2d83dffdfeb8496f29d6...
[openjpeg.git] / abi-check / installed / openjpeg / current / include / openjpeg-2.3 / openjpeg.h
1 /*
2 * The copyright in this software is being made available under the 2-clauses
3 * BSD License, included below. This software may be subject to other third
4 * party and contributor rights, including patent rights, and no such rights
5 * are granted under this license.
6 *
7 * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
8 * Copyright (c) 2002-2014, Professor Benoit Macq
9 * Copyright (c) 2001-2003, David Janssens
10 * Copyright (c) 2002-2003, Yannick Verschueren
11 * Copyright (c) 2003-2007, Francois-Olivier Devaux
12 * Copyright (c) 2003-2014, Antonin Descampe
13 * Copyright (c) 2005, Herve Drolon, FreeImage Team
14 * Copyright (c) 2006-2007, Parvatha Elangovan
15 * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr>
16 * Copyright (c) 2010-2011, Kaori Hagihara
17 * Copyright (c) 2011-2012, Centre National d'Etudes Spatiales (CNES), France
18 * Copyright (c) 2012, CS Systemes d'Information, France
19 * All rights reserved.
20 *
21 * Redistribution and use in source and binary forms, with or without
22 * modification, are permitted provided that the following conditions
23 * are met:
24 * 1. Redistributions of source code must retain the above copyright
25 *    notice, this list of conditions and the following disclaimer.
26 * 2. Redistributions in binary form must reproduce the above copyright
27 *    notice, this list of conditions and the following disclaimer in the
28 *    documentation and/or other materials provided with the distribution.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
31 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33 * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
34 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
35 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
36 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
37 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
38 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
39 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
40 * POSSIBILITY OF SUCH DAMAGE.
41 */
42 #ifndef OPENJPEG_H
43 #define OPENJPEG_H
44
45
46 /*
47 ==========================================================
48    Compiler directives
49 ==========================================================
50 */
51
52 /*
53 The inline keyword is supported by C99 but not by C90.
54 Most compilers implement their own version of this keyword ...
55 */
56 #ifndef INLINE
57 #if defined(_MSC_VER)
58 #define INLINE __forceinline
59 #elif defined(__GNUC__)
60 #define INLINE __inline__
61 #elif defined(__MWERKS__)
62 #define INLINE inline
63 #else
64 /* add other compilers here ... */
65 #define INLINE
66 #endif /* defined(<Compiler>) */
67 #endif /* INLINE */
68
69 /* deprecated attribute */
70 #ifdef __GNUC__
71 #define OPJ_DEPRECATED(func) func __attribute__ ((deprecated))
72 #elif defined(_MSC_VER)
73 #define OPJ_DEPRECATED(func) __declspec(deprecated) func
74 #else
75 #pragma message("WARNING: You need to implement DEPRECATED for this compiler")
76 #define OPJ_DEPRECATED(func) func
77 #endif
78
79 #if defined(OPJ_STATIC) || !defined(_WIN32)
80 /* http://gcc.gnu.org/wiki/Visibility */
81 #   if __GNUC__ >= 4
82 #       if defined(OPJ_STATIC) /* static library uses "hidden" */
83 #           define OPJ_API    __attribute__ ((visibility ("hidden")))
84 #       else
85 #           define OPJ_API    __attribute__ ((visibility ("default")))
86 #       endif
87 #       define OPJ_LOCAL  __attribute__ ((visibility ("hidden")))
88 #   else
89 #       define OPJ_API
90 #       define OPJ_LOCAL
91 #   endif
92 #   define OPJ_CALLCONV
93 #else
94 #   define OPJ_CALLCONV __stdcall
95 /*
96 The following ifdef block is the standard way of creating macros which make exporting
97 from a DLL simpler. All files within this DLL are compiled with the OPJ_EXPORTS
98 symbol defined on the command line. this symbol should not be defined on any project
99 that uses this DLL. This way any other project whose source files include this file see
100 OPJ_API functions as being imported from a DLL, whereas this DLL sees symbols
101 defined with this macro as being exported.
102 */
103 #   if defined(OPJ_EXPORTS) || defined(DLL_EXPORT)
104 #       define OPJ_API __declspec(dllexport)
105 #   else
106 #       define OPJ_API __declspec(dllimport)
107 #   endif /* OPJ_EXPORTS */
108 #endif /* !OPJ_STATIC || !_WIN32 */
109
110 typedef int OPJ_BOOL;
111 #define OPJ_TRUE 1
112 #define OPJ_FALSE 0
113
114 typedef char          OPJ_CHAR;
115 typedef float         OPJ_FLOAT32;
116 typedef double        OPJ_FLOAT64;
117 typedef unsigned char OPJ_BYTE;
118
119 #include "opj_stdint.h"
120
121 typedef int8_t   OPJ_INT8;
122 typedef uint8_t  OPJ_UINT8;
123 typedef int16_t  OPJ_INT16;
124 typedef uint16_t OPJ_UINT16;
125 typedef int32_t  OPJ_INT32;
126 typedef uint32_t OPJ_UINT32;
127 typedef int64_t  OPJ_INT64;
128 typedef uint64_t OPJ_UINT64;
129
130 typedef int64_t  OPJ_OFF_T; /* 64-bit file offset type */
131
132 #include <stdio.h>
133 typedef size_t   OPJ_SIZE_T;
134
135 /* Avoid compile-time warning because parameter is not used */
136 #define OPJ_ARG_NOT_USED(x) (void)(x)
137
138 /*
139 ==========================================================
140    Useful constant definitions
141 ==========================================================
142 */
143
144 #define OPJ_PATH_LEN 4096 /**< Maximum allowed size for filenames */
145
146 #define OPJ_J2K_MAXRLVLS 33                 /**< Number of maximum resolution level authorized */
147 #define OPJ_J2K_MAXBANDS (3*OPJ_J2K_MAXRLVLS-2) /**< Number of maximum sub-band linked to number of resolution level */
148
149 #define OPJ_J2K_DEFAULT_NB_SEGS             10
150 #define OPJ_J2K_STREAM_CHUNK_SIZE           0x100000 /** 1 mega by default */
151 #define OPJ_J2K_DEFAULT_HEADER_SIZE         1000
152 #define OPJ_J2K_MCC_DEFAULT_NB_RECORDS      10
153 #define OPJ_J2K_MCT_DEFAULT_NB_RECORDS      10
154
155 /* UniPG>> */ /* NOT YET USED IN THE V2 VERSION OF OPENJPEG */
156 #define JPWL_MAX_NO_TILESPECS   16 /**< Maximum number of tile parts expected by JPWL: increase at your will */
157 #define JPWL_MAX_NO_PACKSPECS   16 /**< Maximum number of packet parts expected by JPWL: increase at your will */
158 #define JPWL_MAX_NO_MARKERS 512 /**< Maximum number of JPWL markers: increase at your will */
159 #define JPWL_PRIVATEINDEX_NAME "jpwl_index_privatefilename" /**< index file name used when JPWL is on */
160 #define JPWL_EXPECTED_COMPONENTS 3 /**< Expect this number of components, so you'll find better the first EPB */
161 #define JPWL_MAXIMUM_TILES 8192 /**< Expect this maximum number of tiles, to avoid some crashes */
162 #define JPWL_MAXIMUM_HAMMING 2 /**< Expect this maximum number of bit errors in marker id's */
163 #define JPWL_MAXIMUM_EPB_ROOM 65450 /**< Expect this maximum number of bytes for composition of EPBs */
164 /* <<UniPG */
165
166 /**
167  * EXPERIMENTAL FOR THE MOMENT
168  * Supported options about file information used only in j2k_dump
169 */
170 #define OPJ_IMG_INFO        1   /**< Basic image information provided to the user */
171 #define OPJ_J2K_MH_INFO     2   /**< Codestream information based only on the main header */
172 #define OPJ_J2K_TH_INFO     4   /**< Tile information based on the current tile header */
173 #define OPJ_J2K_TCH_INFO    8   /**< Tile/Component information of all tiles */
174 #define OPJ_J2K_MH_IND      16  /**< Codestream index based only on the main header */
175 #define OPJ_J2K_TH_IND      32  /**< Tile index based on the current tile */
176 /*FIXME #define OPJ_J2K_CSTR_IND    48*/    /**<  */
177 #define OPJ_JP2_INFO        128 /**< JP2 file information */
178 #define OPJ_JP2_IND         256 /**< JP2 file index */
179
180 /**
181  * JPEG 2000 Profiles, see Table A.10 from 15444-1 (updated in various AMD)
182  * These values help choosing the RSIZ value for the J2K codestream.
183  * The RSIZ value triggers various encoding options, as detailed in Table A.10.
184  * If OPJ_PROFILE_PART2 is chosen, it has to be combined with one or more extensions
185  * described hereunder.
186  *   Example: rsiz = OPJ_PROFILE_PART2 | OPJ_EXTENSION_MCT;
187  * For broadcast profiles, the OPJ_PROFILE value has to be combined with the targeted
188  * mainlevel (3-0 LSB, value between 0 and 11):
189  *   Example: rsiz = OPJ_PROFILE_BC_MULTI | 0x0005; (here mainlevel 5)
190  * For IMF profiles, the OPJ_PROFILE value has to be combined with the targeted mainlevel
191  * (3-0 LSB, value between 0 and 11) and sublevel (7-4 LSB, value between 0 and 9):
192  *   Example: rsiz = OPJ_PROFILE_IMF_2K | 0x0040 | 0x0005; (here main 5 and sublevel 4)
193  * */
194 #define OPJ_PROFILE_NONE        0x0000 /** no profile, conform to 15444-1 */
195 #define OPJ_PROFILE_0           0x0001 /** Profile 0 as described in 15444-1,Table A.45 */
196 #define OPJ_PROFILE_1           0x0002 /** Profile 1 as described in 15444-1,Table A.45 */
197 #define OPJ_PROFILE_PART2       0x8000 /** At least 1 extension defined in 15444-2 (Part-2) */
198 #define OPJ_PROFILE_CINEMA_2K   0x0003 /** 2K cinema profile defined in 15444-1 AMD1 */
199 #define OPJ_PROFILE_CINEMA_4K   0x0004 /** 4K cinema profile defined in 15444-1 AMD1 */
200 #define OPJ_PROFILE_CINEMA_S2K  0x0005 /** Scalable 2K cinema profile defined in 15444-1 AMD2 */
201 #define OPJ_PROFILE_CINEMA_S4K  0x0006 /** Scalable 4K cinema profile defined in 15444-1 AMD2 */
202 #define OPJ_PROFILE_CINEMA_LTS  0x0007 /** Long term storage cinema profile defined in 15444-1 AMD2 */
203 #define OPJ_PROFILE_BC_SINGLE   0x0100 /** Single Tile Broadcast profile defined in 15444-1 AMD3 */
204 #define OPJ_PROFILE_BC_MULTI    0x0200 /** Multi Tile Broadcast profile defined in 15444-1 AMD3 */
205 #define OPJ_PROFILE_BC_MULTI_R  0x0300 /** Multi Tile Reversible Broadcast profile defined in 15444-1 AMD3 */
206 #define OPJ_PROFILE_IMF_2K      0x0400 /** 2K Single Tile Lossy IMF profile defined in 15444-1 AMD 8 */
207 #define OPJ_PROFILE_IMF_4K      0x0500 /** 4K Single Tile Lossy IMF profile defined in 15444-1 AMD 8 */
208 #define OPJ_PROFILE_IMF_8K      0x0600 /** 8K Single Tile Lossy IMF profile defined in 15444-1 AMD 8 */
209 #define OPJ_PROFILE_IMF_2K_R    0x0700 /** 2K Single/Multi Tile Reversible IMF profile defined in 15444-1 AMD 8 */
210 #define OPJ_PROFILE_IMF_4K_R    0x0800 /** 4K Single/Multi Tile Reversible IMF profile defined in 15444-1 AMD 8 */
211 #define OPJ_PROFILE_IMF_8K_R    0x0900 /** 8K Single/Multi Tile Reversible IMF profile defined in 15444-1 AMD 8 */
212
213 /**
214  * JPEG 2000 Part-2 extensions
215  * */
216 #define OPJ_EXTENSION_NONE      0x0000 /** No Part-2 extension */
217 #define OPJ_EXTENSION_MCT       0x0100  /** Custom MCT support */
218
219 /**
220  * JPEG 2000 profile macros
221  * */
222 #define OPJ_IS_CINEMA(v)     (((v) >= OPJ_PROFILE_CINEMA_2K)&&((v) <= OPJ_PROFILE_CINEMA_S4K))
223 #define OPJ_IS_STORAGE(v)    ((v) == OPJ_PROFILE_CINEMA_LTS)
224 #define OPJ_IS_BROADCAST(v)  (((v) >= OPJ_PROFILE_BC_SINGLE)&&((v) <= ((OPJ_PROFILE_BC_MULTI_R) | (0x000b))))
225 #define OPJ_IS_IMF(v)        (((v) >= OPJ_PROFILE_IMF_2K)&&((v) <= ((OPJ_PROFILE_IMF_8K_R) | (0x009b))))
226 #define OPJ_IS_PART2(v)      ((v) & OPJ_PROFILE_PART2)
227
228 #define OPJ_GET_IMF_PROFILE(v)   ((v) & 0xff00)      /** Extract IMF profile without mainlevel/sublevel */
229 #define OPJ_GET_IMF_MAINLEVEL(v) ((v) & 0xf)         /** Extract IMF main level */
230 #define OPJ_GET_IMF_SUBLEVEL(v)  (((v) >> 4) & 0xf)  /** Extract IMF sub level */
231
232 #define OPJ_IMF_MAINLEVEL_MAX    11   /** Maximum main level */
233
234 /** Max. Components Sampling Rate (MSamples/sec) per IMF main level */
235 #define OPJ_IMF_MAINLEVEL_1_MSAMPLESEC   65      /** MSamples/sec for IMF main level 1 */
236 #define OPJ_IMF_MAINLEVEL_2_MSAMPLESEC   130     /** MSamples/sec for IMF main level 2 */
237 #define OPJ_IMF_MAINLEVEL_3_MSAMPLESEC   195     /** MSamples/sec for IMF main level 3 */
238 #define OPJ_IMF_MAINLEVEL_4_MSAMPLESEC   260     /** MSamples/sec for IMF main level 4 */
239 #define OPJ_IMF_MAINLEVEL_5_MSAMPLESEC   520     /** MSamples/sec for IMF main level 5 */
240 #define OPJ_IMF_MAINLEVEL_6_MSAMPLESEC   1200    /** MSamples/sec for IMF main level 6 */
241 #define OPJ_IMF_MAINLEVEL_7_MSAMPLESEC   2400    /** MSamples/sec for IMF main level 7 */
242 #define OPJ_IMF_MAINLEVEL_8_MSAMPLESEC   4800    /** MSamples/sec for IMF main level 8 */
243 #define OPJ_IMF_MAINLEVEL_9_MSAMPLESEC   9600    /** MSamples/sec for IMF main level 9 */
244 #define OPJ_IMF_MAINLEVEL_10_MSAMPLESEC  19200   /** MSamples/sec for IMF main level 10 */
245 #define OPJ_IMF_MAINLEVEL_11_MSAMPLESEC  38400   /** MSamples/sec for IMF main level 11 */
246
247 /** Max. compressed Bit Rate (Mbits/s) per IMF sub level */
248 #define OPJ_IMF_SUBLEVEL_1_MBITSSEC      200     /** Mbits/s for IMF sub level 1 */
249 #define OPJ_IMF_SUBLEVEL_2_MBITSSEC      400     /** Mbits/s for IMF sub level 2 */
250 #define OPJ_IMF_SUBLEVEL_3_MBITSSEC      800     /** Mbits/s for IMF sub level 3 */
251 #define OPJ_IMF_SUBLEVEL_4_MBITSSEC     1600     /** Mbits/s for IMF sub level 4 */
252 #define OPJ_IMF_SUBLEVEL_5_MBITSSEC     3200     /** Mbits/s for IMF sub level 5 */
253 #define OPJ_IMF_SUBLEVEL_6_MBITSSEC     6400     /** Mbits/s for IMF sub level 6 */
254 #define OPJ_IMF_SUBLEVEL_7_MBITSSEC    12800     /** Mbits/s for IMF sub level 7 */
255 #define OPJ_IMF_SUBLEVEL_8_MBITSSEC    25600     /** Mbits/s for IMF sub level 8 */
256 #define OPJ_IMF_SUBLEVEL_9_MBITSSEC    51200     /** Mbits/s for IMF sub level 9 */
257
258 /**
259  * JPEG 2000 codestream and component size limits in cinema profiles
260  * */
261 #define OPJ_CINEMA_24_CS     1302083    /** Maximum codestream length for 24fps */
262 #define OPJ_CINEMA_48_CS     651041     /** Maximum codestream length for 48fps */
263 #define OPJ_CINEMA_24_COMP   1041666    /** Maximum size per color component for 2K & 4K @ 24fps */
264 #define OPJ_CINEMA_48_COMP   520833     /** Maximum size per color component for 2K @ 48fps */
265
266 /*
267 ==========================================================
268    enum definitions
269 ==========================================================
270 */
271
272 /**
273  * DEPRECATED: use RSIZ, OPJ_PROFILE_* and OPJ_EXTENSION_* instead
274  * Rsiz Capabilities
275  * */
276 typedef enum RSIZ_CAPABILITIES {
277     OPJ_STD_RSIZ = 0,       /** Standard JPEG2000 profile*/
278     OPJ_CINEMA2K = 3,       /** Profile name for a 2K image*/
279     OPJ_CINEMA4K = 4,       /** Profile name for a 4K image*/
280     OPJ_MCT = 0x8100
281 } OPJ_RSIZ_CAPABILITIES;
282
283 /**
284  * DEPRECATED: use RSIZ, OPJ_PROFILE_* and OPJ_EXTENSION_* instead
285  * Digital cinema operation mode
286  * */
287 typedef enum CINEMA_MODE {
288     OPJ_OFF = 0,            /** Not Digital Cinema*/
289     OPJ_CINEMA2K_24 = 1,    /** 2K Digital Cinema at 24 fps*/
290     OPJ_CINEMA2K_48 = 2,    /** 2K Digital Cinema at 48 fps*/
291     OPJ_CINEMA4K_24 = 3     /** 4K Digital Cinema at 24 fps*/
292 } OPJ_CINEMA_MODE;
293
294 /**
295  * Progression order
296  * */
297 typedef enum PROG_ORDER {
298     OPJ_PROG_UNKNOWN = -1,  /**< place-holder */
299     OPJ_LRCP = 0,           /**< layer-resolution-component-precinct order */
300     OPJ_RLCP = 1,           /**< resolution-layer-component-precinct order */
301     OPJ_RPCL = 2,           /**< resolution-precinct-component-layer order */
302     OPJ_PCRL = 3,           /**< precinct-component-resolution-layer order */
303     OPJ_CPRL = 4            /**< component-precinct-resolution-layer order */
304 } OPJ_PROG_ORDER;
305
306 /**
307  * Supported image color spaces
308 */
309 typedef enum COLOR_SPACE {
310     OPJ_CLRSPC_UNKNOWN = -1,    /**< not supported by the library */
311     OPJ_CLRSPC_UNSPECIFIED = 0, /**< not specified in the codestream */
312     OPJ_CLRSPC_SRGB = 1,        /**< sRGB */
313     OPJ_CLRSPC_GRAY = 2,        /**< grayscale */
314     OPJ_CLRSPC_SYCC = 3,        /**< YUV */
315     OPJ_CLRSPC_EYCC = 4,        /**< e-YCC */
316     OPJ_CLRSPC_CMYK = 5         /**< CMYK */
317 } OPJ_COLOR_SPACE;
318
319 /**
320  * Supported codec
321 */
322 typedef enum CODEC_FORMAT {
323     OPJ_CODEC_UNKNOWN = -1, /**< place-holder */
324     OPJ_CODEC_J2K  = 0,     /**< JPEG-2000 codestream : read/write */
325     OPJ_CODEC_JPT  = 1,     /**< JPT-stream (JPEG 2000, JPIP) : read only */
326     OPJ_CODEC_JP2  = 2,     /**< JP2 file format : read/write */
327     OPJ_CODEC_JPP  = 3,     /**< JPP-stream (JPEG 2000, JPIP) : to be coded */
328     OPJ_CODEC_JPX  = 4      /**< JPX file format (JPEG 2000 Part-2) : to be coded */
329 } OPJ_CODEC_FORMAT;
330
331
332 /*
333 ==========================================================
334    event manager typedef definitions
335 ==========================================================
336 */
337
338 /**
339  * Callback function prototype for events
340  * @param msg               Event message
341  * @param client_data       Client object where will be return the event message
342  * */
343 typedef void (*opj_msg_callback)(const char *msg, void *client_data);
344
345 /*
346 ==========================================================
347    codec typedef definitions
348 ==========================================================
349 */
350
351 #ifndef OPJ_UINT32_SEMANTICALLY_BUT_INT32
352 #define OPJ_UINT32_SEMANTICALLY_BUT_INT32 OPJ_INT32
353 #endif
354
355 /**
356  * Progression order changes
357  *
358  */
359 typedef struct opj_poc {
360     /** Resolution num start, Component num start, given by POC */
361     OPJ_UINT32 resno0, compno0;
362     /** Layer num end,Resolution num end, Component num end, given by POC */
363     OPJ_UINT32 layno1, resno1, compno1;
364     /** Layer num start,Precinct num start, Precinct num end */
365     OPJ_UINT32 layno0, precno0, precno1;
366     /** Progression order enum*/
367     OPJ_PROG_ORDER prg1, prg;
368     /** Progression order string*/
369     OPJ_CHAR progorder[5];
370     /** Tile number (starting at 1) */
371     OPJ_UINT32 tile;
372     /** Start and end values for Tile width and height*/
373     OPJ_UINT32_SEMANTICALLY_BUT_INT32 tx0, tx1, ty0, ty1;
374     /** Start value, initialised in pi_initialise_encode*/
375     OPJ_UINT32 layS, resS, compS, prcS;
376     /** End value, initialised in pi_initialise_encode */
377     OPJ_UINT32 layE, resE, compE, prcE;
378     /** Start and end values of Tile width and height, initialised in pi_initialise_encode*/
379     OPJ_UINT32 txS, txE, tyS, tyE, dx, dy;
380     /** Temporary values for Tile parts, initialised in pi_create_encode */
381     OPJ_UINT32 lay_t, res_t, comp_t, prc_t, tx0_t, ty0_t;
382 } opj_poc_t;
383
384 /**
385  * Compression parameters
386  * */
387 typedef struct opj_cparameters {
388     /** size of tile: tile_size_on = false (not in argument) or = true (in argument) */
389     OPJ_BOOL tile_size_on;
390     /** XTOsiz */
391     int cp_tx0;
392     /** YTOsiz */
393     int cp_ty0;
394     /** XTsiz */
395     int cp_tdx;
396     /** YTsiz */
397     int cp_tdy;
398     /** allocation by rate/distortion */
399     int cp_disto_alloc;
400     /** allocation by fixed layer */
401     int cp_fixed_alloc;
402     /** add fixed_quality */
403     int cp_fixed_quality;
404     /** fixed layer */
405     int *cp_matrice;
406     /** comment for coding */
407     char *cp_comment;
408     /** csty : coding style */
409     int csty;
410     /** progression order (default OPJ_LRCP) */
411     OPJ_PROG_ORDER prog_order;
412     /** progression order changes */
413     opj_poc_t POC[32];
414     /** number of progression order changes (POC), default to 0 */
415     OPJ_UINT32 numpocs;
416     /** number of layers */
417     int tcp_numlayers;
418     /** rates of layers - might be subsequently limited by the max_cs_size field.
419      * Should be decreasing. 1 can be
420      * used as last value to indicate the last layer is lossless. */
421     float tcp_rates[100];
422     /** different psnr for successive layers. Should be increasing. 0 can be
423      * used as last value to indicate the last layer is lossless. */
424     float tcp_distoratio[100];
425     /** number of resolutions */
426     int numresolution;
427     /** initial code block width, default to 64 */
428     int cblockw_init;
429     /** initial code block height, default to 64 */
430     int cblockh_init;
431     /** mode switch (cblk_style) */
432     int mode;
433     /** 1 : use the irreversible DWT 9-7, 0 : use lossless compression (default) */
434     int irreversible;
435     /** region of interest: affected component in [0..3], -1 means no ROI */
436     int roi_compno;
437     /** region of interest: upshift value */
438     int roi_shift;
439     /* number of precinct size specifications */
440     int res_spec;
441     /** initial precinct width */
442     int prcw_init[OPJ_J2K_MAXRLVLS];
443     /** initial precinct height */
444     int prch_init[OPJ_J2K_MAXRLVLS];
445
446     /**@name command line encoder parameters (not used inside the library) */
447     /*@{*/
448     /** input file name */
449     char infile[OPJ_PATH_LEN];
450     /** output file name */
451     char outfile[OPJ_PATH_LEN];
452     /** DEPRECATED. Index generation is now handeld with the opj_encode_with_info() function. Set to NULL */
453     int index_on;
454     /** DEPRECATED. Index generation is now handeld with the opj_encode_with_info() function. Set to NULL */
455     char index[OPJ_PATH_LEN];
456     /** subimage encoding: origin image offset in x direction */
457     int image_offset_x0;
458     /** subimage encoding: origin image offset in y direction */
459     int image_offset_y0;
460     /** subsampling value for dx */
461     int subsampling_dx;
462     /** subsampling value for dy */
463     int subsampling_dy;
464     /** input file format 0: PGX, 1: PxM, 2: BMP 3:TIF*/
465     int decod_format;
466     /** output file format 0: J2K, 1: JP2, 2: JPT */
467     int cod_format;
468     /*@}*/
469
470     /* UniPG>> */ /* NOT YET USED IN THE V2 VERSION OF OPENJPEG */
471     /**@name JPWL encoding parameters */
472     /*@{*/
473     /** enables writing of EPC in MH, thus activating JPWL */
474     OPJ_BOOL jpwl_epc_on;
475     /** error protection method for MH (0,1,16,32,37-128) */
476     int jpwl_hprot_MH;
477     /** tile number of header protection specification (>=0) */
478     int jpwl_hprot_TPH_tileno[JPWL_MAX_NO_TILESPECS];
479     /** error protection methods for TPHs (0,1,16,32,37-128) */
480     int jpwl_hprot_TPH[JPWL_MAX_NO_TILESPECS];
481     /** tile number of packet protection specification (>=0) */
482     int jpwl_pprot_tileno[JPWL_MAX_NO_PACKSPECS];
483     /** packet number of packet protection specification (>=0) */
484     int jpwl_pprot_packno[JPWL_MAX_NO_PACKSPECS];
485     /** error protection methods for packets (0,1,16,32,37-128) */
486     int jpwl_pprot[JPWL_MAX_NO_PACKSPECS];
487     /** enables writing of ESD, (0=no/1/2 bytes) */
488     int jpwl_sens_size;
489     /** sensitivity addressing size (0=auto/2/4 bytes) */
490     int jpwl_sens_addr;
491     /** sensitivity range (0-3) */
492     int jpwl_sens_range;
493     /** sensitivity method for MH (-1=no,0-7) */
494     int jpwl_sens_MH;
495     /** tile number of sensitivity specification (>=0) */
496     int jpwl_sens_TPH_tileno[JPWL_MAX_NO_TILESPECS];
497     /** sensitivity methods for TPHs (-1=no,0-7) */
498     int jpwl_sens_TPH[JPWL_MAX_NO_TILESPECS];
499     /*@}*/
500     /* <<UniPG */
501
502     /**
503      * DEPRECATED: use RSIZ, OPJ_PROFILE_* and MAX_COMP_SIZE instead
504      * Digital Cinema compliance 0-not compliant, 1-compliant
505      * */
506     OPJ_CINEMA_MODE cp_cinema;
507     /**
508      * Maximum size (in bytes) for each component.
509      * If == 0, component size limitation is not considered
510      * */
511     int max_comp_size;
512     /**
513      * DEPRECATED: use RSIZ, OPJ_PROFILE_* and OPJ_EXTENSION_* instead
514      * Profile name
515      * */
516     OPJ_RSIZ_CAPABILITIES cp_rsiz;
517     /** Tile part generation*/
518     char tp_on;
519     /** Flag for Tile part generation*/
520     char tp_flag;
521     /** MCT (multiple component transform) */
522     char tcp_mct;
523     /** Enable JPIP indexing*/
524     OPJ_BOOL jpip_on;
525     /** Naive implementation of MCT restricted to a single reversible array based
526         encoding without offset concerning all the components. */
527     void * mct_data;
528     /**
529      * Maximum size (in bytes) for the whole codestream.
530      * If == 0, codestream size limitation is not considered
531      * If it does not comply with tcp_rates, max_cs_size prevails
532      * and a warning is issued.
533      * */
534     int max_cs_size;
535     /** RSIZ value
536         To be used to combine OPJ_PROFILE_*, OPJ_EXTENSION_* and (sub)levels values. */
537     OPJ_UINT16 rsiz;
538 } opj_cparameters_t;
539
540 #define OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG  0x0001
541 #define OPJ_DPARAMETERS_DUMP_FLAG 0x0002
542
543 /**
544  * Decompression parameters
545  * */
546 typedef struct opj_dparameters {
547     /**
548     Set the number of highest resolution levels to be discarded.
549     The image resolution is effectively divided by 2 to the power of the number of discarded levels.
550     The reduce factor is limited by the smallest total number of decomposition levels among tiles.
551     if != 0, then original dimension divided by 2^(reduce);
552     if == 0 or not used, image is decoded to the full resolution
553     */
554     OPJ_UINT32 cp_reduce;
555     /**
556     Set the maximum number of quality layers to decode.
557     If there are less quality layers than the specified number, all the quality layers are decoded.
558     if != 0, then only the first "layer" layers are decoded;
559     if == 0 or not used, all the quality layers are decoded
560     */
561     OPJ_UINT32 cp_layer;
562
563     /**@name command line decoder parameters (not used inside the library) */
564     /*@{*/
565     /** input file name */
566     char infile[OPJ_PATH_LEN];
567     /** output file name */
568     char outfile[OPJ_PATH_LEN];
569     /** input file format 0: J2K, 1: JP2, 2: JPT */
570     int decod_format;
571     /** output file format 0: PGX, 1: PxM, 2: BMP */
572     int cod_format;
573
574     /** Decoding area left boundary */
575     OPJ_UINT32 DA_x0;
576     /** Decoding area right boundary */
577     OPJ_UINT32 DA_x1;
578     /** Decoding area up boundary */
579     OPJ_UINT32 DA_y0;
580     /** Decoding area bottom boundary */
581     OPJ_UINT32 DA_y1;
582     /** Verbose mode */
583     OPJ_BOOL m_verbose;
584
585     /** tile number of the decoded tile */
586     OPJ_UINT32 tile_index;
587     /** Nb of tile to decode */
588     OPJ_UINT32 nb_tile_to_decode;
589
590     /*@}*/
591
592     /* UniPG>> */ /* NOT YET USED IN THE V2 VERSION OF OPENJPEG */
593     /**@name JPWL decoding parameters */
594     /*@{*/
595     /** activates the JPWL correction capabilities */
596     OPJ_BOOL jpwl_correct;
597     /** expected number of components */
598     int jpwl_exp_comps;
599     /** maximum number of tiles */
600     int jpwl_max_tiles;
601     /*@}*/
602     /* <<UniPG */
603
604     unsigned int flags;
605
606 } opj_dparameters_t;
607
608
609 /**
610  * JPEG2000 codec V2.
611  * */
612 typedef void * opj_codec_t;
613
614 /*
615 ==========================================================
616    I/O stream typedef definitions
617 ==========================================================
618 */
619
620 /**
621  * Stream open flags.
622  * */
623 /** The stream was opened for reading. */
624 #define OPJ_STREAM_READ OPJ_TRUE
625 /** The stream was opened for writing. */
626 #define OPJ_STREAM_WRITE OPJ_FALSE
627
628 /*
629  * Callback function prototype for read function
630  */
631 typedef OPJ_SIZE_T(* opj_stream_read_fn)(void * p_buffer, OPJ_SIZE_T p_nb_bytes,
632         void * p_user_data) ;
633
634 /*
635  * Callback function prototype for write function
636  */
637 typedef OPJ_SIZE_T(* opj_stream_write_fn)(void * p_buffer,
638         OPJ_SIZE_T p_nb_bytes, void * p_user_data) ;
639
640 /*
641  * Callback function prototype for skip function
642  */
643 typedef OPJ_OFF_T(* opj_stream_skip_fn)(OPJ_OFF_T p_nb_bytes,
644                                         void * p_user_data) ;
645
646 /*
647  * Callback function prototype for seek function
648  */
649 typedef OPJ_BOOL(* opj_stream_seek_fn)(OPJ_OFF_T p_nb_bytes,
650                                        void * p_user_data) ;
651
652 /*
653  * Callback function prototype for free user data function
654  */
655 typedef void (* opj_stream_free_user_data_fn)(void * p_user_data) ;
656
657 /*
658  * JPEG2000 Stream.
659  */
660 typedef void * opj_stream_t;
661
662 /*
663 ==========================================================
664    image typedef definitions
665 ==========================================================
666 */
667
668 /**
669  * Defines a single image component
670  * */
671 typedef struct opj_image_comp {
672     /** XRsiz: horizontal separation of a sample of ith component with respect to the reference grid */
673     OPJ_UINT32 dx;
674     /** YRsiz: vertical separation of a sample of ith component with respect to the reference grid */
675     OPJ_UINT32 dy;
676     /** data width */
677     OPJ_UINT32 w;
678     /** data height */
679     OPJ_UINT32 h;
680     /** x component offset compared to the whole image */
681     OPJ_UINT32 x0;
682     /** y component offset compared to the whole image */
683     OPJ_UINT32 y0;
684     /** precision */
685     OPJ_UINT32 prec;
686     /** image depth in bits */
687     OPJ_UINT32 bpp;
688     /** signed (1) / unsigned (0) */
689     OPJ_UINT32 sgnd;
690     /** number of decoded resolution */
691     OPJ_UINT32 resno_decoded;
692     /** number of division by 2 of the out image compared to the original size of image */
693     OPJ_UINT32 factor;
694     /** image component data */
695     OPJ_INT32 *data;
696     /** alpha channel */
697     OPJ_UINT16 alpha;
698 } opj_image_comp_t;
699
700 /**
701  * Defines image data and characteristics
702  * */
703 typedef struct opj_image {
704     /** XOsiz: horizontal offset from the origin of the reference grid to the left side of the image area */
705     OPJ_UINT32 x0;
706     /** YOsiz: vertical offset from the origin of the reference grid to the top side of the image area */
707     OPJ_UINT32 y0;
708     /** Xsiz: width of the reference grid */
709     OPJ_UINT32 x1;
710     /** Ysiz: height of the reference grid */
711     OPJ_UINT32 y1;
712     /** number of components in the image */
713     OPJ_UINT32 numcomps;
714     /** color space: sRGB, Greyscale or YUV */
715     OPJ_COLOR_SPACE color_space;
716     /** image components */
717     opj_image_comp_t *comps;
718     /** 'restricted' ICC profile */
719     OPJ_BYTE *icc_profile_buf;
720     /** size of ICC profile */
721     OPJ_UINT32 icc_profile_len;
722 } opj_image_t;
723
724
725 /**
726  * Component parameters structure used by the opj_image_create function
727  * */
728 typedef struct opj_image_comptparm {
729     /** XRsiz: horizontal separation of a sample of ith component with respect to the reference grid */
730     OPJ_UINT32 dx;
731     /** YRsiz: vertical separation of a sample of ith component with respect to the reference grid */
732     OPJ_UINT32 dy;
733     /** data width */
734     OPJ_UINT32 w;
735     /** data height */
736     OPJ_UINT32 h;
737     /** x component offset compared to the whole image */
738     OPJ_UINT32 x0;
739     /** y component offset compared to the whole image */
740     OPJ_UINT32 y0;
741     /** precision */
742     OPJ_UINT32 prec;
743     /** image depth in bits */
744     OPJ_UINT32 bpp;
745     /** signed (1) / unsigned (0) */
746     OPJ_UINT32 sgnd;
747 } opj_image_cmptparm_t;
748
749
750 /*
751 ==========================================================
752    Information on the JPEG 2000 codestream
753 ==========================================================
754 */
755 /* QUITE EXPERIMENTAL FOR THE MOMENT */
756
757 /**
758  * Index structure : Information concerning a packet inside tile
759  * */
760 typedef struct opj_packet_info {
761     /** packet start position (including SOP marker if it exists) */
762     OPJ_OFF_T start_pos;
763     /** end of packet header position (including EPH marker if it exists)*/
764     OPJ_OFF_T end_ph_pos;
765     /** packet end position */
766     OPJ_OFF_T end_pos;
767     /** packet distorsion */
768     double disto;
769 } opj_packet_info_t;
770
771
772 /* UniPG>> */
773 /**
774  * Marker structure
775  * */
776 typedef struct opj_marker_info {
777     /** marker type */
778     unsigned short int type;
779     /** position in codestream */
780     OPJ_OFF_T pos;
781     /** length, marker val included */
782     int len;
783 } opj_marker_info_t;
784 /* <<UniPG */
785
786 /**
787  * Index structure : Information concerning tile-parts
788 */
789 typedef struct opj_tp_info {
790     /** start position of tile part */
791     int tp_start_pos;
792     /** end position of tile part header */
793     int tp_end_header;
794     /** end position of tile part */
795     int tp_end_pos;
796     /** start packet of tile part */
797     int tp_start_pack;
798     /** number of packets of tile part */
799     int tp_numpacks;
800 } opj_tp_info_t;
801
802 /**
803  * Index structure : information regarding tiles
804 */
805 typedef struct opj_tile_info {
806     /** value of thresh for each layer by tile cfr. Marcela   */
807     double *thresh;
808     /** number of tile */
809     int tileno;
810     /** start position */
811     int start_pos;
812     /** end position of the header */
813     int end_header;
814     /** end position */
815     int end_pos;
816     /** precinct number for each resolution level (width) */
817     int pw[33];
818     /** precinct number for each resolution level (height) */
819     int ph[33];
820     /** precinct size (in power of 2), in X for each resolution level */
821     int pdx[33];
822     /** precinct size (in power of 2), in Y for each resolution level */
823     int pdy[33];
824     /** information concerning packets inside tile */
825     opj_packet_info_t *packet;
826     /** add fixed_quality */
827     int numpix;
828     /** add fixed_quality */
829     double distotile;
830     /** number of markers */
831     int marknum;
832     /** list of markers */
833     opj_marker_info_t *marker;
834     /** actual size of markers array */
835     int maxmarknum;
836     /** number of tile parts */
837     int num_tps;
838     /** information concerning tile parts */
839     opj_tp_info_t *tp;
840 } opj_tile_info_t;
841
842 /**
843  * Index structure of the codestream
844 */
845 typedef struct opj_codestream_info {
846     /** maximum distortion reduction on the whole image (add for Marcela) */
847     double D_max;
848     /** packet number */
849     int packno;
850     /** writing the packet in the index with t2_encode_packets */
851     int index_write;
852     /** image width */
853     int image_w;
854     /** image height */
855     int image_h;
856     /** progression order */
857     OPJ_PROG_ORDER prog;
858     /** tile size in x */
859     int tile_x;
860     /** tile size in y */
861     int tile_y;
862     /** */
863     int tile_Ox;
864     /** */
865     int tile_Oy;
866     /** number of tiles in X */
867     int tw;
868     /** number of tiles in Y */
869     int th;
870     /** component numbers */
871     int numcomps;
872     /** number of layer */
873     int numlayers;
874     /** number of decomposition for each component */
875     int *numdecompos;
876     /* UniPG>> */
877     /** number of markers */
878     int marknum;
879     /** list of markers */
880     opj_marker_info_t *marker;
881     /** actual size of markers array */
882     int maxmarknum;
883     /* <<UniPG */
884     /** main header position */
885     int main_head_start;
886     /** main header position */
887     int main_head_end;
888     /** codestream's size */
889     int codestream_size;
890     /** information regarding tiles inside image */
891     opj_tile_info_t *tile;
892 } opj_codestream_info_t;
893
894 /* <----------------------------------------------------------- */
895 /* new output management of the codestream information and index */
896
897 /**
898  * Tile-component coding parameters information
899  */
900 typedef struct opj_tccp_info {
901     /** component index */
902     OPJ_UINT32 compno;
903     /** coding style */
904     OPJ_UINT32 csty;
905     /** number of resolutions */
906     OPJ_UINT32 numresolutions;
907     /** log2 of code-blocks width */
908     OPJ_UINT32 cblkw;
909     /** log2 of code-blocks height */
910     OPJ_UINT32 cblkh;
911     /** code-block coding style */
912     OPJ_UINT32 cblksty;
913     /** discrete wavelet transform identifier: 0 = 9-7 irreversible, 1 = 5-3 reversible */
914     OPJ_UINT32 qmfbid;
915     /** quantisation style */
916     OPJ_UINT32 qntsty;
917     /** stepsizes used for quantization */
918     OPJ_UINT32 stepsizes_mant[OPJ_J2K_MAXBANDS];
919     /** stepsizes used for quantization */
920     OPJ_UINT32 stepsizes_expn[OPJ_J2K_MAXBANDS];
921     /** number of guard bits */
922     OPJ_UINT32 numgbits;
923     /** Region Of Interest shift */
924     OPJ_INT32 roishift;
925     /** precinct width */
926     OPJ_UINT32 prcw[OPJ_J2K_MAXRLVLS];
927     /** precinct height */
928     OPJ_UINT32 prch[OPJ_J2K_MAXRLVLS];
929 }
930 opj_tccp_info_t;
931
932 /**
933  * Tile coding parameters information
934  */
935 typedef struct opj_tile_v2_info {
936
937     /** number (index) of tile */
938     int tileno;
939     /** coding style */
940     OPJ_UINT32 csty;
941     /** progression order */
942     OPJ_PROG_ORDER prg;
943     /** number of layers */
944     OPJ_UINT32 numlayers;
945     /** multi-component transform identifier */
946     OPJ_UINT32 mct;
947
948     /** information concerning tile component parameters*/
949     opj_tccp_info_t *tccp_info;
950
951 } opj_tile_info_v2_t;
952
953 /**
954  * Information structure about the codestream (FIXME should be expand and enhance)
955  */
956 typedef struct opj_codestream_info_v2 {
957     /* Tile info */
958     /** tile origin in x = XTOsiz */
959     OPJ_UINT32 tx0;
960     /** tile origin in y = YTOsiz */
961     OPJ_UINT32 ty0;
962     /** tile size in x = XTsiz */
963     OPJ_UINT32 tdx;
964     /** tile size in y = YTsiz */
965     OPJ_UINT32 tdy;
966     /** number of tiles in X */
967     OPJ_UINT32 tw;
968     /** number of tiles in Y */
969     OPJ_UINT32 th;
970
971     /** number of components*/
972     OPJ_UINT32 nbcomps;
973
974     /** Default information regarding tiles inside image */
975     opj_tile_info_v2_t m_default_tile_info;
976
977     /** information regarding tiles inside image */
978     opj_tile_info_v2_t *tile_info; /* FIXME not used for the moment */
979
980 } opj_codestream_info_v2_t;
981
982
983 /**
984  * Index structure about a tile part
985  */
986 typedef struct opj_tp_index {
987     /** start position */
988     OPJ_OFF_T start_pos;
989     /** end position of the header */
990     OPJ_OFF_T end_header;
991     /** end position */
992     OPJ_OFF_T end_pos;
993
994 } opj_tp_index_t;
995
996 /**
997  * Index structure about a tile
998  */
999 typedef struct opj_tile_index {
1000     /** tile index */
1001     OPJ_UINT32 tileno;
1002
1003     /** number of tile parts */
1004     OPJ_UINT32 nb_tps;
1005     /** current nb of tile part (allocated)*/
1006     OPJ_UINT32 current_nb_tps;
1007     /** current tile-part index */
1008     OPJ_UINT32 current_tpsno;
1009     /** information concerning tile parts */
1010     opj_tp_index_t *tp_index;
1011
1012     /* UniPG>> */ /* NOT USED FOR THE MOMENT IN THE V2 VERSION */
1013     /** number of markers */
1014     OPJ_UINT32 marknum;
1015     /** list of markers */
1016     opj_marker_info_t *marker;
1017     /** actual size of markers array */
1018     OPJ_UINT32 maxmarknum;
1019     /* <<UniPG */
1020
1021     /** packet number */
1022     OPJ_UINT32 nb_packet;
1023     /** information concerning packets inside tile */
1024     opj_packet_info_t *packet_index;
1025
1026 } opj_tile_index_t;
1027
1028 /**
1029  * Index structure of the codestream (FIXME should be expand and enhance)
1030  */
1031 typedef struct opj_codestream_index {
1032     /** main header start position (SOC position) */
1033     OPJ_OFF_T main_head_start;
1034     /** main header end position (first SOT position) */
1035     OPJ_OFF_T main_head_end;
1036
1037     /** codestream's size */
1038     OPJ_UINT64 codestream_size;
1039
1040     /* UniPG>> */ /* NOT USED FOR THE MOMENT IN THE V2 VERSION */
1041     /** number of markers */
1042     OPJ_UINT32 marknum;
1043     /** list of markers */
1044     opj_marker_info_t *marker;
1045     /** actual size of markers array */
1046     OPJ_UINT32 maxmarknum;
1047     /* <<UniPG */
1048
1049     /** */
1050     OPJ_UINT32 nb_of_tiles;
1051     /** */
1052     opj_tile_index_t *tile_index; /* FIXME not used for the moment */
1053
1054 } opj_codestream_index_t;
1055 /* -----------------------------------------------------------> */
1056
1057 /*
1058 ==========================================================
1059    Metadata from the JP2file
1060 ==========================================================
1061 */
1062
1063 /**
1064  * Info structure of the JP2 file
1065  * EXPERIMENTAL FOR THE MOMENT
1066  */
1067 typedef struct opj_jp2_metadata {
1068     /** */
1069     OPJ_INT32   not_used;
1070
1071 } opj_jp2_metadata_t;
1072
1073 /**
1074  * Index structure of the JP2 file
1075  * EXPERIMENTAL FOR THE MOMENT
1076  */
1077 typedef struct opj_jp2_index {
1078     /** */
1079     OPJ_INT32   not_used;
1080
1081 } opj_jp2_index_t;
1082
1083
1084 #ifdef __cplusplus
1085 extern "C" {
1086 #endif
1087
1088
1089 /*
1090 ==========================================================
1091    openjpeg version
1092 ==========================================================
1093 */
1094
1095 /* Get the version of the openjpeg library*/
1096 OPJ_API const char * OPJ_CALLCONV opj_version(void);
1097
1098 /*
1099 ==========================================================
1100    image functions definitions
1101 ==========================================================
1102 */
1103
1104 /**
1105  * Create an image
1106  *
1107  * @param numcmpts      number of components
1108  * @param cmptparms     components parameters
1109  * @param clrspc        image color space
1110  * @return returns      a new image structure if successful, returns NULL otherwise
1111  * */
1112 OPJ_API opj_image_t* OPJ_CALLCONV opj_image_create(OPJ_UINT32 numcmpts,
1113         opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc);
1114
1115 /**
1116  * Deallocate any resources associated with an image
1117  *
1118  * @param image         image to be destroyed
1119  */
1120 OPJ_API void OPJ_CALLCONV opj_image_destroy(opj_image_t *image);
1121
1122 /**
1123  * Creates an image without allocating memory for the image (used in the new version of the library).
1124  *
1125  * @param   numcmpts    the number of components
1126  * @param   cmptparms   the components parameters
1127  * @param   clrspc      the image color space
1128  *
1129  * @return  a new image structure if successful, NULL otherwise.
1130 */
1131 OPJ_API opj_image_t* OPJ_CALLCONV opj_image_tile_create(OPJ_UINT32 numcmpts,
1132         opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc);
1133
1134 /**
1135  * Allocator for opj_image_t->comps[].data
1136  * To be paired with opj_image_data_free.
1137  *
1138  * @param   size    number of bytes to allocate
1139  *
1140  * @return  a new pointer if successful, NULL otherwise.
1141  * @since 2.2.0
1142 */
1143 OPJ_API void* OPJ_CALLCONV opj_image_data_alloc(OPJ_SIZE_T size);
1144
1145 /**
1146  * Destructor for opj_image_t->comps[].data
1147  * To be paired with opj_image_data_alloc.
1148  *
1149  * @param   ptr    Pointer to free
1150  *
1151  * @since 2.2.0
1152 */
1153 OPJ_API void OPJ_CALLCONV opj_image_data_free(void* ptr);
1154
1155 /*
1156 ==========================================================
1157    stream functions definitions
1158 ==========================================================
1159 */
1160
1161 /**
1162  * Creates an abstract stream. This function does nothing except allocating memory and initializing the abstract stream.
1163  *
1164  * @param   p_is_input      if set to true then the stream will be an input stream, an output stream else.
1165  *
1166  * @return  a stream object.
1167 */
1168 OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_default_create(
1169     OPJ_BOOL p_is_input);
1170
1171 /**
1172  * Creates an abstract stream. This function does nothing except allocating memory and initializing the abstract stream.
1173  *
1174  * @param   p_buffer_size  FIXME DOC
1175  * @param   p_is_input      if set to true then the stream will be an input stream, an output stream else.
1176  *
1177  * @return  a stream object.
1178 */
1179 OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create(OPJ_SIZE_T p_buffer_size,
1180         OPJ_BOOL p_is_input);
1181
1182 /**
1183  * Destroys a stream created by opj_create_stream. This function does NOT close the abstract stream. If needed the user must
1184  * close its own implementation of the stream.
1185  *
1186  * @param   p_stream    the stream to destroy.
1187  */
1188 OPJ_API void OPJ_CALLCONV opj_stream_destroy(opj_stream_t* p_stream);
1189
1190 /**
1191  * Sets the given function to be used as a read function.
1192  * @param       p_stream    the stream to modify
1193  * @param       p_function  the function to use a read function.
1194 */
1195 OPJ_API void OPJ_CALLCONV opj_stream_set_read_function(opj_stream_t* p_stream,
1196         opj_stream_read_fn p_function);
1197
1198 /**
1199  * Sets the given function to be used as a write function.
1200  * @param       p_stream    the stream to modify
1201  * @param       p_function  the function to use a write function.
1202 */
1203 OPJ_API void OPJ_CALLCONV opj_stream_set_write_function(opj_stream_t* p_stream,
1204         opj_stream_write_fn p_function);
1205
1206 /**
1207  * Sets the given function to be used as a skip function.
1208  * @param       p_stream    the stream to modify
1209  * @param       p_function  the function to use a skip function.
1210 */
1211 OPJ_API void OPJ_CALLCONV opj_stream_set_skip_function(opj_stream_t* p_stream,
1212         opj_stream_skip_fn p_function);
1213
1214 /**
1215  * Sets the given function to be used as a seek function, the stream is then seekable,
1216  * using SEEK_SET behavior.
1217  * @param       p_stream    the stream to modify
1218  * @param       p_function  the function to use a skip function.
1219 */
1220 OPJ_API void OPJ_CALLCONV opj_stream_set_seek_function(opj_stream_t* p_stream,
1221         opj_stream_seek_fn p_function);
1222
1223 /**
1224  * Sets the given data to be used as a user data for the stream.
1225  * @param       p_stream    the stream to modify
1226  * @param       p_data      the data to set.
1227  * @param       p_function  the function to free p_data when opj_stream_destroy() is called.
1228 */
1229 OPJ_API void OPJ_CALLCONV opj_stream_set_user_data(opj_stream_t* p_stream,
1230         void * p_data, opj_stream_free_user_data_fn p_function);
1231
1232 /**
1233  * Sets the length of the user data for the stream.
1234  *
1235  * @param p_stream    the stream to modify
1236  * @param data_length length of the user_data.
1237 */
1238 OPJ_API void OPJ_CALLCONV opj_stream_set_user_data_length(
1239     opj_stream_t* p_stream, OPJ_UINT64 data_length);
1240
1241 /**
1242  * Create a stream from a file identified with its filename with default parameters (helper function)
1243  * @param fname             the filename of the file to stream
1244  * @param p_is_read_stream  whether the stream is a read stream (true) or not (false)
1245 */
1246 OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create_default_file_stream(
1247     const char *fname, OPJ_BOOL p_is_read_stream);
1248
1249 /** Create a stream from a file identified with its filename with a specific buffer size
1250  * @param fname             the filename of the file to stream
1251  * @param p_buffer_size     size of the chunk used to stream
1252  * @param p_is_read_stream  whether the stream is a read stream (true) or not (false)
1253 */
1254 OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream(
1255     const char *fname,
1256     OPJ_SIZE_T p_buffer_size,
1257     OPJ_BOOL p_is_read_stream);
1258
1259 /*
1260 ==========================================================
1261    event manager functions definitions
1262 ==========================================================
1263 */
1264 /**
1265  * Set the info handler use by openjpeg.
1266  * @param p_codec       the codec previously initialise
1267  * @param p_callback    the callback function which will be used
1268  * @param p_user_data   client object where will be returned the message
1269 */
1270 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_info_handler(opj_codec_t * p_codec,
1271         opj_msg_callback p_callback,
1272         void * p_user_data);
1273 /**
1274  * Set the warning handler use by openjpeg.
1275  * @param p_codec       the codec previously initialise
1276  * @param p_callback    the callback function which will be used
1277  * @param p_user_data   client object where will be returned the message
1278 */
1279 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_warning_handler(opj_codec_t * p_codec,
1280         opj_msg_callback p_callback,
1281         void * p_user_data);
1282 /**
1283  * Set the error handler use by openjpeg.
1284  * @param p_codec       the codec previously initialise
1285  * @param p_callback    the callback function which will be used
1286  * @param p_user_data   client object where will be returned the message
1287 */
1288 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_error_handler(opj_codec_t * p_codec,
1289         opj_msg_callback p_callback,
1290         void * p_user_data);
1291
1292 /*
1293 ==========================================================
1294    codec functions definitions
1295 ==========================================================
1296 */
1297
1298 /**
1299  * Creates a J2K/JP2 decompression structure
1300  * @param format        Decoder to select
1301  *
1302  * @return Returns a handle to a decompressor if successful, returns NULL otherwise
1303  * */
1304 OPJ_API opj_codec_t* OPJ_CALLCONV opj_create_decompress(
1305     OPJ_CODEC_FORMAT format);
1306
1307 /**
1308  * Destroy a decompressor handle
1309  *
1310  * @param   p_codec         decompressor handle to destroy
1311  */
1312 OPJ_API void OPJ_CALLCONV opj_destroy_codec(opj_codec_t * p_codec);
1313
1314 /**
1315  * Read after the codestream if necessary
1316  * @param   p_codec         the JPEG2000 codec to read.
1317  * @param   p_stream        the JPEG2000 stream.
1318  */
1319 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_end_decompress(opj_codec_t *p_codec,
1320         opj_stream_t *p_stream);
1321
1322
1323 /**
1324  * Set decoding parameters to default values
1325  * @param parameters Decompression parameters
1326  */
1327 OPJ_API void OPJ_CALLCONV opj_set_default_decoder_parameters(
1328     opj_dparameters_t *parameters);
1329
1330 /**
1331  * Setup the decoder with decompression parameters provided by the user and with the message handler
1332  * provided by the user.
1333  *
1334  * @param p_codec       decompressor handler
1335  * @param parameters    decompression parameters
1336  *
1337  * @return true         if the decoder is correctly set
1338  */
1339 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_setup_decoder(opj_codec_t *p_codec,
1340         opj_dparameters_t *parameters);
1341
1342 /**
1343  * Allocates worker threads for the compressor/decompressor.
1344  *
1345  * By default, only the main thread is used. If this function is not used,
1346  * but the OPJ_NUM_THREADS environment variable is set, its value will be
1347  * used to initialize the number of threads. The value can be either an integer
1348  * number, or "ALL_CPUS". If OPJ_NUM_THREADS is set and this function is called,
1349  * this function will override the behaviour of the environment variable.
1350  *
1351  * This function must be called after opj_setup_decoder() and
1352  * before opj_read_header() for the decoding side, or after opj_setup_encoder()
1353  * and before opj_start_compress() for the encoding side.
1354  *
1355  * @param p_codec       decompressor or compressor handler
1356  * @param num_threads   number of threads.
1357  *
1358  * @return OPJ_TRUE     if the function is successful.
1359  */
1360 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_codec_set_threads(opj_codec_t *p_codec,
1361         int num_threads);
1362
1363 /**
1364  * Decodes an image header.
1365  *
1366  * @param   p_stream        the jpeg2000 stream.
1367  * @param   p_codec         the jpeg2000 codec to read.
1368  * @param   p_image         the image structure initialized with the characteristics of encoded image.
1369  *
1370  * @return true             if the main header of the codestream and the JP2 header is correctly read.
1371  */
1372 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_read_header(opj_stream_t *p_stream,
1373         opj_codec_t *p_codec,
1374         opj_image_t **p_image);
1375
1376
1377 /** Restrict the number of components to decode.
1378  *
1379  * This function should be called after opj_read_header().
1380  *
1381  * This function enables to restrict the set of decoded components to the
1382  * specified indices.
1383  * Note that the current implementation (apply_color_transforms == OPJ_FALSE)
1384  * is such that neither the multi-component transform at codestream level,
1385  * nor JP2 channel transformations will be applied.
1386  * Consequently the indices are relative to the codestream.
1387  *
1388  * Note: opj_decode_tile_data() should not be used together with opj_set_decoded_components().
1389  *
1390  * @param   p_codec         the jpeg2000 codec to read.
1391  * @param   numcomps        Size of the comps_indices array.
1392  * @param   comps_indices   Array of numcomps values representing the indices
1393  *                          of the components to decode (relative to the
1394  *                          codestream, starting at 0)
1395  * @param   apply_color_transforms Whether multi-component transform at codestream level
1396  *                                 or JP2 channel transformations should be applied.
1397  *                                 Currently this parameter should be set to OPJ_FALSE.
1398  *                                 Setting it to OPJ_TRUE will result in an error.
1399  *
1400  * @return OPJ_TRUE         in case of success.
1401  */
1402 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_decoded_components(opj_codec_t *p_codec,
1403         OPJ_UINT32 numcomps,
1404         const OPJ_UINT32* comps_indices,
1405         OPJ_BOOL apply_color_transforms);
1406
1407 /**
1408  * Sets the given area to be decoded. This function should be called right after opj_read_header and before any tile header reading.
1409  *
1410  * The coordinates passed to this function should be expressed in the reference grid,
1411  * that is to say at the highest resolution level, even if requesting the image at lower
1412  * resolution levels.
1413  *
1414  * Generally opj_set_decode_area() should be followed by opj_decode(), and the
1415  * codec cannot be re-used.
1416  * In the particular case of an image made of a single tile, several sequences of
1417  * calls to opoj_set_decode_area() and opj_decode() are allowed, and will bring
1418  * performance improvements when reading an image by chunks.
1419  *
1420  * @param   p_codec         the jpeg2000 codec.
1421  * @param   p_image         the decoded image previously set by opj_read_header
1422  * @param   p_start_x       the left position of the rectangle to decode (in image coordinates).
1423  * @param   p_end_x         the right position of the rectangle to decode (in image coordinates).
1424  * @param   p_start_y       the up position of the rectangle to decode (in image coordinates).
1425  * @param   p_end_y         the bottom position of the rectangle to decode (in image coordinates).
1426  *
1427  * @return  true            if the area could be set.
1428  */
1429 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_decode_area(opj_codec_t *p_codec,
1430         opj_image_t* p_image,
1431         OPJ_INT32 p_start_x, OPJ_INT32 p_start_y,
1432         OPJ_INT32 p_end_x, OPJ_INT32 p_end_y);
1433
1434 /**
1435  * Decode an image from a JPEG-2000 codestream
1436  *
1437  * @param p_decompressor    decompressor handle
1438  * @param p_stream          Input buffer stream
1439  * @param p_image           the decoded image
1440  * @return                  true if success, otherwise false
1441  * */
1442 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_decode(opj_codec_t *p_decompressor,
1443         opj_stream_t *p_stream,
1444         opj_image_t *p_image);
1445
1446 /**
1447  * Get the decoded tile from the codec
1448  *
1449  * @param   p_codec         the jpeg2000 codec.
1450  * @param   p_stream        input streamm
1451  * @param   p_image         output image
1452  * @param   tile_index      index of the tile which will be decode
1453  *
1454  * @return                  true if success, otherwise false
1455  */
1456 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_get_decoded_tile(opj_codec_t *p_codec,
1457         opj_stream_t *p_stream,
1458         opj_image_t *p_image,
1459         OPJ_UINT32 tile_index);
1460
1461 /**
1462  * Set the resolution factor of the decoded image
1463  * @param   p_codec         the jpeg2000 codec.
1464  * @param   res_factor      resolution factor to set
1465  *
1466  * @return                  true if success, otherwise false
1467  */
1468 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_decoded_resolution_factor(
1469     opj_codec_t *p_codec, OPJ_UINT32 res_factor);
1470
1471 /**
1472  * Writes a tile with the given data.
1473  *
1474  * @param   p_codec             the jpeg2000 codec.
1475  * @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.
1476  * @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.
1477  * @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
1478  *                              tile_width * tile_height * component_size. component_size can be 1,2 or 4 bytes, depending on the precision of the given component.
1479  * @param   p_stream            the stream to write data to.
1480  *
1481  * @return  true if the data could be written.
1482  */
1483 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_write_tile(opj_codec_t *p_codec,
1484         OPJ_UINT32 p_tile_index,
1485         OPJ_BYTE * p_data,
1486         OPJ_UINT32 p_data_size,
1487         opj_stream_t *p_stream);
1488
1489 /**
1490  * Reads a tile header. This function is compulsory and allows one to know the size of the tile that will be decoded.
1491  * The user may need to refer to the image got by opj_read_header to understand the size being taken by the tile.
1492  *
1493  * @param   p_codec         the jpeg2000 codec.
1494  * @param   p_tile_index    pointer to a value that will hold the index of the tile being decoded, in case of success.
1495  * @param   p_data_size     pointer to a value that will hold the maximum size of the decoded data, in case of success. In case
1496  *                          of truncated codestreams, the actual number of bytes decoded may be lower. The computation of the size is the same
1497  *                          as depicted in opj_write_tile.
1498  * @param   p_tile_x0       pointer to a value that will hold the x0 pos of the tile (in the image).
1499  * @param   p_tile_y0       pointer to a value that will hold the y0 pos of the tile (in the image).
1500  * @param   p_tile_x1       pointer to a value that will hold the x1 pos of the tile (in the image).
1501  * @param   p_tile_y1       pointer to a value that will hold the y1 pos of the tile (in the image).
1502  * @param   p_nb_comps      pointer to a value that will hold the number of components in the tile.
1503  * @param   p_should_go_on  pointer to a boolean that will hold the fact that the decoding should go on. In case the
1504  *                          codestream is over at the time of the call, the value will be set to false. The user should then stop
1505  *                          the decoding.
1506  * @param   p_stream        the stream to decode.
1507  * @return  true            if the tile header could be decoded. In case the decoding should end, the returned value is still true.
1508  *                          returning false may be the result of a shortage of memory or an internal error.
1509  */
1510 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_read_tile_header(opj_codec_t *p_codec,
1511         opj_stream_t * p_stream,
1512         OPJ_UINT32 * p_tile_index,
1513         OPJ_UINT32 * p_data_size,
1514         OPJ_INT32 * p_tile_x0, OPJ_INT32 * p_tile_y0,
1515         OPJ_INT32 * p_tile_x1, OPJ_INT32 * p_tile_y1,
1516         OPJ_UINT32 * p_nb_comps,
1517         OPJ_BOOL * p_should_go_on);
1518
1519 /**
1520  * Reads a tile data. This function is compulsory and allows one to decode tile data. opj_read_tile_header should be called before.
1521  * The user may need to refer to the image got by opj_read_header to understand the size being taken by the tile.
1522  *
1523  * Note: opj_decode_tile_data() should not be used together with opj_set_decoded_components().
1524  *
1525  * @param   p_codec         the jpeg2000 codec.
1526  * @param   p_tile_index    the index of the tile being decoded, this should be the value set by opj_read_tile_header.
1527  * @param   p_data          pointer to a memory block that will hold the decoded data.
1528  * @param   p_data_size     size of p_data. p_data_size should be bigger or equal to the value set by opj_read_tile_header.
1529  * @param   p_stream        the stream to decode.
1530  *
1531  * @return  true            if the data could be decoded.
1532  */
1533 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_decode_tile_data(opj_codec_t *p_codec,
1534         OPJ_UINT32 p_tile_index,
1535         OPJ_BYTE * p_data,
1536         OPJ_UINT32 p_data_size,
1537         opj_stream_t *p_stream);
1538
1539 /* COMPRESSION FUNCTIONS*/
1540
1541 /**
1542  * Creates a J2K/JP2 compression structure
1543  * @param   format      Coder to select
1544  * @return              Returns a handle to a compressor if successful, returns NULL otherwise
1545  */
1546 OPJ_API opj_codec_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format);
1547
1548 /**
1549 Set encoding parameters to default values, that means :
1550 <ul>
1551 <li>Lossless
1552 <li>1 tile
1553 <li>Size of precinct : 2^15 x 2^15 (means 1 precinct)
1554 <li>Size of code-block : 64 x 64
1555 <li>Number of resolutions: 6
1556 <li>No SOP marker in the codestream
1557 <li>No EPH marker in the codestream
1558 <li>No sub-sampling in x or y direction
1559 <li>No mode switch activated
1560 <li>Progression order: LRCP
1561 <li>No index file
1562 <li>No ROI upshifted
1563 <li>No offset of the origin of the image
1564 <li>No offset of the origin of the tiles
1565 <li>Reversible DWT 5-3
1566 </ul>
1567 @param parameters Compression parameters
1568 */
1569 OPJ_API void OPJ_CALLCONV opj_set_default_encoder_parameters(
1570     opj_cparameters_t *parameters);
1571
1572 /**
1573  * Setup the encoder parameters using the current image and using user parameters.
1574  * @param p_codec       Compressor handle
1575  * @param parameters    Compression parameters
1576  * @param image         Input filled image
1577  */
1578 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_setup_encoder(opj_codec_t *p_codec,
1579         opj_cparameters_t *parameters,
1580         opj_image_t *image);
1581
1582
1583 /**
1584  * Specify extra options for the encoder.
1585  *
1586  * This may be called after opj_setup_encoder() and before opj_start_compress()
1587  *
1588  * This is the way to add new options in a fully ABI compatible way, without
1589  * extending the opj_cparameters_t structure.
1590  *
1591  * Currently supported options are:
1592  * <ul>
1593  * <li>PLT=YES/NO. Defaults to NO. If set to YES, PLT marker segments,
1594  *     indicating the length of each packet in the tile-part header, will be
1595  *     written. Since 2.3.2</li>
1596  * </ul>
1597  *
1598  * @param p_codec       Compressor handle
1599  * @param p_options     Compression options. This should be a NULL terminated
1600  *                      array of strings. Each string is of the form KEY=VALUE.
1601  *
1602  * @return OPJ_TRUE in case of success.
1603  * @since 2.3.2
1604  */
1605 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_encoder_set_extra_options(
1606     opj_codec_t *p_codec,
1607     const char* const* p_options);
1608
1609 /**
1610  * Start to compress the current image.
1611  * @param p_codec       Compressor handle
1612  * @param p_image       Input filled image
1613  * @param p_stream      Input stgream
1614  */
1615 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_start_compress(opj_codec_t *p_codec,
1616         opj_image_t * p_image,
1617         opj_stream_t *p_stream);
1618
1619 /**
1620  * End to compress the current image.
1621  * @param p_codec       Compressor handle
1622  * @param p_stream      Input stgream
1623  */
1624 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_end_compress(opj_codec_t *p_codec,
1625         opj_stream_t *p_stream);
1626
1627 /**
1628  * Encode an image into a JPEG-2000 codestream
1629  * @param p_codec       compressor handle
1630  * @param p_stream      Output buffer stream
1631  *
1632  * @return              Returns true if successful, returns false otherwise
1633  */
1634 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_encode(opj_codec_t *p_codec,
1635         opj_stream_t *p_stream);
1636 /*
1637 ==========================================================
1638    codec output functions definitions
1639 ==========================================================
1640 */
1641 /* EXPERIMENTAL FUNCTIONS FOR NOW, USED ONLY IN J2K_DUMP*/
1642
1643 /**
1644 Destroy Codestream information after compression or decompression
1645 @param cstr_info Codestream information structure
1646 */
1647 OPJ_API void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_v2_t
1648         **cstr_info);
1649
1650
1651 /**
1652  * Dump the codec information into the output stream
1653  *
1654  * @param   p_codec         the jpeg2000 codec.
1655  * @param   info_flag       type of information dump.
1656  * @param   output_stream   output stream where dump the information gotten from the codec.
1657  *
1658  */
1659 OPJ_API void OPJ_CALLCONV opj_dump_codec(opj_codec_t *p_codec,
1660         OPJ_INT32 info_flag,
1661         FILE* output_stream);
1662
1663 /**
1664  * Get the codestream information from the codec
1665  *
1666  * @param   p_codec         the jpeg2000 codec.
1667  *
1668  * @return                  a pointer to a codestream information structure.
1669  *
1670  */
1671 OPJ_API opj_codestream_info_v2_t* OPJ_CALLCONV opj_get_cstr_info(
1672     opj_codec_t *p_codec);
1673
1674 /**
1675  * Get the codestream index from the codec
1676  *
1677  * @param   p_codec         the jpeg2000 codec.
1678  *
1679  * @return                  a pointer to a codestream index structure.
1680  *
1681  */
1682 OPJ_API opj_codestream_index_t * OPJ_CALLCONV opj_get_cstr_index(
1683     opj_codec_t *p_codec);
1684
1685 OPJ_API void OPJ_CALLCONV opj_destroy_cstr_index(opj_codestream_index_t
1686         **p_cstr_index);
1687
1688
1689 /**
1690  * Get the JP2 file information from the codec FIXME
1691  *
1692  * @param   p_codec         the jpeg2000 codec.
1693  *
1694  * @return                  a pointer to a JP2 metadata structure.
1695  *
1696  */
1697 OPJ_API opj_jp2_metadata_t* OPJ_CALLCONV opj_get_jp2_metadata(
1698     opj_codec_t *p_codec);
1699
1700 /**
1701  * Get the JP2 file index from the codec FIXME
1702  *
1703  * @param   p_codec         the jpeg2000 codec.
1704  *
1705  * @return                  a pointer to a JP2 index structure.
1706  *
1707  */
1708 OPJ_API opj_jp2_index_t* OPJ_CALLCONV opj_get_jp2_index(opj_codec_t *p_codec);
1709
1710
1711 /*
1712 ==========================================================
1713    MCT functions
1714 ==========================================================
1715 */
1716
1717 /**
1718  * Sets the MCT matrix to use.
1719  *
1720  * @param   parameters      the parameters to change.
1721  * @param   pEncodingMatrix the encoding matrix.
1722  * @param   p_dc_shift      the dc shift coefficients to use.
1723  * @param   pNbComp         the number of components of the image.
1724  *
1725  * @return  true if the parameters could be set.
1726  */
1727 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_MCT(opj_cparameters_t *parameters,
1728         OPJ_FLOAT32 * pEncodingMatrix,
1729         OPJ_INT32 * p_dc_shift,
1730         OPJ_UINT32 pNbComp);
1731
1732 /*
1733 ==========================================================
1734    Thread functions
1735 ==========================================================
1736 */
1737
1738 /** Returns if the library is built with thread support.
1739  * OPJ_TRUE if mutex, condition, thread, thread pool are available.
1740  */
1741 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_has_thread_support(void);
1742
1743 /** Return the number of virtual CPUs */
1744 OPJ_API int OPJ_CALLCONV opj_get_num_cpus(void);
1745
1746
1747 #ifdef __cplusplus
1748 }
1749 #endif
1750
1751 #endif /* OPENJPEG_H */