Fixed a copy-and-paste type assignment error (bool instead of int) in the JPWL sectio...
[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  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 #ifndef OPENJPEG_H
32 #define OPENJPEG_H
33
34 #define OPENJPEG_VERSION "1.1.0"
35
36 /* 
37 ==========================================================
38    Compiler directives
39 ==========================================================
40 */
41
42 #if defined(OPJ_STATIC) || !(defined(WIN32) || defined(__WIN32__))
43 #define OPJ_API
44 #define OPJ_CALLCONV
45 #else
46 #define OPJ_CALLCONV __stdcall
47 /*
48 The following ifdef block is the standard way of creating macros which make exporting 
49 from a DLL simpler. All files within this DLL are compiled with the OPJ_EXPORTS
50 symbol defined on the command line. this symbol should not be defined on any project
51 that uses this DLL. This way any other project whose source files include this file see 
52 OPJ_API functions as being imported from a DLL, wheras this DLL sees symbols
53 defined with this macro as being exported.
54 */
55 #ifdef OPJ_EXPORTS
56 #define OPJ_API __declspec(dllexport)
57 #else
58 #define OPJ_API __declspec(dllimport)
59 #endif /* OPJ_EXPORTS */
60 #endif /* !OPJ_STATIC || !WIN32 */
61
62 #ifndef __cplusplus
63 #if defined(HAVE_STDBOOL_H)
64 /*
65 The C language implementation does correctly provide the standard header
66 file "stdbool.h".
67  */
68 #include <stdbool.h>
69 #else
70 /*
71 The C language implementation does not provide the standard header file
72 "stdbool.h" as required by ISO/IEC 9899:1999.  Try to compensate for this
73 braindamage below.
74 */
75 #if !defined(bool)
76 #define bool    int
77 #endif
78 #if !defined(true)
79 #define true    1
80 #endif
81 #if !defined(false)
82 #define false   0
83 #endif
84 #endif
85 #endif /* __cplusplus */
86
87 /* 
88 ==========================================================
89    Useful constant definitions
90 ==========================================================
91 */
92
93 #define OPJ_PATH_LEN 4096 /**< Maximum allowed size for filenames */
94
95 #define J2K_MAXRLVLS 33                                 /**< Number of maximum resolution level authorized */
96 #define J2K_MAXBANDS (3*J2K_MAXRLVLS-2) /**< Number of maximum sub-band linked to number of resolution level */
97
98 /* UniPG>> */
99 #ifdef USE_JPWL
100 #define JPWL_MAX_NO_TILESPECS   16 /**< Maximum number of tile parts expected by JPWL: increase at your will */
101 #define JPWL_MAX_NO_PACKSPECS   16 /**< Maximum number of packet parts expected by JPWL: increase at your will */
102 #define JPWL_MAX_NO_MARKERS     512 /**< Maximum number of JPWL markers: increase at your will */
103 #define JPWL_PRIVATEINDEX_NAME "jpwl_index_privatefilename" /**< index file name used when JPWL is on */
104 #define JPWL_EXPECTED_COMPONENTS 3 /**< Expect this number of components, so you'll find better the first EPB */
105 #define JPWL_MAXIMUM_TILES 8192 /**< Expect this maximum number of tiles, to avoid some crashes */
106 #define JPWL_MAXIMUM_HAMMING 2 /**< Expect this maximum number of bit errors in marker id's */
107 #endif /* USE_JPWL */
108 /* <<UniPG */
109
110 /* 
111 ==========================================================
112    enum definitions
113 ==========================================================
114 */
115
116 /** Progression order */
117 typedef enum PROG_ORDER {
118         PROG_UNKNOWN = -1,      /**< place-holder */
119         LRCP = 0,               /**< layer-resolution-component-precinct order */
120         RLCP = 1,               /**< resolution-layer-component-precinct order */
121         RPCL = 2,               /**< resolution-precinct-component-layer order */
122         PCRL = 3,               /**< precinct-component-resolution-layer order */
123         CPRL = 4                /**< component-precinct-resolution-layer order */
124 } OPJ_PROG_ORDER;
125
126 /**
127 Supported image color spaces
128 */
129 typedef enum COLOR_SPACE {
130         CLRSPC_UNKNOWN = -1,    /**< place-holder */
131         CLRSPC_SRGB = 1,                /**< sRGB */
132         CLRSPC_GRAY = 2,                /**< grayscale */
133         CLRSPC_SYCC = 3                 /**< YUV */
134 } OPJ_COLOR_SPACE;
135
136 /**
137 Supported codec
138 */
139 typedef enum CODEC_FORMAT {
140         CODEC_UNKNOWN = -1,     /**< place-holder */
141         CODEC_J2K = 0,          /**< JPEG-2000 codestream : read/write */
142         CODEC_JPT = 1,          /**< JPT-stream (JPEG 2000, JPIP) : read only */
143         CODEC_JP2 = 2           /**< JPEG-2000 file format : read/write */
144 } OPJ_CODEC_FORMAT;
145
146 /** 
147 Limit decoding to certain portions of the codestream. 
148 */
149 typedef enum LIMIT_DECODING {
150         NO_LIMITATION = 0,                              /**< No limitation for the decoding. The entire codestream will de decoded */
151         LIMIT_TO_MAIN_HEADER = 1        /**< The decoding is limited to the Main Header */
152 } OPJ_LIMIT_DECODING;
153
154 /* 
155 ==========================================================
156    event manager typedef definitions
157 ==========================================================
158 */
159
160 /**
161 Callback function prototype for events
162 @param msg Event message
163 @param client_data 
164 */
165 typedef void (*opj_msg_callback) (const char *msg, void *client_data);
166
167 /**
168 Message handler object
169 used for 
170 <ul>
171 <li>Error messages
172 <li>Warning messages
173 <li>Debugging messages
174 </ul>
175 */
176 typedef struct opj_event_mgr {
177         /** Error message callback if available, NULL otherwise */
178         opj_msg_callback error_handler;
179         /** Warning message callback if available, NULL otherwise */
180         opj_msg_callback warning_handler;
181         /** Debug message callback if available, NULL otherwise */
182         opj_msg_callback info_handler;
183 } opj_event_mgr_t;
184
185
186 /* 
187 ==========================================================
188    codec typedef definitions
189 ==========================================================
190 */
191
192 /**
193 Progression order changes
194 */
195 typedef struct opj_poc {
196   int resno0, compno0;
197   int layno1, resno1, compno1;
198   OPJ_PROG_ORDER prg;
199   int tile;
200   char progorder[4];
201 } opj_poc_t;
202
203 /**
204 Compression parameters
205 */
206 typedef struct opj_cparameters {
207         /** size of tile: tile_size_on = false (not in argument) or = true (in argument) */
208         bool tile_size_on;
209         /** XTOsiz */
210         int cp_tx0;
211         /** YTOsiz */
212         int cp_ty0;
213         /** XTsiz */
214         int cp_tdx;
215         /** YTsiz */
216         int cp_tdy;
217         /** allocation by rate/distortion */
218         int cp_disto_alloc;
219         /** allocation by fixed layer */
220         int cp_fixed_alloc;
221         /** add fixed_quality */
222         int cp_fixed_quality;
223         /** fixed layer */
224         int *cp_matrice;
225         /** comment for coding */
226         char *cp_comment;
227         /** csty : coding style */
228         int csty;
229         /** progression order (default LRCP) */
230         OPJ_PROG_ORDER prog_order;
231         /** progression order changes */
232         opj_poc_t POC[32];
233         /** number of progression order changes (POC), default to 0 */
234         int numpocs;
235         /** number of layers */
236         int tcp_numlayers;
237         /** rates of layers */
238         float tcp_rates[100];
239         /** different psnr for successive layers */
240         float tcp_distoratio[100];
241         /** number of resolutions */
242         int numresolution;
243         /** initial code block width, default to 64 */
244         int cblockw_init;
245         /** initial code block height, default to 64 */
246         int cblockh_init;
247         /** mode switch (cblk_style) */
248         int mode;
249         /** 1 : use the irreversible DWT 9-7, 0 : use lossless compression (default) */
250         int irreversible;
251         /** region of interest: affected component in [0..3], -1 means no ROI */
252         int roi_compno;
253         /** region of interest: upshift value */
254         int roi_shift;
255         /* number of precinct size specifications */
256         int res_spec;
257         /** initial precinct width */
258         int prcw_init[J2K_MAXRLVLS];
259         /** initial precinct height */
260         int prch_init[J2K_MAXRLVLS];
261
262         /**@name command line encoder parameters (not used inside the library) */
263         /*@{*/
264         /** input file name */
265         char infile[OPJ_PATH_LEN];
266         /** output file name */
267         char outfile[OPJ_PATH_LEN];
268         /** creation of an index file, default to 0 (false) */
269         int index_on;
270         /** index file name */
271         char index[OPJ_PATH_LEN];
272         /** subimage encoding: origin image offset in x direction */
273         int image_offset_x0;
274         /** subimage encoding: origin image offset in y direction */
275         int image_offset_y0;
276         /** subsampling value for dx */
277         int subsampling_dx;
278         /** subsampling value for dy */
279         int subsampling_dy;
280         /** input file format 0: PGX, 1: PxM, 2: BMP */
281         int decod_format;
282         /** output file format 0: J2K, 1: JP2, 2: JPT */
283         int cod_format;
284         /*@}*/
285
286 /* UniPG>> */
287 #ifdef USE_JPWL
288         /**@name JPWL encoding parameters */
289         /*@{*/
290         /** enables writing of EPC in MH, thus activating JPWL */
291         bool jpwl_epc_on;
292         /** error protection method for MH (0,1,16,32,37-128) */
293         int jpwl_hprot_MH;
294         /** tile number of header protection specification (>=0) */
295         int jpwl_hprot_TPH_tileno[JPWL_MAX_NO_TILESPECS];
296         /** error protection methods for TPHs (0,1,16,32,37-128) */
297         int jpwl_hprot_TPH[JPWL_MAX_NO_TILESPECS];
298         /** tile number of packet protection specification (>=0) */
299         int jpwl_pprot_tileno[JPWL_MAX_NO_PACKSPECS];
300         /** packet number of packet protection specification (>=0) */
301         int jpwl_pprot_packno[JPWL_MAX_NO_PACKSPECS];
302         /** error protection methods for packets (0,1,16,32,37-128) */
303         int jpwl_pprot[JPWL_MAX_NO_PACKSPECS];
304         /** enables writing of ESD, (0=no/1/2 bytes) */
305         int jpwl_sens_size;
306         /** sensitivity addressing size (0=auto/2/4 bytes) */
307         int jpwl_sens_addr;
308         /** sensitivity range (0-3) */
309         int jpwl_sens_range;
310         /** sensitivity method for MH (-1=no,0-7) */
311         int jpwl_sens_MH;
312         /** tile number of sensitivity specification (>=0) */
313         int jpwl_sens_TPH_tileno[JPWL_MAX_NO_TILESPECS];
314         /** sensitivity methods for TPHs (-1=no,0-7) */
315         int jpwl_sens_TPH[JPWL_MAX_NO_TILESPECS];
316         /*@}*/
317 #endif /* USE_JPWL */
318 /* <<UniPG */
319
320 } opj_cparameters_t;
321
322 /**
323 Decompression parameters
324 */
325 typedef struct opj_dparameters {
326         /** 
327         Set the number of highest resolution levels to be discarded. 
328         The image resolution is effectively divided by 2 to the power of the number of discarded levels. 
329         The reduce factor is limited by the smallest total number of decomposition levels among tiles.
330         if != 0, then original dimension divided by 2^(reduce); 
331         if == 0 or not used, image is decoded to the full resolution 
332         */
333         int cp_reduce;
334         /** 
335         Set the maximum number of quality layers to decode. 
336         If there are less quality layers than the specified number, all the quality layers are decoded.
337         if != 0, then only the first "layer" layers are decoded; 
338         if == 0 or not used, all the quality layers are decoded 
339         */
340         int cp_layer;
341
342         /** 
343         Specify whether the decoding should be done on the entire codestream, or be limited to the main header
344         Limiting the decoding to the main header makes it possible to extract the characteristics of the codestream
345         if == NO_LIMITATION, the entire codestream is decoded; 
346         if == LIMIT_TO_MAIN_HEADER, only the main header is decoded; 
347         */
348         OPJ_LIMIT_DECODING cp_limit_decoding;
349
350         /**@name command line encoder parameters (not used inside the library) */
351         /*@{*/
352         /** input file name */
353         char infile[OPJ_PATH_LEN];
354         /** output file name */
355         char outfile[OPJ_PATH_LEN];
356         /** input file format 0: J2K, 1: JP2, 2: JPT */
357         int decod_format;
358         /** output file format 0: PGX, 1: PxM, 2: BMP */
359         int cod_format;
360         /*@}*/
361
362 /* UniPG>> */
363 #ifdef USE_JPWL
364         /**@name JPWL decoding parameters */
365         /*@{*/
366         /** activates the JPWL correction capabilities */
367         bool jpwl_correct;
368         /** expected number of components */
369         int jpwl_exp_comps;
370         /** maximum number of tiles */
371         int jpwl_max_tiles;
372         /*@}*/
373 #endif /* USE_JPWL */
374 /* <<UniPG */
375 } opj_dparameters_t;
376
377 /** Common fields between JPEG-2000 compression and decompression master structs. */
378
379 #define opj_common_fields \
380         opj_event_mgr_t *event_mgr;     /**< pointer to the event manager */\
381         void * client_data;                     /**< Available for use by application */\
382         bool is_decompressor;           /**< So common code can tell which is which */\
383         OPJ_CODEC_FORMAT codec_format;  /**< selected codec */\
384         void *j2k_handle;                       /**< pointer to the J2K codec */\
385         void *jp2_handle                        /**< pointer to the JP2 codec */
386         
387 /* Routines that are to be used by both halves of the library are declared
388  * to receive a pointer to this structure.  There are no actual instances of
389  * opj_common_struct_t, only of opj_cinfo_t and opj_dinfo_t.
390  */
391 typedef struct opj_common_struct {
392   opj_common_fields;            /* Fields common to both master struct types */
393   /* Additional fields follow in an actual opj_cinfo_t or
394    * opj_dinfo_t.  All three structs must agree on these
395    * initial fields!  (This would be a lot cleaner in C++.)
396    */
397 } opj_common_struct_t;
398
399 typedef opj_common_struct_t * opj_common_ptr;
400
401 /**
402 Compression context info
403 */
404 typedef struct opj_cinfo {
405         /** Fields shared with opj_dinfo_t */
406         opj_common_fields;      
407         /* other specific fields go here */
408 } opj_cinfo_t;
409
410 /**
411 Decompression context info
412 */
413 typedef struct opj_dinfo {
414         /** Fields shared with opj_cinfo_t */
415         opj_common_fields;      
416         /* other specific fields go here */
417 } opj_dinfo_t;
418
419 /* 
420 ==========================================================
421    I/O stream typedef definitions
422 ==========================================================
423 */
424
425 /*
426  * Stream open flags.
427  */
428 /** The stream was opened for reading. */
429 #define OPJ_STREAM_READ 0x0001
430 /** The stream was opened for writing. */
431 #define OPJ_STREAM_WRITE 0x0002
432
433 /**
434 Byte input-output stream (CIO)
435 */
436 typedef struct opj_cio {
437         /** codec context */
438         opj_common_ptr cinfo;
439
440         /** open mode (read/write) either OPJ_STREAM_READ or OPJ_STREAM_WRITE */
441         int openmode;
442         /** pointer to the start of the buffer */
443         unsigned char *buffer;
444         /** buffer size in bytes */
445         int length;
446
447         /** pointer to the start of the stream */
448         unsigned char *start;
449         /** pointer to the end of the stream */
450         unsigned char *end;
451         /** pointer to the current position */
452         unsigned char *bp;
453 } opj_cio_t;
454
455 /* 
456 ==========================================================
457    image typedef definitions
458 ==========================================================
459 */
460
461 /**
462 Defines a single image component
463 */
464 typedef struct opj_image_comp {
465         /** XRsiz: horizontal separation of a sample of ith component with respect to the reference grid */
466         int dx;
467         /** YRsiz: vertical separation of a sample of ith component with respect to the reference grid */
468         int dy;
469         /** data width */
470         int w;
471         /** data height */
472         int h;
473         /** x component offset compared to the whole image */
474         int x0;
475         /** y component offset compared to the whole image */
476         int y0;
477         /** precision */
478         int prec;
479         /** image depth in bits */
480         int bpp;
481         /** signed (1) / unsigned (0) */
482         int sgnd;
483         /** number of decoded resolution */
484         int resno_decoded;
485         /** number of division by 2 of the out image compared to the original size of image */
486         int factor;
487         /** image component data */
488         int *data;
489 } opj_image_comp_t;
490
491 /** 
492 Defines image data and characteristics
493 */
494 typedef struct opj_image {
495         /** XOsiz: horizontal offset from the origin of the reference grid to the left side of the image area */
496         int x0;
497         /** YOsiz: vertical offset from the origin of the reference grid to the top side of the image area */
498         int y0;
499         /** Xsiz: width of the reference grid */
500         int x1;
501         /** Ysiz: height of the reference grid */
502         int y1;
503         /** number of components in the image */
504         int numcomps;
505         /** color space: sRGB, Greyscale or YUV */
506         OPJ_COLOR_SPACE color_space;
507         /** image components */
508         opj_image_comp_t *comps;
509 } opj_image_t;
510
511 /**
512 Component parameters structure used by the opj_image_create function
513 */
514 typedef struct opj_image_comptparm {
515         /** XRsiz: horizontal separation of a sample of ith component with respect to the reference grid */
516         int dx;
517         /** YRsiz: vertical separation of a sample of ith component with respect to the reference grid */
518         int dy;
519         /** data width */
520         int w;
521         /** data height */
522         int h;
523         /** x component offset compared to the whole image */
524         int x0;
525         /** y component offset compared to the whole image */
526         int y0;
527         /** precision */
528         int prec;
529         /** image depth in bits */
530         int bpp;
531         /** signed (1) / unsigned (0) */
532         int sgnd;
533 } opj_image_cmptparm_t;
534
535 #ifdef __cplusplus
536 extern "C" {
537 #endif
538
539
540 /* 
541 ==========================================================
542    openjpeg version
543 ==========================================================
544 */
545
546 OPJ_API const char * OPJ_CALLCONV opj_version();
547
548 /* 
549 ==========================================================
550    image functions definitions
551 ==========================================================
552 */
553
554 /**
555 Create an image
556 @param numcmpts number of components
557 @param cmptparms components parameters
558 @param clrspc image color space
559 @return returns a new image structure if successful, returns NULL otherwise
560 */
561 OPJ_API opj_image_t* OPJ_CALLCONV opj_image_create(int numcmpts, opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc);
562
563 /**
564 Deallocate any resources associated with an image
565 @param image image to be destroyed
566 */
567 OPJ_API void OPJ_CALLCONV opj_image_destroy(opj_image_t *image);
568
569 /* 
570 ==========================================================
571    stream functions definitions
572 ==========================================================
573 */
574
575 /**
576 Open and allocate a memory stream for read / write. 
577 On reading, the user must provide a buffer containing encoded data. The buffer will be 
578 wrapped by the returned CIO handle. 
579 On writing, buffer parameters must be set to 0: a buffer will be allocated by the library 
580 to contain encoded data. 
581 @param cinfo Codec context info
582 @param buffer Reading: buffer address. Writing: NULL
583 @param length Reading: buffer length. Writing: 0
584 @return Returns a CIO handle if successful, returns NULL otherwise
585 */
586 OPJ_API opj_cio_t* OPJ_CALLCONV opj_cio_open(opj_common_ptr cinfo, unsigned char *buffer, int length);
587
588 /**
589 Close and free a CIO handle
590 @param cio CIO handle to free
591 */
592 OPJ_API void OPJ_CALLCONV opj_cio_close(opj_cio_t *cio);
593
594 /**
595 Get position in byte stream
596 @param cio CIO handle
597 @return Returns the position in bytes
598 */
599 OPJ_API int OPJ_CALLCONV cio_tell(opj_cio_t *cio);
600 /**
601 Set position in byte stream
602 @param cio CIO handle
603 @param pos Position, in number of bytes, from the beginning of the stream
604 */
605 OPJ_API void OPJ_CALLCONV cio_seek(opj_cio_t *cio, int pos);
606
607 /* 
608 ==========================================================
609    event manager functions definitions
610 ==========================================================
611 */
612
613 OPJ_API opj_event_mgr_t* OPJ_CALLCONV opj_set_event_mgr(opj_common_ptr cinfo, opj_event_mgr_t *event_mgr, void *context);
614
615 /* 
616 ==========================================================
617    codec functions definitions
618 ==========================================================
619 */
620 /**
621 Creates a J2K/JPT/JP2 decompression structure
622 @param format Decoder to select
623 @return Returns a handle to a decompressor if successful, returns NULL otherwise
624 */
625 OPJ_API opj_dinfo_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT format);
626 /**
627 Destroy a decompressor handle
628 @param dinfo decompressor handle to destroy
629 */
630 OPJ_API void OPJ_CALLCONV opj_destroy_decompress(opj_dinfo_t *dinfo);
631 /**
632 Set decoding parameters to default values
633 @param parameters Decompression parameters
634 */
635 OPJ_API void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *parameters);
636 /**
637 Setup the decoder decoding parameters using user parameters.
638 Decoding parameters are returned in j2k->cp. 
639 @param dinfo decompressor handle
640 @param parameters decompression parameters
641 */
642 OPJ_API void OPJ_CALLCONV opj_setup_decoder(opj_dinfo_t *dinfo, opj_dparameters_t *parameters);
643 /**
644 Decode an image from a JPEG-2000 codestream
645 @param dinfo decompressor handle
646 @param cio Input buffer stream
647 @return Returns a decoded image if successful, returns NULL otherwise
648 */
649 OPJ_API opj_image_t* OPJ_CALLCONV opj_decode(opj_dinfo_t *dinfo, opj_cio_t *cio);
650 /**
651 Creates a J2K/JP2 compression structure
652 @param format Coder to select
653 @return Returns a handle to a compressor if successful, returns NULL otherwise
654 */
655 OPJ_API opj_cinfo_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format);
656 /**
657 Destroy a compressor handle
658 @param cinfo compressor handle to destroy
659 */
660 OPJ_API void OPJ_CALLCONV opj_destroy_compress(opj_cinfo_t *cinfo);
661 /**
662 Set encoding parameters to default values, that means : 
663 <ul>
664 <li>Lossless
665 <li>1 tile
666 <li>Size of precinct : 2^15 x 2^15 (means 1 precinct)
667 <li>Size of code-block : 64 x 64
668 <li>Number of resolutions: 6
669 <li>No SOP marker in the codestream
670 <li>No EPH marker in the codestream
671 <li>No sub-sampling in x or y direction
672 <li>No mode switch activated
673 <li>Progression order: LRCP
674 <li>No index file
675 <li>No ROI upshifted
676 <li>No offset of the origin of the image
677 <li>No offset of the origin of the tiles
678 <li>Reversible DWT 5-3
679 </ul>
680 @param parameters Compression parameters
681 */
682 OPJ_API void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *parameters);
683 /**
684 Setup the encoder parameters using the current image and using user parameters. 
685 @param cinfo compressor handle
686 @param parameters compression parameters
687 @param image input filled image
688 */
689 OPJ_API void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_image_t *image);
690 /**
691 Encode an image into a JPEG-2000 codestream
692 @param cinfo compressor handle
693 @param cio Output buffer stream
694 @param image Image to encode
695 @param index Name of the index file if required, NULL otherwise
696 @return Returns true if successful, returns false otherwise
697 */
698 OPJ_API bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index);
699
700 #ifdef __cplusplus
701 }
702 #endif
703
704 #endif /* OPENJPEG_H */