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