94fbdfa5dae5417e4df205b2076ee14d82e8795a
[openjpeg.git] / libopenjpeg / openjpeg.h
1  /*
2  * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
3  * Copyright (c) 2002-2007, Professor Benoit Macq
4  * Copyright (c) 2001-2003, David Janssens
5  * Copyright (c) 2002-2003, Yannick Verschueren
6  * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
7  * Copyright (c) 2005, Herve Drolon, FreeImage Team
8  * Copyright (c) 2006-2007, Parvatha Elangovan
9  * Copyright (c) 2010-2011, Kaori Hagihara
10  * All rights reserved.
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  * 1. Redistributions of source code must retain the above copyright
16  *    notice, this list of conditions and the following disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright
18  *    notice, this list of conditions and the following disclaimer in the
19  *    documentation and/or other materials provided with the distribution.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  */
33 #ifndef OPENJPEG_H
34 #define OPENJPEG_H
35
36
37 /* 
38 ==========================================================
39    Compiler directives
40 ==========================================================
41 */
42
43 #if defined(OPJ_STATIC) || !defined(_WIN32)
44 #define OPJ_API
45 #define OPJ_CALLCONV
46 #else
47 #define OPJ_CALLCONV __stdcall
48 /*
49 The following ifdef block is the standard way of creating macros which make exporting 
50 from a DLL simpler. All files within this DLL are compiled with the OPJ_EXPORTS
51 symbol defined on the command line. this symbol should not be defined on any project
52 that uses this DLL. This way any other project whose source files include this file see 
53 OPJ_API functions as being imported from a DLL, wheras this DLL sees symbols
54 defined with this macro as being exported.
55 */
56 #if defined(OPJ_EXPORTS) || defined(DLL_EXPORT)
57 #define OPJ_API __declspec(dllexport)
58 #else
59 #define OPJ_API __declspec(dllimport)
60 #endif /* OPJ_EXPORTS */
61 #endif /* !OPJ_STATIC || !_WIN32 */
62
63 typedef int opj_bool;
64 #define OPJ_TRUE 1
65 #define OPJ_FALSE 0
66
67 typedef unsigned int    OPJ_UINT32;
68 typedef int                             OPJ_INT32;
69 typedef unsigned short  OPJ_UINT16;
70 typedef short                   OPJ_INT16;
71 typedef char                    OPJ_CHAR;
72 typedef unsigned char   OPJ_BYTE;
73 typedef unsigned int    OPJ_SIZE_T;
74 typedef double                  OPJ_FLOAT64;
75 typedef float                   OPJ_FLOAT32;
76
77 // Avoid compile-time warning because parameter is not used
78 #define OPJ_ARG_NOT_USED(x) (void)(x)
79
80 /* 
81 ==========================================================
82    Useful constant definitions
83 ==========================================================
84 */
85
86 #define OPJ_PATH_LEN 4096 /**< Maximum allowed size for filenames */
87
88 #define J2K_MAXRLVLS 33                                 /**< Number of maximum resolution level authorized */
89 #define J2K_MAXBANDS (3*J2K_MAXRLVLS-2) /**< Number of maximum sub-band linked to number of resolution level */
90
91 #define J2K_DEFAULT_NB_SEGS                             10
92 #define J2K_STREAM_CHUNK_SIZE                   0x100000 /** 1 mega by default */
93 #define J2K_DEFAULT_HEADER_SIZE                 1000
94 #define J2K_MCC_DEFAULT_NB_RECORDS              10
95 #define J2K_MCT_DEFAULT_NB_RECORDS              10
96
97 /* UniPG>> */
98 #define JPWL_MAX_NO_TILESPECS   16 /**< Maximum number of tile parts expected by JPWL: increase at your will */
99 #define JPWL_MAX_NO_PACKSPECS   16 /**< Maximum number of packet parts expected by JPWL: increase at your will */
100 #define JPWL_MAX_NO_MARKERS     512 /**< Maximum number of JPWL markers: increase at your will */
101 #define JPWL_PRIVATEINDEX_NAME "jpwl_index_privatefilename" /**< index file name used when JPWL is on */
102 #define JPWL_EXPECTED_COMPONENTS 3 /**< Expect this number of components, so you'll find better the first EPB */
103 #define JPWL_MAXIMUM_TILES 8192 /**< Expect this maximum number of tiles, to avoid some crashes */
104 #define JPWL_MAXIMUM_HAMMING 2 /**< Expect this maximum number of bit errors in marker id's */
105 #define JPWL_MAXIMUM_EPB_ROOM 65450 /**< Expect this maximum number of bytes for composition of EPBs */
106 /* <<UniPG */
107
108 /**
109 Supported options about file information
110 */
111 #define OPJ_NO_INFO             0x0     /**< No information provied to the user */
112 #define OPJ_IMG_INFO    0x1     /**< Basic image information provided to the user */
113 #define OPJ_J2K_INFO    0x2     /**< J2K codestream information provided to the user */
114 #define OPJ_JP2_INFO    0x4     /**< JP2 file information provided to the user */
115
116
117 /* 
118 ==========================================================
119    enum definitions
120 ==========================================================
121 */
122 /** 
123 Rsiz Capabilities
124 */
125 typedef enum RSIZ_CAPABILITIES {
126         STD_RSIZ = 0,           /** Standard JPEG2000 profile*/
127         CINEMA2K = 3,           /** Profile name for a 2K image*/
128         CINEMA4K = 4            /** Profile name for a 4K image*/
129 } OPJ_RSIZ_CAPABILITIES;
130
131 /** 
132 Digital cinema operation mode 
133 */
134 typedef enum CINEMA_MODE {
135         OFF = 0,                                        /** Not Digital Cinema*/
136         CINEMA2K_24 = 1,        /** 2K Digital Cinema at 24 fps*/
137         CINEMA2K_48 = 2,        /** 2K Digital Cinema at 48 fps*/
138         CINEMA4K_24 = 3         /** 4K Digital Cinema at 24 fps*/
139 }OPJ_CINEMA_MODE;
140
141 /** 
142 Progression order 
143 */
144 typedef enum PROG_ORDER {
145         PROG_UNKNOWN = -1,      /**< place-holder */
146         LRCP = 0,               /**< layer-resolution-component-precinct order */
147         RLCP = 1,               /**< resolution-layer-component-precinct order */
148         RPCL = 2,               /**< resolution-precinct-component-layer order */
149         PCRL = 3,               /**< precinct-component-resolution-layer order */
150         CPRL = 4                /**< component-precinct-resolution-layer order */
151 } OPJ_PROG_ORDER;
152
153 /**
154 Supported image color spaces
155 */
156 typedef enum COLOR_SPACE {
157         CLRSPC_UNKNOWN = -1,    /**< not supported by the library */
158         CLRSPC_UNSPECIFIED = 0, /**< not specified in the codestream */ 
159         CLRSPC_SRGB = 1,                /**< sRGB */
160         CLRSPC_GRAY = 2,                /**< grayscale */
161         CLRSPC_SYCC = 3                 /**< YUV */
162 } OPJ_COLOR_SPACE;
163
164 /**
165 Supported codec
166 */
167 typedef enum CODEC_FORMAT {
168         CODEC_UNKNOWN = -1,     /**< place-holder */
169         CODEC_J2K  = 0,         /**< JPEG-2000 codestream : read/write */
170         CODEC_JPT  = 1,         /**< JPT-stream (JPEG 2000, JPIP) : read only */
171         CODEC_JP2  = 2,         /**< JPEG-2000 file format : read/write */
172 } OPJ_CODEC_FORMAT;
173
174 /** 
175 Limit decoding to certain portions of the codestream. 
176 */
177 typedef enum LIMIT_DECODING {
178         NO_LIMITATION = 0,                                /**< No limitation for the decoding. The entire codestream will de decoded */
179         LIMIT_TO_MAIN_HEADER = 1,               /**< The decoding is limited to the Main Header */
180         DECODE_ALL_BUT_PACKETS = 2      /**< Decode everything except the JPEG 2000 packets */
181 } OPJ_LIMIT_DECODING;
182
183
184
185
186 /* 
187 ==========================================================
188    event manager typedef definitions
189 ==========================================================
190 */
191
192 /**
193 Callback function prototype for events
194 @param msg Event message
195 @param client_data 
196 */
197 typedef void (*opj_msg_callback) (const char *msg, void *client_data);
198
199 /**
200 Message handler object
201 used for 
202 <ul>
203 <li>Error messages
204 <li>Warning messages
205 <li>Debugging messages
206 </ul>
207 */
208 typedef struct opj_event_mgr {
209         void* client_data;
210         /** Error message callback if available, NULL otherwise */
211         opj_msg_callback error_handler;
212         /** Warning message callback if available, NULL otherwise */
213         opj_msg_callback warning_handler;
214         /** Debug message callback if available, NULL otherwise */
215         opj_msg_callback info_handler;
216 } opj_event_mgr_t;
217
218
219 /* 
220 ==========================================================
221    codec typedef definitions
222 ==========================================================
223 */
224
225 /**
226 Progression order changes
227 */
228 typedef struct opj_poc {
229         /** Resolution num start, Component num start, given by POC */
230         int resno0, compno0;
231         /** Layer num end,Resolution num end, Component num end, given by POC */
232         int layno1, resno1, compno1;
233         /** Layer num start,Precinct num start, Precinct num end */
234         int layno0, precno0, precno1;
235         /** Progression order enum*/
236         OPJ_PROG_ORDER prg1,prg;
237         /** Progression order string*/
238         char progorder[5];
239         /** Tile number */
240         int tile;
241         /** Start and end values for Tile width and height*/
242         int tx0,tx1,ty0,ty1;
243         /** Start value, initialised in pi_initialise_encode*/
244         int layS, resS, compS, prcS;
245         /** End value, initialised in pi_initialise_encode */
246         int layE, resE, compE, prcE;
247         /** Start and end values of Tile width and height, initialised in pi_initialise_encode*/
248         int txS,txE,tyS,tyE,dx,dy;
249         /** Temporary values for Tile parts, initialised in pi_create_encode */
250         int lay_t, res_t, comp_t, prc_t,tx0_t,ty0_t;
251 } opj_poc_t;
252
253 /**
254 Compression parameters
255 */
256 typedef struct opj_cparameters {
257         /** size of tile: tile_size_on = false (not in argument) or = true (in argument) */
258         opj_bool tile_size_on;
259         /** XTOsiz */
260         int cp_tx0;
261         /** YTOsiz */
262         int cp_ty0;
263         /** XTsiz */
264         int cp_tdx;
265         /** YTsiz */
266         int cp_tdy;
267         /** allocation by rate/distortion */
268         int cp_disto_alloc;
269         /** allocation by fixed layer */
270         int cp_fixed_alloc;
271         /** add fixed_quality */
272         int cp_fixed_quality;
273         /** fixed layer */
274         int *cp_matrice;
275         /** comment for coding */
276         char *cp_comment;
277         /** csty : coding style */
278         int csty;
279         /** progression order (default LRCP) */
280         OPJ_PROG_ORDER prog_order;
281         /** progression order changes */
282         opj_poc_t POC[32];
283         /** number of progression order changes (POC), default to 0 */
284         int numpocs;
285         /** number of layers */
286         int tcp_numlayers;
287         /** rates of layers */
288         float tcp_rates[100];
289         /** different psnr for successive layers */
290         float tcp_distoratio[100];
291         /** number of resolutions */
292         int numresolution;
293         /** initial code block width, default to 64 */
294         int cblockw_init;
295         /** initial code block height, default to 64 */
296         int cblockh_init;
297         /** mode switch (cblk_style) */
298         int mode;
299         /** 1 : use the irreversible DWT 9-7, 0 : use lossless compression (default) */
300         int irreversible;
301         /** region of interest: affected component in [0..3], -1 means no ROI */
302         int roi_compno;
303         /** region of interest: upshift value */
304         int roi_shift;
305         /* number of precinct size specifications */
306         int res_spec;
307         /** initial precinct width */
308         int prcw_init[J2K_MAXRLVLS];
309         /** initial precinct height */
310         int prch_init[J2K_MAXRLVLS];
311
312         /**@name command line encoder parameters (not used inside the library) */
313         /*@{*/
314         /** input file name */
315         char infile[OPJ_PATH_LEN];
316         /** output file name */
317         char outfile[OPJ_PATH_LEN];
318         /** DEPRECATED. Index generation is now handeld with the opj_encode_with_info() function. Set to NULL */
319         int index_on;
320         /** DEPRECATED. Index generation is now handeld with the opj_encode_with_info() function. Set to NULL */
321         char index[OPJ_PATH_LEN];
322         /** subimage encoding: origin image offset in x direction */
323         int image_offset_x0;
324         /** subimage encoding: origin image offset in y direction */
325         int image_offset_y0;
326         /** subsampling value for dx */
327         int subsampling_dx;
328         /** subsampling value for dy */
329         int subsampling_dy;
330         /** input file format 0: PGX, 1: PxM, 2: BMP 3:TIF*/
331         int decod_format;
332         /** output file format 0: J2K, 1: JP2, 2: JPT */
333         int cod_format;
334         /*@}*/
335
336 /* UniPG>> */
337         /**@name JPWL encoding parameters */
338         /*@{*/
339         /** enables writing of EPC in MH, thus activating JPWL */
340         opj_bool jpwl_epc_on;
341         /** error protection method for MH (0,1,16,32,37-128) */
342         int jpwl_hprot_MH;
343         /** tile number of header protection specification (>=0) */
344         int jpwl_hprot_TPH_tileno[JPWL_MAX_NO_TILESPECS];
345         /** error protection methods for TPHs (0,1,16,32,37-128) */
346         int jpwl_hprot_TPH[JPWL_MAX_NO_TILESPECS];
347         /** tile number of packet protection specification (>=0) */
348         int jpwl_pprot_tileno[JPWL_MAX_NO_PACKSPECS];
349         /** packet number of packet protection specification (>=0) */
350         int jpwl_pprot_packno[JPWL_MAX_NO_PACKSPECS];
351         /** error protection methods for packets (0,1,16,32,37-128) */
352         int jpwl_pprot[JPWL_MAX_NO_PACKSPECS];
353         /** enables writing of ESD, (0=no/1/2 bytes) */
354         int jpwl_sens_size;
355         /** sensitivity addressing size (0=auto/2/4 bytes) */
356         int jpwl_sens_addr;
357         /** sensitivity range (0-3) */
358         int jpwl_sens_range;
359         /** sensitivity method for MH (-1=no,0-7) */
360         int jpwl_sens_MH;
361         /** tile number of sensitivity specification (>=0) */
362         int jpwl_sens_TPH_tileno[JPWL_MAX_NO_TILESPECS];
363         /** sensitivity methods for TPHs (-1=no,0-7) */
364         int jpwl_sens_TPH[JPWL_MAX_NO_TILESPECS];
365         /*@}*/
366 /* <<UniPG */
367
368         /** Digital Cinema compliance 0-not compliant, 1-compliant*/
369         OPJ_CINEMA_MODE cp_cinema;
370         /** Maximum rate for each component. If == 0, component size limitation is not considered */
371         int max_comp_size;
372         /** Profile name*/
373         OPJ_RSIZ_CAPABILITIES cp_rsiz;
374         /** Tile part generation*/
375         char tp_on;
376         /** Flag for Tile part generation*/
377         char tp_flag;
378         /** MCT (multiple component transform) */
379         char tcp_mct;
380         /** Enable JPIP indexing*/
381         opj_bool jpip_on;
382 } opj_cparameters_t;
383
384 /**
385 Decompression parameters
386 */
387 typedef struct opj_dparameters {
388         /** 
389         Set the number of highest resolution levels to be discarded. 
390         The image resolution is effectively divided by 2 to the power of the number of discarded levels. 
391         The reduce factor is limited by the smallest total number of decomposition levels among tiles.
392         if != 0, then original dimension divided by 2^(reduce); 
393         if == 0 or not used, image is decoded to the full resolution 
394         */
395         int cp_reduce;
396         /** 
397         Set the maximum number of quality layers to decode. 
398         If there are less quality layers than the specified number, all the quality layers are decoded.
399         if != 0, then only the first "layer" layers are decoded; 
400         if == 0 or not used, all the quality layers are decoded 
401         */
402         int cp_layer;
403
404         /**@name command line encoder parameters (not used inside the library) */
405         /*@{*/
406         /** input file name */
407         char infile[OPJ_PATH_LEN];
408         /** output file name */
409         char outfile[OPJ_PATH_LEN];
410         /** input file format 0: J2K, 1: JP2, 2: JPT */
411         int decod_format;
412         /** output file format 0: PGX, 1: PxM, 2: BMP */
413         int cod_format;
414         /*@}*/
415
416 /* UniPG>> */
417         /**@name JPWL decoding parameters */
418         /*@{*/
419         /** activates the JPWL correction capabilities */
420         opj_bool jpwl_correct;
421         /** expected number of components */
422         int jpwl_exp_comps;
423         /** maximum number of tiles */
424         int jpwl_max_tiles;
425         /*@}*/
426 /* <<UniPG */
427
428         /** 
429         Specify whether the decoding should be done on the entire codestream, or be limited to the main header
430         Limiting the decoding to the main header makes it possible to extract the characteristics of the codestream
431         if == NO_LIMITATION, the entire codestream is decoded; 
432         if == LIMIT_TO_MAIN_HEADER, only the main header is decoded; 
433         */
434         OPJ_LIMIT_DECODING cp_limit_decoding;
435
436
437         /* V2 */
438         OPJ_UINT32 ROI_x0;
439         OPJ_UINT32 ROI_x1;
440         OPJ_UINT32 ROI_y0;
441         OPJ_UINT32 ROI_y1;
442
443
444 } opj_dparameters_t;
445
446 /** Common fields between JPEG-2000 compression and decompression master structs. */
447
448 #define opj_common_fields \
449         opj_event_mgr_t *event_mgr;     /**< pointer to the event manager */\
450         void * client_data;                     /**< Available for use by application */\
451         opj_bool is_decompressor;       /**< So common code can tell which is which */\
452         OPJ_CODEC_FORMAT codec_format;  /**< selected codec */\
453         void *j2k_handle;                       /**< pointer to the J2K codec */\
454         void *jp2_handle;                       /**< pointer to the JP2 codec */\
455         void *mj2_handle                        /**< pointer to the MJ2 codec */
456         
457 /* Routines that are to be used by both halves of the library are declared
458  * to receive a pointer to this structure.  There are no actual instances of
459  * opj_common_struct_t, only of opj_cinfo_t and opj_dinfo_t.
460  */
461 typedef struct opj_common_struct {
462   opj_common_fields;            /* Fields common to both master struct types */
463   /* Additional fields follow in an actual opj_cinfo_t or
464    * opj_dinfo_t.  All three structs must agree on these
465    * initial fields!  (This would be a lot cleaner in C++.)
466    */
467 } opj_common_struct_t;
468
469 typedef opj_common_struct_t * opj_common_ptr;
470
471 /**
472 Compression context info
473 */
474 typedef struct opj_cinfo {
475         /** Fields shared with opj_dinfo_t */
476         opj_common_fields;      
477         /* other specific fields go here */
478 } opj_cinfo_t;
479
480 /**
481 Decompression context info
482 */
483 typedef struct opj_dinfo {
484         /** Fields shared with opj_cinfo_t */
485         opj_common_fields;      
486         /* other specific fields go here */
487 } opj_dinfo_t;
488
489 /**
490  * J2k codec.
491  */
492 typedef void * opj_codec_t;
493
494 /* 
495 ==========================================================
496    I/O stream typedef definitions
497 ==========================================================
498 */
499
500 /*
501  * Stream open flags.
502  */
503 /** The stream was opened for reading. */
504 #define OPJ_STREAM_READ 0x0001
505 /** The stream was opened for writing. */
506 #define OPJ_STREAM_WRITE 0x0002
507
508 /**
509 Byte input-output stream (CIO)
510 */
511 typedef struct opj_cio {
512         /** codec context */
513         opj_common_ptr cinfo;
514
515         /** open mode (read/write) either OPJ_STREAM_READ or OPJ_STREAM_WRITE */
516         int openmode;
517         /** pointer to the start of the buffer */
518         unsigned char *buffer;
519         /** buffer size in bytes */
520         int length;
521
522         /** pointer to the start of the stream */
523         unsigned char *start;
524         /** pointer to the end of the stream */
525         unsigned char *end;
526         /** pointer to the current position */
527         unsigned char *bp;
528 } opj_cio_t;
529
530 typedef OPJ_UINT32 (* opj_stream_read_fn) (void * p_buffer, OPJ_UINT32 p_nb_bytes, void * p_user_data) ;
531 typedef OPJ_UINT32 (* opj_stream_write_fn) (void * p_buffer, OPJ_UINT32 p_nb_bytes, void * p_user_data) ;
532 typedef OPJ_SIZE_T (* opj_stream_skip_fn) (OPJ_SIZE_T p_nb_bytes, void * p_user_data) ;
533 typedef opj_bool (* opj_stream_seek_fn) (OPJ_SIZE_T p_nb_bytes, void * p_user_data) ;
534
535
536 typedef void * opj_stream_t;
537
538 /* 
539 ==========================================================
540    image typedef definitions
541 ==========================================================
542 */
543
544 /**
545 Defines a single image component
546 */
547 typedef struct opj_image_comp {
548         /** XRsiz: horizontal separation of a sample of ith component with respect to the reference grid */
549         int dx;
550         /** YRsiz: vertical separation of a sample of ith component with respect to the reference grid */
551         int dy;
552         /** data width */
553         int w;
554         /** data height */
555         int h;
556         /** x component offset compared to the whole image */
557         int x0;
558         /** y component offset compared to the whole image */
559         int y0;
560         /** precision */
561         int prec;
562         /** image depth in bits */
563         int bpp;
564         /** signed (1) / unsigned (0) */
565         int sgnd;
566         /** number of decoded resolution */
567         int resno_decoded;
568         /** number of division by 2 of the out image compared to the original size of image */
569         int factor;
570         /** image component data */
571         int *data;
572 } opj_image_comp_t;
573
574 /** 
575 Defines image data and characteristics
576 */
577 typedef struct opj_image {
578         /** XOsiz: horizontal offset from the origin of the reference grid to the left side of the image area */
579         OPJ_UINT32 x0;
580         /** YOsiz: vertical offset from the origin of the reference grid to the top side of the image area */
581         OPJ_UINT32 y0;
582         /** Xsiz: width of the reference grid */
583         OPJ_UINT32 x1;
584         /** Ysiz: height of the reference grid */
585         OPJ_UINT32 y1;
586         /** number of components in the image */
587         OPJ_UINT16 numcomps;
588         /** color space: sRGB, Greyscale or YUV */
589         OPJ_COLOR_SPACE color_space;
590         /** image components */
591         opj_image_comp_t *comps;
592         /** 'restricted' ICC profile */
593         unsigned char *icc_profile_buf;
594         /** size of ICC profile */
595         int icc_profile_len;
596 } opj_image_t;
597
598
599 /**
600 Component parameters structure used by the opj_image_create function
601 */
602 typedef struct opj_image_comptparm {
603         /** XRsiz: horizontal separation of a sample of ith component with respect to the reference grid */
604         int dx;
605         /** YRsiz: vertical separation of a sample of ith component with respect to the reference grid */
606         int dy;
607         /** data width */
608         int w;
609         /** data height */
610         int h;
611         /** x component offset compared to the whole image */
612         int x0;
613         /** y component offset compared to the whole image */
614         int y0;
615         /** precision */
616         int prec;
617         /** image depth in bits */
618         int bpp;
619         /** signed (1) / unsigned (0) */
620         int sgnd;
621 } opj_image_cmptparm_t;
622
623
624
625 /**
626 Defines a single image component characteristics (uses in new API)
627 */
628 typedef struct opj_image_comp_header {
629         /** XRsiz: horizontal separation of a sample of ith component with respect to the reference grid */
630         int dx;
631         /** YRsiz: vertical separation of a sample of ith component with respect to the reference grid */
632         int dy;
633         /** data width */
634         int w;
635         /** data height */
636         int h;
637         /** x component offset compared to the whole image */
638         int x0;
639         /** y component offset compared to the whole image */
640         int y0;
641         /** precision */
642         int prec;
643         /** image depth in bits */
644         int bpp;
645         /** signed (1) / unsigned (0) */
646         int sgnd;
647         /** number of decoded resolution */
648         int resno_decoded;
649         /** number of division by 2 of the out image compared to the original size of image */
650         int factor;
651 } opj_image_comp_header_t;
652
653 /**
654 Defines image characteristics (uses in new API)
655 */
656 typedef struct opj_image_header {
657         /** XOsiz: horizontal offset from the origin of the reference grid to the left side of the image area */
658         OPJ_UINT32 x0;
659         /** YOsiz: vertical offset from the origin of the reference grid to the top side of the image area */
660         OPJ_UINT32 y0;
661         /** Xsiz: width of the reference grid */
662         OPJ_UINT32 x1;
663         /** Ysiz: height of the reference grid */
664         OPJ_UINT32 y1;
665         /** number of components in the image */
666         OPJ_UINT16 numcomps;
667         /** color space: sRGB, Greyscale or YUV */
668         OPJ_COLOR_SPACE color_space;
669         /** image components */
670         opj_image_comp_header_t *comps;
671
672 #ifdef TODO_MSD
673         /** XTOsiz */
674         OPJ_UINT32 tile_x0;
675         /** YTOsiz */
676         OPJ_UINT32 tile_y0;
677         /** XTsiz */
678         OPJ_UINT32 tile_width;
679         /** YTsiz */
680         OPJ_UINT32 tile_height;
681         /** number of tiles in width */
682         OPJ_UINT32 nb_tiles_x;
683         /** number of tiles in height */
684         OPJ_UINT32 nb_tiles_y;
685 #endif
686
687         /** 'restricted' ICC profile */
688         unsigned char *icc_profile_buf;
689         /** size of ICC profile */
690         int icc_profile_len;
691 } opj_image_header_t;
692
693
694 /* 
695 ==========================================================
696    Information on the JPEG 2000 codestream
697 ==========================================================
698 */
699
700 /**
701 Index structure : Information concerning a packet inside tile
702 */
703 typedef struct opj_packet_info {
704         /** packet start position (including SOP marker if it exists) */
705         int start_pos;
706         /** end of packet header position (including EPH marker if it exists)*/
707         int end_ph_pos;
708         /** packet end position */
709         int end_pos;
710         /** packet distorsion */
711         double disto;
712 } opj_packet_info_t;
713
714
715 /* UniPG>> */
716 /**
717 Marker structure
718 */
719 typedef struct opj_marker_info_t {
720         /** marker type */
721         unsigned short int type;
722         /** position in codestream */
723         int pos;
724         /** length, marker val included */
725         int len;
726 } opj_marker_info_t;
727 /* <<UniPG */
728
729 /**
730 Index structure : Information concerning tile-parts
731 */
732 typedef struct opj_tp_info {
733         /** start position of tile part */
734         int tp_start_pos;
735         /** end position of tile part header */
736         int tp_end_header;
737         /** end position of tile part */
738         int tp_end_pos;
739         /** start packet of tile part */
740         int tp_start_pack;
741         /** number of packets of tile part */
742         int tp_numpacks;
743 } opj_tp_info_t;
744
745 /**
746 Index structure : information regarding tiles 
747 */
748 typedef struct opj_tile_info {
749         /** value of thresh for each layer by tile cfr. Marcela   */
750         double *thresh;
751         /** number of tile */
752         int tileno;
753         /** start position */
754         int start_pos;
755         /** end position of the header */
756         int end_header;
757         /** end position */
758         int end_pos;
759         /** precinct number for each resolution level (width) */
760         int pw[33];
761         /** precinct number for each resolution level (height) */
762         int ph[33];
763         /** precinct size (in power of 2), in X for each resolution level */
764         int pdx[33];
765         /** precinct size (in power of 2), in Y for each resolution level */
766         int pdy[33];
767         /** information concerning packets inside tile */
768         opj_packet_info_t *packet;
769         /** add fixed_quality */
770         int numpix;
771         /** add fixed_quality */
772         double distotile;
773         /** number of markers */
774         int marknum;
775         /** list of markers */
776         opj_marker_info_t *marker;
777         /** actual size of markers array */
778         int maxmarknum;
779         /** number of tile parts */
780         int num_tps;
781         /** information concerning tile parts */
782         opj_tp_info_t *tp;
783 } opj_tile_info_t;
784
785 /**
786 Index structure of the codestream
787 */
788 typedef struct opj_codestream_info {
789         /** maximum distortion reduction on the whole image (add for Marcela) */
790         double D_max;
791         /** packet number */
792         int packno;
793         /** writing the packet in the index with t2_encode_packets */
794         int index_write;
795         /** image width */
796         int image_w;
797         /** image height */
798         int image_h;
799         /** progression order */
800         OPJ_PROG_ORDER prog;
801         /** tile size in x */
802         int tile_x;
803         /** tile size in y */
804         int tile_y;
805         /** */
806         int tile_Ox;
807         /** */
808         int tile_Oy;
809         /** number of tiles in X */
810         int tw;
811         /** number of tiles in Y */
812         int th;
813         /** component numbers */
814         int numcomps;
815         /** number of layer */
816         int numlayers;
817         /** number of decomposition for each component */
818         int *numdecompos;
819 /* UniPG>> */
820         /** number of markers */
821         int marknum;
822         /** list of markers */
823         opj_marker_info_t *marker;
824         /** actual size of markers array */
825         int maxmarknum;
826 /* <<UniPG */
827         /** main header position */
828         int main_head_start;
829         /** main header position */
830         int main_head_end;
831         /** codestream's size */
832         int codestream_size;
833         /** information regarding tiles inside image */
834         opj_tile_info_t *tile;
835 } opj_codestream_info_t;
836
837 // NEW codestream
838
839 /**
840 Tile-component coding parameters
841 */
842 typedef struct opj_tccp_info
843 {
844         /** component index */
845         OPJ_UINT32 compno;
846         /** coding style */
847         OPJ_UINT32 csty;
848         /** number of resolutions */
849         OPJ_UINT32 numresolutions;
850         /** code-blocks width */
851         OPJ_UINT32 cblkw;
852         /** code-blocks height */
853         OPJ_UINT32 cblkh;
854         /** code-block coding style */
855         OPJ_UINT32 cblksty;
856         /** discrete wavelet transform identifier */
857         OPJ_UINT32 qmfbid;
858         /** quantisation style */
859         OPJ_UINT32 qntsty;
860         /** stepsizes used for quantization */
861         //FIXME opj_stepsize_t stepsizes[J2K_MAXBANDS];
862         /** number of guard bits */
863         OPJ_UINT32 numgbits;
864         /** Region Of Interest shift */
865         OPJ_INT32 roishift;
866         /** precinct width */
867         OPJ_UINT32 prcw[J2K_MAXRLVLS];
868         /** precinct height */
869         OPJ_UINT32 prch[J2K_MAXRLVLS];
870 }
871 opj_tccp_info_t;
872
873 typedef struct opj_tile_v2_info {
874
875         /** number (index) of tile */
876         int tileno;
877
878         /** start position */
879         int start_pos;
880         /** end position of the header */
881         int end_header;
882         /** end position */
883         int end_pos;
884
885         /** add fixed_quality */
886         int numpix;
887         /** add fixed_quality */
888         double distotile;
889
890         /** coding style */
891         OPJ_UINT32 csty;
892         /** progression order */
893         OPJ_PROG_ORDER prg;
894         /** number of layers */
895         OPJ_UINT32 numlayers;
896         /** multi-component transform identifier */
897         OPJ_UINT32 mct;
898         /** rates of layers */
899         OPJ_FLOAT32 rates[100];
900
901         /** precinct number for each resolution level (width) */
902         int pw[33];
903         /** precinct number for each resolution level (height) */
904         int ph[33];
905         /** precinct size (in power of 2), in X for each resolution level */
906         int pdx[33];
907         /** precinct size (in power of 2), in Y for each resolution level */
908         int pdy[33];
909         /** information concerning packets inside tile */
910         opj_packet_info_t *packet;
911
912
913         /** number of tile parts */
914         int num_tps;
915         /** information concerning tile parts */
916         opj_tp_info_t *tp;
917
918         /** information concerning tile component parameters*/
919         opj_tccp_info_t *tccp_info;
920
921         /** value of thresh for each layer by tile cfr. Marcela   */
922         double *thresh;
923 } opj_tile_info_v2_t;
924
925 /**
926 Index structure of the codestream
927 */
928 typedef struct opj_codestream_info_v2 {
929         /* Basic image info */
930         /** image width */
931         int image_w;
932         /** image height */
933         int image_h;
934         /** numbers of component */
935         int numcomps;
936
937         /* Codestream Info */
938         /** progression order */
939         OPJ_PROG_ORDER prog;
940         /** number of layer */
941         int numlayers;
942
943         /** tile origin in x */
944         int tx0;
945         /** tile origin in y */
946         int ty0;
947         /** tile size in x */
948         int tdx;
949         /** tile size in y */
950         int tdy;
951         /** number of tiles in X */
952         int tw;
953         /** number of tiles in Y */
954         int th;
955
956         /** number of decomposition for each component */
957         int *numdecompos;
958
959         /** maximum distortion reduction on the whole image (add for Marcela) */
960         double D_max;
961         /** packet number */
962         int packno;
963         /** writing the packet in the index with t2_encode_packets */
964         int index_write;
965
966
967
968 /* UniPG>> */
969         /** number of markers */
970         int marknum;
971         /** list of markers */
972         opj_marker_info_t *marker;
973         /** actual size of markers array */
974         int maxmarknum;
975 /* <<UniPG */
976
977         /** main header position */
978         int main_head_start;
979         /** main header position */
980         int main_head_end;
981         /** codestream's size */
982         int codestream_size;
983
984         /** information regarding tiles inside image */
985         opj_tile_info_v2_t *tile;
986 } opj_codestream_info_v2_t;
987
988
989 /*
990 ==========================================================
991    Metadata from the JP2file
992 ==========================================================
993 */
994
995 /**
996 Info structure of the file
997 */
998 typedef struct opj_jp2_metadata {
999         /** */
1000         OPJ_INT32       empty_fields;
1001
1002 } opj_jp2_metadata_t;
1003
1004 /*
1005 ==========================================================
1006    Information on the JPEG2000 file
1007 ==========================================================
1008 */
1009
1010 /**
1011 Info structure of the file
1012 */
1013 typedef struct opj_file_info {
1014         /** file format */
1015         OPJ_INT32       file_format;
1016         /** file info level*/
1017         OPJ_INT32       file_info_flag;
1018         /** image info*/
1019         opj_image_header_t img_info;
1020         /** codestream info */
1021         opj_codestream_info_v2_t codestream_info;
1022         /** file info */
1023         opj_jp2_metadata_t jp2_metadata;
1024
1025 } opj_file_info_t;
1026
1027
1028
1029 #ifdef __cplusplus
1030 extern "C" {
1031 #endif
1032
1033
1034 /* 
1035 ==========================================================
1036    openjpeg version
1037 ==========================================================
1038 */
1039
1040 OPJ_API const char * OPJ_CALLCONV opj_version(void);
1041
1042 /* 
1043 ==========================================================
1044    image functions definitions
1045 ==========================================================
1046 */
1047
1048 /**
1049 Create an image
1050 @param numcmpts number of components
1051 @param cmptparms components parameters
1052 @param clrspc image color space
1053 @return returns a new image structure if successful, returns NULL otherwise
1054 */
1055 OPJ_API opj_image_t* OPJ_CALLCONV opj_image_create(int numcmpts, opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc);
1056
1057 /**
1058 Deallocate any resources associated with an image
1059 @param image image to be destroyed
1060 */
1061 OPJ_API void OPJ_CALLCONV opj_image_destroy(opj_image_t *image);
1062
1063 OPJ_API void OPJ_CALLCONV opj_image_header_destroy(opj_image_header_t *image_header);
1064
1065 /* 
1066 ==========================================================
1067    stream functions definitions
1068 ==========================================================
1069 */
1070
1071 /**
1072 Open and allocate a memory stream for read / write. 
1073 On reading, the user must provide a buffer containing encoded data. The buffer will be 
1074 wrapped by the returned CIO handle. 
1075 On writing, buffer parameters must be set to 0: a buffer will be allocated by the library 
1076 to contain encoded data. 
1077 @param cinfo Codec context info
1078 @param buffer Reading: buffer address. Writing: NULL
1079 @param length Reading: buffer length. Writing: 0
1080 @return Returns a CIO handle if successful, returns NULL otherwise
1081 */
1082 OPJ_API opj_cio_t* OPJ_CALLCONV opj_cio_open(opj_common_ptr cinfo, unsigned char *buffer, int length);
1083
1084 /**
1085 Close and free a CIO handle
1086 @param cio CIO handle to free
1087 */
1088 OPJ_API void OPJ_CALLCONV opj_cio_close(opj_cio_t *cio);
1089
1090 /**
1091 Get position in byte stream
1092 @param cio CIO handle
1093 @return Returns the position in bytes
1094 */
1095 OPJ_API int OPJ_CALLCONV cio_tell(opj_cio_t *cio);
1096 /**
1097 Set position in byte stream
1098 @param cio CIO handle
1099 @param pos Position, in number of bytes, from the beginning of the stream
1100 */
1101 OPJ_API void OPJ_CALLCONV cio_seek(opj_cio_t *cio, int pos);
1102
1103
1104 /**
1105  * Creates an abstract stream. This function does nothing except allocating memory and initializing the abstract stream.
1106  *
1107  * @param       l_is_reader             if set to true then the stream will be an input stream, an output stream else.
1108  *
1109  * @return      a stream object.
1110 */
1111 OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_default_create(opj_bool p_is_input);
1112 OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create(OPJ_UINT32 p_size, opj_bool p_is_input);
1113
1114 /**
1115  * Destroys a stream created by opj_create_stream. This function does NOT close the abstract stream. If needed the user must
1116  * close its own implementation of the stream.
1117  *
1118  * @param       p_stream        the stream to destroy.
1119  */
1120 OPJ_API void OPJ_CALLCONV opj_stream_destroy(opj_stream_t* p_stream);
1121
1122 /**
1123  * Sets the given function to be used as a read function.
1124  * @param               p_stream        the stream to modify
1125  * @param               p_function      the function to use a read function.
1126 */
1127 OPJ_API void OPJ_CALLCONV opj_stream_set_read_function(opj_stream_t* p_stream, opj_stream_read_fn p_function);
1128
1129 /**
1130  * Sets the given function to be used as a write function.
1131  * @param               p_stream        the stream to modify
1132  * @param               p_function      the function to use a write function.
1133 */
1134 OPJ_API void OPJ_CALLCONV opj_stream_set_write_function(opj_stream_t* p_stream, opj_stream_write_fn p_function);
1135
1136 /**
1137  * Sets the given function to be used as a skip function.
1138  * @param               p_stream        the stream to modify
1139  * @param               p_function      the function to use a skip function.
1140 */
1141 OPJ_API void OPJ_CALLCONV opj_stream_set_skip_function(opj_stream_t* p_stream, opj_stream_skip_fn p_function);
1142
1143 /**
1144  * Sets the given function to be used as a seek function, the stream is then seekable.
1145  * @param               p_stream        the stream to modify
1146  * @param               p_function      the function to use a skip function.
1147 */
1148 OPJ_API void OPJ_CALLCONV opj_stream_set_seek_function(opj_stream_t* p_stream, opj_stream_seek_fn p_function);
1149
1150
1151 /**
1152  * Sets the given data to be used as a user data for the stream.
1153  * @param               p_stream        the stream to modify
1154  * @param               p_data          the data to set.
1155 */
1156 OPJ_API void OPJ_CALLCONV opj_stream_set_user_data (opj_stream_t* p_stream, void * p_data);
1157
1158
1159 /**
1160  * Helper function.
1161  * Sets the stream to be a file stream. The FILE must have been open previously.
1162  * @param               p_stream        the stream to modify
1163  * @param               p_file          handler to an already open file.
1164 */
1165 OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create_default_file_stream (FILE * p_file, opj_bool p_is_read_stream);
1166 OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream (FILE * p_file, OPJ_UINT32 p_buffer_size, opj_bool p_is_read_stream);
1167
1168
1169
1170 /* 
1171 ==========================================================
1172    event manager functions definitions
1173 ==========================================================
1174 */
1175
1176 OPJ_API opj_event_mgr_t* OPJ_CALLCONV opj_set_event_mgr(opj_common_ptr cinfo, opj_event_mgr_t *event_mgr, void *context);
1177
1178 /* 
1179 ==========================================================
1180    codec functions definitions
1181 ==========================================================
1182 */
1183 /**
1184 Creates a J2K/JPT/JP2 decompression structure
1185 @param format Decoder to select
1186 @return Returns a handle to a decompressor if successful, returns NULL otherwise
1187 */
1188 OPJ_API opj_codec_t* OPJ_CALLCONV opj_create_decompress_v2(OPJ_CODEC_FORMAT format);
1189
1190
1191 /**
1192 Creates a J2K/JPT/JP2 decompression structure
1193 @param format Decoder to select
1194 @return Returns a handle to a decompressor if successful, returns NULL otherwise
1195 */
1196 OPJ_API opj_dinfo_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT format);
1197 /**
1198 Destroy a decompressor handle
1199 @param dinfo decompressor handle to destroy
1200 */
1201 OPJ_API void OPJ_CALLCONV opj_destroy_decompress(opj_dinfo_t *dinfo);
1202 /**
1203 Set decoding parameters to default values
1204 @param parameters Decompression parameters
1205 */
1206 OPJ_API void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *parameters);
1207 /**
1208 Setup the decoder decoding parameters using user parameters.
1209 Decoding parameters are returned in j2k->cp. 
1210 @param dinfo decompressor handle
1211 @param parameters decompression parameters
1212 */
1213 OPJ_API void OPJ_CALLCONV opj_setup_decoder(opj_dinfo_t *dinfo, opj_dparameters_t *parameters);
1214
1215 OPJ_API opj_bool OPJ_CALLCONV opj_setup_decoder_v2(     opj_codec_t *p_info,
1216                                                                                                         opj_dparameters_t *parameters,
1217                                                                                                         opj_event_mgr_t* event_mgr);
1218
1219 /**
1220 Decode an image from a JPEG-2000 codestream 
1221 @param dinfo decompressor handle
1222 @param cio Input buffer stream
1223 @return Returns a decoded image if successful, returns NULL otherwise
1224 */
1225 OPJ_API opj_image_t* OPJ_CALLCONV opj_decode(opj_dinfo_t *dinfo, opj_cio_t *cio);
1226
1227 /**
1228 Decode an image from a JPEG-2000 codestream and extract the codestream information
1229 @param dinfo decompressor handle
1230 @param cio Input buffer stream
1231 @param cstr_info Codestream information structure if needed afterwards, NULL otherwise
1232 @return Returns a decoded image if successful, returns NULL otherwise
1233 */
1234 OPJ_API opj_image_t* OPJ_CALLCONV opj_decode_with_info(opj_dinfo_t *dinfo, opj_cio_t *cio, opj_codestream_info_t *cstr_info);
1235 /**
1236 Creates a J2K/JP2 compression structure
1237 @param format Coder to select
1238 @return Returns a handle to a compressor if successful, returns NULL otherwise
1239 */
1240 OPJ_API opj_cinfo_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format);
1241 /**
1242 Destroy a compressor handle
1243 @param cinfo compressor handle to destroy
1244 */
1245 OPJ_API void OPJ_CALLCONV opj_destroy_compress(opj_cinfo_t *cinfo);
1246 /**
1247 Set encoding parameters to default values, that means : 
1248 <ul>
1249 <li>Lossless
1250 <li>1 tile
1251 <li>Size of precinct : 2^15 x 2^15 (means 1 precinct)
1252 <li>Size of code-block : 64 x 64
1253 <li>Number of resolutions: 6
1254 <li>No SOP marker in the codestream
1255 <li>No EPH marker in the codestream
1256 <li>No sub-sampling in x or y direction
1257 <li>No mode switch activated
1258 <li>Progression order: LRCP
1259 <li>No index file
1260 <li>No ROI upshifted
1261 <li>No offset of the origin of the image
1262 <li>No offset of the origin of the tiles
1263 <li>Reversible DWT 5-3
1264 </ul>
1265 @param parameters Compression parameters
1266 */
1267 OPJ_API void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *parameters);
1268 /**
1269 Setup the encoder parameters using the current image and using user parameters. 
1270 @param cinfo Compressor handle
1271 @param parameters Compression parameters
1272 @param image Input filled image
1273 */
1274 OPJ_API void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_image_t *image);
1275 /**
1276 Encode an image into a JPEG-2000 codestream
1277 3@param cinfo compressor handle
1278 @param cio Output buffer stream
1279 @param image Image to encode
1280 @param index Depreacted -> Set to NULL. To extract index, used opj_encode_wci()
1281 @return Returns true if successful, returns false otherwise
1282 */
1283 OPJ_API opj_bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index);
1284 /**
1285 Encode an image into a JPEG-2000 codestream and extract the codestream information
1286 @param cinfo compressor handle
1287 @param cio Output buffer stream
1288 @param image Image to encode
1289 @param cstr_info Codestream information structure if needed afterwards, NULL otherwise
1290 @return Returns true if successful, returns false otherwise
1291 */
1292 OPJ_API opj_bool OPJ_CALLCONV opj_encode_with_info(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info);
1293 /**
1294 Destroy Codestream information after compression or decompression
1295 @param cstr_info Codestream information structure
1296 */
1297 OPJ_API void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_t *cstr_info);
1298
1299
1300 /**
1301  * Decodes an image header.
1302  *
1303  * @param       p_codec                 codec to use to decode the image.
1304  * @param       p_image                 pointer to a previously created image.
1305  * @param       p_tile_x0               pointer to a value that will hold the reference point x0 of the tiling grid.
1306  * @param       p_tile_y0               pointer to a value that will hold the reference point y0 of the tiling grid.
1307  * @param       p_tile_width    pointer to a value that will hold the size in x of a tile in the grid.
1308  * @param       p_tile_height   pointer to a value that will hold the size in y of a tile in the grid.
1309  * @param       p_nb_tiles_x    pointer to a value that will hold the number of tiles in the x direction.
1310  * @param       p_nb_tiles_y    pointer to a value that will hold the number of tiles in the y direction.
1311  */
1312 OPJ_API opj_bool OPJ_CALLCONV opj_read_header ( opj_stream_t *p_cio,
1313                                                                                                 opj_codec_t *p_codec,
1314                                                                                                 opj_file_info_t * p_file_info,
1315                                                                                                 OPJ_INT32 file_info_flag);
1316
1317 /**
1318 Destroy a decompressor handle
1319 @param dinfo decompressor handle to destroy
1320 */
1321 OPJ_API void OPJ_CALLCONV opj_destroy_codec(opj_codec_t * p_codec);
1322
1323 /**
1324  * Sets the given area to be decoded. This function should be called right after opj_read_header and before any tile header reading.
1325  *
1326  * @param       p_codec                 the jpeg2000 codec.
1327  * @param       p_start_x               the left position of the rectangle to decode (in image coordinates).
1328  * @param       p_end_x                 the right position of the rectangle to decode (in image coordinates).
1329  * @param       p_start_y               the up position of the rectangle to decode (in image coordinates).
1330  * @param       p_end_y                 the bottom position of the rectangle to decode (in image coordinates).
1331  *
1332  * @return      true                    if the area could be set.
1333  */
1334 OPJ_API opj_bool OPJ_CALLCONV opj_set_decode_area(      opj_codec_t *p_codec,
1335                                                                                                         OPJ_INT32 p_start_x, OPJ_INT32 p_start_y,
1336                                                                                                         OPJ_INT32 p_end_x, OPJ_INT32 p_end_y );
1337
1338 #ifdef __cplusplus
1339 }
1340 #endif
1341
1342 #endif /* OPENJPEG_H */
1343
1344