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