Implement writing of IMF profiles
[openjpeg.git] / src / lib / openjp2 / 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 /**
352  * Progression order changes
353  *
354  */
355 typedef struct opj_poc {
356     /** Resolution num start, Component num start, given by POC */
357     OPJ_UINT32 resno0, compno0;
358     /** Layer num end,Resolution num end, Component num end, given by POC */
359     OPJ_UINT32 layno1, resno1, compno1;
360     /** Layer num start,Precinct num start, Precinct num end */
361     OPJ_UINT32 layno0, precno0, precno1;
362     /** Progression order enum*/
363     OPJ_PROG_ORDER prg1, prg;
364     /** Progression order string*/
365     OPJ_CHAR progorder[5];
366     /** Tile number (starting at 1) */
367     OPJ_UINT32 tile;
368     /** Start and end values for Tile width and height*/
369     OPJ_INT32 tx0, tx1, ty0, ty1;
370     /** Start value, initialised in pi_initialise_encode*/
371     OPJ_UINT32 layS, resS, compS, prcS;
372     /** End value, initialised in pi_initialise_encode */
373     OPJ_UINT32 layE, resE, compE, prcE;
374     /** Start and end values of Tile width and height, initialised in pi_initialise_encode*/
375     OPJ_UINT32 txS, txE, tyS, tyE, dx, dy;
376     /** Temporary values for Tile parts, initialised in pi_create_encode */
377     OPJ_UINT32 lay_t, res_t, comp_t, prc_t, tx0_t, ty0_t;
378 } opj_poc_t;
379
380 /**
381  * Compression parameters
382  * */
383 typedef struct opj_cparameters {
384     /** size of tile: tile_size_on = false (not in argument) or = true (in argument) */
385     OPJ_BOOL tile_size_on;
386     /** XTOsiz */
387     int cp_tx0;
388     /** YTOsiz */
389     int cp_ty0;
390     /** XTsiz */
391     int cp_tdx;
392     /** YTsiz */
393     int cp_tdy;
394     /** allocation by rate/distortion */
395     int cp_disto_alloc;
396     /** allocation by fixed layer */
397     int cp_fixed_alloc;
398     /** add fixed_quality */
399     int cp_fixed_quality;
400     /** fixed layer */
401     int *cp_matrice;
402     /** comment for coding */
403     char *cp_comment;
404     /** csty : coding style */
405     int csty;
406     /** progression order (default OPJ_LRCP) */
407     OPJ_PROG_ORDER prog_order;
408     /** progression order changes */
409     opj_poc_t POC[32];
410     /** number of progression order changes (POC), default to 0 */
411     OPJ_UINT32 numpocs;
412     /** number of layers */
413     int tcp_numlayers;
414     /** rates of layers - might be subsequently limited by the max_cs_size field.
415      * Should be decreasing. 1 can be
416      * used as last value to indicate the last layer is lossless. */
417     float tcp_rates[100];
418     /** different psnr for successive layers. Should be increasing. 0 can be
419      * used as last value to indicate the last layer is lossless. */
420     float tcp_distoratio[100];
421     /** number of resolutions */
422     int numresolution;
423     /** initial code block width, default to 64 */
424     int cblockw_init;
425     /** initial code block height, default to 64 */
426     int cblockh_init;
427     /** mode switch (cblk_style) */
428     int mode;
429     /** 1 : use the irreversible DWT 9-7, 0 : use lossless compression (default) */
430     int irreversible;
431     /** region of interest: affected component in [0..3], -1 means no ROI */
432     int roi_compno;
433     /** region of interest: upshift value */
434     int roi_shift;
435     /* number of precinct size specifications */
436     int res_spec;
437     /** initial precinct width */
438     int prcw_init[OPJ_J2K_MAXRLVLS];
439     /** initial precinct height */
440     int prch_init[OPJ_J2K_MAXRLVLS];
441
442     /**@name command line encoder parameters (not used inside the library) */
443     /*@{*/
444     /** input file name */
445     char infile[OPJ_PATH_LEN];
446     /** output file name */
447     char outfile[OPJ_PATH_LEN];
448     /** DEPRECATED. Index generation is now handeld with the opj_encode_with_info() function. Set to NULL */
449     int index_on;
450     /** DEPRECATED. Index generation is now handeld with the opj_encode_with_info() function. Set to NULL */
451     char index[OPJ_PATH_LEN];
452     /** subimage encoding: origin image offset in x direction */
453     int image_offset_x0;
454     /** subimage encoding: origin image offset in y direction */
455     int image_offset_y0;
456     /** subsampling value for dx */
457     int subsampling_dx;
458     /** subsampling value for dy */
459     int subsampling_dy;
460     /** input file format 0: PGX, 1: PxM, 2: BMP 3:TIF*/
461     int decod_format;
462     /** output file format 0: J2K, 1: JP2, 2: JPT */
463     int cod_format;
464     /*@}*/
465
466     /* UniPG>> */ /* NOT YET USED IN THE V2 VERSION OF OPENJPEG */
467     /**@name JPWL encoding parameters */
468     /*@{*/
469     /** enables writing of EPC in MH, thus activating JPWL */
470     OPJ_BOOL jpwl_epc_on;
471     /** error protection method for MH (0,1,16,32,37-128) */
472     int jpwl_hprot_MH;
473     /** tile number of header protection specification (>=0) */
474     int jpwl_hprot_TPH_tileno[JPWL_MAX_NO_TILESPECS];
475     /** error protection methods for TPHs (0,1,16,32,37-128) */
476     int jpwl_hprot_TPH[JPWL_MAX_NO_TILESPECS];
477     /** tile number of packet protection specification (>=0) */
478     int jpwl_pprot_tileno[JPWL_MAX_NO_PACKSPECS];
479     /** packet number of packet protection specification (>=0) */
480     int jpwl_pprot_packno[JPWL_MAX_NO_PACKSPECS];
481     /** error protection methods for packets (0,1,16,32,37-128) */
482     int jpwl_pprot[JPWL_MAX_NO_PACKSPECS];
483     /** enables writing of ESD, (0=no/1/2 bytes) */
484     int jpwl_sens_size;
485     /** sensitivity addressing size (0=auto/2/4 bytes) */
486     int jpwl_sens_addr;
487     /** sensitivity range (0-3) */
488     int jpwl_sens_range;
489     /** sensitivity method for MH (-1=no,0-7) */
490     int jpwl_sens_MH;
491     /** tile number of sensitivity specification (>=0) */
492     int jpwl_sens_TPH_tileno[JPWL_MAX_NO_TILESPECS];
493     /** sensitivity methods for TPHs (-1=no,0-7) */
494     int jpwl_sens_TPH[JPWL_MAX_NO_TILESPECS];
495     /*@}*/
496     /* <<UniPG */
497
498     /**
499      * DEPRECATED: use RSIZ, OPJ_PROFILE_* and MAX_COMP_SIZE instead
500      * Digital Cinema compliance 0-not compliant, 1-compliant
501      * */
502     OPJ_CINEMA_MODE cp_cinema;
503     /**
504      * Maximum size (in bytes) for each component.
505      * If == 0, component size limitation is not considered
506      * */
507     int max_comp_size;
508     /**
509      * DEPRECATED: use RSIZ, OPJ_PROFILE_* and OPJ_EXTENSION_* instead
510      * Profile name
511      * */
512     OPJ_RSIZ_CAPABILITIES cp_rsiz;
513     /** Tile part generation*/
514     char tp_on;
515     /** Flag for Tile part generation*/
516     char tp_flag;
517     /** MCT (multiple component transform) */
518     char tcp_mct;
519     /** Enable JPIP indexing*/
520     OPJ_BOOL jpip_on;
521     /** Naive implementation of MCT restricted to a single reversible array based
522         encoding without offset concerning all the components. */
523     void * mct_data;
524     /**
525      * Maximum size (in bytes) for the whole codestream.
526      * If == 0, codestream size limitation is not considered
527      * If it does not comply with tcp_rates, max_cs_size prevails
528      * and a warning is issued.
529      * */
530     int max_cs_size;
531     /** RSIZ value
532         To be used to combine OPJ_PROFILE_*, OPJ_EXTENSION_* and (sub)levels values. */
533     OPJ_UINT16 rsiz;
534 } opj_cparameters_t;
535
536 #define OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG  0x0001
537 #define OPJ_DPARAMETERS_DUMP_FLAG 0x0002
538
539 /**
540  * Decompression parameters
541  * */
542 typedef struct opj_dparameters {
543     /**
544     Set the number of highest resolution levels to be discarded.
545     The image resolution is effectively divided by 2 to the power of the number of discarded levels.
546     The reduce factor is limited by the smallest total number of decomposition levels among tiles.
547     if != 0, then original dimension divided by 2^(reduce);
548     if == 0 or not used, image is decoded to the full resolution
549     */
550     OPJ_UINT32 cp_reduce;
551     /**
552     Set the maximum number of quality layers to decode.
553     If there are less quality layers than the specified number, all the quality layers are decoded.
554     if != 0, then only the first "layer" layers are decoded;
555     if == 0 or not used, all the quality layers are decoded
556     */
557     OPJ_UINT32 cp_layer;
558
559     /**@name command line decoder parameters (not used inside the library) */
560     /*@{*/
561     /** input file name */
562     char infile[OPJ_PATH_LEN];
563     /** output file name */
564     char outfile[OPJ_PATH_LEN];
565     /** input file format 0: J2K, 1: JP2, 2: JPT */
566     int decod_format;
567     /** output file format 0: PGX, 1: PxM, 2: BMP */
568     int cod_format;
569
570     /** Decoding area left boundary */
571     OPJ_UINT32 DA_x0;
572     /** Decoding area right boundary */
573     OPJ_UINT32 DA_x1;
574     /** Decoding area up boundary */
575     OPJ_UINT32 DA_y0;
576     /** Decoding area bottom boundary */
577     OPJ_UINT32 DA_y1;
578     /** Verbose mode */
579     OPJ_BOOL m_verbose;
580
581     /** tile number of the decoded tile */
582     OPJ_UINT32 tile_index;
583     /** Nb of tile to decode */
584     OPJ_UINT32 nb_tile_to_decode;
585
586     /*@}*/
587
588     /* UniPG>> */ /* NOT YET USED IN THE V2 VERSION OF OPENJPEG */
589     /**@name JPWL decoding parameters */
590     /*@{*/
591     /** activates the JPWL correction capabilities */
592     OPJ_BOOL jpwl_correct;
593     /** expected number of components */
594     int jpwl_exp_comps;
595     /** maximum number of tiles */
596     int jpwl_max_tiles;
597     /*@}*/
598     /* <<UniPG */
599
600     unsigned int flags;
601
602 } opj_dparameters_t;
603
604
605 /**
606  * JPEG2000 codec V2.
607  * */
608 typedef void * opj_codec_t;
609
610 /*
611 ==========================================================
612    I/O stream typedef definitions
613 ==========================================================
614 */
615
616 /**
617  * Stream open flags.
618  * */
619 /** The stream was opened for reading. */
620 #define OPJ_STREAM_READ OPJ_TRUE
621 /** The stream was opened for writing. */
622 #define OPJ_STREAM_WRITE OPJ_FALSE
623
624 /*
625  * Callback function prototype for read function
626  */
627 typedef OPJ_SIZE_T(* opj_stream_read_fn)(void * p_buffer, OPJ_SIZE_T p_nb_bytes,
628         void * p_user_data) ;
629
630 /*
631  * Callback function prototype for write function
632  */
633 typedef OPJ_SIZE_T(* opj_stream_write_fn)(void * p_buffer,
634         OPJ_SIZE_T p_nb_bytes, void * p_user_data) ;
635
636 /*
637  * Callback function prototype for skip function
638  */
639 typedef OPJ_OFF_T(* opj_stream_skip_fn)(OPJ_OFF_T p_nb_bytes,
640                                         void * p_user_data) ;
641
642 /*
643  * Callback function prototype for seek function
644  */
645 typedef OPJ_BOOL(* opj_stream_seek_fn)(OPJ_OFF_T p_nb_bytes,
646                                        void * p_user_data) ;
647
648 /*
649  * Callback function prototype for free user data function
650  */
651 typedef void (* opj_stream_free_user_data_fn)(void * p_user_data) ;
652
653 /*
654  * JPEG2000 Stream.
655  */
656 typedef void * opj_stream_t;
657
658 /*
659 ==========================================================
660    image typedef definitions
661 ==========================================================
662 */
663
664 /**
665  * Defines a single image component
666  * */
667 typedef struct opj_image_comp {
668     /** XRsiz: horizontal separation of a sample of ith component with respect to the reference grid */
669     OPJ_UINT32 dx;
670     /** YRsiz: vertical separation of a sample of ith component with respect to the reference grid */
671     OPJ_UINT32 dy;
672     /** data width */
673     OPJ_UINT32 w;
674     /** data height */
675     OPJ_UINT32 h;
676     /** x component offset compared to the whole image */
677     OPJ_UINT32 x0;
678     /** y component offset compared to the whole image */
679     OPJ_UINT32 y0;
680     /** precision */
681     OPJ_UINT32 prec;
682     /** image depth in bits */
683     OPJ_UINT32 bpp;
684     /** signed (1) / unsigned (0) */
685     OPJ_UINT32 sgnd;
686     /** number of decoded resolution */
687     OPJ_UINT32 resno_decoded;
688     /** number of division by 2 of the out image compared to the original size of image */
689     OPJ_UINT32 factor;
690     /** image component data */
691     OPJ_INT32 *data;
692     /** alpha channel */
693     OPJ_UINT16 alpha;
694 } opj_image_comp_t;
695
696 /**
697  * Defines image data and characteristics
698  * */
699 typedef struct opj_image {
700     /** XOsiz: horizontal offset from the origin of the reference grid to the left side of the image area */
701     OPJ_UINT32 x0;
702     /** YOsiz: vertical offset from the origin of the reference grid to the top side of the image area */
703     OPJ_UINT32 y0;
704     /** Xsiz: width of the reference grid */
705     OPJ_UINT32 x1;
706     /** Ysiz: height of the reference grid */
707     OPJ_UINT32 y1;
708     /** number of components in the image */
709     OPJ_UINT32 numcomps;
710     /** color space: sRGB, Greyscale or YUV */
711     OPJ_COLOR_SPACE color_space;
712     /** image components */
713     opj_image_comp_t *comps;
714     /** 'restricted' ICC profile */
715     OPJ_BYTE *icc_profile_buf;
716     /** size of ICC profile */
717     OPJ_UINT32 icc_profile_len;
718 } opj_image_t;
719
720
721 /**
722  * Component parameters structure used by the opj_image_create function
723  * */
724 typedef struct opj_image_comptparm {
725     /** XRsiz: horizontal separation of a sample of ith component with respect to the reference grid */
726     OPJ_UINT32 dx;
727     /** YRsiz: vertical separation of a sample of ith component with respect to the reference grid */
728     OPJ_UINT32 dy;
729     /** data width */
730     OPJ_UINT32 w;
731     /** data height */
732     OPJ_UINT32 h;
733     /** x component offset compared to the whole image */
734     OPJ_UINT32 x0;
735     /** y component offset compared to the whole image */
736     OPJ_UINT32 y0;
737     /** precision */
738     OPJ_UINT32 prec;
739     /** image depth in bits */
740     OPJ_UINT32 bpp;
741     /** signed (1) / unsigned (0) */
742     OPJ_UINT32 sgnd;
743 } opj_image_cmptparm_t;
744
745
746 /*
747 ==========================================================
748    Information on the JPEG 2000 codestream
749 ==========================================================
750 */
751 /* QUITE EXPERIMENTAL FOR THE MOMENT */
752
753 /**
754  * Index structure : Information concerning a packet inside tile
755  * */
756 typedef struct opj_packet_info {
757     /** packet start position (including SOP marker if it exists) */
758     OPJ_OFF_T start_pos;
759     /** end of packet header position (including EPH marker if it exists)*/
760     OPJ_OFF_T end_ph_pos;
761     /** packet end position */
762     OPJ_OFF_T end_pos;
763     /** packet distorsion */
764     double disto;
765 } opj_packet_info_t;
766
767
768 /* UniPG>> */
769 /**
770  * Marker structure
771  * */
772 typedef struct opj_marker_info {
773     /** marker type */
774     unsigned short int type;
775     /** position in codestream */
776     OPJ_OFF_T pos;
777     /** length, marker val included */
778     int len;
779 } opj_marker_info_t;
780 /* <<UniPG */
781
782 /**
783  * Index structure : Information concerning tile-parts
784 */
785 typedef struct opj_tp_info {
786     /** start position of tile part */
787     int tp_start_pos;
788     /** end position of tile part header */
789     int tp_end_header;
790     /** end position of tile part */
791     int tp_end_pos;
792     /** start packet of tile part */
793     int tp_start_pack;
794     /** number of packets of tile part */
795     int tp_numpacks;
796 } opj_tp_info_t;
797
798 /**
799  * Index structure : information regarding tiles
800 */
801 typedef struct opj_tile_info {
802     /** value of thresh for each layer by tile cfr. Marcela   */
803     double *thresh;
804     /** number of tile */
805     int tileno;
806     /** start position */
807     int start_pos;
808     /** end position of the header */
809     int end_header;
810     /** end position */
811     int end_pos;
812     /** precinct number for each resolution level (width) */
813     int pw[33];
814     /** precinct number for each resolution level (height) */
815     int ph[33];
816     /** precinct size (in power of 2), in X for each resolution level */
817     int pdx[33];
818     /** precinct size (in power of 2), in Y for each resolution level */
819     int pdy[33];
820     /** information concerning packets inside tile */
821     opj_packet_info_t *packet;
822     /** add fixed_quality */
823     int numpix;
824     /** add fixed_quality */
825     double distotile;
826     /** number of markers */
827     int marknum;
828     /** list of markers */
829     opj_marker_info_t *marker;
830     /** actual size of markers array */
831     int maxmarknum;
832     /** number of tile parts */
833     int num_tps;
834     /** information concerning tile parts */
835     opj_tp_info_t *tp;
836 } opj_tile_info_t;
837
838 /**
839  * Index structure of the codestream
840 */
841 typedef struct opj_codestream_info {
842     /** maximum distortion reduction on the whole image (add for Marcela) */
843     double D_max;
844     /** packet number */
845     int packno;
846     /** writing the packet in the index with t2_encode_packets */
847     int index_write;
848     /** image width */
849     int image_w;
850     /** image height */
851     int image_h;
852     /** progression order */
853     OPJ_PROG_ORDER prog;
854     /** tile size in x */
855     int tile_x;
856     /** tile size in y */
857     int tile_y;
858     /** */
859     int tile_Ox;
860     /** */
861     int tile_Oy;
862     /** number of tiles in X */
863     int tw;
864     /** number of tiles in Y */
865     int th;
866     /** component numbers */
867     int numcomps;
868     /** number of layer */
869     int numlayers;
870     /** number of decomposition for each component */
871     int *numdecompos;
872     /* UniPG>> */
873     /** number of markers */
874     int marknum;
875     /** list of markers */
876     opj_marker_info_t *marker;
877     /** actual size of markers array */
878     int maxmarknum;
879     /* <<UniPG */
880     /** main header position */
881     int main_head_start;
882     /** main header position */
883     int main_head_end;
884     /** codestream's size */
885     int codestream_size;
886     /** information regarding tiles inside image */
887     opj_tile_info_t *tile;
888 } opj_codestream_info_t;
889
890 /* <----------------------------------------------------------- */
891 /* new output management of the codestream information and index */
892
893 /**
894  * Tile-component coding parameters information
895  */
896 typedef struct opj_tccp_info {
897     /** component index */
898     OPJ_UINT32 compno;
899     /** coding style */
900     OPJ_UINT32 csty;
901     /** number of resolutions */
902     OPJ_UINT32 numresolutions;
903     /** log2 of code-blocks width */
904     OPJ_UINT32 cblkw;
905     /** log2 of code-blocks height */
906     OPJ_UINT32 cblkh;
907     /** code-block coding style */
908     OPJ_UINT32 cblksty;
909     /** discrete wavelet transform identifier: 0 = 9-7 irreversible, 1 = 5-3 reversible */
910     OPJ_UINT32 qmfbid;
911     /** quantisation style */
912     OPJ_UINT32 qntsty;
913     /** stepsizes used for quantization */
914     OPJ_UINT32 stepsizes_mant[OPJ_J2K_MAXBANDS];
915     /** stepsizes used for quantization */
916     OPJ_UINT32 stepsizes_expn[OPJ_J2K_MAXBANDS];
917     /** number of guard bits */
918     OPJ_UINT32 numgbits;
919     /** Region Of Interest shift */
920     OPJ_INT32 roishift;
921     /** precinct width */
922     OPJ_UINT32 prcw[OPJ_J2K_MAXRLVLS];
923     /** precinct height */
924     OPJ_UINT32 prch[OPJ_J2K_MAXRLVLS];
925 }
926 opj_tccp_info_t;
927
928 /**
929  * Tile coding parameters information
930  */
931 typedef struct opj_tile_v2_info {
932
933     /** number (index) of tile */
934     int tileno;
935     /** coding style */
936     OPJ_UINT32 csty;
937     /** progression order */
938     OPJ_PROG_ORDER prg;
939     /** number of layers */
940     OPJ_UINT32 numlayers;
941     /** multi-component transform identifier */
942     OPJ_UINT32 mct;
943
944     /** information concerning tile component parameters*/
945     opj_tccp_info_t *tccp_info;
946
947 } opj_tile_info_v2_t;
948
949 /**
950  * Information structure about the codestream (FIXME should be expand and enhance)
951  */
952 typedef struct opj_codestream_info_v2 {
953     /* Tile info */
954     /** tile origin in x = XTOsiz */
955     OPJ_UINT32 tx0;
956     /** tile origin in y = YTOsiz */
957     OPJ_UINT32 ty0;
958     /** tile size in x = XTsiz */
959     OPJ_UINT32 tdx;
960     /** tile size in y = YTsiz */
961     OPJ_UINT32 tdy;
962     /** number of tiles in X */
963     OPJ_UINT32 tw;
964     /** number of tiles in Y */
965     OPJ_UINT32 th;
966
967     /** number of components*/
968     OPJ_UINT32 nbcomps;
969
970     /** Default information regarding tiles inside image */
971     opj_tile_info_v2_t m_default_tile_info;
972
973     /** information regarding tiles inside image */
974     opj_tile_info_v2_t *tile_info; /* FIXME not used for the moment */
975
976 } opj_codestream_info_v2_t;
977
978
979 /**
980  * Index structure about a tile part
981  */
982 typedef struct opj_tp_index {
983     /** start position */
984     OPJ_OFF_T start_pos;
985     /** end position of the header */
986     OPJ_OFF_T end_header;
987     /** end position */
988     OPJ_OFF_T end_pos;
989
990 } opj_tp_index_t;
991
992 /**
993  * Index structure about a tile
994  */
995 typedef struct opj_tile_index {
996     /** tile index */
997     OPJ_UINT32 tileno;
998
999     /** number of tile parts */
1000     OPJ_UINT32 nb_tps;
1001     /** current nb of tile part (allocated)*/
1002     OPJ_UINT32 current_nb_tps;
1003     /** current tile-part index */
1004     OPJ_UINT32 current_tpsno;
1005     /** information concerning tile parts */
1006     opj_tp_index_t *tp_index;
1007
1008     /* UniPG>> */ /* NOT USED FOR THE MOMENT IN THE V2 VERSION */
1009     /** number of markers */
1010     OPJ_UINT32 marknum;
1011     /** list of markers */
1012     opj_marker_info_t *marker;
1013     /** actual size of markers array */
1014     OPJ_UINT32 maxmarknum;
1015     /* <<UniPG */
1016
1017     /** packet number */
1018     OPJ_UINT32 nb_packet;
1019     /** information concerning packets inside tile */
1020     opj_packet_info_t *packet_index;
1021
1022 } opj_tile_index_t;
1023
1024 /**
1025  * Index structure of the codestream (FIXME should be expand and enhance)
1026  */
1027 typedef struct opj_codestream_index {
1028     /** main header start position (SOC position) */
1029     OPJ_OFF_T main_head_start;
1030     /** main header end position (first SOT position) */
1031     OPJ_OFF_T main_head_end;
1032
1033     /** codestream's size */
1034     OPJ_UINT64 codestream_size;
1035
1036     /* UniPG>> */ /* NOT USED FOR THE MOMENT IN THE V2 VERSION */
1037     /** number of markers */
1038     OPJ_UINT32 marknum;
1039     /** list of markers */
1040     opj_marker_info_t *marker;
1041     /** actual size of markers array */
1042     OPJ_UINT32 maxmarknum;
1043     /* <<UniPG */
1044
1045     /** */
1046     OPJ_UINT32 nb_of_tiles;
1047     /** */
1048     opj_tile_index_t *tile_index; /* FIXME not used for the moment */
1049
1050 } opj_codestream_index_t;
1051 /* -----------------------------------------------------------> */
1052
1053 /*
1054 ==========================================================
1055    Metadata from the JP2file
1056 ==========================================================
1057 */
1058
1059 /**
1060  * Info structure of the JP2 file
1061  * EXPERIMENTAL FOR THE MOMENT
1062  */
1063 typedef struct opj_jp2_metadata {
1064     /** */
1065     OPJ_INT32   not_used;
1066
1067 } opj_jp2_metadata_t;
1068
1069 /**
1070  * Index structure of the JP2 file
1071  * EXPERIMENTAL FOR THE MOMENT
1072  */
1073 typedef struct opj_jp2_index {
1074     /** */
1075     OPJ_INT32   not_used;
1076
1077 } opj_jp2_index_t;
1078
1079
1080 #ifdef __cplusplus
1081 extern "C" {
1082 #endif
1083
1084
1085 /*
1086 ==========================================================
1087    openjpeg version
1088 ==========================================================
1089 */
1090
1091 /* Get the version of the openjpeg library*/
1092 OPJ_API const char * OPJ_CALLCONV opj_version(void);
1093
1094 /*
1095 ==========================================================
1096    image functions definitions
1097 ==========================================================
1098 */
1099
1100 /**
1101  * Create an image
1102  *
1103  * @param numcmpts      number of components
1104  * @param cmptparms     components parameters
1105  * @param clrspc        image color space
1106  * @return returns      a new image structure if successful, returns NULL otherwise
1107  * */
1108 OPJ_API opj_image_t* OPJ_CALLCONV opj_image_create(OPJ_UINT32 numcmpts,
1109         opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc);
1110
1111 /**
1112  * Deallocate any resources associated with an image
1113  *
1114  * @param image         image to be destroyed
1115  */
1116 OPJ_API void OPJ_CALLCONV opj_image_destroy(opj_image_t *image);
1117
1118 /**
1119  * Creates an image without allocating memory for the image (used in the new version of the library).
1120  *
1121  * @param   numcmpts    the number of components
1122  * @param   cmptparms   the components parameters
1123  * @param   clrspc      the image color space
1124  *
1125  * @return  a new image structure if successful, NULL otherwise.
1126 */
1127 OPJ_API opj_image_t* OPJ_CALLCONV opj_image_tile_create(OPJ_UINT32 numcmpts,
1128         opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc);
1129
1130 /**
1131  * Allocator for opj_image_t->comps[].data
1132  * To be paired with opj_image_data_free.
1133  *
1134  * @param   size    number of bytes to allocate
1135  *
1136  * @return  a new pointer if successful, NULL otherwise.
1137  * @since 2.2.0
1138 */
1139 OPJ_API void* OPJ_CALLCONV opj_image_data_alloc(OPJ_SIZE_T size);
1140
1141 /**
1142  * Destructor for opj_image_t->comps[].data
1143  * To be paired with opj_image_data_alloc.
1144  *
1145  * @param   ptr    Pointer to free
1146  *
1147  * @since 2.2.0
1148 */
1149 OPJ_API void OPJ_CALLCONV opj_image_data_free(void* ptr);
1150
1151 /*
1152 ==========================================================
1153    stream functions definitions
1154 ==========================================================
1155 */
1156
1157 /**
1158  * Creates an abstract stream. This function does nothing except allocating memory and initializing the abstract stream.
1159  *
1160  * @param   p_is_input      if set to true then the stream will be an input stream, an output stream else.
1161  *
1162  * @return  a stream object.
1163 */
1164 OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_default_create(
1165     OPJ_BOOL p_is_input);
1166
1167 /**
1168  * Creates an abstract stream. This function does nothing except allocating memory and initializing the abstract stream.
1169  *
1170  * @param   p_buffer_size  FIXME DOC
1171  * @param   p_is_input      if set to true then the stream will be an input stream, an output stream else.
1172  *
1173  * @return  a stream object.
1174 */
1175 OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create(OPJ_SIZE_T p_buffer_size,
1176         OPJ_BOOL p_is_input);
1177
1178 /**
1179  * Destroys a stream created by opj_create_stream. This function does NOT close the abstract stream. If needed the user must
1180  * close its own implementation of the stream.
1181  *
1182  * @param   p_stream    the stream to destroy.
1183  */
1184 OPJ_API void OPJ_CALLCONV opj_stream_destroy(opj_stream_t* p_stream);
1185
1186 /**
1187  * Sets the given function to be used as a read function.
1188  * @param       p_stream    the stream to modify
1189  * @param       p_function  the function to use a read function.
1190 */
1191 OPJ_API void OPJ_CALLCONV opj_stream_set_read_function(opj_stream_t* p_stream,
1192         opj_stream_read_fn p_function);
1193
1194 /**
1195  * Sets the given function to be used as a write function.
1196  * @param       p_stream    the stream to modify
1197  * @param       p_function  the function to use a write function.
1198 */
1199 OPJ_API void OPJ_CALLCONV opj_stream_set_write_function(opj_stream_t* p_stream,
1200         opj_stream_write_fn p_function);
1201
1202 /**
1203  * Sets the given function to be used as a skip function.
1204  * @param       p_stream    the stream to modify
1205  * @param       p_function  the function to use a skip function.
1206 */
1207 OPJ_API void OPJ_CALLCONV opj_stream_set_skip_function(opj_stream_t* p_stream,
1208         opj_stream_skip_fn p_function);
1209
1210 /**
1211  * Sets the given function to be used as a seek function, the stream is then seekable,
1212  * using SEEK_SET behavior.
1213  * @param       p_stream    the stream to modify
1214  * @param       p_function  the function to use a skip function.
1215 */
1216 OPJ_API void OPJ_CALLCONV opj_stream_set_seek_function(opj_stream_t* p_stream,
1217         opj_stream_seek_fn p_function);
1218
1219 /**
1220  * Sets the given data to be used as a user data for the stream.
1221  * @param       p_stream    the stream to modify
1222  * @param       p_data      the data to set.
1223  * @param       p_function  the function to free p_data when opj_stream_destroy() is called.
1224 */
1225 OPJ_API void OPJ_CALLCONV opj_stream_set_user_data(opj_stream_t* p_stream,
1226         void * p_data, opj_stream_free_user_data_fn p_function);
1227
1228 /**
1229  * Sets the length of the user data for the stream.
1230  *
1231  * @param p_stream    the stream to modify
1232  * @param data_length length of the user_data.
1233 */
1234 OPJ_API void OPJ_CALLCONV opj_stream_set_user_data_length(
1235     opj_stream_t* p_stream, OPJ_UINT64 data_length);
1236
1237 /**
1238  * Create a stream from a file identified with its filename with default parameters (helper function)
1239  * @param fname             the filename of the file to stream
1240  * @param p_is_read_stream  whether the stream is a read stream (true) or not (false)
1241 */
1242 OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create_default_file_stream(
1243     const char *fname, OPJ_BOOL p_is_read_stream);
1244
1245 /** Create a stream from a file identified with its filename with a specific buffer size
1246  * @param fname             the filename of the file to stream
1247  * @param p_buffer_size     size of the chunk used to stream
1248  * @param p_is_read_stream  whether the stream is a read stream (true) or not (false)
1249 */
1250 OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream(
1251     const char *fname,
1252     OPJ_SIZE_T p_buffer_size,
1253     OPJ_BOOL p_is_read_stream);
1254
1255 /*
1256 ==========================================================
1257    event manager functions definitions
1258 ==========================================================
1259 */
1260 /**
1261  * Set the info handler use by openjpeg.
1262  * @param p_codec       the codec previously initialise
1263  * @param p_callback    the callback function which will be used
1264  * @param p_user_data   client object where will be returned the message
1265 */
1266 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_info_handler(opj_codec_t * p_codec,
1267         opj_msg_callback p_callback,
1268         void * p_user_data);
1269 /**
1270  * Set the warning handler use by openjpeg.
1271  * @param p_codec       the codec previously initialise
1272  * @param p_callback    the callback function which will be used
1273  * @param p_user_data   client object where will be returned the message
1274 */
1275 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_warning_handler(opj_codec_t * p_codec,
1276         opj_msg_callback p_callback,
1277         void * p_user_data);
1278 /**
1279  * Set the error handler use by openjpeg.
1280  * @param p_codec       the codec previously initialise
1281  * @param p_callback    the callback function which will be used
1282  * @param p_user_data   client object where will be returned the message
1283 */
1284 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_error_handler(opj_codec_t * p_codec,
1285         opj_msg_callback p_callback,
1286         void * p_user_data);
1287
1288 /*
1289 ==========================================================
1290    codec functions definitions
1291 ==========================================================
1292 */
1293
1294 /**
1295  * Creates a J2K/JP2 decompression structure
1296  * @param format        Decoder to select
1297  *
1298  * @return Returns a handle to a decompressor if successful, returns NULL otherwise
1299  * */
1300 OPJ_API opj_codec_t* OPJ_CALLCONV opj_create_decompress(
1301     OPJ_CODEC_FORMAT format);
1302
1303 /**
1304  * Destroy a decompressor handle
1305  *
1306  * @param   p_codec         decompressor handle to destroy
1307  */
1308 OPJ_API void OPJ_CALLCONV opj_destroy_codec(opj_codec_t * p_codec);
1309
1310 /**
1311  * Read after the codestream if necessary
1312  * @param   p_codec         the JPEG2000 codec to read.
1313  * @param   p_stream        the JPEG2000 stream.
1314  */
1315 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_end_decompress(opj_codec_t *p_codec,
1316         opj_stream_t *p_stream);
1317
1318
1319 /**
1320  * Set decoding parameters to default values
1321  * @param parameters Decompression parameters
1322  */
1323 OPJ_API void OPJ_CALLCONV opj_set_default_decoder_parameters(
1324     opj_dparameters_t *parameters);
1325
1326 /**
1327  * Setup the decoder with decompression parameters provided by the user and with the message handler
1328  * provided by the user.
1329  *
1330  * @param p_codec       decompressor handler
1331  * @param parameters    decompression parameters
1332  *
1333  * @return true         if the decoder is correctly set
1334  */
1335 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_setup_decoder(opj_codec_t *p_codec,
1336         opj_dparameters_t *parameters);
1337
1338 /**
1339  * Allocates worker threads for the compressor/decompressor.
1340  *
1341  * By default, only the main thread is used. If this function is not used,
1342  * but the OPJ_NUM_THREADS environment variable is set, its value will be
1343  * used to initialize the number of threads. The value can be either an integer
1344  * number, or "ALL_CPUS". If OPJ_NUM_THREADS is set and this function is called,
1345  * this function will override the behaviour of the environment variable.
1346  *
1347  * Currently this function must be called after opj_setup_decoder() and
1348  * before opj_read_header().
1349  *
1350  * Note: currently only has effect on the decompressor.
1351  *
1352  * @param p_codec       decompressor handler
1353  * @param num_threads   number of threads.
1354  *
1355  * @return OPJ_TRUE     if the decoder is correctly set
1356  */
1357 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_codec_set_threads(opj_codec_t *p_codec,
1358         int num_threads);
1359
1360 /**
1361  * Decodes an image header.
1362  *
1363  * @param   p_stream        the jpeg2000 stream.
1364  * @param   p_codec         the jpeg2000 codec to read.
1365  * @param   p_image         the image structure initialized with the characteristics of encoded image.
1366  *
1367  * @return true             if the main header of the codestream and the JP2 header is correctly read.
1368  */
1369 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_read_header(opj_stream_t *p_stream,
1370         opj_codec_t *p_codec,
1371         opj_image_t **p_image);
1372
1373
1374 /** Restrict the number of components to decode.
1375  *
1376  * This function should be called after opj_read_header().
1377  *
1378  * This function enables to restrict the set of decoded components to the
1379  * specified indices.
1380  * Note that the current implementation (apply_color_transforms == OPJ_FALSE)
1381  * is such that neither the multi-component transform at codestream level,
1382  * nor JP2 channel transformations will be applied.
1383  * Consequently the indices are relative to the codestream.
1384  *
1385  * Note: opj_decode_tile_data() should not be used together with opj_set_decoded_components().
1386  *
1387  * @param   p_codec         the jpeg2000 codec to read.
1388  * @param   numcomps        Size of the comps_indices array.
1389  * @param   comps_indices   Array of numcomps values representing the indices
1390  *                          of the components to decode (relative to the
1391  *                          codestream, starting at 0)
1392  * @param   apply_color_transforms Whether multi-component transform at codestream level
1393  *                                 or JP2 channel transformations should be applied.
1394  *                                 Currently this parameter should be set to OPJ_FALSE.
1395  *                                 Setting it to OPJ_TRUE will result in an error.
1396  *
1397  * @return OPJ_TRUE         in case of success.
1398  */
1399 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_decoded_components(opj_codec_t *p_codec,
1400         OPJ_UINT32 numcomps,
1401         const OPJ_UINT32* comps_indices,
1402         OPJ_BOOL apply_color_transforms);
1403
1404 /**
1405  * Sets the given area to be decoded. This function should be called right after opj_read_header and before any tile header reading.
1406  *
1407  * The coordinates passed to this function should be expressed in the reference grid,
1408  * that is to say at the highest resolution level, even if requesting the image at lower
1409  * resolution levels.
1410  *
1411  * Generally opj_set_decode_area() should be followed by opj_decode(), and the
1412  * codec cannot be re-used.
1413  * In the particular case of an image made of a single tile, several sequences of
1414  * calls to opoj_set_decode_area() and opj_decode() are allowed, and will bring
1415  * performance improvements when reading an image by chunks.
1416  *
1417  * @param   p_codec         the jpeg2000 codec.
1418  * @param   p_image         the decoded image previously set by opj_read_header
1419  * @param   p_start_x       the left position of the rectangle to decode (in image coordinates).
1420  * @param   p_end_x         the right position of the rectangle to decode (in image coordinates).
1421  * @param   p_start_y       the up position of the rectangle to decode (in image coordinates).
1422  * @param   p_end_y         the bottom position of the rectangle to decode (in image coordinates).
1423  *
1424  * @return  true            if the area could be set.
1425  */
1426 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_decode_area(opj_codec_t *p_codec,
1427         opj_image_t* p_image,
1428         OPJ_INT32 p_start_x, OPJ_INT32 p_start_y,
1429         OPJ_INT32 p_end_x, OPJ_INT32 p_end_y);
1430
1431 /**
1432  * Decode an image from a JPEG-2000 codestream
1433  *
1434  * @param p_decompressor    decompressor handle
1435  * @param p_stream          Input buffer stream
1436  * @param p_image           the decoded image
1437  * @return                  true if success, otherwise false
1438  * */
1439 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_decode(opj_codec_t *p_decompressor,
1440         opj_stream_t *p_stream,
1441         opj_image_t *p_image);
1442
1443 /**
1444  * Get the decoded tile from the codec
1445  *
1446  * @param   p_codec         the jpeg2000 codec.
1447  * @param   p_stream        input streamm
1448  * @param   p_image         output image
1449  * @param   tile_index      index of the tile which will be decode
1450  *
1451  * @return                  true if success, otherwise false
1452  */
1453 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_get_decoded_tile(opj_codec_t *p_codec,
1454         opj_stream_t *p_stream,
1455         opj_image_t *p_image,
1456         OPJ_UINT32 tile_index);
1457
1458 /**
1459  * Set the resolution factor of the decoded image
1460  * @param   p_codec         the jpeg2000 codec.
1461  * @param   res_factor      resolution factor to set
1462  *
1463  * @return                  true if success, otherwise false
1464  */
1465 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_decoded_resolution_factor(
1466     opj_codec_t *p_codec, OPJ_UINT32 res_factor);
1467
1468 /**
1469  * Writes a tile with the given data.
1470  *
1471  * @param   p_codec             the jpeg2000 codec.
1472  * @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.
1473  * @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.
1474  * @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
1475  *                              tile_width * tile_height * component_size. component_size can be 1,2 or 4 bytes, depending on the precision of the given component.
1476  * @param   p_stream            the stream to write data to.
1477  *
1478  * @return  true if the data could be written.
1479  */
1480 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_write_tile(opj_codec_t *p_codec,
1481         OPJ_UINT32 p_tile_index,
1482         OPJ_BYTE * p_data,
1483         OPJ_UINT32 p_data_size,
1484         opj_stream_t *p_stream);
1485
1486 /**
1487  * Reads a tile header. This function is compulsory and allows one to know the size of the tile that will be decoded.
1488  * The user may need to refer to the image got by opj_read_header to understand the size being taken by the tile.
1489  *
1490  * @param   p_codec         the jpeg2000 codec.
1491  * @param   p_tile_index    pointer to a value that will hold the index of the tile being decoded, in case of success.
1492  * @param   p_data_size     pointer to a value that will hold the maximum size of the decoded data, in case of success. In case
1493  *                          of truncated codestreams, the actual number of bytes decoded may be lower. The computation of the size is the same
1494  *                          as depicted in opj_write_tile.
1495  * @param   p_tile_x0       pointer to a value that will hold the x0 pos of the tile (in the image).
1496  * @param   p_tile_y0       pointer to a value that will hold the y0 pos of the tile (in the image).
1497  * @param   p_tile_x1       pointer to a value that will hold the x1 pos of the tile (in the image).
1498  * @param   p_tile_y1       pointer to a value that will hold the y1 pos of the tile (in the image).
1499  * @param   p_nb_comps      pointer to a value that will hold the number of components in the tile.
1500  * @param   p_should_go_on  pointer to a boolean that will hold the fact that the decoding should go on. In case the
1501  *                          codestream is over at the time of the call, the value will be set to false. The user should then stop
1502  *                          the decoding.
1503  * @param   p_stream        the stream to decode.
1504  * @return  true            if the tile header could be decoded. In case the decoding should end, the returned value is still true.
1505  *                          returning false may be the result of a shortage of memory or an internal error.
1506  */
1507 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_read_tile_header(opj_codec_t *p_codec,
1508         opj_stream_t * p_stream,
1509         OPJ_UINT32 * p_tile_index,
1510         OPJ_UINT32 * p_data_size,
1511         OPJ_INT32 * p_tile_x0, OPJ_INT32 * p_tile_y0,
1512         OPJ_INT32 * p_tile_x1, OPJ_INT32 * p_tile_y1,
1513         OPJ_UINT32 * p_nb_comps,
1514         OPJ_BOOL * p_should_go_on);
1515
1516 /**
1517  * Reads a tile data. This function is compulsory and allows one to decode tile data. opj_read_tile_header should be called before.
1518  * The user may need to refer to the image got by opj_read_header to understand the size being taken by the tile.
1519  *
1520  * Note: opj_decode_tile_data() should not be used together with opj_set_decoded_components().
1521  *
1522  * @param   p_codec         the jpeg2000 codec.
1523  * @param   p_tile_index    the index of the tile being decoded, this should be the value set by opj_read_tile_header.
1524  * @param   p_data          pointer to a memory block that will hold the decoded data.
1525  * @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.
1526  * @param   p_stream        the stream to decode.
1527  *
1528  * @return  true            if the data could be decoded.
1529  */
1530 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_decode_tile_data(opj_codec_t *p_codec,
1531         OPJ_UINT32 p_tile_index,
1532         OPJ_BYTE * p_data,
1533         OPJ_UINT32 p_data_size,
1534         opj_stream_t *p_stream);
1535
1536 /* COMPRESSION FUNCTIONS*/
1537
1538 /**
1539  * Creates a J2K/JP2 compression structure
1540  * @param   format      Coder to select
1541  * @return              Returns a handle to a compressor if successful, returns NULL otherwise
1542  */
1543 OPJ_API opj_codec_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format);
1544
1545 /**
1546 Set encoding parameters to default values, that means :
1547 <ul>
1548 <li>Lossless
1549 <li>1 tile
1550 <li>Size of precinct : 2^15 x 2^15 (means 1 precinct)
1551 <li>Size of code-block : 64 x 64
1552 <li>Number of resolutions: 6
1553 <li>No SOP marker in the codestream
1554 <li>No EPH marker in the codestream
1555 <li>No sub-sampling in x or y direction
1556 <li>No mode switch activated
1557 <li>Progression order: LRCP
1558 <li>No index file
1559 <li>No ROI upshifted
1560 <li>No offset of the origin of the image
1561 <li>No offset of the origin of the tiles
1562 <li>Reversible DWT 5-3
1563 </ul>
1564 @param parameters Compression parameters
1565 */
1566 OPJ_API void OPJ_CALLCONV opj_set_default_encoder_parameters(
1567     opj_cparameters_t *parameters);
1568
1569 /**
1570  * Setup the encoder parameters using the current image and using user parameters.
1571  * @param p_codec       Compressor handle
1572  * @param parameters    Compression parameters
1573  * @param image         Input filled image
1574  */
1575 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_setup_encoder(opj_codec_t *p_codec,
1576         opj_cparameters_t *parameters,
1577         opj_image_t *image);
1578
1579 /**
1580  * Start to compress the current image.
1581  * @param p_codec       Compressor handle
1582  * @param p_image       Input filled image
1583  * @param p_stream      Input stgream
1584  */
1585 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_start_compress(opj_codec_t *p_codec,
1586         opj_image_t * p_image,
1587         opj_stream_t *p_stream);
1588
1589 /**
1590  * End to compress the current image.
1591  * @param p_codec       Compressor handle
1592  * @param p_stream      Input stgream
1593  */
1594 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_end_compress(opj_codec_t *p_codec,
1595         opj_stream_t *p_stream);
1596
1597 /**
1598  * Encode an image into a JPEG-2000 codestream
1599  * @param p_codec       compressor handle
1600  * @param p_stream      Output buffer stream
1601  *
1602  * @return              Returns true if successful, returns false otherwise
1603  */
1604 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_encode(opj_codec_t *p_codec,
1605         opj_stream_t *p_stream);
1606 /*
1607 ==========================================================
1608    codec output functions definitions
1609 ==========================================================
1610 */
1611 /* EXPERIMENTAL FUNCTIONS FOR NOW, USED ONLY IN J2K_DUMP*/
1612
1613 /**
1614 Destroy Codestream information after compression or decompression
1615 @param cstr_info Codestream information structure
1616 */
1617 OPJ_API void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_v2_t
1618         **cstr_info);
1619
1620
1621 /**
1622  * Dump the codec information into the output stream
1623  *
1624  * @param   p_codec         the jpeg2000 codec.
1625  * @param   info_flag       type of information dump.
1626  * @param   output_stream   output stream where dump the information gotten from the codec.
1627  *
1628  */
1629 OPJ_API void OPJ_CALLCONV opj_dump_codec(opj_codec_t *p_codec,
1630         OPJ_INT32 info_flag,
1631         FILE* output_stream);
1632
1633 /**
1634  * Get the codestream information from the codec
1635  *
1636  * @param   p_codec         the jpeg2000 codec.
1637  *
1638  * @return                  a pointer to a codestream information structure.
1639  *
1640  */
1641 OPJ_API opj_codestream_info_v2_t* OPJ_CALLCONV opj_get_cstr_info(
1642     opj_codec_t *p_codec);
1643
1644 /**
1645  * Get the codestream index from the codec
1646  *
1647  * @param   p_codec         the jpeg2000 codec.
1648  *
1649  * @return                  a pointer to a codestream index structure.
1650  *
1651  */
1652 OPJ_API opj_codestream_index_t * OPJ_CALLCONV opj_get_cstr_index(
1653     opj_codec_t *p_codec);
1654
1655 OPJ_API void OPJ_CALLCONV opj_destroy_cstr_index(opj_codestream_index_t
1656         **p_cstr_index);
1657
1658
1659 /**
1660  * Get the JP2 file information from the codec FIXME
1661  *
1662  * @param   p_codec         the jpeg2000 codec.
1663  *
1664  * @return                  a pointer to a JP2 metadata structure.
1665  *
1666  */
1667 OPJ_API opj_jp2_metadata_t* OPJ_CALLCONV opj_get_jp2_metadata(
1668     opj_codec_t *p_codec);
1669
1670 /**
1671  * Get the JP2 file index from the codec FIXME
1672  *
1673  * @param   p_codec         the jpeg2000 codec.
1674  *
1675  * @return                  a pointer to a JP2 index structure.
1676  *
1677  */
1678 OPJ_API opj_jp2_index_t* OPJ_CALLCONV opj_get_jp2_index(opj_codec_t *p_codec);
1679
1680
1681 /*
1682 ==========================================================
1683    MCT functions
1684 ==========================================================
1685 */
1686
1687 /**
1688  * Sets the MCT matrix to use.
1689  *
1690  * @param   parameters      the parameters to change.
1691  * @param   pEncodingMatrix the encoding matrix.
1692  * @param   p_dc_shift      the dc shift coefficients to use.
1693  * @param   pNbComp         the number of components of the image.
1694  *
1695  * @return  true if the parameters could be set.
1696  */
1697 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_MCT(opj_cparameters_t *parameters,
1698         OPJ_FLOAT32 * pEncodingMatrix,
1699         OPJ_INT32 * p_dc_shift,
1700         OPJ_UINT32 pNbComp);
1701
1702 /*
1703 ==========================================================
1704    Thread functions
1705 ==========================================================
1706 */
1707
1708 /** Returns if the library is built with thread support.
1709  * OPJ_TRUE if mutex, condition, thread, thread pool are available.
1710  */
1711 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_has_thread_support(void);
1712
1713 /** Return the number of virtual CPUs */
1714 OPJ_API int OPJ_CALLCONV opj_get_num_cpus(void);
1715
1716
1717 #ifdef __cplusplus
1718 }
1719 #endif
1720
1721 #endif /* OPENJPEG_H */