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