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