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