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