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