2 * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
3 * Copyright (c) 2002-2007, Professor Benoit Macq
4 * Copyright (c) 2001-2003, David Janssens
5 * Copyright (c) 2002-2003, Yannick Verschueren
6 * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
7 * Copyright (c) 2005, Herve Drolon, FreeImage Team
8 * Copyright (c) 2006-2007, Parvatha Elangovan
9 * Copyright (c) 2010-2011, Kaori Hagihara
10 * All rights reserved.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
37 ==========================================================
39 ==========================================================
42 #if defined(OPJ_STATIC) || !defined(_WIN32)
43 /* http://gcc.gnu.org/wiki/Visibility */
45 #define OPJ_API __attribute__ ((visibility ("default")))
46 #define OPJ_LOCAL __attribute__ ((visibility ("hidden")))
53 #define OPJ_CALLCONV __stdcall
55 The following ifdef block is the standard way of creating macros which make exporting
56 from a DLL simpler. All files within this DLL are compiled with the OPJ_EXPORTS
57 symbol defined on the command line. this symbol should not be defined on any project
58 that uses this DLL. This way any other project whose source files include this file see
59 OPJ_API functions as being imported from a DLL, wheras this DLL sees symbols
60 defined with this macro as being exported.
62 #if defined(OPJ_EXPORTS) || defined(DLL_EXPORT)
63 #define OPJ_API __declspec(dllexport)
65 #define OPJ_API __declspec(dllimport)
66 #endif /* OPJ_EXPORTS */
67 #endif /* !OPJ_STATIC || !_WIN32 */
73 /* Avoid compile-time warning because parameter is not used */
74 #define OPJ_ARG_NOT_USED(x) (void)(x)
76 ==========================================================
77 Useful constant definitions
78 ==========================================================
81 #define OPJ_PATH_LEN 4096 /**< Maximum allowed size for filenames */
83 #define J2K_MAXRLVLS 33 /**< Number of maximum resolution level authorized */
84 #define J2K_MAXBANDS (3*J2K_MAXRLVLS-2) /**< Number of maximum sub-band linked to number of resolution level */
87 #define JPWL_MAX_NO_TILESPECS 16 /**< Maximum number of tile parts expected by JPWL: increase at your will */
88 #define JPWL_MAX_NO_PACKSPECS 16 /**< Maximum number of packet parts expected by JPWL: increase at your will */
89 #define JPWL_MAX_NO_MARKERS 512 /**< Maximum number of JPWL markers: increase at your will */
90 #define JPWL_PRIVATEINDEX_NAME "jpwl_index_privatefilename" /**< index file name used when JPWL is on */
91 #define JPWL_EXPECTED_COMPONENTS 3 /**< Expect this number of components, so you'll find better the first EPB */
92 #define JPWL_MAXIMUM_TILES 8192 /**< Expect this maximum number of tiles, to avoid some crashes */
93 #define JPWL_MAXIMUM_HAMMING 2 /**< Expect this maximum number of bit errors in marker id's */
94 #define JPWL_MAXIMUM_EPB_ROOM 65450 /**< Expect this maximum number of bytes for composition of EPBs */
98 ==========================================================
100 ==========================================================
105 typedef enum RSIZ_CAPABILITIES {
106 STD_RSIZ = 0, /** Standard JPEG2000 profile*/
107 CINEMA2K = 3, /** Profile name for a 2K image*/
108 CINEMA4K = 4 /** Profile name for a 4K image*/
109 } OPJ_RSIZ_CAPABILITIES;
112 Digital cinema operation mode
114 typedef enum CINEMA_MODE {
115 OFF = 0, /** Not Digital Cinema*/
116 CINEMA2K_24 = 1, /** 2K Digital Cinema at 24 fps*/
117 CINEMA2K_48 = 2, /** 2K Digital Cinema at 48 fps*/
118 CINEMA4K_24 = 3 /** 4K Digital Cinema at 24 fps*/
124 typedef enum PROG_ORDER {
125 PROG_UNKNOWN = -1, /**< place-holder */
126 LRCP = 0, /**< layer-resolution-component-precinct order */
127 RLCP = 1, /**< resolution-layer-component-precinct order */
128 RPCL = 2, /**< resolution-precinct-component-layer order */
129 PCRL = 3, /**< precinct-component-resolution-layer order */
130 CPRL = 4 /**< component-precinct-resolution-layer order */
134 Supported image color spaces
136 typedef enum COLOR_SPACE {
137 CLRSPC_UNKNOWN = -1, /**< not supported by the library */
138 CLRSPC_UNSPECIFIED = 0, /**< not specified in the codestream */
139 CLRSPC_SRGB = 1, /**< sRGB */
140 CLRSPC_GRAY = 2, /**< grayscale */
141 CLRSPC_SYCC = 3 /**< YUV */
144 #define ENUMCS_SRGB 16
145 #define ENUMCS_GRAY 17
146 #define ENUMCS_SYCC 18
151 typedef enum CODEC_FORMAT {
152 CODEC_UNKNOWN = -1, /**< place-holder */
153 CODEC_J2K = 0, /**< JPEG-2000 codestream : read/write */
154 CODEC_JPT = 1, /**< JPT-stream (JPEG 2000, JPIP) : read only */
155 CODEC_JP2 = 2 /**< JPEG-2000 file format : read/write */
159 Limit decoding to certain portions of the codestream.
161 typedef enum LIMIT_DECODING {
162 NO_LIMITATION = 0, /**< No limitation for the decoding. The entire codestream will de decoded */
163 LIMIT_TO_MAIN_HEADER = 1, /**< The decoding is limited to the Main Header */
164 DECODE_ALL_BUT_PACKETS = 2 /**< Decode everything except the JPEG 2000 packets */
165 } OPJ_LIMIT_DECODING;
168 ==========================================================
169 event manager typedef definitions
170 ==========================================================
174 Callback function prototype for events
175 @param msg Event message
178 typedef void (*opj_msg_callback) (const char *msg, void *client_data);
181 Message handler object
186 <li>Debugging messages
189 typedef struct opj_event_mgr {
190 /** Error message callback if available, NULL otherwise */
191 opj_msg_callback error_handler;
192 /** Warning message callback if available, NULL otherwise */
193 opj_msg_callback warning_handler;
194 /** Debug message callback if available, NULL otherwise */
195 opj_msg_callback info_handler;
200 ==========================================================
201 codec typedef definitions
202 ==========================================================
206 Progression order changes
208 typedef struct opj_poc {
209 /** Resolution num start, Component num start, given by POC */
211 /** Layer num end,Resolution num end, Component num end, given by POC */
212 int layno1, resno1, compno1;
213 /** Layer num start,Precinct num start, Precinct num end */
214 int layno0, precno0, precno1;
215 /** Progression order enum*/
216 OPJ_PROG_ORDER prg1,prg;
217 /** Progression order string*/
221 /** Start and end values for Tile width and height*/
223 /** Start value, initialised in pi_initialise_encode*/
224 int layS, resS, compS, prcS;
225 /** End value, initialised in pi_initialise_encode */
226 int layE, resE, compE, prcE;
227 /** Start and end values of Tile width and height, initialised in pi_initialise_encode*/
228 int txS,txE,tyS,tyE,dx,dy;
229 /** Temporary values for Tile parts, initialised in pi_create_encode */
230 int lay_t, res_t, comp_t, prc_t,tx0_t,ty0_t;
234 Compression parameters
236 typedef struct opj_cparameters {
237 /** size of tile: tile_size_on = false (not in argument) or = true (in argument) */
238 opj_bool tile_size_on;
247 /** allocation by rate/distortion */
249 /** allocation by fixed layer */
251 /** add fixed_quality */
252 int cp_fixed_quality;
255 /** comment for coding */
257 /** csty : coding style */
259 /** progression order (default LRCP) */
260 OPJ_PROG_ORDER prog_order;
261 /** progression order changes */
263 /** number of progression order changes (POC), default to 0 */
265 /** number of layers */
267 /** rates of layers */
268 float tcp_rates[100];
269 /** different psnr for successive layers */
270 float tcp_distoratio[100];
271 /** number of resolutions */
273 /** initial code block width, default to 64 */
275 /** initial code block height, default to 64 */
277 /** mode switch (cblk_style) */
279 /** 1 : use the irreversible DWT 9-7, 0 : use lossless compression (default) */
281 /** region of interest: affected component in [0..3], -1 means no ROI */
283 /** region of interest: upshift value */
285 /* number of precinct size specifications */
287 /** initial precinct width */
288 int prcw_init[J2K_MAXRLVLS];
289 /** initial precinct height */
290 int prch_init[J2K_MAXRLVLS];
292 /**@name command line encoder parameters (not used inside the library) */
294 /** input file name */
295 char infile[OPJ_PATH_LEN];
296 /** output file name */
297 char outfile[OPJ_PATH_LEN];
298 /** DEPRECATED. Index generation is now handeld with the opj_encode_with_info() function. Set to NULL */
300 /** DEPRECATED. Index generation is now handeld with the opj_encode_with_info() function. Set to NULL */
301 char index[OPJ_PATH_LEN];
302 /** subimage encoding: origin image offset in x direction */
304 /** subimage encoding: origin image offset in y direction */
306 /** subsampling value for dx */
308 /** subsampling value for dy */
310 /** input file format 0: PGX, 1: PxM, 2: BMP 3:TIF*/
312 /** output file format 0: J2K, 1: JP2, 2: JPT */
317 /**@name JPWL encoding parameters */
319 /** enables writing of EPC in MH, thus activating JPWL */
320 opj_bool jpwl_epc_on;
321 /** error protection method for MH (0,1,16,32,37-128) */
323 /** tile number of header protection specification (>=0) */
324 int jpwl_hprot_TPH_tileno[JPWL_MAX_NO_TILESPECS];
325 /** error protection methods for TPHs (0,1,16,32,37-128) */
326 int jpwl_hprot_TPH[JPWL_MAX_NO_TILESPECS];
327 /** tile number of packet protection specification (>=0) */
328 int jpwl_pprot_tileno[JPWL_MAX_NO_PACKSPECS];
329 /** packet number of packet protection specification (>=0) */
330 int jpwl_pprot_packno[JPWL_MAX_NO_PACKSPECS];
331 /** error protection methods for packets (0,1,16,32,37-128) */
332 int jpwl_pprot[JPWL_MAX_NO_PACKSPECS];
333 /** enables writing of ESD, (0=no/1/2 bytes) */
335 /** sensitivity addressing size (0=auto/2/4 bytes) */
337 /** sensitivity range (0-3) */
339 /** sensitivity method for MH (-1=no,0-7) */
341 /** tile number of sensitivity specification (>=0) */
342 int jpwl_sens_TPH_tileno[JPWL_MAX_NO_TILESPECS];
343 /** sensitivity methods for TPHs (-1=no,0-7) */
344 int jpwl_sens_TPH[JPWL_MAX_NO_TILESPECS];
348 /** Digital Cinema compliance 0-not compliant, 1-compliant*/
349 OPJ_CINEMA_MODE cp_cinema;
350 /** Maximum rate for each component. If == 0, component size limitation is not considered */
353 OPJ_RSIZ_CAPABILITIES cp_rsiz;
354 /** Tile part generation*/
356 /** Flag for Tile part generation*/
358 /** MCT (multiple component transform) */
362 #define OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG 0x0001
365 Decompression parameters
367 typedef struct opj_dparameters {
369 Set the number of highest resolution levels to be discarded.
370 The image resolution is effectively divided by 2 to the power of the number of discarded levels.
371 The reduce factor is limited by the smallest total number of decomposition levels among tiles.
372 if != 0, then original dimension divided by 2^(reduce);
373 if == 0 or not used, image is decoded to the full resolution
377 Set the maximum number of quality layers to decode.
378 If there are less quality layers than the specified number, all the quality layers are decoded.
379 if != 0, then only the first "layer" layers are decoded;
380 if == 0 or not used, all the quality layers are decoded
384 /**@name command line encoder parameters (not used inside the library) */
386 /** input file name */
387 char infile[OPJ_PATH_LEN];
388 /** output file name */
389 char outfile[OPJ_PATH_LEN];
390 /** input file format 0: J2K, 1: JP2, 2: JPT */
392 /** output file format 0: PGX, 1: PxM, 2: BMP */
397 /**@name JPWL decoding parameters */
399 /** activates the JPWL correction capabilities */
400 opj_bool jpwl_correct;
401 /** expected number of components */
403 /** maximum number of tiles */
409 Specify whether the decoding should be done on the entire codestream, or be limited to the main header
410 Limiting the decoding to the main header makes it possible to extract the characteristics of the codestream
411 if == NO_LIMITATION, the entire codestream is decoded;
412 if == LIMIT_TO_MAIN_HEADER, only the main header is decoded;
414 OPJ_LIMIT_DECODING cp_limit_decoding;
419 /** Common fields between JPEG-2000 compression and decompression master structs. */
421 #define opj_common_fields \
422 opj_event_mgr_t *event_mgr; /**< pointer to the event manager */\
423 void * client_data; /**< Available for use by application */\
424 opj_bool is_decompressor; /**< So common code can tell which is which */\
425 OPJ_CODEC_FORMAT codec_format; /**< selected codec */\
426 void *j2k_handle; /**< pointer to the J2K codec */\
427 void *jp2_handle; /**< pointer to the JP2 codec */\
428 void *mj2_handle /**< pointer to the MJ2 codec */
430 /* Routines that are to be used by both halves of the library are declared
431 * to receive a pointer to this structure. There are no actual instances of
432 * opj_common_struct_t, only of opj_cinfo_t and opj_dinfo_t.
434 typedef struct opj_common_struct {
435 opj_common_fields; /* Fields common to both master struct types */
436 /* Additional fields follow in an actual opj_cinfo_t or
437 * opj_dinfo_t. All three structs must agree on these
438 * initial fields! (This would be a lot cleaner in C++.)
440 } opj_common_struct_t;
442 typedef opj_common_struct_t * opj_common_ptr;
445 Compression context info
447 typedef struct opj_cinfo {
448 /** Fields shared with opj_dinfo_t */
450 /* other specific fields go here */
454 Decompression context info
456 typedef struct opj_dinfo {
457 /** Fields shared with opj_cinfo_t */
459 /* other specific fields go here */
463 ==========================================================
464 I/O stream typedef definitions
465 ==========================================================
471 /** The stream was opened for reading. */
472 #define OPJ_STREAM_READ 0x0001
473 /** The stream was opened for writing. */
474 #define OPJ_STREAM_WRITE 0x0002
477 Byte input-output stream (CIO)
479 typedef struct opj_cio {
481 opj_common_ptr cinfo;
483 /** open mode (read/write) either OPJ_STREAM_READ or OPJ_STREAM_WRITE */
485 /** pointer to the start of the buffer */
486 unsigned char *buffer;
487 /** buffer size in bytes */
490 /** pointer to the start of the stream */
491 unsigned char *start;
492 /** pointer to the end of the stream */
494 /** pointer to the current position */
499 ==========================================================
500 image typedef definitions
501 ==========================================================
505 Defines a single image component
507 typedef struct opj_image_comp {
508 /** XRsiz: horizontal separation of a sample of ith component with respect to the reference grid */
510 /** YRsiz: vertical separation of a sample of ith component with respect to the reference grid */
516 /** x component offset compared to the whole image */
518 /** y component offset compared to the whole image */
522 /** image depth in bits */
524 /** signed (1) / unsigned (0) */
526 /** number of decoded resolution */
528 /** number of division by 2 of the out image compared to the original size of image */
530 /** image component data */
535 Defines image data and characteristics
537 typedef struct opj_image {
538 /** XOsiz: horizontal offset from the origin of the reference grid to the left side of the image area */
540 /** YOsiz: vertical offset from the origin of the reference grid to the top side of the image area */
542 /** Xsiz: width of the reference grid */
544 /** Ysiz: height of the reference grid */
546 /** number of components in the image */
548 /** color space: sRGB, Greyscale or YUV */
549 OPJ_COLOR_SPACE color_space;
550 /** image components */
551 opj_image_comp_t *comps;
552 /** 'restricted' ICC profile */
553 unsigned char *icc_profile_buf;
554 /** size of ICC profile */
559 Component parameters structure used by the opj_image_create function
561 typedef struct opj_image_comptparm {
562 /** XRsiz: horizontal separation of a sample of ith component with respect to the reference grid */
564 /** YRsiz: vertical separation of a sample of ith component with respect to the reference grid */
570 /** x component offset compared to the whole image */
572 /** y component offset compared to the whole image */
576 /** image depth in bits */
578 /** signed (1) / unsigned (0) */
580 } opj_image_cmptparm_t;
583 ==========================================================
584 Information on the JPEG 2000 codestream
585 ==========================================================
589 Index structure : Information concerning a packet inside tile
591 typedef struct opj_packet_info {
592 /** packet start position (including SOP marker if it exists) */
594 /** end of packet header position (including EPH marker if it exists)*/
596 /** packet end position */
598 /** packet distorsion */
607 typedef struct opj_marker_info_t {
609 unsigned short int type;
610 /** position in codestream */
612 /** length, marker val included */
618 Index structure : Information concerning tile-parts
620 typedef struct opj_tp_info {
621 /** start position of tile part */
623 /** end position of tile part header */
625 /** end position of tile part */
627 /** start packet of tile part */
629 /** number of packets of tile part */
634 Index structure : information regarding tiles
636 typedef struct opj_tile_info {
637 /** value of thresh for each layer by tile cfr. Marcela */
639 /** number of tile */
641 /** start position */
643 /** end position of the header */
647 /** precinct number for each resolution level (width) */
649 /** precinct number for each resolution level (height) */
651 /** precinct size (in power of 2), in X for each resolution level */
653 /** precinct size (in power of 2), in Y for each resolution level */
655 /** information concerning packets inside tile */
656 opj_packet_info_t *packet;
657 /** add fixed_quality */
659 /** add fixed_quality */
661 /** number of markers */
663 /** list of markers */
664 opj_marker_info_t *marker;
665 /** actual size of markers array */
667 /** number of tile parts */
669 /** information concerning tile parts */
674 Index structure of the codestream
676 typedef struct opj_codestream_info {
677 /** maximum distortion reduction on the whole image (add for Marcela) */
681 /** writing the packet in the index with t2_encode_packets */
687 /** progression order */
689 /** tile size in x */
691 /** tile size in y */
697 /** number of tiles in X */
699 /** number of tiles in Y */
701 /** component numbers */
703 /** number of layer */
705 /** number of decomposition for each component */
708 /** number of markers */
710 /** list of markers */
711 opj_marker_info_t *marker;
712 /** actual size of markers array */
715 /** main header position */
717 /** main header position */
719 /** codestream's size */
721 /** information regarding tiles inside image */
722 opj_tile_info_t *tile;
723 } opj_codestream_info_t;
731 ==========================================================
733 ==========================================================
736 OPJ_API const char * OPJ_CALLCONV opj_version(void);
739 ==========================================================
740 image functions definitions
741 ==========================================================
746 @param numcmpts number of components
747 @param cmptparms components parameters
748 @param clrspc image color space
749 @return returns a new image structure if successful, returns NULL otherwise
751 OPJ_API opj_image_t* OPJ_CALLCONV opj_image_create(int numcmpts, opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc);
754 Deallocate any resources associated with an image
755 @param image image to be destroyed
757 OPJ_API void OPJ_CALLCONV opj_image_destroy(opj_image_t *image);
760 ==========================================================
761 stream functions definitions
762 ==========================================================
766 Open and allocate a memory stream for read / write.
767 On reading, the user must provide a buffer containing encoded data. The buffer will be
768 wrapped by the returned CIO handle.
769 On writing, buffer parameters must be set to 0: a buffer will be allocated by the library
770 to contain encoded data.
771 @param cinfo Codec context info
772 @param buffer Reading: buffer address. Writing: NULL
773 @param length Reading: buffer length. Writing: 0
774 @return Returns a CIO handle if successful, returns NULL otherwise
776 OPJ_API opj_cio_t* OPJ_CALLCONV opj_cio_open(opj_common_ptr cinfo, unsigned char *buffer, int length);
779 Close and free a CIO handle
780 @param cio CIO handle to free
782 OPJ_API void OPJ_CALLCONV opj_cio_close(opj_cio_t *cio);
785 Get position in byte stream
786 @param cio CIO handle
787 @return Returns the position in bytes
789 OPJ_API int OPJ_CALLCONV cio_tell(opj_cio_t *cio);
791 Set position in byte stream
792 @param cio CIO handle
793 @param pos Position, in number of bytes, from the beginning of the stream
795 OPJ_API void OPJ_CALLCONV cio_seek(opj_cio_t *cio, int pos);
798 ==========================================================
799 event manager functions definitions
800 ==========================================================
803 OPJ_API opj_event_mgr_t* OPJ_CALLCONV opj_set_event_mgr(opj_common_ptr cinfo, opj_event_mgr_t *event_mgr, void *context);
806 ==========================================================
807 codec functions definitions
808 ==========================================================
811 Creates a J2K/JPT/JP2 decompression structure
812 @param format Decoder to select
813 @return Returns a handle to a decompressor if successful, returns NULL otherwise
815 OPJ_API opj_dinfo_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT format);
817 Destroy a decompressor handle
818 @param dinfo decompressor handle to destroy
820 OPJ_API void OPJ_CALLCONV opj_destroy_decompress(opj_dinfo_t *dinfo);
822 Set decoding parameters to default values
823 @param parameters Decompression parameters
825 OPJ_API void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *parameters);
827 Setup the decoder decoding parameters using user parameters.
828 Decoding parameters are returned in j2k->cp.
829 @param dinfo decompressor handle
830 @param parameters decompression parameters
832 OPJ_API void OPJ_CALLCONV opj_setup_decoder(opj_dinfo_t *dinfo, opj_dparameters_t *parameters);
834 Decode an image from a JPEG-2000 codestream
835 @param dinfo decompressor handle
836 @param cio Input buffer stream
837 @return Returns a decoded image if successful, returns NULL otherwise
839 OPJ_API opj_image_t* OPJ_CALLCONV opj_decode(opj_dinfo_t *dinfo, opj_cio_t *cio);
842 Decode an image from a JPEG-2000 codestream and extract the codestream information
843 @param dinfo decompressor handle
844 @param cio Input buffer stream
845 @param cstr_info Codestream information structure if needed afterwards, NULL otherwise
846 @return Returns a decoded image if successful, returns NULL otherwise
848 OPJ_API opj_image_t* OPJ_CALLCONV opj_decode_with_info(opj_dinfo_t *dinfo, opj_cio_t *cio, opj_codestream_info_t *cstr_info);
850 Creates a J2K/JP2 compression structure
851 @param format Coder to select
852 @return Returns a handle to a compressor if successful, returns NULL otherwise
854 OPJ_API opj_cinfo_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format);
856 Destroy a compressor handle
857 @param cinfo compressor handle to destroy
859 OPJ_API void OPJ_CALLCONV opj_destroy_compress(opj_cinfo_t *cinfo);
861 Set encoding parameters to default values, that means :
865 <li>Size of precinct : 2^15 x 2^15 (means 1 precinct)
866 <li>Size of code-block : 64 x 64
867 <li>Number of resolutions: 6
868 <li>No SOP marker in the codestream
869 <li>No EPH marker in the codestream
870 <li>No sub-sampling in x or y direction
871 <li>No mode switch activated
872 <li>Progression order: LRCP
875 <li>No offset of the origin of the image
876 <li>No offset of the origin of the tiles
877 <li>Reversible DWT 5-3
879 @param parameters Compression parameters
881 OPJ_API void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *parameters);
883 Setup the encoder parameters using the current image and using user parameters.
884 @param cinfo Compressor handle
885 @param parameters Compression parameters
886 @param image Input filled image
888 OPJ_API void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_image_t *image);
890 Encode an image into a JPEG-2000 codestream
891 3@param cinfo compressor handle
892 @param cio Output buffer stream
893 @param image Image to encode
894 @param index Depreacted -> Set to NULL. To extract index, used opj_encode_wci()
895 @return Returns true if successful, returns false otherwise
897 OPJ_API opj_bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index);
899 Encode an image into a JPEG-2000 codestream and extract the codestream information
900 @param cinfo compressor handle
901 @param cio Output buffer stream
902 @param image Image to encode
903 @param cstr_info Codestream information structure if needed afterwards, NULL otherwise
904 @return Returns true if successful, returns false otherwise
906 OPJ_API opj_bool OPJ_CALLCONV opj_encode_with_info(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info);
908 Destroy Codestream information after compression or decompression
909 @param cstr_info Codestream information structure
911 OPJ_API void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_t *cstr_info);
918 #endif /* OPENJPEG_H */